lilei 8 月之前
父节点
当前提交
a10918072c

+ 2 - 2
src/views/common/productTypeAll.js

@@ -63,8 +63,8 @@ const ProductType = {
       console.log(inputValue, path)
       return path.some(option => option.productTypeName.indexOf(inputValue) > -1);
     },
-    setDefValue(defaultVal){
-      this.handleChange(defaultVal)
+    setDefValue(defaultVal,row){
+      this.handleChange(defaultVal,row)
     },
     handleChange (value,row) {
       this.defaultVal = value

+ 1 - 1
src/views/expenseManagement/expenseReimbursement/epenseCdfModal.vue

@@ -127,7 +127,7 @@
             </template>
             <template slot="footer" slot-scope="currentPageData">
               <a-button
-                :id="'cdfTable-add-'+index"
+                id="cdfTable-add-0"
                 type="link"
                 class="button-info"
                 block

+ 29 - 20
src/views/expenseManagement/expenseReimbursement/productInfoModal.vue

@@ -26,9 +26,9 @@
           <a-table
             class="sTable fixPagination"
             ref="table"
-            :scroll="{ y: 200 }"
+            :scroll="{ y: 300 }"
             size="small"
-            :rowKey="(record) => record.id"
+            :rowKey="(record,index) => 'productTable-'+index"
             :columns="columns"
             :data-source="dataList"
             :pagination="false"
@@ -36,7 +36,7 @@
             <div slot="customTitle"><span style="color: red;">*</span>费用金额</div>
             <template slot="action" slot-scope="text,record,index">
               <a-button
-                :id="'productInfoModal-del-'+record.id"
+                :id="'del-'+index"
                 size="small"
                 type="link"
                 class="button-error"
@@ -45,26 +45,30 @@
             </template>
             <!-- 产品品牌 -->
             <template slot="productBrand" slot-scope="text,record,index">
-              <ProductBrand style="width: 100%;" :disabled="!!record.productCode" :id="'productBrand-'+index" @change="productBrandChange" v-model="record.productBrandSn"></ProductBrand>
+              <span v-if="!!record.productCode">{{ record.productBrandName }}</span>
+              <ProductBrand style="width: 100%;" v-else :id="'productBrand-'+index" @change="productBrandChange" v-model="record.productBrandSn"></ProductBrand>
             </template>
             <!-- 产品分类 -->
             <template slot="productType" slot-scope="text,record,index">
+              <span v-if="!!record.productCode">
+                {{ record.productTypeName1 }}>{{ record.productTypeName2 }}>{{ record.productTypeName3 }}
+              </span>
               <ProductTypeAll
+                v-else
                 style="width: 100%;"
-                :disabled="!!record.productCode"
                 :ref="'productType-'+record.no"
-                :id="'productInfoModal-productType-'+record.id"
+                :id="'productType-'+index"
                 v-model="record.productType"
                 @change="changeProductType"></ProductTypeAll>
             </template>
             <!-- 产品编码 -->
             <template slot="productCode" slot-scope="text,record,index">
-              <productCodeList :ref="'productCode-'+record.no" :key="'productCode-'+index" :id="'productCode-'+record.id" @change="e => productCodeChange(e, record)" />
+              <productCodeList :ref="'productCode-'+record.no" :key="'productCode-'+index" :id="'productCode-'+index" @change="productCodeChange" />
             </template>
             <!-- 费用金额 -->
-            <template slot="expense" slot-scope="text,record">
+            <template slot="expense" slot-scope="text,record,index">
               <a-input-number
-                :id="'productInfoModal-expense-'+record.id"
+                :id="'expense-'+index"
                 style="width: 100%;"
                 v-model="record.expense"
                 :precision="2"
@@ -73,9 +77,9 @@
                 placeholder="请输入"
               />
             </template>
-            <template slot="footer" slot-scope="currentPageData">
+            <template slot="footer">
               <a-button
-                :id="'productInfoModal-add-'+record.id"
+                id="productInfoModal-add-0"
                 type="link"
                 class="button-info"
                 v-if="dataList.length==0"
@@ -129,7 +133,7 @@ export default {
       baseData: null, // 详细信息
       columns: [
         { title: '产品品牌', scopedSlots: { customRender: 'productBrand' }, align: 'center', width: '20%' },
-        { title: '产品分类', scopedSlots: { customRender: 'productType' }, align: 'center', width: '30%' },
+        { title: '产品分类', scopedSlots: { customRender: 'productType' }, align: 'center', width: '40%' },
         { title: '产品编码', scopedSlots: { customRender: 'productCode' }, align: 'center', width: '20%' },
         // { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'expense' }, align: 'center', width: '20%' }
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
@@ -138,7 +142,9 @@ export default {
   },
   methods: {
     // 产品编码
-    productCodeChange (val, row) {
+    productCodeChange (val, id) {
+      const index = id.split('-')[1]
+      const row = this.dataList[index]
       row.productSn = val.key || undefined
       row.productCode = val.row && val.row.code ? val.row.code : undefined
       row.productName = val.row && val.row.name ? val.row.name : undefined
@@ -152,9 +158,10 @@ export default {
       row.productTypeName3 = val.row && val.row.productTypeName3 ? val.row.productTypeName3 : undefined
       // 设置默认值
       const defval = row.productTypeSn1 || row.productTypeSn2 || row.productTypeSn3 ? [row.productTypeSn1, row.productTypeSn2, row.productTypeSn3] : []
-      this.$set(row, 'productType', defval)
+      row.productType = defval
+      console.log(row)
       this.$nextTick(() => {
-        this.$refs['productType-' + row.no].setDefValue(defval)
+        this.$refs['productType-' + row.no].setDefValue(defval, row)
       })
     },
     // 产品品牌
@@ -165,6 +172,7 @@ export default {
     },
     //  产品分类  change
     changeProductType (val, id, options) {
+      console.log(val, id, options)
       const index = id.split('-')[1]
       const row = this.dataList[index]
       if (val.length > 1) {
@@ -179,7 +187,7 @@ export default {
       } else if (val.length == 1) {
         this.$set(row, 'productType', [])
         this.$nextTick(() => {
-          this.$refs['productType-' + row.no].setDefValue([])
+          this.$refs['productType-' + row.no].setDefValue([], row)
         })
         this.$message.info('不能只选择一级分类')
       }
@@ -265,12 +273,13 @@ export default {
           this.dataList.map(item => {
             item.no = item.id
             this.$nextTick(() => {
-              if (item.productTypeSn1 || item.productTypeSn2 || item.productTypeSn3) {
-                item.productType = [item.productTypeSn1, item.productTypeSn2, item.productTypeSn3]
-                this.$refs['productType-' + item.no].setDefValue([item.productTypeSn1, item.productTypeSn2, item.productTypeSn3])
-              }
               if (item.productCode) {
                 this.$refs['productCode-' + item.no].setDufaultVal(item.productCode)
+              } else {
+                if (item.productTypeSn1 || item.productTypeSn2 || item.productTypeSn3) {
+                  item.productType = [item.productTypeSn1, item.productTypeSn2, item.productTypeSn3]
+                  this.$refs['productType-' + item.no].setDefValue([item.productTypeSn1, item.productTypeSn2, item.productTypeSn3], item)
+                }
               }
             })
           })