Browse Source

套餐属性update

chenrui 4 years ago
parent
commit
10cdc9b9c1

+ 5 - 0
package-lock.json

@@ -3639,6 +3639,11 @@
       "integrity": "sha512-YpeKZngUmG65rLudJ4taU7VLkOCTMhNl/u4ctNC56LQS/zJTyNH0Lrtwm1tfTsbLlwvlfsA2d1c8vCf/Kh2KwQ==",
       "dev": true
     },
+    "china-division": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/china-division/-/china-division-2.3.1.tgz",
+      "integrity": "sha512-mOfLagVRZ+lRmbIIZ0sci0+9Sr+uGyPCp9an4Orov2KxLf3DGSB/4qyao/jy3pegW4Weppvh0yzGfs+dAPJA7A=="
+    },
     "chokidar": {
       "version": "2.1.8",
       "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",

+ 1 - 0
package.json

@@ -17,6 +17,7 @@
     "@antv/data-set": "^0.10.2",
     "ant-design-vue": "^1.5.2",
     "axios": "^0.19.0",
+    "china-division": "^2.3.1",
     "core-js": "2.6.9",
     "echarts": "^4.9.0",
     "enquire.js": "^2.1.6",

+ 20 - 0
src/api/SetmealSales.js

@@ -44,3 +44,23 @@ export const settlementRecordsExport = (params) => {
     responseType: 'blob'
   })
 }
+//  套餐属性 列表
+export const salesChannelGoodsList = (params) => {
+  const url = `/salesChannelGoods/query/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  套餐属性  设置
+export const salesChannelGoodsConfig = (params) => {
+  const url = `/salesChannelGoods/setPropertiesConfig`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}

+ 37 - 0
src/api/address.js

@@ -0,0 +1,37 @@
+import provinces from 'china-division/dist/provinces.json'
+import cities from 'china-division/dist/cities.json'
+import areas from 'china-division/dist/areas.json'
+
+areas.forEach((area) => {
+  const matchCity = cities.filter(city => city.code === area.cityCode)[0]
+  if (matchCity) {
+    matchCity.children = matchCity.children || []
+    matchCity.children.push({
+      label: area.name,
+      value: area.code
+    })
+  }
+})
+
+cities.forEach((city) => {
+  const matchProvince = provinces.filter(province => province.code === city.provinceCode)[0]
+  if (matchProvince) {
+    matchProvince.children = matchProvince.children || []
+    matchProvince.children.push({
+      label: city.name,
+      value: city.code,
+      children: city.children
+    })
+  }
+})
+
+const options = provinces.map(province => ({
+  label: province.name,
+  value: province.code,
+  children: province.children
+}))
+export const province = provinces
+export const city = cities
+export const area = areas
+
+export default options

+ 1 - 0
src/store/getters.js

@@ -10,6 +10,7 @@ const getters = {
   welcome: state => state.user.welcome,
   roles: state => state.user.roles,
   userInfo: state => state.user.info,
+  authUserInfo: state => state.user.authUserInfo,
   addRouters: state => state.permission.addRouters,
   multiTab: state => state.app.multiTab,
   lang: state => state.i18n.lang

+ 8 - 1
src/store/modules/user.js

@@ -12,7 +12,8 @@ const user = {
     welcome: '',
     avatar: '',
     roles: { permissionList: [] },
-    info: {}
+    info: {},
+    authUserInfo: {}
   },
 
   mutations: {
@@ -39,6 +40,9 @@ const user = {
     },
     SET_INFO: (state, info) => {
       state.info = info
+    },
+    SET_AUTH_USER_INFO: (state, authUserInfo) => {
+      state.authUserInfo = authUserInfo
     }
   },
 
@@ -57,6 +61,8 @@ const user = {
               commit('SET_TOKEN', res.access_token)
               commit('SET_NAME', { name: users.userNameCN, welcome: welcome() })
               commit('SET_CHANNELNAME', users.extInfo.channel.salesChannelName)
+              console.log('登陆成功user数据', users)
+              commit('SET_AUTH_USER_INFO', users)
               commit('SET_MUSTCHANGEPWD', users.mustChangePwd)
               Vue.ls.set('rolesAccess', { permissionList: users.permCodes }, 7 * 24 * 60 * 60 * 1000)
               commit('SET_AVATAR', res.avatar ? res.avatar : '')
@@ -99,6 +105,7 @@ const user = {
         }).finally(() => {
           commit('SET_NAME', { name: '', welcome: '' })
           commit('SET_CHANNELNAME', '')
+          commit('SET_AUTH_USER_INFO', {})
           commit('SET_MUSTCHANGEPWD', '')
           commit('SET_AVATAR', '')
           commit('SET_TOKEN', '')

+ 72 - 60
src/views/Home.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="home">
-    <a-alert message="欢迎登录合作商运营管理平台系统" type="info" showIcon />
+    <a-alert :message="alertMessage" type="info" showIcon />
     <div class="report-page">
       <!-- 查询条件 -->
       <a-row>
@@ -166,6 +166,7 @@ import _ from 'lodash'
 import getDate from '@/libs/getDate'
 import moment from 'moment'
 import { getOrderstatistics } from '@/api/report-charts.js'
+import { salesChannelList } from '@/api/FinancialManagement'
 export default {
   name: 'Home',
   components: {
@@ -190,7 +191,7 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['mustChangePwd']),
+    ...mapGetters(['mustChangePwd', 'authUserInfo']),
     resize () {
       console.log(this.screenWidth, 'this.screenWidth')
       if (this.screenWidth < 1640) {
@@ -244,75 +245,67 @@ export default {
         bundleNum: 0 //  套餐销售量
       },
       // 快速删选tab
-      tabList: [{
-        name: '今天',
-        type: 'today'
-      },
-      {
-        name: '本周',
-        type: 'thisWeek'
-      },
-      {
-        name: '上周',
-        type: 'lastWeek'
-      },
-      {
-        name: '本月',
-        type: 'thisMonth'
-      }
+      tabList: [
+        { name: '今天', type: 'today' },
+        { name: '本周', type: 'thisWeek' },
+        { name: '上周', type: 'lastWeek' },
+        { name: '本月', type: 'thisMonth' }
       ],
       curentType: 'thisWeek', // 当前所选时间查询类型
       beginDate: null, // 开始时间
       endDate: null, // 结束时间
       // 套餐量图表数据
-      washCarsChartData: [{
-        name: '当日套餐销售量',
-        type: 'line',
-        data: []
-      },
-      {
-        name: '当日套餐使用量',
-        type: 'line',
-        data: []
-      }
+      washCarsChartData: [
+        {
+          name: '当日套餐销售量',
+          type: 'line',
+          data: []
+        },
+        {
+          name: '当日套餐使用量',
+          type: 'line',
+          data: []
+        }
       ],
       couponColor: ['#d48265', '#ff55ff'],
       // 套餐类型数据
       currentTabChart: 'tab1', // 套餐类型详情数据与变化趋势的tab 默认展示详情数据
       XdaysData: [], // 图表X轴时间集合
       // 套餐类型柱状图表数据
-      washTypeBarData: [{
-        name: '洗美套餐',
-        type: 'bar',
-        data: []
-      },
-      {
-        name: '保养套餐',
-        type: 'bar',
-        data: []
-      },
-      {
-        name: '系统养护套餐',
-        type: 'bar',
-        data: []
-      }
+      washTypeBarData: [
+        {
+          name: '洗美套餐',
+          type: 'bar',
+          data: []
+        },
+        {
+          name: '保养套餐',
+          type: 'bar',
+          data: []
+        },
+        {
+          name: '系统养护套餐',
+          type: 'bar',
+          data: []
+        }
       ],
       // 套餐类型折线图表数据
-      washTypeLineData: [{
-        name: '洗美套餐',
-        type: 'line',
-        data: []
-      },
-      {
-        name: '保养套餐',
-        type: 'line',
-        data: []
-      },
-      {
-        name: '系统养护套餐',
-        type: 'line',
-        data: []
-      }
+      washTypeLineData: [
+        {
+          name: '洗美套餐',
+          type: 'line',
+          data: []
+        },
+        {
+          name: '保养套餐',
+          type: 'line',
+          data: []
+        },
+        {
+          name: '系统养护套餐',
+          type: 'line',
+          data: []
+        }
       ],
       // 各类型占比
       washTypePieColor: ['#ffaa00', '#00ff00', '#00aaff', '#ff55ff', '#1dc5d4', '#8465c7', '#00ffff'],
@@ -321,7 +314,8 @@ export default {
         washTypePieData: [],
         chartData: {}
       },
-      openResetPwd: false //  重置密码是否显示
+      openResetPwd: false, //  重置密码是否显示
+      alertMessage: '欢迎登录合作商运营管理平台系统' //  系统提示语
     }
   },
   methods: {
@@ -438,6 +432,20 @@ export default {
       // 套餐量图表数据赋值
       this.washCarsChartData[0].data = totalData
       this.washCarsChartData[1].data = useCouponData
+    },
+    //  获取渠道商下的合作商信息
+    getSalesChannel () {
+      salesChannelList().then(res => {
+        if (res.status == 200) {
+          let msg = '以下统计来源于'
+          res.data.map((item, index) => {
+            if (index < 3) {
+              msg += item.salesChannelName + '、'
+            }
+          })
+          this.alertMessage = msg.substr(0, msg.length - 1) + '等' + res.data.length + '家合作商的数据汇总'
+        }
+      })
     }
   },
   beforeRouteEnter (to, from, next) {
@@ -448,7 +456,11 @@ export default {
       } else {
         vm.openResetPwd = true
       }
-      console.log(vm.mustChangePwd, '-------是否需要重置密码')
+      const salesChannelType = vm.authUserInfo.extInfo.channel.salesChannelType
+      if (salesChannelType == 'CHANNEL') { //  渠道商
+        vm.getSalesChannel()
+      }
+      // console.log(vm.mustChangePwd, '-------是否需要重置密码', vm.authUserInfo)
       vm.pageInit()
       vm.curentType = 'thisWeek'
       vm.getCurentSearchTime()

+ 125 - 66
src/views/SetmealSales/SetmealAttr.vue

@@ -1,149 +1,208 @@
 <template>
   <a-card :bordered="false" class="setmealAttr-wrap">
+    <v-select v-show="false" code="BELONG_COMPANY" ref="belongCompany" ></v-select>
     <!-- 搜索条件 -->
     <div class="setmealAttr-searchForm">
-      <a-form ref="searchForm" @keyup.enter.native="$refs.table.refresh(true)">
+      <a-form ref="searchForm" @keyup.enter.native="searchFun">
         <a-row :gutter="48">
           <a-col :span="6">
-            <a-form-item label="合作商" :label-col="{ span: 7 }" :wrapper-col="{ span: 17 }">
+            <a-form-item label="合作商" required :label-col="{ span: 7 }" :wrapper-col="{ span: 17 }">
               <a-select
                 id="setmealAttr-partner"
                 allowClear
                 show-search
                 option-filter-prop="children"
                 placeholder="请选择合作商"
-                v-model="searchForm.partner"
-                @change="pageInit">
-                <a-select-option v-for="(item, index) in partnerList" :key="index" :value="item.value">{{ item.name }}</a-select-option>
+                v-model="searchForm.salesChannelNo">
+                <a-select-option v-for="(item, index) in partnerList" :key="index" :value="item.salesChannelNo">{{ item.salesChannelName }}</a-select-option>
               </a-select>
             </a-form-item>
           </a-col>
           <a-col :span="6">
             <a-form-item label="套餐名称" :label-col="{ span: 7 }" :wrapper-col="{ span: 17 }">
-              <a-input v-model.trim="searchForm.bundleName" id="setmealAttr-bundleName" placeholder="请输入套餐名称" allowClear />
+              <a-input v-model.trim="searchForm.bundle.name" id="setmealAttr-bundleName" placeholder="请输入套餐名称" allowClear />
             </a-form-item>
           </a-col>
           <a-col :span="12">
-            <a-button class="handle-btn serach-btn" id="setmealAttr-serach" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
+            <a-button class="handle-btn serach-btn" id="setmealAttr-serach" type="primary" @click="searchFun">查询</a-button>
             <a-button class="handle-btn" type="" id="setmealAttr-reset" @click="handleReset">重置</a-button>
           </a-col>
         </a-row>
       </a-form>
     </div>
     <!-- 未选择合作商 -->
-    <div class="unChoose" v-if="!searchForm.partner">
+    <div class="unChoose" v-if="!isSearch">
       <a-icon type="exclamation-circle" theme="filled" :style="{ fontSize: '18px', color: '#ff9900', verticalAlign: 'sub', marginRight: '5px' }" />
       <span>请先选择合作商</span>
     </div>
     <!-- 列表 -->
     <a-table
-      v-if="searchForm.partner"
+      v-if="isSearch"
       class="table"
       ref="table"
       size="default"
       :rowKey="record => record.id"
       :columns="columns"
       :dataSource="loadData"
+      :pagination="paginationProps"
       bordered>
-      <!-- 客户信息 -->
-      <p slot="custInfo" slot-scope="text, record">
-        <span v-if="record.custMobile">{{ record.custMobile }}</span>
+      <!-- 所属地区 -->
+      <p slot="areas" slot-scope="text, record">
+        <span v-if="record.addrProvinceName">{{ record.addrProvinceName }}{{ record.addrCityName }}{{ record.addrDistrictName }}</span>
+        <span v-else>--</span>
+      </p>
+      <!-- 分公司名称 -->
+      <p slot="belongCompany" slot-scope="text, record">
+        <span v-if="record.belongCompany">{{ $refs.belongCompany.getNameByCode(record.belongCompany) }}</span>
         <span v-else>--</span>
       </p>
       <!-- 操作 -->
       <span slot="action" slot-scope="text, record"><a-button type="primary" id="setmealAttr-set" @click="setAttr(record)">设置套餐属性</a-button></span>
     </a-table>
     <!-- 设置套餐属性 -->
-    <attr-modal :openModal="openModal" :setmealId="setmealId" @close="openModal=false" />
+    <attr-modal :openModal="openModal" :setmealId="setmealId" :setmealData="setmealData" @close="closeModal" />
   </a-card>
 </template>
 
 <script>
-import { STable } from '@/components'
+import { STable, VSelect } from '@/components'
 import AttrModal from './attrModal.vue'
+import { mapGetters } from 'vuex'
+import { salesChannelList } from '@/api/FinancialManagement'
+import { salesChannelGoodsList } from '@/api/SetmealSales'
 export default {
-  components: { STable, AttrModal },
+  components: { STable, VSelect, AttrModal },
   data () {
     return {
       // 查询参数
       searchForm: {
-        bundleName: '', // 套餐名称
-        partner: undefined //  合作商
+        bundle: { name: '' }, // 套餐名称
+        salesChannelNo: undefined //  合作商
       },
-      partnerList: [{ value: 1, name: '合作商1' }, { value: 2, name: '合作商2' }, { value: 3, name: '合作商3' }, { value: 4, name: '合作商4' }], //  合作商  下拉数据
+      partnerList: [], //  合作商  下拉数据
       columns: [
         { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
-        { title: '合作商名称', dataIndex: 'partner', width: 100, align: 'center' },
-        { title: '套餐名称', dataIndex: 'bundleName', width: 100, align: 'center' },
-        { title: '套餐别名', dataIndex: 'bundleNames', width: 100, align: 'center' },
-        { title: '所属地区', dataIndex: 'number', width: 100, align: 'center' },
-        { title: '所属项目名称', dataIndex: 'orderDate', width: 100, align: 'center' },
-        { title: '分公司名称', dataIndex: 'payedAmount', width: 100, align: 'center' },
-        { title: '折扣比例', dataIndex: 'payedAmounts', width: 80, align: 'center' },
+        { title: '合作商名称', dataIndex: 'salesChannelName', width: 100, align: 'center' },
+        { title: '套餐名称', dataIndex: 'bundle.name', width: 100, align: 'center' },
+        { title: '套餐别名', width: 100, align: 'center', customRender: (record, text) => { return record ? (record.goodsAlias ? record.goodsAlias : '--') : '--' } },
+        { title: '所属地区', scopedSlots: { customRender: 'areas' }, width: 100, align: 'center' },
+        { title: '所属项目名称', width: 100, align: 'center', customRender: (record, text) => { return record ? (record.belongProject ? record.belongProject : '--') : '--' } },
+        { title: '分公司名称', scopedSlots: { customRender: 'belongCompany' }, width: 100, align: 'center' },
+        { title: '折扣比例', width: 80, align: 'center', customRender: (record, text) => { return record ? (record.useDiscountRate ? record.useDiscountRate + '%' : '--') : '--' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center' }
       ],
       loadData: [], //  表格数据
       setmealId: '', //  套餐id
-      openModal: false //  设置套餐属性弹框
+      openModal: false, //  设置套餐属性弹框
+      pageNo: 1, //  分页页码
+      pageSize: 10, //  分页 每页多少条
+      paginationProps: {
+        showSizeChanger: true, //  是否可以改变 pageSize
+        total: 0, //  分页总条数
+        onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
+        onChange: (current) => this.changePage(current)
+      },
+      setmealData: null, //  套餐属性数据
+      isSearch: false //  是否点击查询
     }
   },
+  computed: {
+    ...mapGetters(['authUserInfo'])
+  },
   methods: {
+    searchFun () {
+      this.isSearch = !!this.searchForm.salesChannelNo
+      this.pageInit(1)
+    },
     //  页面初始化
-    pageInit () {
-      if (this.searchForm.partner) {
+    pageInit (pageNo, pageSize) {
+      if (this.searchForm.salesChannelNo) {
+        this.pageNo = pageNo || this.pageNo
+        this.pageSize = pageSize || this.pageSize
         //  请求列表数据
-        this.loadData = [
-          {
-            id: 1,
-            no: 1,
-            partner: '合作商1',
-            bundleName: '车内精致洗护套餐',
-            bundleNames: '洗护套餐',
-            number: '陕西省西安市',
-            orderDate: '项目名称11',
-            payedAmount: '上海有限公司',
-            payedAmounts: '45%'
-          },
-          {
-            id: 2,
-            no: 2,
-            partner: '合作商2',
-            bundleName: '车内精致洗护套餐',
-            bundleNames: '洗护套餐',
-            number: '海南市',
-            orderDate: '项目名称22',
-            payedAmount: '海南有限公司',
-            payedAmounts: '5%'
-          },
-          {
-            id: 3,
-            no: 3,
-            partner: '合作商3',
-            bundleName: '车内精致洗护套餐',
-            bundleNames: '洗护套餐',
-            number: '省天津市',
-            orderDate: '项目名称33',
-            payedAmount: '天津有限公司',
-            payedAmounts: '80%'
+        salesChannelGoodsList({
+          salesChannelNo: this.searchForm.salesChannelNo,
+          bundle: { name: this.searchForm.bundle.name },
+          pageNo: this.pageNo,
+          pageSize: this.pageSize
+        }).then(res => {
+          if (res.status == 200) {
+            const data = res.data
+            if (res.data.count > 10) {
+              this.paginationProps = {
+                showSizeChanger: true, //  是否可以改变 pageSize
+                total: 0, //  分页总条数
+                onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
+                onChange: (current) => this.changePage(current)
+              }
+              this.paginationProps.total = res.data.count || 0
+            } else {
+              this.paginationProps = false
+            }
+            const no = (data.pageNo - 1) * data.pageSize
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+            }
+            this.loadData = data.list
+          } else {
+            this.loadData = []
           }
-        ]
+        })
+      } else {
+        this.isSearch = false
       }
     },
+    //  分页  一页多少条change
+    changePageSize (current, pageSize) {
+      this.pageNo = current
+      this.pageSize = pageSize
+      this.pageInit()
+    },
+    //  分页 页码change
+    changePage (current) {
+      this.pageNo = current
+      this.pageInit()
+    },
     //  设置套餐属性
     setAttr (row) {
       this.setmealId = row.id
+      this.setmealData = row
       this.openModal = true
     },
     // 重置
     handleReset () {
-      this.searchForm.bundleName = ''
-      this.searchForm.partner = undefined
-      this.$refs.table.refresh(true)
+      this.searchForm.bundle.name = ''
+      this.searchForm.salesChannelNo = undefined
+      this.isSearch = false
+      this.pageInit(1)
+    },
+    //  关闭
+    closeModal () {
+      this.openModal = false
+      this.setmealData = null
+      this.pageInit()
+    },
+    //  获取渠道商下的合作商信息
+    getSalesChannel () {
+      salesChannelList().then(res => {
+        if (res.status == 200) {
+          this.partnerList = res.data
+          const salesChannelType = this.authUserInfo.extInfo.channel.salesChannelType
+          if (salesChannelType == 'SALLER') { //  合作商
+            this.searchForm.salesChannelNo = res.data.length > 0 ? res.data[0].salesChannelNo : undefined
+          }
+          this.pageInit(1)
+        } else {
+          this.partnerList = []
+          this.searchForm.salesChannelNo = undefined
+        }
+      })
     }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
-      vm.pageInit()
+      vm.isSearch = false
+      vm.getSalesChannel()
     })
   }
 }

+ 99 - 129
src/views/SetmealSales/attrModal.vue

@@ -10,56 +10,47 @@
     @cancel="isShow = false"
     v-model="isShow">
     <!-- 表单 -->
-    <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
+    <a-form-model
+      ref="ruleForm"
+      :model="form"
+      :rules="rules"
+      :label-col="{ span: 6 }"
+      :wrapper-col="{ span: 18 }"
+      v-if="setmealData">
       <!-- 合作商名称 -->
-      <a-form-model-item label="合作商名称" class="item-con"><p class="item-main">清泉洗车(VIP)</p></a-form-model-item>
+      <a-form-model-item label="合作商名称" class="item-con"><p class="item-main">{{ setmealData.salesChannelName }}</p></a-form-model-item>
       <!-- 套餐名称 -->
-      <a-form-model-item label="套餐名称" class="item-con"><p class="item-main">2020-11-28</p></a-form-model-item>
+      <a-form-model-item label="套餐名称" class="item-con"><p class="item-main">{{ setmealData.bundle.name || '--' }}</p></a-form-model-item>
       <!-- 套餐别名 -->
-      <a-form-model-item label="套餐别名" class="item-con"><p class="item-main">15次</p></a-form-model-item>
+      <a-form-model-item label="套餐别名" class="item-con">
+        <a-input id="attr-goodsAlias" v-model.trim="form.goodsAlias" :maxLength="30" placeholder="请输入套餐别名" />
+      </a-form-model-item>
       <!-- 所属地区 -->
-      <a-form-model-item label="所属地区" style="margin: 0;">
-        <a-row :gutter="20">
-          <a-col span="8">
-            <a-form-model-item>
-              <a-select id="attr-edit-provinceCode" @change="getCityList" v-model="form.provinceCode" placeholder="请选择省">
-                <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
-              </a-select>
-            </a-form-model-item>
-          </a-col>
-          <a-col span="8">
-            <a-form-model-item prop="cityCode">
-              <a-select id="attr-edit-cityCode" v-model="form.cityCode" @change="getAreaList" placeholder="请选择市">
-                <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
-              </a-select>
-            </a-form-model-item>
-          </a-col>
-          <a-col span="8">
-            <a-form-model-item prop="districtCode">
-              <a-select id="attr-edit-districtCode" v-model="form.districtCode" placeholder="请选择区/县">
-                <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
-              </a-select>
-            </a-form-model-item>
-          </a-col>
-        </a-row>
+      <a-form-model-item label="所属地区" class="item-con">
+        <a-cascader id="attr-areas" v-model="areas" :options="options" placeholder="请选择省市区" />
       </a-form-model-item>
       <!-- 所属项目名称 -->
-      <a-form-model-item label="所属项目名称" class="item-con" prop="itemName">
-        <a-input id="attr-itemName" v-model.trim="form.itemName" :maxLength="30" placeholder="请输入所属项目名称" />
+      <a-form-model-item label="所属项目名称" class="item-con" prop="belongProject" v-if="propertiesConfig.indexOf('BELONG_PROJECT')!=-1">
+        <a-input id="attr-belongProject" v-model.trim="form.belongProject" :maxLength="30" placeholder="请输入所属项目名称" />
       </a-form-model-item>
       <!-- 分公司名称 -->
-      <a-form-model-item label="分公司名称" class="item-con" prop="company">
-        <a-select id="attr-company" v-model="form.company" placeholder="请选择分公司名称">
-          <a-select-option v-for="item in companyList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
-        </a-select>
+      <a-form-model-item label="分公司名称" class="item-con" prop="belongCompany" v-if="propertiesConfig.indexOf('BELONG_COMPANY')!=-1">
+        <v-select
+          code="BELONG_COMPANY"
+          ref="belongCompany"
+          v-model="form.belongCompany"
+          id="attr-belongCompany"
+          allowClear
+          placeholder="请选择分公司名称" ></v-select>
       </a-form-model-item>
       <!-- 折扣比例 -->
-      <a-form-model-item label="折扣比例" class="item-con" prop="discount">
+      <a-form-model-item label="折扣比例" class="item-con" prop="useDiscountRate" v-if="propertiesConfig.indexOf('USE_DISCOUNT_RATE')!=-1">
         <a-input-number
-          id="attr-discount"
-          v-model="form.discount"
+          id="attr-useDiscountRate"
+          v-model="form.useDiscountRate"
           :min="0"
-          :max="999999"
+          :max="100"
+          :precision="2"
           placeholder="请输入折扣比例"
           style="width: 80%;margin-right: 10px;" />%
       </a-form-model-item>
@@ -72,9 +63,13 @@
 </template>
 
 <script>
-import { getProvince, getCityByPro, getDistrictByCity } from '@/api/lookup'
+import { VSelect } from '@/components'
+import addrData, { province, city, area } from '@/api/address'
+import { salesChannelGoodsConfig } from '@/api/SetmealSales'
+import _ from 'lodash'
 export default {
   name: 'AttrModal',
+  components: { VSelect },
   props: {
     openModal: {
       //  弹框是否展示
@@ -85,27 +80,31 @@ export default {
       //  套餐id
       type: [String, Number],
       default: ''
+    },
+    setmealData: { //  套餐数据
+      type: Object,
+      default: () => { return {} }
     }
   },
   data () {
     return {
       isShow: this.openModal, //  弹框是否展示
       form: {
-        provinceCode: undefined, //  省
-        provinceName: '',
-        cityCode: undefined, // 市
-        cityName: '',
-        districtCode: undefined, // 区
-        districtName: '',
-        itemName: '', //  所属项目名称
-        company: undefined, //  分公司名称
-        discount: '' //  折扣比例
+        goodsAlias: '', //  套餐别名
+        addrProvince: undefined, //  省
+        addrProvinceName: '',
+        addrCity: undefined, // 市
+        addrCityName: '',
+        addrDistrict: undefined, // 区
+        addrDistrictName: '',
+        belongProject: '', //  所属项目名称
+        belongCompany: undefined, //  分公司名称
+        useDiscountRate: '' //  折扣比例
       },
       rules: {},
-      addrProvinceList: [], //  省下拉
-      addrCityList: [], //  市下拉
-      addrDistrictList: [], //  区下拉
-      companyList: [] //  分公司  下拉
+      options: addrData,
+      areas: [],
+      propertiesConfig: [] //  套餐属性
     }
   },
   methods: {
@@ -116,88 +115,53 @@ export default {
     },
     // 重置表单
     resetForm () {
-      this.form.provinceCode = undefined
-      this.form.provinceName = ''
-      this.form.cityCode = undefined
-      this.form.cityName = ''
-      this.form.districtCode = undefined
-      this.form.districtName = ''
-      this.form.itemName = ''
-      this.form.company = undefined
-      this.form.discount = ''
+      this.form.goodsAlias = ''
+      this.form.addrProvince = undefined
+      this.form.addrProvinceName = ''
+      this.form.addrCity = undefined
+      this.form.addrCityName = ''
+      this.form.addrDistrict = undefined
+      this.form.addrDistrictName = ''
+      this.areas = []
+      this.form.belongProject = ''
+      this.form.belongCompany = undefined
+      this.form.useDiscountRate = ''
     },
     //  提交
     onSubmit () {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
+          if (this.areas.length) {
+            this.form.addrProvince = this.areas[0]
+            this.form.addrProvinceName = _.find(province, ['code', this.areas[0]]).name
+            this.form.addrCity = this.areas[1]
+            this.form.addrCityName = _.find(city, ['code', this.areas[1]]).name
+            this.form.addrDistrict = this.areas[2]
+            this.form.addrDistrictName = _.find(area, ['code', this.areas[2]]).name
+          }
           const params = {
-            bundleId: this.setmealId,
-            provinceCode: this.form.provinceCode,
-            provinceName: this.form.provinceName,
-            cityCode: this.form.cityCode,
-            cityName: this.form.cityName,
-            districtCode: this.form.districtCode,
-            districtName: this.form.districtName,
-            itemName: this.form.itemName,
-            company: this.form.company,
-            discount: this.form.discount
+            id: this.setmealId,
+            goodsAlias: this.form.goodsAlias,
+            addrProvince: this.form.addrProvince,
+            addrProvinceName: this.form.addrProvinceName,
+            addrCity: this.form.addrCity,
+            addrCityName: this.form.addrCityName,
+            addrDistrict: this.form.addrDistrict,
+            addrDistrictName: this.form.addrDistrictName,
+            belongProject: this.form.belongProject,
+            belongCompany: this.form.belongCompany,
+            useDiscountRate: this.form.useDiscountRate
           }
-          // bundleBuy(params).then(res => {
-          //   if (res.status == 200) {
-          //     this.cancel()
-          //   }
-          // })
+          salesChannelGoodsConfig(params).then(res => {
+            if (res.status == 200) {
+              this.cancel()
+            }
+          })
         } else {
           console.log('error submit!!')
           return false
         }
       })
-    },
-    // 获取省列表'
-    getProvinceList () {
-      getProvince().then(res => {
-        if (res.status == 200) {
-          this.addrProvinceList = res.data || []
-        } else {
-          this.addrProvinceList = []
-        }
-      })
-    },
-    // 获取城市列表
-    getCityList (val) {
-      this.addrCityList = []
-      this.addrDistrictList = []
-      this.form.cityCode = undefined
-      this.form.districtCode = undefined
-      this.getCityListRequest(val)
-    },
-    getCityListRequest (val) {
-      getCityByPro({
-        id: val
-      }).then(res => {
-        if (res.status == 200) {
-          this.addrCityList = res.data || []
-        } else {
-          this.addrCityList = []
-        }
-      })
-    },
-    // 获取区县列表
-    getAreaList (val) {
-      this.addrDistrictList = []
-      this.form.districtCode = undefined
-      this.getAreaListRequest(val)
-    },
-    getAreaListRequest (val) {
-      getDistrictByCity({
-        id: val
-      }).then(res => {
-        if (res.status == 200) {
-          this.addrDistrictList = res.data || []
-        } else {
-          this.addrDistrictList = []
-        }
-      })
     }
   },
   watch: {
@@ -211,15 +175,21 @@ export default {
         this.$emit('close')
       } else {
         this.resetForm() //  重置表单数据
-        this.getProvinceList()
       }
     },
-    setmealId (newValue, oldValue) {
-      if (newValue && this.isShow) {
-
-      } else {
-
-      }
+    setmealData: {
+      handler: function (obj) {
+        if (obj) {
+          this.propertiesConfig = obj.salesChannel.propertiesConfig ? obj.salesChannel.propertiesConfig.split(',') : []
+          this.form.goodsAlias = obj.goodsAlias
+          //  省市区
+          this.areas = obj.addrProvince ? [obj.addrProvince + '', obj.addrCity + '', obj.addrDistrict + ''] : []
+          this.form.belongProject = obj.belongProject || ''
+          this.form.belongCompany = obj.belongCompany || undefined
+          this.form.useDiscountRate = obj.useDiscountRate || ''
+        }
+      },
+      deep: true
     }
   }
 }