002201 há 1 ano atrás
pai
commit
fd7dca4c9c

+ 3 - 4
src/components/FileUpload/index.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="upload-file">
     <el-upload
-      drag
       multiple
       :action="uploadFileUrl"
       :before-upload="handleBeforeUpload"
@@ -16,12 +15,12 @@
       ref="fileUpload"
     >
       <!-- 上传按钮 -->
-      <!-- <el-button size="mini" type="primary">选取文件</el-button> -->
-      <i class="el-icon-upload"></i>
+      <el-button size="mini" type="primary">选取文件</el-button>
+      <!-- <i class="el-icon-upload"></i>
       <div class="el-upload__text">
         将文件拖到此处,或
         <em>点击上传</em>
-      </div>
+      </div> -->
       <!-- 上传提示 -->
       <div class="el-upload__tip" slot="tip" v-if="showTip">
         请上传

+ 0 - 1
src/components/popover-select-v2/index.vue

@@ -155,7 +155,6 @@ export default {
     // select
     useSelect(prop) {
       this.selectData = prop;
-      console.log(" this.selectData ", this.selectData);
     },
     // confirm
     useConfirm(prop) {

+ 8 - 0
src/utils/expression.js

@@ -0,0 +1,8 @@
+import CONFIG from "@/config";
+
+// 无税单价
+export function iunitprice(tax = 0, price = 0) {
+  return ((Number(price) / (Number(tax) / 100 + 1)) * 1).toFixed(
+    CONFIG.precision
+  );
+}

+ 18 - 12
src/views/purchase/apply/add/columns.js

@@ -1,4 +1,5 @@
 import CONFIG from "@/config";
+import { iunitprice } from "@/utils/expression";
 
 export default function useColumns() {
   const TableColumns = [
@@ -194,10 +195,7 @@ export default function useColumns() {
           attr: {
             formatter: (prop) => {
               const { tax = 0, taxPrice = 0 } = prop;
-              prop.price = ((taxPrice / (tax / 100 + 1)) * 1).toFixed(
-                CONFIG.precision
-              );
-              return prop.price;
+              return (prop.price = iunitprice(tax, taxPrice));
             },
           },
         },
@@ -312,19 +310,25 @@ export default function useColumns() {
         {
           item: { width: 100, key: "priceDiffer", title: "单价差" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
+              const { taxPrice = 0, recentlyPrice = 0 } = prop;
+              return (prop.priceDiffer = (
+                Number(taxPrice) - Number(recentlyPrice)
+              ).toFixed(CONFIG.precision));
             },
           },
         },
 
         {
-          item: { width: 100, key: "increase", title: "涨幅" },
+          item: { width: 100, key: "increase", title: "涨幅(%)" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
+              const { priceDiffer = 0, recentlyPrice = 0 } = prop;
+              return (prop.increase = recentlyPrice
+                ? ((Number(priceDiffer) / Number(recentlyPrice)) * 100).toFixed(
+                    2
+                  )
+                : "0.00");
             },
           },
         },
@@ -339,11 +343,13 @@ export default function useColumns() {
           },
         },
         {
-          item: { width: 100, key: "yAffectedAmount", title: "预计年影响" },
+          item: { width: 100, key: "yAffectedAmount", title: "预计年影响金额" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
+              const { priceDiffer = 0, yPurchaseQuantity = 0 } = prop;
+              return (prop.yAffectedAmount = (
+                Number(priceDiffer) * Number(yPurchaseQuantity)
+              ).toFixed(CONFIG.precision));
             },
           },
         },

+ 8 - 7
src/views/purchase/apply/add/index.vue

@@ -67,10 +67,12 @@ export default {
         currencyCode,
         currencyName,
       } = this.params;
+      const { nickName: createByName } = this.$store.state.user;
       if (selectData.length) {
         this.params[this.tabName].splice(-1);
       }
       for (const item of selectData) {
+        this.loading = true;
         const { tax: taxName, unitName, code: materialCode } = item;
         // task 1
         const { ntaxrate } = await tax(taxName);
@@ -86,6 +88,7 @@ export default {
           isApprovalFirst = "N",
           isPriceAdjustment = "N",
         } = await fetchExist({ puOrg, customer, supplier, materialCode });
+        this.loading = false;
         await this.onRowAdd(this.tabName, {
           ...item,
           currency: currency,
@@ -101,6 +104,8 @@ export default {
           isApprovalFirst,
           isPriceAdjustment,
           tax: Number(ntaxrate === "0E-8" ? 0 : ntaxrate).toFixed(6),
+          createByName: createByName,
+          updateByName: createByName,
         });
       }
     },
@@ -220,10 +225,10 @@ export default {
         ref="superForm"
         label-width="auto"
         label-position="right"
-        style="padding: 20px"
+        style="padding: 18px"
       >
       </el-super-form>
-      <el-tabs v-model="tabName" style="padding: 0 20px 20px">
+      <el-tabs v-model="tabName" style="padding: 0 18px 18px">
         <el-tab-pane
           v-for="({ item, TableColumns: columns }, index) in TabColumns"
           :key="index"
@@ -272,8 +277,4 @@ export default {
   </el-button>
 </template>
 
-<style scoped>
-::v-deep .el-table__row.is-hidden {
-  display: none;
-}
-</style>
+<style scoped></style>

+ 18 - 20
src/views/purchase/apply/columns.js

@@ -2,34 +2,34 @@ import CONFIG from "@/config";
 
 export default function useColumns() {
   const TableColumns = [
-    { item: { key: "priceCode", title: "价格编码" ,  width:150 }, attr: {} },
+    { item: { key: "priceCode", title: "价格编码", width: 150 }, attr: {} },
     {
-      item: { key: "status", title: "状态" ,  width:100},
-      attr: { is: "el-dict-tag", dictName: "sys_status",  width:100 },
+      item: { key: "status", title: "状态", width: 100 },
+      attr: { is: "el-dict-tag", dictName: "sys_status", width: 100 },
     },
-    { item: { key: "supplierName", title: "供应商" ,  width:150}, attr: {} },
-    { item: { key: "currencyName", title: "币种" ,  width:100}, attr: {} },
+    { item: { key: "supplierName", title: "供应商", width: 150 }, attr: {} },
+    { item: { key: "currencyName", title: "币种", width: 100 }, attr: {} },
     {
-      item: { key: "explainStr", title: "价格合理性说明" ,  width:100},
+      item: { key: "explainStr", title: "价格合理性说明", width: 100 },
       attr: {},
     },
-    { item: { key: "buyerName", title: "采购员",  width:100 }, attr: {} },
-    { item: { key: "puDeptName", title: "采购部门" ,  width:100}, attr: {} },
+    { item: { key: "buyerName", title: "采购员", width: 100 }, attr: {} },
+    { item: { key: "puDeptName", title: "采购部门", width: 100 }, attr: {} },
     {
-      item: { key: "file", title: "附件", filter: false,  width:100 },
+      item: { key: "file", title: "附件", filter: false, width: 100 },
       attr: { is: "el-file-preview" },
     },
-    { item: { key: "createByName", title: "创建人",  width:100 }, attr: {} },
+    { item: { key: "createByName", title: "创建人", width: 100 }, attr: {} },
     {
-      item: { key: "isEffective", title: "是否已推价格" ,  width:100},
-      attr: { is: "el-dict-tag", dictName: "is_effective" ,  width:100},
+      item: { key: "isEffective", title: "是否已推价格", width: 100 },
+      attr: { is: "el-dict-tag", dictName: "is_effective", width: 100 },
     },
     {
-      item: { key: "effectiveDate", title: "生效日期" ,  width:100},
+      item: { key: "effectiveDate", title: "生效日期", width: 100 },
       attr: {},
     },
     {
-      item: { key: "sourceType", title: "来源单据类型" ,  width:100},
+      item: { key: "sourceType", title: "来源单据类型", width: 100 },
       attr: {},
     },
   ].map(({ item, attr }) => ({
@@ -43,19 +43,17 @@ export default function useColumns() {
     },
   }));
   const SearchColumns = [
-    
-    { 
-      item:{
+    {
+      item: {
         key: "priceCode",
-        title: "价格编码", 
+        title: "价格编码",
       },
       attr: {
-        clearable:true,
+        clearable: true,
         is: "el-input",
       },
     },
     {
-      
       item: { key: "supplierName", title: "供应商" },
       attr: {
         is: "el-popover-select-v2",

+ 75 - 45
src/views/purchase/apply/copy/columns.js

@@ -1,4 +1,5 @@
 import CONFIG from "@/config";
+import { iunitprice } from "@/utils/expression";
 
 export default function useColumns() {
   const TableColumns = [
@@ -117,6 +118,7 @@ export default function useColumns() {
           item: { key: "materialName", title: "物料名称", require: true },
           attr: {
             is: "el-popover-select-v2",
+            multiple: true,
             valueKey: "name",
             referName: "MATERIAL_PARAM",
             dataMapping: {
@@ -141,7 +143,7 @@ export default function useColumns() {
         { item: { key: "specification", title: "规格" }, attr: {} },
         { item: { key: "model", title: "型号" }, attr: {} },
         {
-          item: { key: "unitName", title: "单位" },
+          item: { key: "unitName", title: "单位", hidden: false },
           attr: {
             is: "el-popover-select-v2",
             valueKey: "name",
@@ -150,7 +152,7 @@ export default function useColumns() {
           },
         },
         {
-          item: { key: "puUnitName", title: "采购单位" },
+          item: { key: "puUnitName", title: "采购单位", hidden: false },
           attr: {
             is: "el-popover-select-v2",
             valueKey: "name",
@@ -167,6 +169,8 @@ export default function useColumns() {
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
+            value: 1,
+            disabled: true,
           },
         },
         {
@@ -176,6 +180,7 @@ export default function useColumns() {
             valueKey: "ntaxrate",
             referName: "TAX_RATE_PARAM",
             dataMapping: { tax: "ntaxrate" },
+            disabled: true,
           },
         },
         {
@@ -190,10 +195,7 @@ export default function useColumns() {
           attr: {
             formatter: (prop) => {
               const { tax = 0, taxPrice = 0 } = prop;
-              prop.price = ((taxPrice / (tax / 100 + 1)) * 1).toFixed(
-                CONFIG.precision
-              );
-              return prop.price;
+              return (prop.price = iunitprice(tax, taxPrice));
             },
           },
         },
@@ -248,12 +250,20 @@ export default function useColumns() {
             },
           },
         },
-        { item: { key: "recentlyPrice", title: "最近价格" }, attr: {} },
+        {
+          item: { key: "recentlyPrice", title: "最近价格" },
+          attr: {
+            is: "el-input-number",
+            precision: CONFIG.precision,
+            disabled: true,
+          },
+        },
         {
           item: { key: "isApprovalFirst", title: "首次报批" },
           attr: {
             is: "el-select",
             dictName: "is_effective",
+            disabled: true,
           },
         },
         {
@@ -261,6 +271,7 @@ export default function useColumns() {
           attr: {
             is: "el-select",
             dictName: "is_effective",
+            disabled: true,
           },
         },
         {
@@ -279,8 +290,9 @@ export default function useColumns() {
             value: "N",
           },
         },
+
         {
-          item: { width:100,key: "isChannel", title: "是否渠道变更" },
+          item: { width: 100, key: "isChannel", title: "是否渠道变更" },
           attr: {
             is: "el-select",
             dictName: "is_effective",
@@ -288,68 +300,80 @@ export default function useColumns() {
           },
         },
         {
-          item: { width:100,key: "brandReplacement", title: "是否品牌替换" },
+          item: { width: 100, key: "brandReplacement", title: "是否品牌替换" },
           attr: {
             is: "el-select",
             dictName: "is_effective",
             value: "N",
           },
-        },{
-          item: { width:100,key: "priceDiffer", title: "单价差" },
+        },
+        {
+          item: { width: 100, key: "priceDiffer", title: "单价差" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              const { taxPrice = 0, recentlyPrice = 0 } = prop;
+              return (prop.priceDiffer = (
+                Number(taxPrice) - Number(recentlyPrice)
+              ).toFixed(CONFIG.precision));
             },
           },
         },
 
         {
-          item: { width:100,key: "increase", title: "涨幅" },
+          item: { width: 100, key: "increase", title: "涨幅(%)" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              const { priceDiffer = 0, recentlyPrice = 0 } = prop;
+              return (prop.increase = recentlyPrice
+                ? ((Number(priceDiffer) / Number(recentlyPrice)) * 100).toFixed(
+                    2
+                  )
+                : "0.00");
             },
           },
         },
 
         {
-          item: { width:100,key: "yPurchaseQuantity", title: "预计年采购量" },
+          item: { width: 100, key: "yPurchaseQuantity", title: "预计年采购量" },
           attr: {
             is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
             },
           },
         },
         {
-          item: { width:100,key: "yAffectedAmount", title: "预计年影响量" },
+          item: { width: 100, key: "yAffectedAmount", title: "预计年影响金额" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              const { priceDiffer = 0, yPurchaseQuantity = 0 } = prop;
+              return (prop.yAffectedAmount = (
+                Number(priceDiffer) * Number(yPurchaseQuantity)
+              ).toFixed(CONFIG.precision));
             },
           },
         },
 
         {
-          item: { width:150,key: "supplierName", title: "供应商名称" },
-          attr: {is: "el-input"},
-        },{
-          item: { width:150,key: "bidPrice", title: "中标价" },
+          item: { width: 150, key: "supplierName", title: "供应商名称" },
+          attr: { is: "el-input" },
+        },
+        {
+          item: { width: 150, key: "bidPrice", title: "中标价" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "unitPrice", title: "单价" },
+        },
+        {
+          item: { width: 150, key: "unitPrice", title: "单价" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "profit", title: "利润比" },
+        },
+        {
+          item: { width: 150, key: "profit", title: "利润比" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
@@ -357,22 +381,25 @@ export default function useColumns() {
         },
 
         {
-          item: { width:150,key: "supplierName1", title: "供应商名称1" },
-          attr: {is: "el-input"},
-        },{
-          item: { width:150,key: "bidPrice1", title: "中标价1" },
+          item: { width: 150, key: "supplierName1", title: "供应商名称1" },
+          attr: { is: "el-input" },
+        },
+        {
+          item: { width: 150, key: "bidPrice1", title: "中标价1" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "unitPrice1", title: "单价1" },
+        },
+        {
+          item: { width: 150, key: "unitPrice1", title: "单价1" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "profit1", title: "利润比1" },
+        },
+        {
+          item: { width: 150, key: "profit1", title: "利润比1" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
@@ -380,22 +407,25 @@ export default function useColumns() {
         },
 
         {
-          item: { width:150,key: "supplierName2", title: "供应商名称2" },
-          attr: {is: "el-input"},
-        },{
-          item: { width:150,key: "bidPrice2", title: "中标价2" },
+          item: { width: 150, key: "supplierName2", title: "供应商名称2" },
+          attr: { is: "el-input" },
+        },
+        {
+          item: { width: 150, key: "bidPrice2", title: "中标价2" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "unitPrice2", title: "单价2" },
+        },
+        {
+          item: { width: 150, key: "unitPrice2", title: "单价2" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "profit2", title: "利润比2" },
+        },
+        {
+          item: { width: 150, key: "profit2", title: "利润比2" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,

+ 89 - 86
src/views/purchase/apply/copy/index.vue

@@ -18,7 +18,7 @@ const fetchExist = async (prop) => {
 };
 
 export default {
-  name: "AddDrawer",
+  name: "CopyDrawer",
   props: {
     dict: {
       type: Object,
@@ -73,43 +73,57 @@ export default {
   watch: {},
   methods: {
     //
-    changeMaterialName(prop) {
-      const { row } = prop;
-      const { puOrg, customer, supplier } = this.params;
-      const { tax: taxName, unitName, code: materialCode } = row;
-      // task 1
-      tax(taxName).then((res) => {
-        const { ntaxrate } = res;
-        row.tax = ntaxrate === "0E-8" ? "0.000000" : (ntaxrate * 1).toFixed(6);
-      });
-      // task 2
-      unit(unitName).then((res) => {
-        const { id, code, name } = res;
-        row.unit = id;
-        row.unitCode = code;
-        row.unitName = name;
-        row.puUnit = id;
-        row.puUnitCode = code;
-        row.puUnitName = name;
-      });
-      // task 3
-      currency("人民币").then((res) => {
-        const { id, code, name } = res;
-        row.currency = id;
-        row.currencyCode = code;
-        row.currencyName = name;
-      });
-      // task 4
-      fetchExist({ puOrg, customer, supplier, materialCode }).then((res) => {
-        const { recentlyPrice, isApprovalFirst, isPriceAdjustment } = res;
-        row.recentlyPrice = recentlyPrice;
-        if (isApprovalFirst) {
-          row.isApprovalFirst = isApprovalFirst == 0 ? "Y" : "N";
-        }
-        if (isPriceAdjustment) {
-          row.isPriceAdjustment = isPriceAdjustment == 0 ? "Y" : "N";
-        }
-      });
+    async changeMaterialName(prop) {
+      const { selectData } = prop;
+      const {
+        puOrg,
+        customer,
+        supplier,
+        currency,
+        currencyCode,
+        currencyName,
+      } = this.params;
+      const { nickName: createByName } = this.$store.state.user;
+      if (selectData.length) {
+        this.params[this.tabName].splice(-1);
+      }
+      for (const item of selectData) {
+        this.loading = true;
+        const { tax: taxName, unitName, code: materialCode } = item;
+        // task 1
+        const { ntaxrate } = await tax(taxName);
+        // task 2
+        const {
+          id: puUnit,
+          code: puUnitCode,
+          name: puUnitName,
+        } = await unit(unitName);
+        // task 3
+        const {
+          recentlyPrice = "0",
+          isApprovalFirst = "N",
+          isPriceAdjustment = "N",
+        } = await fetchExist({ puOrg, customer, supplier, materialCode });
+        this.loading = false;
+        await this.onRowAdd(this.tabName, {
+          ...item,
+          currency: currency,
+          currencyCode: currencyCode,
+          currencyName: currencyName,
+          unit: puUnit,
+          unitCode: puUnitCode,
+          unitName: puUnitName,
+          puUnit: puUnit,
+          puUnitCode: puUnitCode,
+          puUnitName: puUnitName,
+          recentlyPrice,
+          isApprovalFirst,
+          isPriceAdjustment,
+          tax: Number(ntaxrate === "0E-8" ? 0 : ntaxrate).toFixed(6),
+          createByName: createByName,
+          updateByName: createByName,
+        });
+      }
     },
     //
     async fetchItem(prop) {
@@ -167,7 +181,7 @@ export default {
       this.params = this.$init.params([...TabColumns, ...TableColumns]);
     },
     //
-    async onRowAdd(prop) {
+    async onRowAdd(prop, pushParams = {}) {
       const {
         $notify,
         TabColumns,
@@ -185,6 +199,7 @@ export default {
       this.params[prop].push({
         delFlag: "0",
         ...this.$init.params(TableColumns),
+        ...pushParams,
       });
     },
     //
@@ -263,20 +278,10 @@ export default {
         ref="superForm"
         label-width="auto"
         label-position="right"
-        style="padding: 20px"
+        style="padding: 18px"
       >
-        <template slot="puOrgName" slot-scope="scope">
-          <component
-            v-bind="scope.attr"
-            v-model="scope.row[scope.item.key]"
-            :size="$attrs.size"
-            :source.sync="scope.row"
-            @change="changePuOrgName({ ...scope, select: $event })"
-          >
-          </component
-        ></template>
       </el-super-form>
-      <el-tabs v-model="tabName" style="padding: 0 20px 20px">
+      <el-tabs v-model="tabName" style="padding: 0 18px 18px">
         <el-tab-pane
           v-for="({ item, TableColumns: columns }, index) in TabColumns"
           :key="index"
@@ -284,47 +289,45 @@ export default {
           :name="item.key"
           lazy
         >
-          <el-super-table
-            v-model="params[item.key]"
-            :dict="dict"
-            :ref="tabName"
-            :columns="columns"
-            :size="$attrs.size"
-          >
-            <template slot="materialName" slot-scope="scope">
-              <component
-                v-bind="scope.attr"
-                v-model="scope.row[scope.item.key]"
-                :size="$attrs.size"
-                :source.sync="scope.row"
-                @change="changeMaterialName(scope)"
-              >
-              </component>
-            </template>
-            <el-table-column fixed="right" label="操作" width="100">
-              <template slot="header" slot-scope="scope">
-                <el-button :size="$attrs.size" @click="onRowAdd(tabName)">
-                  新增
-                </el-button>
-              </template>
-              <template slot-scope="scope">
-                <el-button
+          <div v-loading="loading" style="height: 600px; display: flex">
+            <el-super-table
+              v-model="params[item.key]"
+              :dict="dict"
+              :ref="tabName"
+              :columns="columns"
+              :size="$attrs.size"
+            >
+              <template slot="materialName" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
                   :size="$attrs.size"
-                  @click.native.prevent="onRowRemove(tabName, scope)"
+                  :source.sync="scope.row"
+                  @change="changeMaterialName({ ...scope, selectData: $event })"
                 >
-                  删除
-                </el-button>
+                </component>
               </template>
-            </el-table-column>
-          </el-super-table>
+              <el-table-column fixed="right" label="操作" width="100">
+                <template slot="header" slot-scope="scope">
+                  <el-button :size="$attrs.size" @click="onRowAdd(tabName)">
+                    新增
+                  </el-button>
+                </template>
+                <template slot-scope="scope">
+                  <el-button
+                    :size="$attrs.size"
+                    @click.native.prevent="onRowRemove(tabName, scope)"
+                  >
+                    删除
+                  </el-button>
+                </template>
+              </el-table-column>
+            </el-super-table>
+          </div>
         </el-tab-pane>
       </el-tabs>
     </el-drawer>
   </el-button>
 </template>
 
-<style scoped>
-::v-deep .el-table__row.is-hidden {
-  display: none;
-}
-</style>
+<style scoped></style>

+ 74 - 46
src/views/purchase/apply/edit/columns.js

@@ -1,4 +1,5 @@
 import CONFIG from "@/config";
+import { iunitprice } from "@/utils/expression";
 
 export default function useColumns() {
   const TableColumns = [
@@ -117,6 +118,7 @@ export default function useColumns() {
           item: { key: "materialName", title: "物料名称", require: true },
           attr: {
             is: "el-popover-select-v2",
+            multiple: true,
             valueKey: "name",
             referName: "MATERIAL_PARAM",
             dataMapping: {
@@ -141,7 +143,7 @@ export default function useColumns() {
         { item: { key: "specification", title: "规格" }, attr: {} },
         { item: { key: "model", title: "型号" }, attr: {} },
         {
-          item: { key: "unitName", title: "单位" },
+          item: { key: "unitName", title: "单位", hidden: false },
           attr: {
             is: "el-popover-select-v2",
             valueKey: "name",
@@ -150,7 +152,7 @@ export default function useColumns() {
           },
         },
         {
-          item: { key: "puUnitName", title: "采购单位" },
+          item: { key: "puUnitName", title: "采购单位", hidden: false },
           attr: {
             is: "el-popover-select-v2",
             valueKey: "name",
@@ -167,6 +169,8 @@ export default function useColumns() {
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
+            value: 1,
+            disabled: true,
           },
         },
         {
@@ -176,6 +180,7 @@ export default function useColumns() {
             valueKey: "ntaxrate",
             referName: "TAX_RATE_PARAM",
             dataMapping: { tax: "ntaxrate" },
+            disabled: true,
           },
         },
         {
@@ -190,10 +195,7 @@ export default function useColumns() {
           attr: {
             formatter: (prop) => {
               const { tax = 0, taxPrice = 0 } = prop;
-              prop.price = ((taxPrice / (tax / 100 + 1)) * 1).toFixed(
-                CONFIG.precision
-              );
-              return prop.price;
+              return (prop.price = iunitprice(tax, taxPrice));
             },
           },
         },
@@ -248,12 +250,20 @@ export default function useColumns() {
             },
           },
         },
-        { item: { key: "recentlyPrice", title: "最近价格" }, attr: {} },
+        {
+          item: { key: "recentlyPrice", title: "最近价格" },
+          attr: {
+            is: "el-input-number",
+            precision: CONFIG.precision,
+            disabled: true,
+          },
+        },
         {
           item: { key: "isApprovalFirst", title: "首次报批" },
           attr: {
             is: "el-select",
             dictName: "is_effective",
+            disabled: true,
           },
         },
         {
@@ -261,6 +271,7 @@ export default function useColumns() {
           attr: {
             is: "el-select",
             dictName: "is_effective",
+            disabled: true,
           },
         },
         {
@@ -281,7 +292,7 @@ export default function useColumns() {
         },
 
         {
-          item: { width:100,key: "isChannel", title: "是否渠道变更" },
+          item: { width: 100, key: "isChannel", title: "是否渠道变更" },
           attr: {
             is: "el-select",
             dictName: "is_effective",
@@ -289,68 +300,80 @@ export default function useColumns() {
           },
         },
         {
-          item: { width:100,key: "brandReplacement", title: "是否品牌替换" },
+          item: { width: 100, key: "brandReplacement", title: "是否品牌替换" },
           attr: {
             is: "el-select",
             dictName: "is_effective",
             value: "N",
           },
-        },{
-          item: { width:100,key: "priceDiffer", title: "单价差" },
+        },
+        {
+          item: { width: 100, key: "priceDiffer", title: "单价差" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              const { taxPrice = 0, recentlyPrice = 0 } = prop;
+              return (prop.priceDiffer = (
+                Number(taxPrice) - Number(recentlyPrice)
+              ).toFixed(CONFIG.precision));
             },
           },
         },
 
         {
-          item: { width:100,key: "increase", title: "涨幅" },
+          item: { width: 100, key: "increase", title: "涨幅(%)" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              const { priceDiffer = 0, recentlyPrice = 0 } = prop;
+              return (prop.increase = recentlyPrice
+                ? ((Number(priceDiffer) / Number(recentlyPrice)) * 100).toFixed(
+                    2
+                  )
+                : "0.00");
             },
           },
         },
 
         {
-          item: { width:100,key: "yPurchaseQuantity", title: "预计年采购量" },
+          item: { width: 100, key: "yPurchaseQuantity", title: "预计年采购量" },
           attr: {
             is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
             },
           },
         },
         {
-          item: { width:100,key: "yAffectedAmount", title: "预计年影响量" },
+          item: { width: 100, key: "yAffectedAmount", title: "预计年影响金额" },
           attr: {
-            is: "el-computed-input-v2",
             formatter: (prop) => {
-              return prop == null ? 0 :(prop * 1).toFixed(CONFIG.precision);
+              const { priceDiffer = 0, yPurchaseQuantity = 0 } = prop;
+              return (prop.yAffectedAmount = (
+                Number(priceDiffer) * Number(yPurchaseQuantity)
+              ).toFixed(CONFIG.precision));
             },
           },
         },
 
         {
-          item: { width:150,key: "supplierName", title: "供应商名称" },
-          attr: {is: "el-input"},
-        },{
-          item: { width:150,key: "bidPrice", title: "中标价" },
+          item: { width: 150, key: "supplierName", title: "供应商名称" },
+          attr: { is: "el-input" },
+        },
+        {
+          item: { width: 150, key: "bidPrice", title: "中标价" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "unitPrice", title: "单价" },
+        },
+        {
+          item: { width: 150, key: "unitPrice", title: "单价" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "profit", title: "利润比" },
+        },
+        {
+          item: { width: 150, key: "profit", title: "利润比" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
@@ -358,22 +381,25 @@ export default function useColumns() {
         },
 
         {
-          item: { width:150,key: "supplierName1", title: "供应商名称1" },
-          attr: {is: "el-input"},
-        },{
-          item: { width:150,key: "bidPrice1", title: "中标价1" },
+          item: { width: 150, key: "supplierName1", title: "供应商名称1" },
+          attr: { is: "el-input" },
+        },
+        {
+          item: { width: 150, key: "bidPrice1", title: "中标价1" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "unitPrice1", title: "单价1" },
+        },
+        {
+          item: { width: 150, key: "unitPrice1", title: "单价1" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "profit1", title: "利润比1" },
+        },
+        {
+          item: { width: 150, key: "profit1", title: "利润比1" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
@@ -381,28 +407,30 @@ export default function useColumns() {
         },
 
         {
-          item: { width:150,key: "supplierName2", title: "供应商名称2" },
-          attr: {is: "el-input"},
-        },{
-          item: { width:150,key: "bidPrice2", title: "中标价2" },
+          item: { width: 150, key: "supplierName2", title: "供应商名称2" },
+          attr: { is: "el-input" },
+        },
+        {
+          item: { width: 150, key: "bidPrice2", title: "中标价2" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "unitPrice2", title: "单价2" },
+        },
+        {
+          item: { width: 150, key: "unitPrice2", title: "单价2" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
-        },{
-          item: { width:150,key: "profit2", title: "利润比2" },
+        },
+        {
+          item: { width: 150, key: "profit2", title: "利润比2" },
           attr: {
             is: "el-input-number",
             precision: CONFIG.precision,
           },
         },
-
         { item: { key: "createByName", title: "创建人名称" }, attr: {} },
         { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
       ],

+ 87 - 79
src/views/purchase/apply/edit/index.vue

@@ -96,40 +96,57 @@ export default {
   watch: {},
   methods: {
     //
-    changeMaterialName(prop) {
-      console.log(prop, "prop");
-      const { row } = prop;
-      const { puOrg, customer, supplier } = this.params;
-      const { tax: taxName, unitName, code: materialCode } = row;
-      // task 1
-      tax(taxName).then((res) => {
-        const { ntaxrate } = res;
-        row.tax = ntaxrate === "0E-8" ? "0.000000" : (ntaxrate * 1).toFixed(6);
-      });
-      // task 2
-      unit(unitName).then((res) => {
-        const { id, code, name } = res;
-        row.unit = id;
-        row.unitCode = code;
-        row.unitName = name;
-        row.puUnit = id;
-        row.puUnitCode = code;
-        row.puUnitName = name;
-      });
-      // task 3
-      currency("人民币").then((res) => {
-        const { id, code, name } = res;
-        row.currency = id;
-        row.currencyCode = code;
-        row.currencyName = name;
-      });
-      // task 4
-      fetchExist({ puOrg, customer, supplier, materialCode }).then((res) => {
-        const { recentlyPrice, isApprovalFirst, isPriceAdjustment } = res;
-        row.recentlyPrice = recentlyPrice;
-        row.isApprovalFirst = isApprovalFirst;
-        row.isPriceAdjustment = isPriceAdjustment;
-      });
+    async changeMaterialName(prop) {
+      const { selectData } = prop;
+      const {
+        puOrg,
+        customer,
+        supplier,
+        currency,
+        currencyCode,
+        currencyName,
+      } = this.params;
+      const { nickName: createByName } = this.$store.state.user;
+      if (selectData.length) {
+        this.params[this.tabName].splice(-1);
+      }
+      for (const item of selectData) {
+        this.loading = true;
+        const { tax: taxName, unitName, code: materialCode } = item;
+        // task 1
+        const { ntaxrate } = await tax(taxName);
+        // task 2
+        const {
+          id: puUnit,
+          code: puUnitCode,
+          name: puUnitName,
+        } = await unit(unitName);
+        // task 3
+        const {
+          recentlyPrice = "0",
+          isApprovalFirst = "N",
+          isPriceAdjustment = "N",
+        } = await fetchExist({ puOrg, customer, supplier, materialCode });
+        this.loading = false;
+        await this.onRowAdd(this.tabName, {
+          ...item,
+          currency: currency,
+          currencyCode: currencyCode,
+          currencyName: currencyName,
+          unit: puUnit,
+          unitCode: puUnitCode,
+          unitName: puUnitName,
+          puUnit: puUnit,
+          puUnitCode: puUnitCode,
+          puUnitName: puUnitName,
+          recentlyPrice,
+          isApprovalFirst,
+          isPriceAdjustment,
+          tax: Number(ntaxrate === "0E-8" ? 0 : ntaxrate).toFixed(6),
+          createByName: createByName,
+          updateByName: createByName,
+        });
+      }
     },
     //
     async fetchItem(prop) {
@@ -173,7 +190,7 @@ export default {
       this.params = this.$init.params([...TabColumns, ...TableColumns]);
     },
     //
-    async onRowAdd(prop) {
+    async onRowAdd(prop, pushParams = {}) {
       const {
         $notify,
         TabColumns,
@@ -191,6 +208,7 @@ export default {
       this.params[prop].push({
         delFlag: "0",
         ...this.$init.params(TableColumns),
+        ...pushParams,
       });
     },
     //
@@ -277,61 +295,51 @@ export default {
         ref="superForm"
         label-width="auto"
         label-position="right"
-        style="padding: 20px"
+        style="padding: 18px"
       >
-        <template slot="puOrgName" slot-scope="scope">
-          <component
-            v-bind="scope.attr"
-            v-model="scope.row[scope.item.key]"
-            :size="$attrs.size"
-            :source.sync="scope.row"
-            @change="changePuOrgName({ ...scope, select: $event })"
-          >
-          </component
-        ></template>
       </el-super-form>
-      <el-tabs v-model="tabName" style="padding: 0 20px 20px">
+      <el-tabs v-model="tabName" style="padding: 0 18px 18px">
         <el-tab-pane
           v-for="({ item, TableColumns: columns }, index) in TabColumns"
           :key="index"
           :label="item.title"
           :name="item.key"
           lazy
-        >
-          <el-super-table
-            v-model="priceApply[item.key]"
-            :dict="dict"
-            :ref="tabName"
-            :columns="columns"
-            :size="$attrs.size"
-            style="padding: 20px 10px;height: 400px;"
-          >
-            <template slot="materialName" slot-scope="scope">
-              <component
-                v-bind="scope.attr"
-                v-model="scope.row[scope.item.key]"
-                :size="$attrs.size"
-                :source.sync="scope.row"
-                @change="changeMaterialName(scope)"
-              >
-              </component>
-            </template>
-            <el-table-column fixed="right" label="操作" width="100">
-              <template slot="header" slot-scope="scope">
-                <el-button :size="$attrs.size" @click="onRowAdd(tabName)">
-                  新增
-                </el-button>
-              </template>
-              <template slot-scope="scope">
-                <el-button
+          ><div v-loading="loading" style="height: 600px; display: flex">
+            <el-super-table
+              v-model="priceApply[item.key]"
+              :dict="dict"
+              :ref="tabName"
+              :columns="columns"
+              :size="$attrs.size"
+            >
+              <template slot="materialName" slot-scope="scope">
+                <component
+                  v-bind="scope.attr"
+                  v-model="scope.row[scope.item.key]"
                   :size="$attrs.size"
-                  @click.native.prevent="onRowRemove(tabName, scope)"
+                  :source.sync="scope.row"
+                  @change="changeMaterialName({ ...scope, selectData: $event })"
                 >
-                  删除
-                </el-button>
+                </component>
               </template>
-            </el-table-column>
-          </el-super-table>
+              <el-table-column fixed="right" label="操作" width="100">
+                <template slot="header" slot-scope="scope">
+                  <el-button :size="$attrs.size" @click="onRowAdd(tabName)">
+                    新增
+                  </el-button>
+                </template>
+                <template slot-scope="scope">
+                  <el-button
+                    :size="$attrs.size"
+                    @click.native.prevent="onRowRemove(tabName, scope)"
+                  >
+                    删除
+                  </el-button>
+                </template>
+              </el-table-column>
+            </el-super-table>
+          </div>
         </el-tab-pane>
       </el-tabs>
     </el-drawer>