Преглед изворни кода

需求单物料多选增行功能

黄梓星 пре 1 година
родитељ
комит
067b86fa3f

+ 13 - 5
src/components/PopDialog/index.vue

@@ -21,7 +21,7 @@
           </el-header>
           <el-main>
             <el-table :data="dataList" v-loading="loading" size="small" border ref="contractTable" @row-click="rowSelect"
-              @select="handleSelectionChange" height="calc(100% - 40px)" style="width: 100%">
+              @select="handleSelectionChange" :selection="selectedRows" @selection-change="watchSel"  height="calc(100% - 40px)" style="width: 100%">
               <el-table-column type="selection" header-align="center" align="center" width="50">
               </el-table-column>
               <el-table-column prop="code" header-align="center" align="center" sortable="custom" min-width="90"
@@ -67,6 +67,7 @@ export default {
       orders: [],
       loading: false,
       visible: false,
+      selectedRows:[]
     };
   },
   props: {
@@ -79,7 +80,7 @@ export default {
     // 是否启用单选
     single: {
       type: Boolean,
-      default: false
+      default: true
     }
   },
   methods: {
@@ -136,14 +137,21 @@ export default {
       this.searchForm.pageNo = 1;
       this.refreshList();
     },
+    watchSel(rows) {
+      console.log('监听得到选中吗', rows)
+      this.dataListAllSelections = rows
+    },
     // 表格选中数据
-    rowSelect(row, column, event) {
-      this.$refs.contractTable.clearSelection();
+    rowSelect(row) {
+      // this.$refs.contractTable.clearSelection();
+      // this.$refs.contractTable.toggleRowSelection(row);
+      // this.dataListAllSelections = this.single ? [row] : selection
       this.$refs.contractTable.toggleRowSelection(row);
-      this.dataListAllSelections = this.single ? [row] : selection
     },
     // 选中数据
     handleSelectionChange(selection, row) {
+      console.log('selection',selection)
+      console.log('row',[row])
       if (this.single && selection.length > 1) {
         this.$refs.contractTable.clearSelection();
         this.$refs.contractTable.toggleRowSelection(row);

+ 2 - 2
src/views/purchase/DemandSummary/add.vue

@@ -21,8 +21,8 @@
           style="font-size: 12px;"
           @selection-change="handleSelectionChange"
         >
-        <el-table-column show-overflow-tooltip type="selection"/>
-        <el-table-column show-overflow-tooltip label="序号" align="center" type="index" width="55"/>
+        <el-table-column show-overflow-tooltip type="selection" fixed="left"/>
+        <el-table-column show-overflow-tooltip label="序号" align="center" type="index" width="55" fixed="left"/>
         <el-table-column show-overflow-tooltip label="行号" align="center" prop="rowNo">
           <template slot-scope="scope">
             {{ scope.$index + 1 + '0' }}

+ 2 - 1
src/views/purchase/DemandSummary/index.vue

@@ -233,7 +233,8 @@
           @selection-change="handleSelectionChange"
           :key="isUpdate"
         >
-          <el-table-column type="selection" width="60" />
+          <el-table-column type="selection" width="60" fixed="left"/>
+          <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px" fixed="left"/>
           <!-- <el-table-column show-overflow-tooltip label="行号" align="center" prop="rowNo"/> -->
           <el-table-column show-overflow-tooltip label="行状态" align="center" prop="status" width="100px" :formatter="hangStatus"/>
           <el-table-column show-overflow-tooltip label="一级品类" align="center" prop="materialClassifyOneName" width="100px"/>

+ 158 - 4
src/views/purchase/PurchaseDemandList/add.vue

@@ -170,8 +170,8 @@
           @selection-change="handleSelectionChange"
           :cell-class-name="cellClassName"
         >
-          <el-table-column show-overflow-tooltip type="selection"/>
-          <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px"/>
+          <el-table-column show-overflow-tooltip type="selection" fixed="left"/>
+          <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px" fixed="left"/>
           <el-table-column show-overflow-tooltip label="行号" align="center" prop="rowNo">
             <template slot-scope="scope">
               {{ scope.$index + 1 + '0' }}
@@ -427,7 +427,7 @@
 
       <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
 
-      <popDialog ref="materialRefer" @doSubmit="selectMaterial" :single="true" />
+      <popDialog ref="materialRefer" @doSubmit="selectMaterial" :single="false" />
 
 
     <!-- 批量调整参数 -->
@@ -1318,6 +1318,7 @@ export default {
     },
     selectMaterial(selection) {
       console.log('选中的物料', selection)
+      if (selection.length <= 1) {
       // 选择新物料时先清空行内其他信息
       this.basicForm.puDemandItemList[this.tableIndex].reservedProportion = null
       this.basicForm.puDemandItemList[this.tableIndex].reservedPeriod = null
@@ -1388,7 +1389,160 @@ export default {
       this.basicForm.puDemandItemList[this.tableIndex].transportationCondition = selection[0].transportationCondition
       this.basicForm.puDemandItemList[this.tableIndex].storageCondition = selection[0].storageCondition
       // 选中骨科耗材时候的物料,需求客户不必填
-
+      } else {
+        console.log('xxxxx', selection)
+        for (let i = 0;i<selection.length;i++) {
+          let line = {
+            contacts: null,
+            id: null,
+            demandId: null,
+            status: null,
+            businessDept: null,
+            businessDeptName: null,
+            materialCategory: null,
+            buyer: null,
+            buyerName: null,
+            mateiralClassifyOne: null,
+            materialClassifyOneName: null,
+            materialClassifyTwo: null,
+            materialClassifyTwoName: null,
+            materialClassifyThree: null,
+            materialClassifyThreeName: null,
+            materialClassifyFour: null,
+            materialClassifyFourName: null,
+            materialCode: null,
+            material: null,
+            materialName: null,
+            classifyId: null,
+            specification: null,
+            unit: null,
+            unitName: null,
+            manufacturerName: null,
+            registrant: null,
+            puPeriod: null,
+            expiryUnit: null,
+            expiry: null,
+            minPackage: null,
+            minOrderQty: null,
+            minBatch: null,
+            safeStock: null,
+            averageQtyMonth: null,
+            qty: null,
+            adjustmentPersonal: null,
+            adjustmentTime: null,
+            manualRegulation: null,
+            updateCause: null,
+            reservedProportion: null,
+            reservedPeriod: null,
+            reservedQty: null,
+            demandPeriod: null,
+            forecastClassify: null,
+            onemonthAvgVolume: null,
+            threemonthAvgVolume: null,
+            puFreight: null,
+            deliveryDate: null,
+            isUrgency: this.basicForm.billType == 'JJXQ' ? 'Y' : 'N',
+            isReplenishment: this.basicForm.billType == 'BDXQ' ? 'Y' : 'N',
+            isBatchLock: 'N',
+            isCustomerSpecified: '',
+            remark: null,
+            puRemark: null,
+            lastWarehouseQty: null,
+            resDemandQty: null,
+            lastWarehouse: null,
+            lastWarehouseName: null,
+            deliveryWarehouse: null,
+            deliveryWarehouseName: null,
+            lastAllocation: null,
+            lastAllocationName: null,
+            deliveryAllocation: null,
+            deliveryAllocationName: null,
+            passageOn: null,
+            puOrg: null,
+            purOrgName: null,
+            lastStockQty: null,
+            superiorCenterQty: null,
+            superiorAllotQty: null,
+            availableQty: null,
+            statusAllot: 'N',
+            additionalSupplier: null,
+            additionalSupplierName: null,
+            periodUnit: null,
+            demandCustomer: this.basicForm.customer,
+            demandCustomerName: this.basicForm.customerName,
+            businessDept: this.basicForm.demandDept,
+            businessDeptName: null,
+            lastStockOrg: null,
+            lastStockOrgName: null,
+            superiorStockOrg: null,
+            superiorStockOrgName: null,
+            allotCode: null,
+            deliveryAddress: null,
+            deliveryAddressName: null,
+            contacts: null,
+            contactsPhone: null,
+            address: null,
+            source: null,
+            priceType: 'order',
+            puManagerApprover: null,
+            puManagerApproverName: null,
+            processTime: null,
+            affirmer: null,
+            tenantId: null,
+            revision: null,
+            createBy: null,
+            createByName: null,
+            createTime: null,
+            updateBy: null,
+            updateByName: null,
+            updateTime: null,
+            delFlag: 0,
+            // 新增字段
+            model: null,
+            storageCondition: null,
+            transportationCondition: null,
+          }
+                // 通过选择物料查询采购员
+          queryMan(selection[i].id).then(res => {
+            if (res.code === 200 && res.rows.length !== 0) {
+              line.buyer = res.rows[0].buyer
+              line.buyerName = res.rows[0].buyerName
+            }
+          })
+          line.businessDept = selection[i].businessDepartment
+          line.businessDeptName = selection[i].businessDepartmentName
+          line.materialCode = selection[i].code
+          line.material = selection[i].id
+          line.materialName = selection[i].name
+          line.classifyId = selection[i].classifyId
+          line.materialClassifyOneName = selection[i].oneClass
+          line.materialClassifyTwoName = selection[i].twoClass
+          line.materialClassifyThreeName = selection[i].threeClass
+          line.materialClassifyFourName = selection[i].fourClass
+          line.specification = selection[i].specification
+          line.model = selection[i].model
+          line.unit = selection[i].unitId
+          line.unitName = selection[i].unitIdName
+          line.registrant = selection[i].registrant
+          line.manufacturerName = selection[i].manufacturerIdName
+          line.puPeriod = selection[i].deliveryPeriod
+          line.expiry = selection[i].usefulLife
+          line.expiryUnit = selection[i].expiryUnitIdName
+          // line.minPackage = selection[i].usefulLife
+          line.minPackage = selection[i].minPackQty
+          line.minOrderQty = selection[i].minOrderQty
+          line.minBatch = selection[i].minBatchQty
+          line.safeStock = selection[i].safeStock
+          line.purOrgName = selection[i].purchasingOrganizationName
+          line.puOrg = selection[i].purchasingOrganization
+          // 物料存储条件和运输条件
+          line.transportationCondition = selection[i].transportationCondition
+          line.storageCondition = selection[i].storageCondition
+          this.basicForm.puDemandItemList.push(line)
+        }
+        // 删除指定下标
+        this.basicForm.puDemandItemList.splice(this.tableIndex,1)
+      }
     },
     // 明细行选择业务部门参照带出业务部门数据
     chooseDept(index, type, isPage, title) {

+ 2 - 1
src/views/purchase/PurchaseDemandList/index.vue

@@ -171,7 +171,8 @@
           style="font-size: 12px;"
           @selection-change="handleSelectionChange"
         >
-          <el-table-column show-overflow-tooltip type="selection" width="55" />
+          <el-table-column show-overflow-tooltip type="selection" width="55" fixed="left"/>
+          <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px" fixed="left"/>
           <el-table-column show-overflow-tooltip label="编码" align="center" width="170" prop="code"/>
           <el-table-column show-overflow-tooltip label="需求日期" align="center" width="120" prop="demandDate"/>
           <el-table-column show-overflow-tooltip label="审批结束日期" align="center" width="120" prop="approverFinishTime"/>