Prechádzať zdrojové kódy

Merge branch 'purchaseDev' of http://172.16.100.139/new-business/drp-web into purchaseDev

002390 1 rok pred
rodič
commit
38b139469c

+ 1 - 1
src/api/business/spd/goal_management/annualSaleGoal.js

@@ -29,7 +29,7 @@ export function addAnnualSaleGoal(data) {
 // 修改年度销售目标
 export function updateAnnualSaleGoal(data) {
   return request({
-    url: '/goal_management/annualSaleGoal',
+    url: '/goal_management/annualSaleGoal/edit',
     method: 'put',
     data: data
   })

+ 8 - 1
src/views/business/spd/target/AnnualSaleGoal.vue

@@ -849,7 +849,7 @@
           this.saveFormTwoPoint(this.form)
           this.annualSaleGoalDetailsList = this.form.annualGoalMergeDetails
           this.open = true;
-          this.title = "修改--年销售目标";
+          this.title = "修改--年销售目标填报";
         });
       },
       // 复制按钮
@@ -887,6 +887,13 @@
         if (!this.justiceDetailsList()) {
           return this.$message.error('子表有必填字段没有赋值')
         }
+        for (let i = 0; i < this.annualSaleGoalDetailsList.length; i++) {
+          for (let j = i + 1; j < this.annualSaleGoalDetailsList.length; j++) {
+            if (this.annualSaleGoalDetailsList[i].materialCode == this.annualSaleGoalDetailsList[j].materialCode) {
+              return this.$message.error('子表存在重复物料');
+            }
+          }
+        }
         this.$refs["form"].validate(valid => {
           if (valid) {
             if (this.form.id != null) {

+ 2 - 0
src/views/business/spd/target/AnnualSaleGoalMerge.vue

@@ -1037,7 +1037,9 @@
         this.form.documentDate = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString()
           .padStart(2, '0') + '-' + new Date().getDate().toString().padStart(2, '0')
         this.form.annual = new Date().getFullYear().toString()
+        this.form.creatorCode = this.$store.state.user.name
         this.form.creator = this.$store.state.user.nickName
+        this.form.deptId = this.$store.state.user.deptId
         this.form.dept = this.$store.state.user.deptName
       },
       handleAddDetails() {

+ 6 - 1
src/views/business/spd/target/MonthGoalMerge.vue

@@ -59,7 +59,7 @@
         <el-col :span="6">
           <el-form-item label="部门" prop="dept">
             <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name" referName="DEPT_PARAM"
-              :dataMapping="{ deptCode: 'code', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门">
+              :dataMapping="{ deptCode: 'id', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门">
             </el-popover-select-v2>
           </el-form-item>
         </el-col>
@@ -741,6 +741,9 @@
         listMonthGoalMerge(this.queryParams).then(response => {
           this.monthGoalMergeList = response.rows;
           this.total = response.total;
+          this.monthGoalMergeList.forEach(item => {
+            item.goalSum = item.goalSum.toFixed(2);
+          })
           this.loading = false;
         });
       },
@@ -848,7 +851,9 @@
         this.form.annual = new Date().getFullYear().toString()
         this.form.monthly = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString().padStart(
           2, '0')
+        this.form.creatorCode = this.$store.state.user.name
         this.form.creator = this.$store.state.user.nickName
+        this.form.deptCode = this.$store.state.user.deptId
         this.form.dept = this.$store.state.user.deptName
       },
       handleAddDetails() {

+ 1 - 1
src/views/business/spd/target/MonthReturnGoal.vue

@@ -71,7 +71,7 @@
         <el-col :span="6">
           <el-form-item label="部门" prop="dept">
             <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name" referName="DEPT_PARAM"
-              :dataMapping="{ deptCode: 'code', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门"
+              :dataMapping="{ deptCode: 'id', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门"
               @keyup.enter.native="handleQuery">
             </el-popover-select-v2>
           </el-form-item>

+ 5 - 3
src/views/business/spd/target/MonthReturnMerge.vue

@@ -76,7 +76,7 @@
         <el-col :span="6">
           <el-form-item label="部门" prop="dept">
             <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name" referName="DEPT_PARAM"
-              :dataMapping="{ deptCode: 'code', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门">
+              :dataMapping="{ deptCode: 'id', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门">
             </el-popover-select-v2>
           </el-form-item>
         </el-col>
@@ -303,7 +303,7 @@
                 </el-table-column>
                 <el-table-column label="目标值(元)" align="center" prop="goalSum" width="220">
                   <template slot-scope="scope">
-                    <el-input-number @change="computeTotal" v-model="monthReturnMergeDetailsList[scope.$index].goalSum"
+                    <el-input-number disabled @change="computeTotal" v-model="monthReturnMergeDetailsList[scope.$index].goalSum"
                       :precision="2" :step="1" :min="0"></el-input-number>
                   </template>
                 </el-table-column>
@@ -709,7 +709,9 @@
         this.form.annual = new Date().getFullYear().toString()
         this.form.monthly = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString().padStart(
           2, '0')
+        this.form.creatorCode = this.$store.state.user.name
         this.form.creator = this.$store.state.user.nickName
+        this.form.deptCode = this.$store.state.user.deptId
         this.form.dept = this.$store.state.user.deptName
       },
       handleAddDetails() {
@@ -867,7 +869,7 @@
         }
         mergeMonthReturnMergeDetails(this.form).then(response => {
           console.log(response)
-          if (response.data.monthReturnMergeDetails) {
+          if (response.data.monthReturnMergeDetails.length > 0) {
             this.monthReturnMergeDetailsList = response.data.monthReturnMergeDetails
             this.computeTotal()
           } else {

+ 9 - 2
src/views/business/spd/target/MonthSaleGoal.vue

@@ -71,7 +71,7 @@
         <el-col :span="6">
           <el-form-item label="部门" prop="dept">
             <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name" referName="DEPT_PARAM"
-              :dataMapping="{ deptCode: 'code', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门"
+              :dataMapping="{ deptCode: 'id', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门"
               @keyup.enter.native="handleQuery">
             </el-popover-select-v2>
           </el-form-item>
@@ -330,7 +330,7 @@
                     </el-date-picker>
                   </template>
                 </el-table-column>
-                <el-table-column label="目标值" align="center" prop="goalValue" width="220" :render-header="addRedStar">
+                <el-table-column label="目标值(元)" align="center" prop="goalValue" width="220" :render-header="addRedStar">
                   <template slot-scope="scope">
                     <el-input-number @change="computeTotal" v-model="monthSaleGoalDetailsList[scope.$index].goalValue"
                       :precision="2" :step="1" :min="0"></el-input-number>
@@ -837,6 +837,13 @@
         if (!this.justiceDetailsList()) {
           return this.$message.error('子表有必填字段未填,或者目标值为0')
         }
+        for (let i = 0; i < this.monthSaleGoalDetailsList.length; i++) {
+          for (let j = i + 1; j < this.monthSaleGoalDetailsList.length; j++) {
+            if (this.monthSaleGoalDetailsList[i].materialCode == this.monthSaleGoalDetailsList[j].materialCode) {
+              return this.$message.error('子表存在重复物料');
+            }
+          }
+        }
         this.$refs["form"].validate(valid => {
           if (valid) {
             if (this.form.id != null) {

+ 3 - 0
src/views/business/spd/target/targetMk/index.vue

@@ -319,6 +319,9 @@
       //查询列表
       getList(params) {
         this.loading = true;
+        if (this.dateRange[1] != null) {
+          this.dateRange[1] = this.dateRange[1] + ' 23:59:59'
+        }
         listTarget(this.addDateRange(params, this.dateRange)).then(res => {
           if (res.code === 200) {
             this.tableList = res.rows;

+ 2 - 1
src/views/business/spd/target/targetMk/item.vue

@@ -70,7 +70,8 @@
         <el-table-column show-overflow-tooltip v-if="head.children" v-for="headChi in head.children" :prop="headChi.prop" :label="headChi.modelName" width="150" align="center">
           <template slot-scope="scope">
             <div v-if="pageStu == 'add' || pageStu == 'edit'">
-              <el-input size="mini" v-model="scope.row[headChi.prop].value" class="input-view" oninput="value=value.replace(/[^0-9]/g,'')"></el-input>
+              <!-- <el-input size="mini" v-model="scope.row[headChi.prop].value" class="input-view" oninput="value=value.replace(/[^0-9]/g,'')"></el-input> -->
+              <el-input-number size="mini" v-model="scope.row[headChi.prop].value" :precision="2" class="input-view" oninput="value=value.replace(/[^0-9]/g,'')"></el-input-number>
             </div>
             <div v-else-if="pageStu == 'see'">
               {{scope.row[headChi.prop].value}}

+ 1 - 0
src/views/business/spd/target/targetTemplate/detail.vue

@@ -460,6 +460,7 @@ export default {
             start.setDate(start.getDate()+1);
           }
         }
+        cycles[cycles.length - 1].deadlineTime = deadline;
       }
       this.form.cycles = cycles;
       console.log('this.form.cycles',this.form.cycles);

+ 5 - 2
src/views/purchase/apply/add/columns.js

@@ -82,7 +82,7 @@ export default function useColumns() {
       attr: { is: "el-input", disabled: true, readonly: true },
     },
     {
-      item: { key: "file", title: "附件", required: true, span: 24 },
+      item: { key: "file", title: "附件", span: 24 },
       attr: { is: "el-file-upload" },
     },
     {
@@ -138,7 +138,10 @@ export default function useColumns() {
         },
         {
           item: { key: "materialCode", title: "物料编码", required: true },
-          attr: {},
+          attr: {
+            is: "el-input",
+            clearable: true,
+          }, 
         },
         { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
         { item: { key: "specification", title: "规格" }, attr: {} },

+ 488 - 3
src/views/purchase/apply/add/index.vue

@@ -3,6 +3,8 @@
   import {EXIST} from "@/api/business/purchase/catalogue";
   import {SAVE} from "@/api/business/purchase/apply";
   import {tax, unit, currency} from "@/components/popover-select-v2/fetch";
+  // 用于回显参照框数据
+  import {getRefer} from '@/api/purchase/basic.js'
 
   const fetchExist = async (prop) => {
     try {
@@ -52,6 +54,7 @@
         tabName: tabName,
         TabColumns: TabColumns,
         TableColumns: TableColumns,
+        delDemandItemList: [],
       };
     },
     computed: {},
@@ -191,8 +194,17 @@
       },
       //
       async onRowRemove(prop, scope) {
-        const {$index} = scope;
-        this.params[prop].splice($index, 1);
+        // const {$index} = scope;
+        // this.params[prop].splice($index, 1);
+        scope.row.delFlag = '2'
+        let delList = []
+        delList = this.params[prop].filter(item => {
+          return item.delFlag == '2'
+        })
+        this.params[prop] = this.params[prop].filter(item => {
+          return item.delFlag == '0'
+        })
+        this.delDemandItemList.push(...delList)
       },
       //
       async useSubmit(prop) {
@@ -200,11 +212,21 @@
           if (valid) {
             try {
               this.loading = true;
-              const {msg, code} = await SAVE(this.params);
+              let list = []
+              list.push(...this.params.priceApplyItems, ...this.delDemandItemList)
+              this.params.priceApplyItems = this.params.priceApplyItems.filter(
+                (item) => item.materialName
+              );
+              // 深拷贝一下参数对象
+              let param = JSON.parse(JSON.stringify(this.params))
+              console.log('深拷贝对象',param);
+              param.priceApplyItems = list
+              const {msg, code} = await SAVE(param);
               if (code === 200) {
                 this.onHide();
                 this.$emit("success");
                 this.$notify.success(msg);
+                this.delDemandItemList = []
               }
             } catch (err) {
               // catch
@@ -218,6 +240,359 @@
           }
         });
       },
+      // 粘贴
+      async pasteMe(e, scope, index, prop) {
+        this.$modal.loading("正在处理数据...");
+        e.preventDefault() //阻止默认粘贴事件
+        let source = e.clipboardData.getData("Text");
+        console.log('scope', scope.column.property)
+        console.log('index', index)
+        // 首先对源头进行解析
+        let rows = source.split("\r\n"); // 拆成一个数组
+        // 数组去除空字符串
+        rows = rows.filter(item => {
+          return item && item.trim()
+        })
+        if (rows.length < 100) {
+          if(scope.column.property == 'materialCode') {
+            let rowList = []
+            let newLine = []
+            await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
+              if (res.code === 200) {
+                rowList = res.rows
+              }
+            })
+            const {
+              puOrg,
+              customer,
+              customerName,
+              supplier,
+              currency,
+              currencyCode,
+              currencyName,
+            } = this.params;
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            // console.log('kk', TableColumns)
+            // console.log('this.$init.params(TableColumns)', this.$init.params(TableColumns))
+            for (let i = 0; i<rowList.length; i++) {
+              let line = {...this.$init.params(TableColumns)}
+              console.log('line',line)
+              const {nickName: createByName} = this.$store.state.user;
+              const {ntaxrate} = await tax(rowList[i].materialRateName);
+              // task 2
+              const {
+                id: puUnit,
+                code: puUnitCode,
+                name: puUnitName,
+              } = await unit(rowList[i].unitIdName);
+              // task 3
+              const {
+                recentlyPrice = "0",
+                isApprovalFirst = "N",
+                purchasequantity,
+                recentlyPriceDate
+              } = await fetchExist({puOrg, customer, supplier, materialCode: rowList[i].code, customerName: "", priceType: line.priceType});
+              line.delFlag = '0'
+              line.materialCode = rowList[i].code
+              line.material = rowList[i].id
+              line.materialName = rowList[i].name
+              line.specification = rowList[i].specification
+              line.model = rowList[i].model
+              line.manufacturerName = rowList[i].manufacturerIdName
+              line.unit = puUnit,
+              line.unitCode = puUnitCode,
+              line.unitName = puUnitName,
+              line.puUnit  = puUnit,
+              line.puUnitCode = puUnitCode,
+              line.puUnitName = puUnitName,
+              line.recentlyPrice = recentlyPrice
+              line.isApprovalFirst = isApprovalFirst
+              line.recentlyPriceDate = recentlyPriceDate,
+              line.yPurchaseQuantity = purchasequantity,
+              line.tax = Number(ntaxrate === "0E-8" ? 0 : ntaxrate),
+              line.createByName = createByName,
+              line.updateByName = createByName,
+              line.currency = currency
+              line.currencyCode = currencyCode
+              line.currencyName = currencyName
+              newLine.push(line)
+              console.log('临时数组', newLine)
+            }
+            // 删除指定下标
+            this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+            this.$modal.closeLoading();
+            this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
+
+          } else if(scope.column.property == 'taxPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.taxPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].taxPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } 
+
+        } else {
+          this.$modal.notifyWarning("复制长度不能超过100!");
+          this.$modal.closeLoading();
+        }
+      },
     },
     created() {
     },
@@ -292,6 +667,116 @@
                 >
                 </component>
               </template>
+              <template slot="materialCode" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="taxPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
               <template slot="customerName" slot-scope="scope">
                 <component
                   v-bind="scope.attr"

+ 5 - 2
src/views/purchase/apply/copy/columns.js

@@ -82,7 +82,7 @@ export default function useColumns() {
       attr: { is: "el-input", disabled: true, readonly: true },
     },
     {
-      item: { key: "file", title: "附件", required: true, span: 24 },
+      item: { key: "file", title: "附件", span: 24 },
       attr: { is: "el-file-upload" },
     },
     {
@@ -138,7 +138,10 @@ export default function useColumns() {
         },
         {
           item: { key: "materialCode", title: "物料编码", required: true },
-          attr: {},
+          attr: {
+            is: "el-input",
+            clearable: true,
+          },
         },
         { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
         { item: { key: "specification", title: "规格" }, attr: {} },

+ 488 - 4
src/views/purchase/apply/copy/index.vue

@@ -3,6 +3,8 @@
   import {EXIST} from "@/api/business/purchase/catalogue";
   import {ITEM, SAVE} from "@/api/business/purchase/apply";
   import {tax, unit, currency} from "@/components/popover-select-v2/fetch";
+  // 用于回显参照框数据
+  import {getRefer} from '@/api/purchase/basic.js'
 
   const fetchExist = async (prop) => {
     try {
@@ -56,6 +58,7 @@
         tabName: tabName,
         TabColumns: TabColumns,
         TableColumns: TableColumns,
+        delDemandItemList: [],
       };
     },
     computed: {
@@ -236,8 +239,17 @@
       },
       //
       async onRowRemove(prop, scope) {
-        const {$index} = scope;
-        this.params[prop].splice($index, 1);
+        // const {$index} = scope;
+        // this.params[prop].splice($index, 1);
+        scope.row.delFlag = '2'
+        let delList = []
+        delList = this.params[prop].filter(item => {
+          return item.delFlag == '2'
+        })
+        this.params[prop] = this.params[prop].filter(item => {
+          return item.delFlag == '0'
+        })
+        this.delDemandItemList.push(...delList)
       },
       //
       async useSubmit(prop) {
@@ -246,12 +258,21 @@
           if (valid) {
             try {
               this.loading = true;
-              this.params.priceApplyOrgs = [];
-              const {msg, code} = await SAVE(this.params);
+              let list = []
+              list.push(...this.params.priceApplyItems, ...this.delDemandItemList)
+              this.params.priceApplyItems = this.params.priceApplyItems.filter(
+                (item) => item.materialName
+              );
+              // 深拷贝一下参数对象
+              let param = JSON.parse(JSON.stringify(this.params))
+              console.log('深拷贝对象',param);
+              param.priceApplyItems = list
+              const {msg, code} = await SAVE(param);
               if (code === 200) {
                 this.onHide();
                 this.$emit("success");
                 this.$notify.success(msg);
+                this.delDemandItemList = []
               }
             } catch (err) {
               // catch
@@ -265,6 +286,359 @@
           }
         });
       },
+      // 粘贴
+      async pasteMe(e, scope, index, prop) {
+        this.$modal.loading("正在处理数据...");
+        e.preventDefault() //阻止默认粘贴事件
+        let source = e.clipboardData.getData("Text");
+        console.log('scope', scope.column.property)
+        console.log('index', index)
+        // 首先对源头进行解析
+        let rows = source.split("\r\n"); // 拆成一个数组
+        // 数组去除空字符串
+        rows = rows.filter(item => {
+          return item && item.trim()
+        })
+        if (rows.length < 100) {
+          if(scope.column.property == 'materialCode') {
+            let rowList = []
+            let newLine = []
+            await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
+              if (res.code === 200) {
+                rowList = res.rows
+              }
+            })
+            const {
+              puOrg,
+              customer,
+              customerName,
+              supplier,
+              currency,
+              currencyCode,
+              currencyName,
+            } = this.params;
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            // console.log('kk', TableColumns)
+            // console.log('this.$init.params(TableColumns)', this.$init.params(TableColumns))
+            for (let i = 0; i<rowList.length; i++) {
+              let line = {...this.$init.params(TableColumns)}
+              console.log('line',line)
+              const {nickName: createByName} = this.$store.state.user;
+              const {ntaxrate} = await tax(rowList[i].materialRateName);
+              // task 2
+              const {
+                id: puUnit,
+                code: puUnitCode,
+                name: puUnitName,
+              } = await unit(rowList[i].unitIdName);
+              // task 3
+              const {
+                recentlyPrice = "0",
+                isApprovalFirst = "N",
+                purchasequantity,
+                recentlyPriceDate
+              } = await fetchExist({puOrg, customer, supplier, materialCode: rowList[i].code, customerName: "", priceType: line.priceType});
+              line.delFlag = '0'
+              line.materialCode = rowList[i].code
+              line.material = rowList[i].id
+              line.materialName = rowList[i].name
+              line.specification = rowList[i].specification
+              line.model = rowList[i].model
+              line.manufacturerName = rowList[i].manufacturerIdName
+              line.unit = puUnit,
+              line.unitCode = puUnitCode,
+              line.unitName = puUnitName,
+              line.puUnit  = puUnit,
+              line.puUnitCode = puUnitCode,
+              line.puUnitName = puUnitName,
+              line.recentlyPrice = recentlyPrice
+              line.isApprovalFirst = isApprovalFirst
+              line.recentlyPriceDate = recentlyPriceDate,
+              line.yPurchaseQuantity = purchasequantity,
+              line.tax = Number(ntaxrate === "0E-8" ? 0 : ntaxrate),
+              line.createByName = createByName,
+              line.updateByName = createByName,
+              line.currency = currency
+              line.currencyCode = currencyCode
+              line.currencyName = currencyName
+              newLine.push(line)
+              console.log('临时数组', newLine)
+            }
+            // 删除指定下标
+            this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+            this.$modal.closeLoading();
+            this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
+
+          } else if(scope.column.property == 'taxPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.taxPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].taxPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } 
+
+        } else {
+          this.$modal.notifyWarning("复制长度不能超过100!");
+          this.$modal.closeLoading();
+        }
+      },
     },
     created() {
     },
@@ -344,6 +718,116 @@
                 >
                 </component>
               </template>
+              <template slot="materialCode" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="taxPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
               <template slot="customerName" slot-scope="scope">
                 <component
                   v-bind="scope.attr"

+ 5 - 2
src/views/purchase/apply/edit/columns.js

@@ -82,7 +82,7 @@ export default function useColumns() {
       attr: { is: "el-input", disabled: true, readonly: true },
     },
     {
-      item: { key: "file", title: "附件", required: true, span: 24 },
+      item: { key: "file", title: "附件", span: 24 },
       attr: { is: "el-file-upload" },
     },
     {
@@ -138,7 +138,10 @@ export default function useColumns() {
         },
         {
           item: { key: "materialCode", title: "物料编码", required: true },
-          attr: {},
+          attr: {
+            is: "el-input",
+            clearable: true,
+          },
         },
         { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
         { item: { key: "specification", title: "规格" }, attr: {} },

+ 494 - 8
src/views/purchase/apply/edit/index.vue

@@ -3,6 +3,8 @@
   import {EXIST} from "@/api/business/purchase/catalogue";
   import {ITEM, SAVE} from "@/api/business/purchase/apply";
   import {tax, unit, currency} from "@/components/popover-select-v2/fetch";
+  // 用于回显参照框数据
+  import {getRefer} from '@/api/purchase/basic.js'
 
   const fetchExist = async (prop) => {
     try {
@@ -56,6 +58,7 @@
         tabName: tabName,
         TabColumns: TabColumns,
         TableColumns: TableColumns,
+        delDemandItemList: [],
       };
     },
     computed: {
@@ -246,13 +249,26 @@
       },
       //
       async onRowRemove(prop, scope) {
-        const {
-          row: {$index},
-        } = scope;
-        this.params[prop] = this.params[prop].map((item, index) => ({
-          ...item,
-          delFlag: index === $index ? "2" : item.delFlag,
-        }));
+        console.log('prop', prop)
+        console.log('scope', scope)
+        // const {
+        //   row: {$index},
+        // } = scope;
+        // this.params[prop] = this.params[prop].map((item, index) => ({
+        //   ...item,
+        //   delFlag: index === $index ? "2" : item.delFlag,
+        // }));
+        scope.row.delFlag = '2'
+        let delList = []
+        delList = this.params[prop].filter(item => {
+          return item.delFlag == '2'
+        })
+        this.params[prop] = this.params[prop].filter(item => {
+          return item.delFlag == '0'
+        })
+        this.delDemandItemList.push(...delList)
+        console.log('删除的数组',this.delDemandItemList)
+        console.log('this.params[prop]', this.params[prop])
       },
       //
       async useSubmit(prop) {
@@ -261,14 +277,21 @@
           if (valid) {
             try {
               this.loading = true;
+              let list = []
+              list.push(...this.params.priceApplyItems, ...this.delDemandItemList)
               this.params.priceApplyItems = this.params.priceApplyItems.filter(
                 (item) => item.materialName
               );
-              const {msg, code} = await SAVE(this.params);
+              // 深拷贝一下参数对象
+              let param = JSON.parse(JSON.stringify(this.params))
+              console.log('深拷贝对象',param);
+              param.priceApplyItems = list
+              const {msg, code} = await SAVE(param);
               if (code === 200) {
                 this.onHide();
                 this.$emit("success");
                 this.$notify.success(msg);
+                this.delDemandItemList = []
               }
             } catch (err) {
               // catch
@@ -282,6 +305,359 @@
           }
         });
       },
+      // 粘贴
+      async pasteMe(e, scope, index, prop) {
+        this.$modal.loading("正在处理数据...");
+        e.preventDefault() //阻止默认粘贴事件
+        let source = e.clipboardData.getData("Text");
+        console.log('scope', scope.column.property)
+        console.log('index', index)
+        // 首先对源头进行解析
+        let rows = source.split("\r\n"); // 拆成一个数组
+        // 数组去除空字符串
+        rows = rows.filter(item => {
+          return item && item.trim()
+        })
+        if (rows.length < 100) {
+          if(scope.column.property == 'materialCode') {
+            let rowList = []
+            let newLine = []
+            await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
+              if (res.code === 200) {
+                rowList = res.rows
+              }
+            })
+            const {
+              puOrg,
+              customer,
+              customerName,
+              supplier,
+              currency,
+              currencyCode,
+              currencyName,
+            } = this.params;
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            // console.log('kk', TableColumns)
+            // console.log('this.$init.params(TableColumns)', this.$init.params(TableColumns))
+            for (let i = 0; i<rowList.length; i++) {
+              let line = {...this.$init.params(TableColumns)}
+              console.log('line',line)
+              const {nickName: createByName} = this.$store.state.user;
+              const {ntaxrate} = await tax(rowList[i].materialRateName);
+              // task 2
+              const {
+                id: puUnit,
+                code: puUnitCode,
+                name: puUnitName,
+              } = await unit(rowList[i].unitIdName);
+              // task 3
+              const {
+                recentlyPrice = "0",
+                isApprovalFirst = "N",
+                purchasequantity,
+                recentlyPriceDate
+              } = await fetchExist({puOrg, customer, supplier, materialCode: rowList[i].code, customerName: "", priceType: line.priceType});
+              line.delFlag = '0'
+              line.materialCode = rowList[i].code
+              line.material = rowList[i].id
+              line.materialName = rowList[i].name
+              line.specification = rowList[i].specification
+              line.model = rowList[i].model
+              line.manufacturerName = rowList[i].manufacturerIdName
+              line.unit = puUnit,
+              line.unitCode = puUnitCode,
+              line.unitName = puUnitName,
+              line.puUnit  = puUnit,
+              line.puUnitCode = puUnitCode,
+              line.puUnitName = puUnitName,
+              line.recentlyPrice = recentlyPrice
+              line.isApprovalFirst = isApprovalFirst
+              line.recentlyPriceDate = recentlyPriceDate,
+              line.yPurchaseQuantity = purchasequantity,
+              line.tax = Number(ntaxrate === "0E-8" ? 0 : ntaxrate),
+              line.createByName = createByName,
+              line.updateByName = createByName,
+              line.currency = currency
+              line.currencyCode = currencyCode
+              line.currencyName = currencyName
+              newLine.push(line)
+              console.log('临时数组', newLine)
+            }
+            // 删除指定下标
+            this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+            this.$modal.closeLoading();
+            this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
+
+          } else if(scope.column.property == 'taxPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.taxPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].taxPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice1') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice1 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice1 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'supplierName2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.supplierName2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].supplierName2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'bidPrice2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.bidPrice2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].bidPrice2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } else if(scope.column.property == 'unitPrice2') {
+            console.log('复制内容:', rows)
+            let newLine = []
+            const {TabColumns} = this;
+            const {TableColumns} = TabColumns.find(
+              ({item: {key}}) => key === prop
+            );
+            if(this.params[prop].length <= 1) {
+              for (let i = 0; i<rows.length; i++) {
+                let line = {...this.$init.params(TableColumns)}
+                line.unitPrice2 = rows[i]
+                newLine.push(line)
+              }
+              // 删除指定下标
+              this.params[prop].splice(index,this.params[prop].length - index,...newLine)
+              this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
+              // this.$refs.table.doLayout()
+              this.$modal.closeLoading();
+            } else {
+              for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
+                this.params[prop][i].unitPrice2 = rows[j]
+              }
+              // this.$refs.table.doLayout()
+              console.log(this.params[prop])
+              this.$modal.closeLoading();
+            }
+          } 
+
+        } else {
+          this.$modal.notifyWarning("复制长度不能超过100!");
+          this.$modal.closeLoading();
+        }
+      },
     },
     created() {
     },
@@ -361,6 +737,116 @@
                 >
                 </component>
               </template>
+              <template slot="materialCode" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="taxPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice1" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="supplierName2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="bidPrice2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
+              <template slot="unitPrice2" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
+                  :size="$attrs.size"
+                  :source.sync="scope.row"
+                  @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
+                >
+                </component>
+              </template>
               <template slot="customerName" slot-scope="scope">
                 <component
                   v-bind="scope.attr"