lilei пре 2 година
родитељ
комит
cb74dacc89

+ 3 - 3
src/views/supplierManagement/associatedProduct/settingCost.vue

@@ -17,10 +17,10 @@
           :label-col="labelCol"
           :wrapper-col="wrapperCol"
         >
-          <a-form-model-item label="产品名称">
-            {{ productName }}
+          <a-form-model-item style="margin-bottom:10px;" label="产品名称">
+            <div style="line-height:normal;padding-top:11px;">{{ productName }}</div>
           </a-form-model-item>
-          <a-form-model-item label="产品编码">
+          <a-form-model-item style="margin-bottom:10px;" label="产品编码">
             {{ productCode }}
           </a-form-model-item>
           <a-form-model-item label="成本价" prop="cost">

+ 67 - 105
src/views/supplierManagement/costSetting/addProductModal.vue

@@ -13,13 +13,15 @@
         <div style="display:flex;align-items: center;padding:10px 0;">
           <div style="font-size:14px;"><span style="color:red;">*</span>供应商名称:</div>
           <div style="flex-grow: 1;">
-            <supplier style="width:50%" v-model="queryParam.supplierSn" placeholder="请输入供应商名称搜索"></supplier>
+            <supplier style="width:50%" v-model="supplierSn" @change="getChoosed" placeholder="请输入供应商名称搜索"></supplier>
           </div>
         </div>
-       <div style="padding:10px 0;border-bottom: 1px solid #eee;">
-         <span style="font-size:14px;">选择产品</span>
-         <span style="font-weight: bold;">(已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length }}个)</span>
-       </div>
+        <div style="padding:10px 0;border-bottom: 1px solid #eee;">
+          <span style="font-size:14px;">选择产品</span>
+          <span style="font-weight: bold;" v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length">
+            (已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length||0 }}个)
+          </span>
+        </div>
         <div style="padding:15px 0 0;">
           <!-- 搜索条件 -->
           <div class="table-page-search-wrapper">
@@ -39,7 +41,7 @@
                   </a-form-model-item>
                 </a-col>
                 <a-col :md="6" :sm="24">
-                  <a-form-model-item label="产品品牌" :prop="type=='dealership'?'productBrandSn':''">
+                  <a-form-model-item label="产品品牌">
                     <a-select
                       placeholder="请选择产品品牌"
                       id="chooseProducts-productBrandSn"
@@ -53,7 +55,7 @@
                   </a-form-model-item>
                 </a-col>
                 <a-col :md="6" :sm="24">
-                  <a-form-model-item label="产品分类" :prop="type=='dealership'?'productType':''">
+                  <a-form-model-item label="产品分类">
                     <a-cascader
                       @change="changeProductType"
                       change-on-select
@@ -80,7 +82,7 @@
             size="small"
             :rowKey="(record) => record.productSn"
             rowKeyName="productSn"
-            :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: (this.type == 'supplier') && (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.indexOf(record.productSn) > -1) }}) }"
+            :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: this.chooseData && this.chooseData.indexOf(record.productSn) > -1 }}) }"
             @rowSelection="rowSelectionFun"
             :columns="columns"
             :data="loadData"
@@ -115,7 +117,8 @@ import { productBrandQuery } from '@/api/productBrand'
 import { productTypeQuery, productTypeQueryAll } from '@/api/productType'
 import supplier from '@/views/common/supplier.js'
 import { dealerScopeValidProduct } from '@/api/dealerScope'
-import { productPricedList, productPricingList } from '@/api/product'
+import { addProduct, supplierProductSnList } from '@/api/supplier'
+import { productPricingList } from '@/api/product'
 export default {
   name: 'ChooseProductsModal',
   components: { STable, supplier },
@@ -124,15 +127,9 @@ export default {
       type: Boolean,
       default: false
     },
-    chooseData: {
-      type: Array,
-      default: () => {
-        return []
-      }
-    },
     type: { //  类型,经销权设置dealership,  供应商添加产品supplier
       type: String,
-      default: ''
+      default: 'supplier'
     },
     dealerSn: {
       type: String || Number,
@@ -147,6 +144,7 @@ export default {
         labelCol: { span: 4 },
         wrapperCol: { span: 20 }
       },
+      supplierSn: undefined, // 供应商sn
       queryParam: { //  查询条件
         code: '', //  产品编码
         productBrandSn: undefined, //  产品品牌
@@ -159,6 +157,7 @@ export default {
         productBrandSn: [ { required: true, message: '请选择产品品牌', trigger: 'change' } ],
         productType: [ { required: true, message: '请选择产品分类', trigger: 'change' } ]
       },
+      chooseData: [], // 已选产品
       disabled: false, //  查询、重置按钮是否可操作
       loading: false, //  表格加载中
       columns: [
@@ -170,15 +169,8 @@ export default {
       loadData: parameter => {
         this.disabled = true
         this.spinning = true
-        let url = productPricedList //  获取定过价的产品
-        if (this.type == 'supplier') { //  供应商增加产品
-          url = productPricingList //  获取定价产品
-        }
         const params = Object.assign(parameter, this.queryParam)
-        if (this.type != 'supplier' && this.type != 'dealership') { //  促销
-          params.onlineFalg = 1
-        }
-        return url(params).then(res => {
+        return productPricingList(params).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -202,49 +194,26 @@ export default {
     rowSelectionFun (obj) {
       this.rowSelectionInfo = obj || null
     },
+    // 查询所有已选sn
+    getChoosed () {
+      this.spinning = true
+      supplierProductSnList({ sn: this.supplierSn }).then(res => {
+        if (res.status == 200) {
+          this.chooseData = res.data //  包含先前所选产品
+          this.handleSearch()
+        }
+        this.spinning = false
+      })
+    },
     // 查询
     handleSearch () {
       const _this = this
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          if (_this.type == 'dealership') { //  设置经销权时选择产品
-            // 校验产品是否被包含在品牌分类中
-            const params = []
-            if (_this.queryParam.productBrandSn) {
-              params.push({
-                dealerSn: _this.dealerSn,
-                goodsType: 'BRAND',
-                goodsSn: _this.queryParam.productBrandSn
-              })
-            }
-            if (_this.queryParam.productTypeSn1) {
-              params.push({
-                dealerSn: _this.dealerSn,
-                goodsType: 'CATEGORY',
-                goodsSn: _this.queryParam.productTypeSn1
-              })
-            }
-            if (_this.queryParam.productTypeSn2) {
-              params.push({
-                dealerSn: _this.dealerSn,
-                goodsType: 'CATEGORY',
-                goodsSn: _this.queryParam.productTypeSn2
-              })
-            }
-            if (_this.queryParam.productTypeSn3) {
-              params.push({
-                dealerSn: _this.dealerSn,
-                goodsType: 'CATEGORY',
-                goodsSn: _this.queryParam.productTypeSn3
-              })
-            }
-            dealerScopeValidProduct(params).then(res => {
-              if (res.status == 200) {
-                _this.$refs.table.refresh(true)
-              }
-            })
-          } else {
+          if (this.supplierSn) {
             _this.$refs.table.refresh(true)
+          } else {
+            this.$message.warning('请先选择供应商!')
           }
         } else {
           return false
@@ -268,22 +237,39 @@ export default {
     // 保存
     handleSave () {
       const _this = this
+      if (!this.supplierSn) {
+        this.$message.warning('请先选择供应商!')
+        return
+      }
       if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
-        this.$message.warning('请在列表勾选后再进行操作!')
+        this.$message.warning('请选择产品!')
         return
       }
-      if (this.type == 'supplier') { //  供应商增加产品
-        const arr = []
-        this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.map(item => {
-          if (_this.chooseData.indexOf(item) == -1) {
-            arr.push(item)
-          }
-        })
-        this.$emit('ok', arr)
+      const arr = []
+      this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.map(item => {
+        if (_this.chooseData.indexOf(item) == -1) {
+          arr.push(item)
+        }
+      })
+      if (arr.length) {
+        this.addProduct(arr)
       } else {
-        this.$emit('ok', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
+        this.$message.warning('请选择产品!')
       }
-      this.isShow = false
+    },
+    // 添加产品  数据处理
+    addProduct (arr) {
+      this.spinning = true
+      addProduct({
+        supplierSn: this.supplierSn,
+        productSnList: arr
+      }).then(res => {
+        if (res.status == 200) {
+          this.$emit('ok')
+          this.isShow = false
+        }
+        this.spinning = false
+      })
     },
     //  产品分类  change
     changeProductType (val, opt) {
@@ -308,23 +294,13 @@ export default {
     },
     //  产品分类  列表
     getProductType () {
-      if (this.type != 'supplier' && this.type != 'dealership') { //  促销
-        productTypeQueryAll({}).then(res => {
-          if (res.status == 200) {
-            this.productTypeList = res.data
-          } else {
-            this.productTypeList = []
-          }
-        })
-      } else {
-        productTypeQuery({}).then(res => {
-          if (res.status == 200) {
-            this.productTypeList = res.data
-          } else {
-            this.productTypeList = []
-          }
-        })
-      }
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
     }
   },
   watch: {
@@ -337,24 +313,10 @@ export default {
       if (!newValue) {
         this.$emit('close')
         this.$refs.table.clearTable()
+        this.chooseData = []
+        this.supplierSn = undefined
         this.resetData()
       } else {
-        const _this = this
-        let selectedRows = []
-        let selectedRowKeys = []
-        if (this.type == 'supplier') { //  供应商增加产品
-          selectedRows = []
-          selectedRowKeys = this.chooseData
-        } else {
-          selectedRows = this.chooseData
-          selectedRowKeys = []
-          this.chooseData.map(item => {
-            selectedRowKeys.push(item.goodsSn)
-          })
-        }
-        this.$nextTick(() => { // 页面渲染完成后的回调
-          _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
-        })
         if (this.productBrandList.length == 0) {
           this.getProductBrand()
         }

+ 11 - 10
src/views/supplierManagement/costSetting/list.vue

@@ -98,7 +98,7 @@
         </template>
       </s-table>
     </a-spin>
-    
+
     <!-- 新增 -->
     <addProductModal :openModal="newProduct" @close="newProduct=false" @ok="handleProductsOk" />
     <!-- 设置成本价 -->
@@ -204,20 +204,21 @@ export default {
       this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
     },
     // 导出明细
-    handleExport(){
-      
+    handleExport () {
+
     },
     // 新增成功
-    handleProductsOk(){
-      
+    handleProductsOk () {
+      this.newProduct = false
+      this.resetSearchForm()
     },
     // 批量导入
-    handleBatchImport(){
-      
+    handleBatchImport () {
+
     },
     // 批量审核
-    handleBatchAudit(){
-      
+    handleBatchAudit () {
+
     },
     // 单个审核
     handleAudit (row) {
@@ -241,7 +242,7 @@ export default {
       })
     },
     // 成本设置
-    handleCostSet(row){
+    handleCostSet (row) {
       this.openSetModal = true
       this.$refs.settingCost.setData(row)
     },

+ 4 - 4
src/views/supplierManagement/costSetting/settingCost.vue

@@ -17,13 +17,13 @@
           :label-col="labelCol"
           :wrapper-col="wrapperCol"
         >
-          <a-form-model-item label="产品名称">
-            {{ productName }}
+          <a-form-model-item style="margin-bottom:10px;" label="产品名称">
+            <div style="line-height:normal;padding-top:11px;">{{ productName }}</div>
           </a-form-model-item>
-          <a-form-model-item label="产品编码">
+          <a-form-model-item style="margin-bottom:10px;" label="产品编码">
             {{ productCode }}
           </a-form-model-item>
-          <a-form-model-item label="供应商名称">
+          <a-form-model-item style="margin-bottom:10px;" label="供应商名称">
             {{ supplierName }}
           </a-form-model-item>
           <a-form-model-item label="成本价" prop="cost">