فهرست منبع

Merge branch 'purchaseDev' into 'dev'

Purchase dev

See merge request new-business/drp-web!275
黄梓星 1 سال پیش
والد
کامیت
c074c5692c

+ 7 - 0
src/api/purchase/purchaseDemand.js

@@ -78,4 +78,11 @@ export function queryMan(id) {
     url: `/material/division/queryBuyer?materialId=${id}`,
     method: 'get',
   })
+}
+// 跳转OA
+export function toOA(userName, fdId) {
+  return request({
+    url: `/oaflow/redirectToOa/${userName}/${fdId}`,
+    method: 'get',
+  })
 }

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

@@ -223,7 +223,6 @@ export default {
         <el-button :size="$attrs.size" :loading="loading" @click="hide"
           >取 消</el-button
         >
-        
       </div>
       <el-form
         v-loading="loading"

+ 14 - 2
src/components/super-form/index.vue

@@ -45,9 +45,21 @@ export default {
     },
   },
   watch: {},
-  methods: {},
+  methods: {
+    // 继承el-table的Method
+    extendMethod() {
+      const refMethod = Object.entries(this.$refs["superForm"]);
+      for (const [key, value] of refMethod) {
+        if (!(key.includes("$") || key.includes("_"))) {
+          this[key] = value;
+        }
+      }
+    },
+  },
   created() {},
-  mounted() {},
+  mounted() {
+    this.extendMethod();
+  },
   destroyed() {},
 };
 </script>

+ 11 - 16
src/components/super-search/index.vue

@@ -74,18 +74,7 @@ export default {
       this.visible = !this.visible;
     },
   },
-  created() {
-    console.log(
-      "span",
-      Math.ceil(
-        this.innerColumns
-          .map(({ item }) => item.span)
-          .reduce((prev, curr) => {
-            return prev + curr;
-          }) / 24
-      )
-    );
-  },
+  created() {},
   mounted() {},
   destroyed() {},
 };
@@ -190,15 +179,21 @@ export default {
         <el-button :size="$attrs.size" type="primary" @click="$emit('submit')">
           搜索
         </el-button>
-        <el-button :size="$attrs.size" type="danger" @click="$emit('reset')">
+        <el-button :size="$attrs.size" @click="$emit('reset')">
           重置
         </el-button>
-        <el-button :size="$attrs.size" @click="visible = !visible">
+        <!-- <el-button :size="$attrs.size" @click="visible = !visible">
           {{ visible ? "展开" : "收起" }}
-        </el-button>
+        </el-button> -->
       </el-row>
     </el-row>
-    <el-divider class="m-0"> </el-divider>
+    <el-divider class="m-0" style="cursor: pointer" @click="visible = !visible">
+      <i
+        class="el-icon-d-arrow-left"
+        style="transition: 250ms"
+        :style="{ transform: `rotate(${visible ? 90 : -90}deg)` }"
+      ></i>
+    </el-divider>
   </el-form>
 </template>
 

+ 36 - 16
src/components/super-table/index.vue

@@ -42,13 +42,8 @@ export default {
       type: Boolean,
       default: false,
     },
-    // 是否列显示
-    hiddenColumns: {
-      type: Boolean,
-      default: false,
-    },
-    // 是否列过滤
-    filterColumns: {
+    // 是否列操作
+    convenitentOperation: {
       type: Boolean,
       default: false,
     },
@@ -64,6 +59,8 @@ export default {
     ElFilePreview: () => import("@/components/file-preview/index.vue"),
     ElComputedInput: () => import("@/components/computed-input/index.vue"),
     ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
+    ElPopoverMultipleSelectV2: () =>
+      import("@/components/popover-select-v2/multiple.vue"),
     ElComputedInputV2: () => import("@/components/computed-input-v2/index.vue"),
     ElPopoverTreeSelect: () =>
       import("@/components/popover-tree-select/index.vue"),
@@ -71,8 +68,8 @@ export default {
     ButtonFreeze: () => import("./freeze.vue"),
     IconHide: () => import("./once/hide.vue"),
     IconSort: () => import("./once/sort.vue"),
-    IconFilter: () => import("./once/filter.vue"),
     IconFreeze: () => import("./once/freeze.vue"),
+    IconFilter: () => import("./once/filters.vue"),
   },
   data() {
     const { columns } = this.$props;
@@ -206,9 +203,20 @@ export default {
       }));
       return dataList;
     },
+    // 继承el-table的Method
+    extendMethod() {
+      const refMethod = Object.entries(this.$refs["superTable"]);
+      for (const [key, value] of refMethod) {
+        if (!(key.includes("$") || key.includes("_"))) {
+          this[key] = value;
+        }
+      }
+    },
   },
   created() {},
-  mounted() {},
+  mounted() {
+    this.extendMethod();
+  },
   destroyed() {},
 };
 </script>
@@ -218,6 +226,7 @@ export default {
     <el-table
       ref="superTable"
       border
+      height="auto"
       :row-key="rowKey"
       :data="innerValue"
       :highlight-current-row="radio"
@@ -225,6 +234,7 @@ export default {
       @selection-change="onSelectionChange"
       v-bind="$attrs"
       v-on="$listeners"
+      style="flex: 1"
     >
       <!-- 序号 -->
       <el-table-column
@@ -233,6 +243,7 @@ export default {
         fixed
         width="50"
         label="序号"
+        align="center"
         class="is-index"
       >
         <template slot-scope="scope">
@@ -275,20 +286,25 @@ export default {
               {{ item.title }}
             </span>
             <template>
-              <icon-sort v-model="item.sort" @sort="onSort(item)"></icon-sort>
+              <icon-sort
+                v-if="item.sortabled"
+                v-model="item.sort"
+                @sort="onSort(item)"
+              ></icon-sort>
               <icon-freeze
+                v-if="item.fixedabled"
                 v-model="item.fixed"
                 @freeze="onFreeze"
               ></icon-freeze>
               <icon-filter
+                v-if="item.filterabled"
                 v-model="item.filter"
                 :filters="onFilters({ item, attr })"
                 @filter="onFilter"
               ></icon-filter>
               <icon-hide
-                v-if="hiddenColumns"
+                v-if="item.hiddenabled"
                 v-model="item.hidden"
-                class="icon-hide"
                 @hide="onHide"
               ></icon-hide>
             </template>
@@ -313,7 +329,7 @@ export default {
               >
               </component>
               <component
-                v-else-if="attr.is === 'el-popover-tree-select'"
+                v-else-if="attr.is === 'el-popover-multiple-select-v2'"
                 v-bind="attr"
                 v-model="scope.row[item.key]"
                 :size="$attrs.size"
@@ -366,7 +382,7 @@ export default {
         align-items: center;
       "
     >
-      <div>
+      <div class="mr-4">
         <template v-if="checkbox">
           <el-button
             v-if="selectState"
@@ -385,7 +401,7 @@ export default {
             {{ selectData.length ? ` :${selectData.length}` : "" }}
           </el-button>
         </template>
-        <template v-if="hiddenColumns">
+        <template v-if="convenitentOperation">
           <button-hide v-model="innerColumns" @hide="onHide"></button-hide>
           <button-freeze
             v-model="showColumns"
@@ -400,7 +416,7 @@ export default {
         :page.sync="page.pageNum"
         :limit.sync="page.pageSize"
         @pagination="$emit('pagination', { ...$event })"
-        style="height: 32px; padding: 0 !important"
+        style="height: 32px; padding: 0 !important; flex: 1; overflow-x: auto"
       />
     </div>
   </div>
@@ -409,6 +425,10 @@ export default {
 <style lang="scss" scoped>
 .el-super-table {
   position: relative;
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  overflow: auto;
 }
 ::v-deep.el-super-table .el-table__header .cell {
   word-break: keep-all;

+ 1 - 1
src/components/super-table/once/filter.vue → src/components/super-table/once/filters.vue

@@ -68,7 +68,7 @@ export default {
   },
   props: {
     value: {
-      type: Array,
+      type: [Array, Boolean],
       require: true,
     },
     filters: {

+ 1 - 1
src/components/super-table/once/hide.vue

@@ -1,7 +1,7 @@
 <template>
   <i
     v-if="innerValue"
-    class="el-icon-circle-close pl-1"
+    class="el-icon-circle-close pl-1 icon-hide"
     style="cursor: pointer; font-weight: 600; transition: 500ms"
     @click="onHide"
   ></i>

+ 26 - 0
src/main.js

@@ -95,6 +95,32 @@ Vue.use(VueMeta);
 Vue.use(Print); //注册
 DictData.install();
 
+// el-table无限滚动解决页面渲染卡死
+Vue.directive("myscroll", {
+  bind(el, bind, vnode) {
+    const self = vnode.context;
+    let target = el.querySelector('.el-table__body-wrapper');
+    target.addEventListener("scroll", () => {
+      // 检测触底
+      if (target.scrollTop + target.clientHeight >= target.scrollHeight) {
+        if (self.over >= self.basicForm.puDemandItemList) {
+          return;
+        }
+        self.over +=15
+      }
+    })
+  }
+})
+Vue.mixin({
+  data() {
+    return {
+      // scrollTop: 0,
+      // tableHeight: 300
+      start: 0,
+      over: 15
+    }
+  }
+})
 /**
  * If you don't want to use mock-server
  * you want to use MockJs for mock api

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

@@ -236,7 +236,6 @@ export default {
       console.log('数据', this.row)
       let param = JSON.parse(JSON.stringify(this.query))
       param.sumFlag = this.row.sumFlag
-      param.demandItemId = this.row.demandItemId
       this.getDetails(param)
     }
   },
@@ -256,6 +255,7 @@ export default {
     },
     // 如果需要回显则调用详情接口
     getDetails(row) {
+      row.demandItemId = this.row.demandItemId
       getSummaryDetail(row).then(res => {
         if (res.code === 200) {
           this.tableList = res.data

+ 22 - 23
src/views/purchase/PurchaseDemandList/add.vue

@@ -84,7 +84,7 @@
 
         <el-col :span="1.5">
           <el-form-item label="是否客户指定">
-            <el-select clearable v-model="basicForm.isSpeical" :disabled="sonDisable" size="mini" style="width: 200px">
+            <el-select clearable v-model="basicForm.isCustomerSpecified" :disabled="sonDisable" size="mini" style="width: 200px">
               <el-option v-for=" item in options" :key="item.value" :label="item.label" :value="item.value">
               </el-option>
             </el-select>
@@ -167,7 +167,8 @@
       </div>
 
       <el-table
-          :data="basicForm.puDemandItemList"
+          v-myscroll
+          :data="basicForm.puDemandItemList.slice(0, over)"
           fit
           border
           :cell-style="{ borderColor: '#c0c0c0' }"
@@ -179,8 +180,8 @@
           @selection-change="handleSelectionChange"
           :cell-class-name="cellClassName"
         >
-          <el-table-column show-overflow-tooltip type="selection" fixed="left"/>
-          <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px" fixed="left"/>
+          <el-table-column show-overflow-tooltip type="selection"/>
+          <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px"/>
           <el-table-column show-overflow-tooltip label="行号" align="center" prop="rowNo">
             <template slot-scope="scope">
               {{ scope.$index + 1 + '0' }}
@@ -374,11 +375,11 @@
               </el-form-item>
             </template>
           </el-table-column>
-          <el-table-column show-overflow-tooltip label="是否客户指定" align="center"  prop="isSpeical" width="120px">
+          <el-table-column show-overflow-tooltip label="是否客户指定" align="center"  prop="isCustomerSpecified" width="120px">
             <template slot-scope="scope">
               <el-form-item class="hang">
                 <el-switch
-                  v-model="scope.row.isSpeical"
+                  v-model="scope.row.isCustomerSpecified"
                   disabled
                   active-value="Y"
                   inactive-value="N"
@@ -417,18 +418,11 @@
       </el-table>
     </el-form>
       <div class="btn_group">
-        <el-col :span="1.5">
-          <el-button type="primary" size="mini"  @click="copy" v-if="sonPageStu == 'check'">复制</el-button>
-        </el-col>
-        <el-col :span="1.5">
-          <el-button type="primary" size="mini"  @click="save" v-if="sonPageStu == 'add' || sonPageStu == 'edit'">保存</el-button>
-        </el-col>
-        <el-col :span="1.5" style="margin: 0 10px;">
-          <el-button type="primary" size="mini"  @click="submit" v-if="sonPageStu == 'check' && (row.status == '0' || row.status == '3')">提交</el-button>
-        </el-col>
-        <el-col :span="1.5">
-          <el-button size="mini" plain @click="back">返回</el-button>
-        </el-col>
+        <el-button type="primary" size="mini"  @click="jumpOA" v-if="sonPageStu == 'check' && (row.status == '1' || row.status == '2')">跳转OA</el-button>
+        <el-button type="primary" size="mini"  @click="copy" v-if="sonPageStu == 'check'">复制</el-button>
+        <el-button type="primary" size="mini"  @click="save" v-if="sonPageStu == 'add' || sonPageStu == 'edit'">保存</el-button>
+        <el-button type="primary" size="mini"  @click="submit" v-if="sonPageStu == 'check' && (row.status == '0' || row.status == '3')">提交</el-button>
+        <el-button size="mini" plain @click="back">返回</el-button>
       </div>
   </el-card>
 
@@ -523,7 +517,7 @@
 <script>
 import Reserved from './reserved.vue'
 import Refers from '@/components/Refers/refers.vue'
-import {addDemand,getDemandDetail, getDemandSonDetail, editDemand, submitDemand, queryMan } from '@/api/purchase/purchaseDemand.js'
+import {addDemand,getDemandDetail, getDemandSonDetail, editDemand, submitDemand, queryMan, toOA } from '@/api/purchase/purchaseDemand.js'
 // 用于回显参照框数据
 import {getRefer} from '@/api/purchase/basic.js'
 // 明细行选择物料参照
@@ -568,7 +562,7 @@ export default {
         createTime: '',
         source: '4',
         billType: 'ZQBH',
-        isSpeical: 'N',
+        isCustomerSpecified: 'N',
         isProcess: '',
         isMonthleyCalculate: '',
         createTime: this.parseTime(new Date().getTime()),
@@ -708,7 +702,7 @@ export default {
       this.basicForm.code = ''
       this.basicForm.createBy = ''
       this.basicForm.source = '4'
-      this.basicForm.isSpeical = 'N'
+      this.basicForm.isCustomerSpecified = 'N'
       this.basicForm.demandPersonal = this.$store.state.user.name
       this.basicForm.demandDept = this.$store.state.user.deptId
       if (this.basicForm.demandPersonal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.demandPersonal, '需求人员') }
@@ -1002,7 +996,7 @@ export default {
     },
     // 单元格标红
     cellClassName({row, column, rowIndex, columnIndex}) {
-      if(this.basicForm.isSpeical == 'N' && column.label == '需求可用周期' && Number(row.demandPeriod) > 1.5 && Number(row.demandPeriod) > Number(row.minOrderQty)) {
+      if(this.basicForm.isCustomerSpecified == 'N' && column.label == '需求可用周期' && Number(row.demandPeriod) > 1.5 && Number(row.demandPeriod) > Number(row.minOrderQty)) {
         return 'success-row';
       }
     },
@@ -1739,6 +1733,11 @@ export default {
         ]; 
       }
     },
+    jumpOA() {
+      toOA(this.$store.state.user.name, this.basicForm.flowId).then(res => {
+
+      })
+    }
   }
 }
 </script>
@@ -1748,7 +1747,7 @@ export default {
   // width: 100%;
   // margin: 20px 0;
   display: flex;
-  // justify-content: center;
+  justify-content: space-between;
   position: absolute;
   top: 10px;right: 20px;
 

+ 1 - 0
src/views/purchase/apply/add/columns.js

@@ -132,6 +132,7 @@ export default function useColumns() {
               specification: "specification",
               manufacturer: "manufacturerId",
               manufacturerName: "manufacturerIdName",
+              tax: "materialRateName",
             },
           },
         },

+ 44 - 190
src/views/purchase/apply/add/index.vue

@@ -1,7 +1,7 @@
 <script>
 import useColumns from "./columns";
 import { EXIST } from "@/api/business/purchase/catalogue";
-import { ITEM, SAVE } from "@/api/business/purchase/apply";
+import { SAVE } from "@/api/business/purchase/apply";
 import { tax, unit, currency } from "@/components/popover-select-v2/fetch";
 
 const fetchExist = async (prop) => {
@@ -23,14 +23,6 @@ export default {
     dict: {
       type: Object,
     },
-    selectData: {
-      type: [Array],
-      require: true,
-    },
-    addType: {
-      type: String,
-      default: "add",
-    },
   },
   components: {
     ElSuperForm: () => import("@/components/super-form/index.vue"),
@@ -50,6 +42,7 @@ export default {
     const rules = this.$init.rules([...TabColumns, ...TableColumns]);
     const params = this.$init.params([...TabColumns, ...TableColumns]);
     return {
+      title: "新 增",
       width: "100%",
       visible: false,
       loading: false,
@@ -60,82 +53,21 @@ export default {
       TableColumns: TableColumns,
     };
   },
-  computed: {
-    title: {
-      get() {
-        const { addType } = this;
-        if (addType === "add") {
-          return "新 增";
-        }
-        if (addType === "copy") {
-          return "复 制";
-        }
-        if (addType === "edit") {
-          return "编 辑";
-        }
-      },
-      set() {},
-    },
-    disabled: {
-      get() {
-        const {
-          addType,
-          selectData,
-          selectData: [{ status } = {}],
-        } = this.$props;
-        if (addType === "add") {
-          return false;
-        }
-        if (addType === "copy") {
-          if (selectData.length !== 1) {
-            return true;
-          }
-        }
-        if (addType === "edit") {
-          if (selectData.length !== 1) {
-            return true;
-          }
-          if (selectData.length === 1 && status === "1") {
-            return true;
-          }
-          if (selectData.length === 1 && status === "2") {
-            return true;
-          }
-        }
-      },
-      set() {},
-    },
-    priceApply: {
-      get() {
-        this.params.priceApplyItems = this.params.priceApplyItems.map(
-          (item, index) => ({
-            ...item,
-            $index: index,
-          })
-        );
-        return {
-          priceApplyItems: this.params.priceApplyItems.filter(
-            ({ delFlag }) => delFlag !== "2"
-          ),
-        };
-      },
-      set() {},
-    },
-  },
+  computed: {},
   watch: {},
   methods: {
     //
     changeMaterialName(prop) {
       const { row } = prop;
       const { puOrg, customer, supplier } = this.params;
-      const { rateCode, unitIdName, code: materialCode } = row;
+      const { tax: taxName, unitName, code: materialCode } = row;
       // task 1
-      tax(rateCode).then((res) => {
+      tax(taxName).then((res) => {
         const { ntaxrate } = res;
         row.tax = ntaxrate === "0E-8" ? "0.000000" : (ntaxrate * 1).toFixed(6);
       });
       // task 2
-      unit(unitIdName).then((res) => {
+      unit(unitName).then((res) => {
         const { id, code, name } = res;
         row.unit = id;
         row.unitCode = code;
@@ -145,99 +77,50 @@ export default {
         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 fetchItem(prop) {
-      try {
-        // try
-        this.loading = true;
-        const { code, data } = await ITEM(prop);
-        if (code === 200) {
-          this.params = data;
-          return true;
-        } else {
-          return false;
+        if (isApprovalFirst) {
+          row.isApprovalFirst = isApprovalFirst == 0 ? "Y" : "N";
         }
-      } catch (err) {
-        // catch
-        console.error(err);
-      } finally {
-        // finally
-        this.loading = false;
-      }
+        if (isPriceAdjustment) {
+          row.isPriceAdjustment = isPriceAdjustment == 0 ? "Y" : "N";
+        }
+      });
     },
     //
     async onOpen() {
-      const { addType, selectData } = this.$props;
-      if (addType === "add") {
-        this.visible = true;
-        const {
-          deptId: puDept,
-          deptName: puDeptName,
-          name: buyer,
-          nickName: buyerName,
-          orgId: puOrg,
-          orgName: puOrgName,
-        } = this.$store.state.user;
-        const { id, code, name } = await currency("人民币");
-        this.params.currency = id;
-        this.params.currencyCode = code;
-        this.params.currencyName = name;
-        this.params.puOrg = puOrg;
-        this.params.puOrgName = puOrgName;
-        this.params.buyer = buyer;
-        this.params.buyerName = buyerName;
-        this.params.puDept = puDept;
-        this.params.puDeptName = puDeptName;
-      }
-      if (addType === "copy") {
-        const [{ id }] = selectData;
-        this.visible = await this.fetchItem(id);
-        this.params.id = null;
-        this.params.createBy = null;
-        this.params.priceCode = null;
-        this.params.createByName = null;
-        this.params.effectiveDate = null;
-        this.params.priceApplyItems = this.params.priceApplyItems.map(
-          (item) => ({
-            ...item,
-            id: null,
-            applyId: null,
-            createByName: null,
-            updateByName: null,
-          })
-        );
-      }
-      if (addType === "edit") {
-        const [{ id }] = selectData;
-        this.visible = await this.fetchItem(id);
-        this.params.priceApplyItems = this.params.priceApplyItems.map(
-          (item) => ({
-            ...item,
-          })
-        );
-      }
+      this.visible = true;
+      const {
+        deptId: puDept,
+        deptName: puDeptName,
+        name: buyer,
+        nickName: buyerName,
+        orgId: puOrg,
+        orgName: puOrgName,
+      } = this.$store.state.user;
+      const { id, code, name } = await currency("人民币");
+      this.params.currency = id;
+      this.params.currencyCode = code;
+      this.params.currencyName = name;
+      this.params.puOrg = puOrg;
+      this.params.puOrgName = puOrgName;
+      this.params.buyer = buyer;
+      this.params.buyerName = buyerName;
+      this.params.puDept = puDept;
+      this.params.puDeptName = puDeptName;
     },
     //
     async onHide() {
-      const {
-        TabColumns,
-        TableColumns,
-        TabColumns: [
-          {
-            item: { key: tabName },
-          },
-        ],
-      } = useColumns();
+      const { TabColumns, TableColumns } = useColumns();
       this.visible = false;
-      this.tabName = tabName;
       this.params = this.$init.params([...TabColumns, ...TableColumns]);
     },
     //
@@ -263,39 +146,15 @@ export default {
     },
     //
     async onRowRemove(prop, scope) {
-      const { addType } = this.$props;
-      const {
-        row: { $index },
-      } = scope;
-      if (addType === "add") {
-        this.params[prop].splice($index, 1);
-      }
-      if (addType === "copy") {
-        this.params[prop].splice($index, 1);
-      }
-      if (addType === "edit") {
-        this.params[prop] = this.params[prop].map((item, index) => ({
-          ...item,
-          delFlag: index === $index ? "2" : item.delFlag,
-        }));
-        console.log(this.params[prop]);
-      }
+      const { $index } = scope;
+      this.params[prop].splice($index, 1);
     },
     //
     async useSubmit(prop) {
-      this.$refs[prop].$refs[prop].validate(async (valid) => {
-        console.log(this.params);
+      this.$refs[prop].validate(async (valid) => {
         if (valid) {
           try {
             this.loading = true;
-            if (this.addType === "copy") {
-              this.params.priceApplyOrgs = [];
-            }
-            if (this.addType === "edit") {
-              this.params.priceApplyItems = this.params.priceApplyItems.filter(
-                (item) => item.materialName
-              );
-            }
             const { msg, code } = await SAVE(this.params);
             if (code === 200) {
               this.onHide();
@@ -321,12 +180,7 @@ export default {
 };
 </script>
 <template>
-  <el-button
-    v-bind="$attrs"
-    v-on="$listeners"
-    :disabled="disabled"
-    @click="onOpen"
-  >
+  <el-button v-bind="$attrs" v-on="$listeners" @click="onOpen">
     {{ title }}
     <el-drawer
       :show-close="false"
@@ -382,7 +236,7 @@ export default {
           lazy
         >
           <el-super-table
-            v-model="priceApply[item.key]"
+            v-model="params[item.key]"
             :dict="dict"
             :ref="tabName"
             :columns="columns"

+ 7 - 1
src/views/purchase/apply/columns.js

@@ -35,7 +35,13 @@ export default function useColumns() {
     },
   ].map(({ item, attr }) => ({
     attr,
-    item: { ...item, fixed: false },
+    item: {
+      ...item,
+      sortabled: true,
+      fixedabled: true,
+      filterabled: true,
+      hiddenabled: true,
+    },
   }));
   const SearchColumns = [
     {

+ 291 - 0
src/views/purchase/apply/copy/columns.js

@@ -0,0 +1,291 @@
+import CONFIG from "@/config";
+
+export default function useColumns() {
+  const TableColumns = [
+    {
+      item: { key: "priceCode", title: "价格编码" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "supplierName", title: "供应商", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "SUPPLIER_PARAM",
+        dataMapping: {
+          supplier: "id",
+          supplierCode: "code",
+          supplierName: "name",
+        },
+      },
+    },
+    {
+      item: { key: "puOrgName", title: "采购组织", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "ORG_PARAM",
+        dataMapping: { puOrg: "id", puOrgCode: "code", puOrgName: "name" },
+      },
+    },
+    {
+      item: { key: "currencyName", title: "币种", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "CURRENCY_PARAM",
+        dataMapping: {
+          currency: "id",
+          currencyCode: "code",
+          currencyName: "name",
+        },
+      },
+    },
+    {
+      item: { key: "explainStr", title: "价格合理性说明", require: true },
+      attr: { is: "el-input" },
+    },
+    {
+      item: { key: "buyerName", title: "采购员", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "CONTACTS_PARAM",
+        dataMapping: { buyer: "code", buyerName: "name" },
+      },
+    },
+    {
+      item: { key: "puDeptName", title: "采购部门", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "DEPT_PARAM",
+        dataMapping: { puDept: "id", puDeptCode: "code", puDeptName: "name" },
+      },
+    },
+    {
+      item: { key: "createByName", title: "创建人" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "source", title: "来源单据号" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "isEffective", title: "是否已推价格" },
+      attr: {
+        is: "el-select",
+        dictName: "is_effective",
+        value: "N",
+      },
+    },
+    {
+      item: { key: "effectiveDate", title: "生效日期" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "file", title: "附件", require: true, span: 24 },
+      attr: { is: "el-file-upload" },
+    },
+    {
+      item: { key: "sourceType", title: "来源单据类型" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "status", title: "单据状态" },
+      attr: {
+        is: "el-select",
+        dictName: "sys_status",
+        disabled: true,
+        readonly: true,
+        value: "0",
+      },
+    },
+  ].map(({ item, attr }) => ({
+    attr,
+    item: { ...item, hidden: true, span: item.span || 6 },
+  }));
+
+  const TabColumns = [
+    {
+      item: {
+        title: "物料信息表",
+        key: "priceApplyItems",
+      },
+      attr: {
+        value: [],
+      },
+      TableColumns: [
+        {
+          item: { key: "materialName", title: "物料名称", require: true },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "MATERIAL_PARAM",
+            dataMapping: {
+              model: "model",
+              material: "id",
+              materialCode: "code",
+              materialName: "name",
+              unitName: "unitIdName",
+              puUnitName: "unitIdName",
+              specification: "specification",
+              manufacturer: "manufacturerId",
+              manufacturerName: "manufacturerIdName",
+            },
+          },
+        },
+        {
+          item: { key: "materialCode", title: "物料编码", require: true },
+          attr: {},
+        },
+        { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
+        { item: { key: "specification", title: "规格" }, attr: {} },
+        { item: { key: "model", title: "型号" }, attr: {} },
+        {
+          item: { key: "unitName", title: "单位" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "UNIT_PARAM",
+            dataMapping: { unit: "id", unitCode: "code", unitName: "name" },
+          },
+        },
+        {
+          item: { key: "puUnitName", title: "采购单位" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "UNIT_PARAM",
+            dataMapping: {
+              puUnit: "id",
+              puUnitCode: "code",
+              puUnitName: "name",
+            },
+          },
+        },
+        {
+          item: { key: "conversionRate", title: "采购换算率", require: true },
+          attr: {
+            is: "el-input-number",
+            precision: CONFIG.precision,
+          },
+        },
+        {
+          item: { key: "tax", title: "税率%", require: true },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "ntaxrate",
+            referName: "TAX_RATE_PARAM",
+            dataMapping: { tax: "ntaxrate" },
+          },
+        },
+        {
+          item: { key: "taxPrice", title: "含税单价", require: true },
+          attr: {
+            is: "el-input-number",
+            precision: CONFIG.precision,
+          },
+        },
+        {
+          item: { key: "price", title: "无税单价", require: true },
+          attr: {
+            formatter: (prop) => {
+              const { tax = 0, taxPrice = 0 } = prop;
+              prop.price = ((taxPrice / (tax / 100 + 1)) * 1).toFixed(
+                CONFIG.precision
+              );
+              return prop.price;
+            },
+          },
+        },
+        {
+          item: { key: "currencyName", title: "币种" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "CURRENCY_PARAM",
+            dataMapping: {
+              currency: "id",
+              currencyCode: "code",
+              currencyName: "name",
+            },
+          },
+        },
+        {
+          item: {
+            key: "periodBegin",
+            title: "价格有效期(起)",
+            require: true,
+          },
+          attr: {
+            is: "el-date-picker",
+            valueFormat: "yyyy-MM-dd",
+            value: new Date(),
+          },
+        },
+        {
+          item: { key: "periodEnd", title: "价格有效期(止)", require: true },
+          attr: {
+            is: "el-date-picker",
+            valueFormat: "yyyy-MM-dd",
+            pickerOptions: {
+              disabledDate(time) {
+                return time.getTime() < Date.now() + 3600 * 1000 * 24 * 365;
+              },
+            },
+            value: new Date(new Date().getTime() + 3600 * 1000 * 24 * 366),
+          },
+        },
+        {
+          item: { key: "customerName", title: "客户" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "CUSTOMER_PARAM",
+            dataMapping: {
+              customer: "id",
+              customerCode: "code",
+              customerName: "name",
+            },
+          },
+        },
+        { item: { key: "recentlyPrice", title: "最近价格" }, attr: {} },
+        {
+          item: { key: "isApprovalFirst", title: "首次报批" },
+          attr: {
+            is: "el-select",
+            dictName: "is_effective",
+          },
+        },
+        {
+          item: { key: "isPriceAdjustment", title: "价格调整" },
+          attr: {
+            is: "el-select",
+            dictName: "is_effective",
+          },
+        },
+        {
+          item: { key: "priceType", title: "价格类型", require: true },
+          attr: {
+            is: "el-select",
+            dictName: "sys_price_type",
+            value: "order",
+          },
+        },
+        {
+          item: { key: "isDistributionPrice", title: "配送价", require: true },
+          attr: {
+            is: "el-select",
+            dictName: "is_effective",
+            value: "N",
+          },
+        },
+        { item: { key: "createByName", title: "创建人名称" }, attr: {} },
+        { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
+      ],
+    },
+  ];
+
+  return { TableColumns, TabColumns };
+}

+ 322 - 0
src/views/purchase/apply/copy/index.vue

@@ -0,0 +1,322 @@
+<script>
+import useColumns from "./columns";
+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";
+
+const fetchExist = async (prop) => {
+  try {
+    // try
+    const { code, data } = await EXIST(prop);
+    if (code === 200) return data;
+  } catch (err) {
+    // catch
+    console.error(err);
+  } finally {
+    // finally
+  }
+};
+
+export default {
+  name: "AddDrawer",
+  props: {
+    dict: {
+      type: Object,
+    },
+    selectData: {
+      type: [Array],
+      require: true,
+    },
+  },
+  components: {
+    ElSuperForm: () => import("@/components/super-form/index.vue"),
+    ElSuperTable: () => import("@/components/super-table/index.vue"),
+    ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
+  },
+  data() {
+    const {
+      TabColumns,
+      TableColumns,
+      TabColumns: [
+        {
+          item: { key: tabName },
+        },
+      ],
+    } = useColumns();
+    const rules = this.$init.rules([...TabColumns, ...TableColumns]);
+    const params = this.$init.params([...TabColumns, ...TableColumns]);
+    return {
+      title: "复 制",
+      width: "100%",
+      visible: false,
+      loading: false,
+      rules: rules,
+      params: params,
+      tabName: tabName,
+      TabColumns: TabColumns,
+      TableColumns: TableColumns,
+    };
+  },
+  computed: {
+    disabled: {
+      get() {
+        const {
+          selectData: { length },
+        } = this.$props;
+        if (length !== 1) {
+          return true;
+        }
+      },
+      set() {},
+    },
+  },
+  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 fetchItem(prop) {
+      try {
+        // try
+        this.loading = true;
+        const { code, data } = await ITEM(prop);
+        if (code === 200) {
+          this.params = data;
+          return true;
+        } else {
+          return false;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
+    },
+    //
+    async onOpen() {
+      const {
+        selectData: [{ id }],
+      } = this.$props;
+      this.visible = await this.fetchItem(id);
+      this.params.id = null;
+      this.params.createBy = null;
+      this.params.priceCode = null;
+      this.params.createByName = null;
+      this.params.effectiveDate = null;
+      this.params.priceApplyOrgs = [];
+      this.params.priceApplyItems = this.params.priceApplyItems.map((item) => ({
+        ...item,
+        id: null,
+        applyId: null,
+        createByName: null,
+        updateByName: null,
+        delFlag: 0,
+      }));
+    },
+    //
+    async onHide() {
+      const { TabColumns, TableColumns } = useColumns();
+      this.visible = false;
+      this.params = this.$init.params([...TabColumns, ...TableColumns]);
+    },
+    //
+    async onRowAdd(prop) {
+      const {
+        $notify,
+        TabColumns,
+        params: { puOrgName, supplierName },
+      } = this;
+      if (!supplierName) {
+        return $notify.info("请选择供应商");
+      }
+      if (!puOrgName) {
+        return $notify.info("请选择采购组织");
+      }
+      const { TableColumns } = TabColumns.find(
+        ({ item: { key } }) => key === prop
+      );
+      this.params[prop].push({
+        delFlag: "0",
+        ...this.$init.params(TableColumns),
+      });
+    },
+    //
+    async onRowRemove(prop, scope) {
+      const { $index } = scope;
+      this.params[prop].splice($index, 1);
+    },
+    //
+    async useSubmit(prop) {
+      this.$refs[prop].validate(async (valid) => {
+        console.log(this.params);
+        if (valid) {
+          try {
+            this.loading = true;
+            const { msg, code } = await SAVE(this.params);
+            if (code === 200) {
+              this.onHide();
+              this.$emit("success");
+              this.$notify.success(msg);
+            }
+          } catch (err) {
+            // catch
+            console.error(err);
+          } finally {
+            // finally
+            this.loading = false;
+          }
+        } else {
+          return false;
+        }
+      });
+    },
+  },
+  created() {},
+  mounted() {},
+  destroyed() {},
+};
+</script>
+<template>
+  <el-button
+    v-bind="$attrs"
+    v-on="$listeners"
+    :disabled="disabled"
+    @click="onOpen"
+  >
+    {{ title }}
+    <el-drawer
+      :show-close="false"
+      :size="width"
+      :title="title"
+      :visible.sync="visible"
+      append-to-body
+      destroy-on-close
+      @close="onHide"
+    >
+      <template slot="title">
+        <span>{{ title }}</span>
+        <el-button
+          type="primary"
+          :size="$attrs.size"
+          :loading="loading"
+          @click="useSubmit('superForm')"
+        >
+          确 认
+        </el-button>
+        <el-button :size="$attrs.size" :loading="loading" @click="onHide">
+          取 消
+        </el-button>
+      </template>
+      <el-super-form
+        v-model="params"
+        :dict="dict"
+        :rules="rules"
+        :size="$attrs.size"
+        :columns="TableColumns"
+        ref="superForm"
+        label-width="auto"
+        label-position="right"
+        style="padding: 20px"
+      >
+        <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-tab-pane
+          v-for="({ item, TableColumns: columns }, index) in TabColumns"
+          :key="index"
+          :label="item.title"
+          :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
+                  :size="$attrs.size"
+                  @click.native.prevent="onRowRemove(tabName, scope)"
+                >
+                  删除
+                </el-button>
+              </template>
+            </el-table-column>
+          </el-super-table>
+        </el-tab-pane>
+      </el-tabs>
+    </el-drawer>
+  </el-button>
+</template>
+
+<style scoped>
+::v-deep .el-table__row.is-hidden {
+  display: none;
+}
+</style>

+ 291 - 0
src/views/purchase/apply/edit/columns.js

@@ -0,0 +1,291 @@
+import CONFIG from "@/config";
+
+export default function useColumns() {
+  const TableColumns = [
+    {
+      item: { key: "priceCode", title: "价格编码" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "supplierName", title: "供应商", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "SUPPLIER_PARAM",
+        dataMapping: {
+          supplier: "id",
+          supplierCode: "code",
+          supplierName: "name",
+        },
+      },
+    },
+    {
+      item: { key: "puOrgName", title: "采购组织", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "ORG_PARAM",
+        dataMapping: { puOrg: "id", puOrgCode: "code", puOrgName: "name" },
+      },
+    },
+    {
+      item: { key: "currencyName", title: "币种", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "CURRENCY_PARAM",
+        dataMapping: {
+          currency: "id",
+          currencyCode: "code",
+          currencyName: "name",
+        },
+      },
+    },
+    {
+      item: { key: "explainStr", title: "价格合理性说明", require: true },
+      attr: { is: "el-input" },
+    },
+    {
+      item: { key: "buyerName", title: "采购员", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "CONTACTS_PARAM",
+        dataMapping: { buyer: "code", buyerName: "name" },
+      },
+    },
+    {
+      item: { key: "puDeptName", title: "采购部门", require: true },
+      attr: {
+        is: "el-popover-select-v2",
+        valueKey: "name",
+        referName: "DEPT_PARAM",
+        dataMapping: { puDept: "id", puDeptCode: "code", puDeptName: "name" },
+      },
+    },
+    {
+      item: { key: "createByName", title: "创建人" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "source", title: "来源单据号" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "isEffective", title: "是否已推价格" },
+      attr: {
+        is: "el-select",
+        dictName: "is_effective",
+        value: "N",
+      },
+    },
+    {
+      item: { key: "effectiveDate", title: "生效日期" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "file", title: "附件", require: true, span: 24 },
+      attr: { is: "el-file-upload" },
+    },
+    {
+      item: { key: "sourceType", title: "来源单据类型" },
+      attr: { is: "el-input", disabled: true, readonly: true },
+    },
+    {
+      item: { key: "status", title: "单据状态" },
+      attr: {
+        is: "el-select",
+        dictName: "sys_status",
+        disabled: true,
+        readonly: true,
+        value: "0",
+      },
+    },
+  ].map(({ item, attr }) => ({
+    attr,
+    item: { ...item, hidden: true, span: item.span || 6 },
+  }));
+
+  const TabColumns = [
+    {
+      item: {
+        title: "物料信息表",
+        key: "priceApplyItems",
+      },
+      attr: {
+        value: [],
+      },
+      TableColumns: [
+        {
+          item: { key: "materialName", title: "物料名称", require: true },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "MATERIAL_PARAM",
+            dataMapping: {
+              model: "model",
+              material: "id",
+              materialCode: "code",
+              materialName: "name",
+              unitName: "unitIdName",
+              puUnitName: "unitIdName",
+              specification: "specification",
+              manufacturer: "manufacturerId",
+              manufacturerName: "manufacturerIdName",
+            },
+          },
+        },
+        {
+          item: { key: "materialCode", title: "物料编码", require: true },
+          attr: {},
+        },
+        { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
+        { item: { key: "specification", title: "规格" }, attr: {} },
+        { item: { key: "model", title: "型号" }, attr: {} },
+        {
+          item: { key: "unitName", title: "单位" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "UNIT_PARAM",
+            dataMapping: { unit: "id", unitCode: "code", unitName: "name" },
+          },
+        },
+        {
+          item: { key: "puUnitName", title: "采购单位" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "UNIT_PARAM",
+            dataMapping: {
+              puUnit: "id",
+              puUnitCode: "code",
+              puUnitName: "name",
+            },
+          },
+        },
+        {
+          item: { key: "conversionRate", title: "采购换算率", require: true },
+          attr: {
+            is: "el-input-number",
+            precision: CONFIG.precision,
+          },
+        },
+        {
+          item: { key: "tax", title: "税率%", require: true },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "ntaxrate",
+            referName: "TAX_RATE_PARAM",
+            dataMapping: { tax: "ntaxrate" },
+          },
+        },
+        {
+          item: { key: "taxPrice", title: "含税单价", require: true },
+          attr: {
+            is: "el-input-number",
+            precision: CONFIG.precision,
+          },
+        },
+        {
+          item: { key: "price", title: "无税单价", require: true },
+          attr: {
+            formatter: (prop) => {
+              const { tax = 0, taxPrice = 0 } = prop;
+              prop.price = ((taxPrice / (tax / 100 + 1)) * 1).toFixed(
+                CONFIG.precision
+              );
+              return prop.price;
+            },
+          },
+        },
+        {
+          item: { key: "currencyName", title: "币种" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "CURRENCY_PARAM",
+            dataMapping: {
+              currency: "id",
+              currencyCode: "code",
+              currencyName: "name",
+            },
+          },
+        },
+        {
+          item: {
+            key: "periodBegin",
+            title: "价格有效期(起)",
+            require: true,
+          },
+          attr: {
+            is: "el-date-picker",
+            valueFormat: "yyyy-MM-dd",
+            value: new Date(),
+          },
+        },
+        {
+          item: { key: "periodEnd", title: "价格有效期(止)", require: true },
+          attr: {
+            is: "el-date-picker",
+            valueFormat: "yyyy-MM-dd",
+            pickerOptions: {
+              disabledDate(time) {
+                return time.getTime() < Date.now() + 3600 * 1000 * 24 * 365;
+              },
+            },
+            value: new Date(new Date().getTime() + 3600 * 1000 * 24 * 366),
+          },
+        },
+        {
+          item: { key: "customerName", title: "客户" },
+          attr: {
+            is: "el-popover-select-v2",
+            valueKey: "name",
+            referName: "CUSTOMER_PARAM",
+            dataMapping: {
+              customer: "id",
+              customerCode: "code",
+              customerName: "name",
+            },
+          },
+        },
+        { item: { key: "recentlyPrice", title: "最近价格" }, attr: {} },
+        {
+          item: { key: "isApprovalFirst", title: "首次报批" },
+          attr: {
+            is: "el-select",
+            dictName: "is_effective",
+          },
+        },
+        {
+          item: { key: "isPriceAdjustment", title: "价格调整" },
+          attr: {
+            is: "el-select",
+            dictName: "is_effective",
+          },
+        },
+        {
+          item: { key: "priceType", title: "价格类型", require: true },
+          attr: {
+            is: "el-select",
+            dictName: "sys_price_type",
+            value: "order",
+          },
+        },
+        {
+          item: { key: "isDistributionPrice", title: "配送价", require: true },
+          attr: {
+            is: "el-select",
+            dictName: "is_effective",
+            value: "N",
+          },
+        },
+        { item: { key: "createByName", title: "创建人名称" }, attr: {} },
+        { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
+      ],
+    },
+  ];
+
+  return { TableColumns, TabColumns };
+}

+ 339 - 0
src/views/purchase/apply/edit/index.vue

@@ -0,0 +1,339 @@
+<script>
+import useColumns from "./columns";
+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";
+
+const fetchExist = async (prop) => {
+  try {
+    // try
+    const { code, data } = await EXIST(prop);
+    if (code === 200) return data;
+  } catch (err) {
+    // catch
+    console.error(err);
+  } finally {
+    // finally
+  }
+};
+
+export default {
+  name: "EditDrawer",
+  props: {
+    dict: {
+      type: Object,
+    },
+    selectData: {
+      type: [Array],
+      require: true,
+    },
+  },
+  components: {
+    ElSuperForm: () => import("@/components/super-form/index.vue"),
+    ElSuperTable: () => import("@/components/super-table/index.vue"),
+    ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
+  },
+  data() {
+    const {
+      TabColumns,
+      TableColumns,
+      TabColumns: [
+        {
+          item: { key: tabName },
+        },
+      ],
+    } = useColumns();
+    const rules = this.$init.rules([...TabColumns, ...TableColumns]);
+    const params = this.$init.params([...TabColumns, ...TableColumns]);
+    return {
+      title: "编 辑",
+      width: "100%",
+      visible: false,
+      loading: false,
+      rules: rules,
+      params: params,
+      tabName: tabName,
+      TabColumns: TabColumns,
+      TableColumns: TableColumns,
+    };
+  },
+  computed: {
+    disabled: {
+      get() {
+        const {
+          selectData,
+          selectData: [{ status } = {}],
+        } = this.$props;
+        if (selectData.length !== 1) {
+          return true;
+        }
+        if (selectData.length === 1 && status === "1") {
+          return true;
+        }
+        if (selectData.length === 1 && status === "2") {
+          return true;
+        }
+      },
+      set() {},
+    },
+    priceApply: {
+      get() {
+        this.params.priceApplyItems = this.params.priceApplyItems.map(
+          (item, index) => ({
+            ...item,
+            $index: index,
+          })
+        );
+        return {
+          priceApplyItems: this.params.priceApplyItems.filter(
+            ({ delFlag }) => delFlag !== "2"
+          ),
+        };
+      },
+      set() {},
+    },
+  },
+  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 fetchItem(prop) {
+      try {
+        // try
+        this.loading = true;
+        const { code, data } = await ITEM(prop);
+        if (code === 200) {
+          this.params = data;
+          return true;
+        } else {
+          return false;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
+    },
+    //
+    async onOpen() {
+      const {
+        selectData: [{ id }],
+      } = this.$props;
+      this.visible = await this.fetchItem(id);
+    },
+    //
+    async onHide() {
+      const { TabColumns, TableColumns } = useColumns();
+      this.visible = false;
+      this.params = this.$init.params([...TabColumns, ...TableColumns]);
+    },
+    //
+    async onRowAdd(prop) {
+      const {
+        $notify,
+        TabColumns,
+        params: { puOrgName, supplierName },
+      } = this;
+      if (!supplierName) {
+        return $notify.info("请选择供应商");
+      }
+      if (!puOrgName) {
+        return $notify.info("请选择采购组织");
+      }
+      const { TableColumns } = TabColumns.find(
+        ({ item: { key } }) => key === prop
+      );
+      this.params[prop].push({
+        delFlag: "0",
+        ...this.$init.params(TableColumns),
+      });
+    },
+    //
+    async onRowRemove(prop, scope) {
+      const {
+        row: { $index },
+      } = scope;
+      this.params[prop] = this.params[prop].map((item, index) => ({
+        ...item,
+        delFlag: index === $index ? "2" : item.delFlag,
+      }));
+    },
+    //
+    async useSubmit(prop) {
+      this.$refs[prop].validate(async (valid) => {
+        console.log(this.params);
+        if (valid) {
+          try {
+            this.loading = true;
+            this.params.priceApplyItems = this.params.priceApplyItems.filter(
+              (item) => item.materialName
+            );
+            const { msg, code } = await SAVE(this.params);
+            if (code === 200) {
+              this.onHide();
+              this.$emit("success");
+              this.$notify.success(msg);
+            }
+          } catch (err) {
+            // catch
+            console.error(err);
+          } finally {
+            // finally
+            this.loading = false;
+          }
+        } else {
+          return false;
+        }
+      });
+    },
+  },
+  created() {},
+  mounted() {},
+  destroyed() {},
+};
+</script>
+<template>
+  <el-button
+    v-bind="$attrs"
+    v-on="$listeners"
+    :disabled="disabled"
+    @click="onOpen"
+  >
+    {{ title }}
+    <el-drawer
+      :show-close="false"
+      :size="width"
+      :title="title"
+      :visible.sync="visible"
+      append-to-body
+      destroy-on-close
+      @close="onHide"
+    >
+      <template slot="title">
+        <span>{{ title }}</span>
+        <el-button
+          type="primary"
+          :size="$attrs.size"
+          :loading="loading"
+          @click="useSubmit('superForm')"
+        >
+          确 认
+        </el-button>
+        <el-button :size="$attrs.size" :loading="loading" @click="onHide">
+          取 消
+        </el-button>
+      </template>
+      <el-super-form
+        v-model="params"
+        :dict="dict"
+        :rules="rules"
+        :size="$attrs.size"
+        :columns="TableColumns"
+        ref="superForm"
+        label-width="auto"
+        label-position="right"
+        style="padding: 20px"
+      >
+        <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-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"
+          >
+            <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
+                  :size="$attrs.size"
+                  @click.native.prevent="onRowRemove(tabName, scope)"
+                >
+                  删除
+                </el-button>
+              </template>
+            </el-table-column>
+          </el-super-table>
+        </el-tab-pane>
+      </el-tabs>
+    </el-drawer>
+  </el-button>
+</template>
+
+<style scoped>
+::v-deep .el-table__row.is-hidden {
+  display: none;
+}
+</style>

+ 19 - 17
src/views/purchase/apply/index.vue

@@ -9,6 +9,8 @@ export default {
   components: {
     SeeButton: () => import("./see/index.vue"),
     AddButton: () => import("./add/index.vue"),
+    CopyButton: () => import("./copy/index.vue"),
+    EditButton: () => import("./edit/index.vue"),
     DeleButton: () => import("./delete/index.vue"),
     SubmButton: () => import("./submit/index.vue"),
     ElSuperTable: () => import("@/components/super-table/index.vue"),
@@ -84,7 +86,15 @@ export default {
 </script>
 
 <template>
-  <el-card v-loading="loading" :body-style="{ padding: 0 }">
+  <el-card
+    v-loading="loading"
+    :body-style="{
+      height: '100%',
+      padding: 0,
+      display: 'flex',
+      'flex-direction': 'column',
+    }"
+  >
     <el-super-search
       v-model="params"
       :size="size"
@@ -95,21 +105,15 @@ export default {
     ></el-super-search>
     <el-row class="my-4" style="text-align: right">
       <el-button-group>
-        <add-button
-          :size="size"
-          :select-data="[]"
-          :dict="dict"
-          add-type="add"
-          @success="useQuery(params, page)"
-        ></add-button>
-        <add-button
+        <add-button :size="size" :dict="dict" @success="useQuery(params, page)">
+        </add-button>
+        <copy-button
           :size="size"
           :dict="dict"
           :select-data="selectData"
-          add-type="copy"
           @success="useQuery(params, page)"
         >
-        </add-button>
+        </copy-button>
       </el-button-group>
       <el-button-group>
         <see-button
@@ -121,13 +125,12 @@ export default {
           ref="SeeButton"
           @success="useQuery(params, page)"
         ></see-button>
-        <add-button
+        <edit-button
           :size="size"
           :dict="dict"
           :select-data="selectData"
-          add-type="edit"
           @success="useQuery(params, page)"
-        ></add-button>
+        ></edit-button>
         <dele-button
           :size="size"
           :select-data="selectData"
@@ -151,9 +154,7 @@ export default {
       index
       checkbox
       pagination
-      hiddenColumns
-      filterColumns
-      height="600"
+      convenitentOperation
       @row-dblclick="useSee"
       @row-select="useSelect"
       @pagination="useQuery(params, page)"
@@ -164,6 +165,7 @@ export default {
 <style scoped lang="scss">
 .el-card {
   width: calc(100% - 32px);
+  height: calc(100vh - 32px);
   margin: 16px;
   padding: 16px;
   border-radius: 8px;

+ 9 - 3
src/views/purchase/catalogue/columns.js

@@ -30,7 +30,7 @@ export default function useColumns() {
     { item: { key: "effectiveDate", title: "价格生效日期" }, attr: {} },
     { item: { key: "endDate", title: "价格失效日期" }, attr: {} },
     { item: { key: "buyerName", title: "采购员" }, attr: {} },
-    { item: { key: "source", title: "来源单据" }, attr: {} },
+    { item: { key: "applyCode", title: "来源单据" }, attr: {} },
     {
       item: { key: "convertRate", title: "换算率" },
       attr: {
@@ -66,7 +66,13 @@ export default function useColumns() {
     { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
   ].map(({ item, attr }) => ({
     attr,
-    item: { ...item, hidden: true, fixed: false },
+    item: {
+      ...item,
+      sortabled: true,
+      fixedabled: true,
+      filterabled: true,
+      hiddenabled: true,
+    },
   }));
 
   const SearchColumns = [
@@ -99,7 +105,7 @@ export default function useColumns() {
       },
     },
     {
-      item: { key: "source", title: "来源单据" },
+      item: { key: "applyCode", title: "来源单据" },
       attr: { is: "el-input" },
     },
     {

+ 15 - 8
src/views/purchase/catalogue/index.vue

@@ -82,7 +82,15 @@ export default {
 </script>
 
 <template>
-  <el-card v-loading="loading" :body-style="{ padding: 0 }">
+  <el-card
+    v-loading="loading"
+    :body-style="{
+      height: '100%',
+      padding: 0,
+      display: 'flex',
+      'flex-direction': 'column',
+    }"
+  >
     <el-super-search
       v-model="params"
       :size="size"
@@ -140,9 +148,7 @@ export default {
       index
       checkbox
       pagination
-      hiddenColumns
-      filterColumns
-      height="600"
+      convenitentOperation
       @row-dblclick="useSee"
       @selection-change="useSelect"
       @pagination="useQuery(params, page)"
@@ -152,10 +158,11 @@ export default {
 </template>
 <style scoped lang="scss">
 .el-card {
-  width: calc(100% - 20px);
-  height: 100%;
-  margin: 10px;
-  padding: 20px;
+  width: calc(100% - 32px);
+  height: calc(100vh - 32px);
+  margin: 16px;
+  padding: 16px;
+  border-radius: 8px;
 }
 .el-button-group + .el-button-group {
   margin: 0 0 0 10px;

+ 29 - 29
src/views/purchase/contract/add/index.vue

@@ -126,25 +126,24 @@ export default {
       this.params.buyerName = buyerName;
       this.params.puDept = puDept;
       this.params.puDeptName = puDeptName;
-      const  {id,code, name } =  await this.getCurrency("人民币");
+      const { id, code, name } = await this.getCurrency("人民币");
       this.params.currency = id;
       this.params.currencyCode = code;
-      this .params.currencyName = name;
+      this.params.currencyName = name;
       this.visible = await this.fetchCode();
     },
-    async getCurrency(search){
-
-      let page = {pageNum: 1, pageSize:10,}
+    async getCurrency(search) {
+      let page = { pageNum: 1, pageSize: 10 };
 
       const { code, rows } = await REFER(
-          {
-            isPage:true,
-            search,
-            type: 'CURRENCY_PARAM',
-          },
-          page
+        {
+          isPage: true,
+          search,
+          type: "CURRENCY_PARAM",
+        },
+        page
       );
-      if(code == 200){
+      if (code == 200) {
         return rows[0];
       }
     },
@@ -177,7 +176,7 @@ export default {
     },
     //
     async useSubmit(prop) {
-      this.$refs[prop].$refs[prop].validate(async (valid) => {
+      this.$refs[prop].validate(async (valid) => {
         if (valid) {
           try {
             // try
@@ -202,8 +201,7 @@ export default {
       });
     },
   },
-  created() {
-  },
+  created() {},
   mounted() {},
   destroyed() {},
 };
@@ -220,24 +218,27 @@ export default {
       :show-close="false"
       @close="hide"
     >
-      <div slot="title" 
-          style="
-            display: flex;
-            justify-content: space-between;
-            align-items: center;
-          ">
-        <h3>{{title}}</h3>
+      <div
+        slot="title"
+        style="
+          display: flex;
+          justify-content: space-between;
+          align-items: center;
+        "
+      >
+        <h3>{{ title }}</h3>
         <div style="text-align: right">
           <el-button
             type="primary"
             :size="$attrs.size"
             :loading="loading"
             @click="useSubmit('superForm')"
-            >确 认</el-button>
+            >确 认</el-button
+          >
           <el-button :size="$attrs.size" :loading="loading" @click="hide"
-            >取 消</el-button>
+            >取 消</el-button
+          >
         </div>
-        
       </div>
 
       <el-super-form
@@ -265,8 +266,8 @@ export default {
             :dict="dict"
             :ref="tabName"
             :columns="columns"
-            :iconOperation="false"
             :size="$attrs.size"
+            index
           >
             <template slot="materialName" slot-scope="scope">
               <component
@@ -284,7 +285,7 @@ export default {
                   type="text"
                   :size="$attrs.size"
                   @click="useRowAdd(tabName)"
-                >增行
+                  >增行
                 </el-button>
               </template>
               <template slot-scope="scope">
@@ -292,14 +293,13 @@ export default {
                   type="text"
                   :size="$attrs.size"
                   @click.native.prevent="useRowRemove(tabName, scope)"
-                >删行
+                  >删行
                 </el-button>
               </template>
             </el-table-column>
           </el-super-table>
         </el-tab-pane>
       </el-tabs>
-      
     </el-drawer>
   </el-button>
 </template>

+ 7 - 1
src/views/purchase/contract/columns.js

@@ -223,7 +223,13 @@ export default function useColumns() {
     },
   ].map(({ item, attr }) => ({
     attr,
-    item: { ...item, hidden: true, fixed: false },
+    item: {
+      ...item,
+      sortabled: true,
+      fixedabled: true,
+      filterabled: true,
+      hiddenabled: true,
+    },
   }));
 
   const SearchColumns = [

+ 22 - 24
src/views/purchase/contract/edit/index.vue

@@ -187,7 +187,7 @@ export default {
     },
     //
     async useSubmit(prop) {
-      this.$refs[prop].$refs[prop].validate(async (valid) => {
+      this.$refs[prop].validate(async (valid) => {
         if (valid) {
           try {
             // try
@@ -238,27 +238,27 @@ export default {
       destroy-on-close
       @close="hide"
     >
-
-    <div slot="title" 
-          style="
-            display: flex;
-            justify-content: space-between;
-            align-items: center;
-          ">
-        <h3>{{title}}</h3>
+      <div
+        slot="title"
+        style="
+          display: flex;
+          justify-content: space-between;
+          align-items: center;
+        "
+      >
+        <h3>{{ title }}</h3>
         <div style="text-align: right">
           <el-button
-          type="primary"
-          :size="$attrs.size"
-          :loading="loading"
-          @click="useSubmit('superForm')"
-          >确 认</el-button
-        >
+            type="primary"
+            :size="$attrs.size"
+            :loading="loading"
+            @click="useSubmit('superForm')"
+            >确 认</el-button
+          >
           <el-button :size="$attrs.size" :loading="loading" @click="hide"
-          >取 消</el-button
-        >
+            >取 消</el-button
+          >
         </div>
-        
       </div>
       <el-super-form
         v-model="params"
@@ -272,7 +272,6 @@ export default {
         style="padding: 20px"
       ></el-super-form>
       <el-tabs v-model="tabName" style="margin: 0 20px">
-        
         <el-tab-pane
           v-for="{ item, TableColumns: columns } in TabColumns"
           :key="item.key"
@@ -286,7 +285,7 @@ export default {
             :ref="tabName"
             :columns="columns"
             :size="$attrs.size"
-            :iconOperation="false"
+            index
           >
             <template slot="materialName" slot-scope="scope">
               <component
@@ -304,7 +303,7 @@ export default {
                   type="text"
                   :size="$attrs.size"
                   @click="useRowAdd(tabName)"
-                >增行
+                  >增行
                 </el-button>
               </template>
               <template slot-scope="scope">
@@ -312,20 +311,19 @@ export default {
                   type="text"
                   :size="$attrs.size"
                   @click.native.prevent="useRowSubmit(tabName, scope)"
-                >更新
+                  >更新
                 </el-button>
                 <el-button
                   type="text"
                   :size="$attrs.size"
                   @click.native.prevent="useRowRemove(tabName, scope)"
-                >删行
+                  >删行
                 </el-button>
               </template>
             </el-table-column>
           </el-super-table>
         </el-tab-pane>
       </el-tabs>
-      
     </el-drawer>
   </el-button>
 </template>

+ 21 - 11
src/views/purchase/contract/index.vue

@@ -36,8 +36,8 @@ export default {
     this.useQuery(this.params, this.page);
   },
   methods: {
-    setSelectable(){
-      return true
+    setSelectable() {
+      return true;
     },
     //
     async fetchList(prop, page) {
@@ -92,7 +92,15 @@ export default {
 </script>
 
 <template>
-  <el-card v-loading="loading" :body-style="{ padding: 0 }">
+  <el-card
+    v-loading="loading"
+    :body-style="{
+      height: '100%',
+      padding: 0,
+      display: 'flex',
+      'flex-direction': 'column',
+    }"
+  >
     <el-super-search
       v-model="params"
       :size="size"
@@ -101,7 +109,7 @@ export default {
       @reset="useReset"
       @submit="useQuery(params, page)"
     ></el-super-search>
-    <div style="margin: 20px 0 ; text-align: right">
+    <div style="margin: 20px 0; text-align: right">
       <el-button-group>
         <add-button
           :size="size"
@@ -168,14 +176,15 @@ export default {
       v-model="tableData"
       :size="size"
       :dict="dict"
-      max-height="600"
+      :page="page"
       :columns="TableColumns"
       :selectable="setSelectable"
+      index
       checkbox
       pagination
+      convenitentOperation
       @row-dblclick="useSee"
       @selection-change="useSelect"
-      :page="page"
       @pagination="useQuery(params, page)"
     >
     </el-super-table>
@@ -183,12 +192,13 @@ export default {
 </template>
 <style scoped lang="scss">
 .el-card {
-  width: calc(100% - 20px);
-  height: 100%;
-  margin: 10px;
-  padding: 20px;
+  width: calc(100% - 32px);
+  height: calc(100vh - 32px);
+  margin: 16px;
+  padding: 16px;
+  border-radius: 8px;
 }
 .el-button-group + .el-button-group {
-  margin: 0 0 0 10px;
+  margin: 0 0 0 8px;
 }
 </style>

+ 7 - 1
src/views/purchase/task/columns.js

@@ -75,7 +75,13 @@ export default function useColumns() {
     { item: { key: "unitName", title: "单位" }, attr: {} },
   ].map(({ item, attr }) => ({
     attr,
-    item: { ...item, hidden: true, width: 200 },
+    item: {
+      ...item,
+      sortabled: true,
+      fixedabled: true,
+      filterabled: true,
+      hiddenabled: true,
+    },
   }));
 
   const SearchColumns = [

+ 4 - 4
src/views/purchase/task/index.vue

@@ -109,6 +109,8 @@ export default {
     :body-style="{
       height: '100%',
       padding: 0,
+      display: 'flex',
+      'flex-direction': 'column',
     }"
   >
     <el-super-search
@@ -167,10 +169,8 @@ export default {
       :columns="TableColumns"
       index
       checkbox
-      hiddenColumns
-      filterColumns
       pagination
-      height="600"
+      convenitentOperation
       @row-select="useSelect"
       @pagination="useQuery(params, page)"
     >
@@ -180,7 +180,7 @@ export default {
 <style scoped lang="scss">
 .el-card {
   width: calc(100% - 32px);
-  // height: calc(100vh - 32px);
+  height: calc(100vh - 32px);
   margin: 16px;
   padding: 16px;
   border-radius: 8px;

+ 8 - 0
src/views/purchase/task/xie-yi-zhi-cai/column.js

@@ -6,6 +6,14 @@ export const TableColumns = [
     attr: {},
   },
   {
+    item: { key: "manufacturerName", title: "生产厂商" },
+    attr: {},
+  },
+  {
+    item: { key: "materialName", title: "物料名称" },
+    attr: {},
+  },
+  {
     item: { key: "demandDate", title: "需求时间" },
     attr: {},
   },