chenrui 2 år sedan
förälder
incheckning
aceff652d6

+ 4 - 1
src/views/common/chooseWarehouse.js

@@ -16,7 +16,7 @@ const warehouse = {
     `,
   props: {
     value: {
-      type: [String,Array],
+      type: [String, Array],
       defatut: ''
     },
     id: {
@@ -72,6 +72,9 @@ const warehouse = {
           this.warehouseData = []
         }
       })
+    },
+    clearData () {
+      this.handleChange([])
     }
   }
 }

+ 35 - 6
src/views/dealerManagement/businessOwnerSettings/addModal.vue

@@ -48,8 +48,9 @@
             </a-radio>
           </a-radio-group>
         </a-form-model-item>
-        <a-form-model-item label="管辖仓库" prop="warehouse" >
-          <chooseWarehouse ref="warehouse" modeType="multiple" @change="handleWarehouse"></chooseWarehouse>
+        <!-- 人员类型为仓库管理员时 显示管辖仓库 -->
+        <a-form-model-item label="管辖仓库" prop="bizUserScopeList" v-show="form.bizUserType == 'cg'">
+          <chooseWarehouse ref="warehouse" modeType="multiple" :value="warehouseList" @change="handleWarehouse"></chooseWarehouse>
         </a-form-model-item>
         <div style="display: flex;justify-content: center;padding: 30px 0;">
           <a-button type="primary" @click="handleSave">{{ itemId?'保存':'确定' }}</a-button>
@@ -87,8 +88,10 @@ export default {
         userSn: '',
         bizUserType: undefined, // 人员类型
         allDealerFlag: undefined,
-        allProductFlag: undefined
+        allProductFlag: undefined,
+        bizUserScopeList: []
       },
+      warehouseList: [],
       user_name: '',
       labelCol: { span: 5 },
       wrapperCol: { span: 16 },
@@ -96,7 +99,8 @@ export default {
         userSn: [{ required: true, message: '请输入人员名称', trigger: 'change' }],
         bizUserType: [{ required: true, message: '请选择人员类型', trigger: 'change' }],
         allDealerFlag: [{ required: true, message: '请选择管辖经销商', trigger: 'change' }],
-        allProductFlag: [{ required: true, message: '请选择管辖产品', trigger: 'change' }]
+        allProductFlag: [{ required: true, message: '请选择管辖产品', trigger: 'change' }],
+        bizUserScopeList: [{ required: true, message: '请选择管辖仓库', trigger: 'change' }]
       }
     }
   },
@@ -123,23 +127,48 @@ export default {
       })
     },
     handleWarehouse (val) {
-      console.log('warehouseSn:', val)
+      this.warehouseList = val
+      const arr = []
+      val.forEach(item => {
+        const obj = {
+          bizSn: item
+        }
+        arr.push(obj)
+      })
+      this.form.bizUserScopeList = arr
     },
     resetSearchForm () {
       this.$refs.userName.resetForm()
       this.user_name = ''
       this.$refs.ruleForm.resetFields()
+      if (this.form.bizUserType == 'cg') {
+        this.$refs.warehouse.clearData()
+        this.form.bizUserScopeList = []
+      }
     },
     userChange (val) {
       this.form.userSn = val.key
     },
     getEditInfo (obj) {
       this.$refs.userName.setDufaultVal(obj.userName)
+      const arr = []
+      const newarr = []
+      if (obj.warehouseList && obj.warehouseList.length > 0) {
+        obj.warehouseList.forEach(item => {
+          arr.push(item.warehouseSn)
+          const newObj = {
+            bizSn: item.warehouseSn
+          }
+          newarr.push(newObj)
+        })
+        this.warehouseList = arr
+      }
       this.form = {
         userSn: obj.userSn,
         bizUserType: obj.bizUserType, // 人员类型
         allDealerFlag: obj.allDealerFlag,
-        allProductFlag: obj.allProductFlag
+        allProductFlag: obj.allProductFlag,
+        bizUserScopeList: newarr
       }
     }
   },

+ 30 - 1
src/views/dealerManagement/businessOwnerSettings/list.vue

@@ -46,6 +46,21 @@
           :scroll="{ y: tableHeight }"
           :defaultLoadData="false"
           bordered>
+         <template slot="showWarehouse" slot-scope="text, record">
+          <div v-if="record.warehouseList &&record.warehouseList.length>0 ">
+            <a-tooltip placement="bottom" class="warehouseBox">
+                    <template slot="title">
+                     <span v-for="con in record.warehouseList" :key="con.id">
+                       {{con.name}}
+                     </span>
+                    </template>
+                   <span v-for="con in record.warehouseList" :key="con.id">
+                     {{con.name}}
+                   </span>
+            </a-tooltip>
+          </div>
+          <div v-else>--</div>
+         </template>
           <!-- 操作 -->
           <template slot="action" slot-scope="text, record">
             <a-button size="small" type="link" class="button-warning" v-if="record.allDealerFlag!=1 || record.allProductFlag!=1" @click="handleSetCategory(record)">设置管辖范围</a-button>
@@ -84,7 +99,7 @@ export default {
         { title: '人员类型', dataIndex: 'bizUserTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '管辖经销商', dataIndex: 'allDealerFlagDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '管辖品类', dataIndex: 'allProductFlagDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '管辖仓库', dataIndex: 'warehouse', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '管辖仓库',scopedSlots: { customRender: 'showWarehouse' },  width: '22%', align: 'center'},
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
       ],
       // 加载数据方法 必须为 Promise 对象
@@ -208,5 +223,19 @@ export default {
     .table-operator{
       text-align:right;
     }
+    .warehouseBox{
+  wwidth: 100%;
+      display: -webkit-box;
+      -webkit-box-orient: vertical;
+      -webkit-line-clamp: 2;
+      overflow: hidden;
+      text-overflow: ellipsis;
+    }
+    .warehouseBox span::after{
+      content:','
+    }
+    .warehouseBox span:last-child::after{
+      content:''
+    }
   }
 </style>