002390 il y a 2 ans
Parent
commit
6be484d642

+ 62 - 38
src/views/purchase/purchase-order/add/column.js

@@ -16,7 +16,7 @@ export const Columns = [
     key: "billTypeName",
     title: "订单类型",
     type: "Select",
-    require: true,
+
     config: {
       optionsName: "sys_order_type", // 字典名
       dataMapping: {
@@ -116,6 +116,7 @@ export const Columns = [
     title: "收货客户",
     type: "InputDialog",
     width: 200,
+    require: true,
     config: {
       componentName: "CUSTOMER_PARAM",
       dataMapping: {
@@ -157,6 +158,7 @@ export const Columns = [
     key: "warehouseName",
     title: "WMS入库仓库", // 收货仓库
     type: "InputDialog",
+    require: true,
     config: {
       componentName: "WAREHOUSE_PARAM",
       dataMapping: {
@@ -169,6 +171,7 @@ export const Columns = [
     key: "goodsAllocationName",
     title: "货位",
     type: "InputDialog",
+    require: true,
     config: {
       componentName: "ALLOCATION_PARAM",
       dataMapping: {
@@ -205,6 +208,7 @@ export const Columns = [
     key: "supplierContactsName",
     title: "供应商业务联系人",
     type: "InputDialog",
+    require: true,
     config: {
       componentName: "SUPPLIERCONTACTS_PARAM",
       dataMapping: {
@@ -229,12 +233,25 @@ export const Columns = [
   //   type: "Input",
   //   // type: "InputDialog",
   // },
-  { key: "supplierPersonalName", title: "供应商业务员名称", type: "Input", },
+  {
+    key: "supplierPersonalName",
+    title: "供应商业务员名称",
+    type: "InputDialog",
+    config: {
+      componentName: "SUPPLIERCONTACTS_PARAM",
+      dataMapping: {
+        supplierPersonal: "code",
+        supplierPersonalName: "name",
+      },
+    },
+    require: true,
+  },
   { key: "isDeliver", title: "是否发货", type: "Checkbox", },
   {
     key: "retReasonName",
     title: "退换原因",
     type: "InputDialog",
+    require: true,
     config: {
       componentName: "RETREASON_PARAM",
       dataMapping: {
@@ -247,6 +264,7 @@ export const Columns = [
     key: "processTypeName",
     title: "处理方式",
     type: "InputDialog",
+    require: true,
     config: {
       componentName: "PROCESSTYPE_PARAM",
       dataMapping: {
@@ -260,6 +278,7 @@ export const Columns = [
     key: "projectNowName",
     title: "在建工程项目",
     type: "InputDialog",
+    require: true,
     config: {
       componentName: "PROJECT_PARAM",
       dataMapping: {
@@ -272,6 +291,7 @@ export const Columns = [
     key: "operatingItemsName",
     title: "经营性项目",
     type: "InputDialog",
+    require: true,
     config: {
       componentName: "OPERATING_PARAM",
       dataMapping: {
@@ -311,13 +331,14 @@ export const TabColumns = [
     key: 'puOrderItemList',
     tableColumns: [
       { key: "rowNo", title: "行号", type: "Input", },
-      { key: "orderId", title: "采购订单ID", type: "Input", },
+      { key: "orderId", title: "采购订单ID", type: "Input", width: 180 },
       // {key: "material",title: "物料",type: "Input",   },
-      { key: "materialName", title: "物料", type: "Input", },
+      { key: "materialName", title: "物料", type: "Input", width: 180 },
       {
         key: "materialCode",
         title: "物料编码",
         type: "InputDialog",
+        width: 180,
         config: {
           componentName: "MATERIAL_PARAM",
           dataMapping: {
@@ -327,13 +348,13 @@ export const TabColumns = [
           },
         },
       },
-      { key: "materialClassify", title: "物料分类", type: "Input", },
-      { key: "materialManufacturersCode", title: "厂家物料编码", type: "Input", },
-      { key: "specification", title: "规格", type: "Input", },
+      { key: "materialClassify", title: "物料分类", type: "Input", width: 180 },
+      { key: "materialManufacturersCode", title: "厂家物料编码", type: "Input", width: 180 },
+      { key: "specification", title: "规格", type: "Input", width: 180 },
       { key: "model", title: "型号", type: "Input", },
-      { key: "isMedcine", title: "医药物料", type: "Input", },
-      { key: "manufacturer", title: "生产厂家代理人", type: "Input", },
-      { key: "isDrug", title: "物料药品属性", type: "Input", },
+      { key: "isMedcine", title: "医药物料", type: "Input", width: 180 },
+      { key: "manufacturer", title: "生产厂家代理人", type: "Input", width: 180 },
+      { key: "isDrug", title: "物料药品属性", type: "Input", width: 180 },
       { key: "unit", title: "单位", type: "Input", },
       { key: "qty", title: "数量", type: "Input", },
       { key: "taxPrice", title: "含税单价", type: "Input", },
@@ -348,7 +369,7 @@ export const TabColumns = [
       { key: "isInvoice", title: "开票关闭", type: "Input", },
       { key: "isArrival", title: "到货关闭", type: "Input", },
       { key: "isPayment", title: "付款关闭", type: "Input", },
-      { key: "isGift", title: "赠品", type: "Input", },
+      { key: "isGift", title: "赠品", type: "Input", width: 180 },
       {
         key: "warehouseName",
         title: "收货仓库", //WMS入库仓库
@@ -362,13 +383,13 @@ export const TabColumns = [
         },
         width: 200,
       },
-      { key: "place", title: "收货地点", type: "Input", },
-      { key: "address", title: "收货地址", type: "Input", },
-      { key: "productBatch", title: "产品批号", type: "Input", },
-      { key: "manufactureDate", title: "生产日期", type: "Input", },
-      { key: "efficacyLoseDate", title: "有效期至/失效日期", type: "Input", },
-      { key: "approvalNumber", title: "批准文号", type: "Input", },
-      { key: "registration", title: "注册证号", type: "Input", },
+      { key: "place", title: "收货地点", type: "Input", width: 180 },
+      { key: "address", title: "收货地址", type: "Input", width: 180 },
+      { key: "productBatch", title: "产品批号", type: "Input", width: 180 },
+      { key: "manufactureDate", title: "生产日期", type: "Input", width: 180 },
+      { key: "efficacyLoseDate", title: "有效期至/失效日期", type: "Input", width: 180 },
+      { key: "approvalNumber", title: "批准文号", type: "Input", width: 180 },
+      { key: "registration", title: "注册证号", type: "Input", width: 180 },
 
       {
         key: "storageCondition",
@@ -377,6 +398,7 @@ export const TabColumns = [
         config: {
           optionsName: "sys_storage_condition",
         },
+        width: 180
       },
       {
         key: "carriageCondition",
@@ -385,6 +407,7 @@ export const TabColumns = [
         config: {
           optionsName: "sys_conditions_carriage",
         },
+        width: 180
       },
 
       { key: "isBatchLock", title: "批号锁定标识", type: "Input", },
@@ -392,16 +415,16 @@ export const TabColumns = [
       { key: "isUrgency", title: "紧急标识", type: "Input", },
       { key: "originalQty", title: "原始数量", type: "Input", },
       { key: "originalMoney", title: "原始金额", type: "Input", },
-      { key: "directProductBatch", title: "直运产品批号", type: "Input", },
-      { key: "discountRule", title: "折扣规则编码", type: "Input", },
+      { key: "directProductBatch", title: "直运产品批号", type: "Input", width: 180 },
+      { key: "discountRule", title: "折扣规则编码", type: "Input", width: 180 },
       { key: "reservedQty", title: "预留数量", type: "Input", },
       { key: "reservedPeriod", title: "预留周期", type: "Input", },
       { key: "taxDeductClassify", title: "扣税类别", type: "Input", },
       { key: "exchangeRate", title: "折本汇率", type: "Input", },
-      { key: "source", title: "上游单据号", type: "Input", },
-      { key: "sourceId", title: "上游单据ID", type: "Input", },
-      { key: "demandCode", title: "采购需求单号", type: "Input", },
-      { key: "arrivalDatePlan", title: "计划到货日期", type: "Input", },
+      { key: "source", title: "上游单据号", type: "Input", width: 180 },
+      { key: "sourceId", title: "上游单据ID", type: "Input", width: 180 },
+      { key: "demandCode", title: "采购需求单号", type: "Input", width: 180 },
+      { key: "arrivalDatePlan", title: "计划到货日期", type: "Input", width: 180 },
       {
         key: "priceType",
         title: "价格类型",
@@ -413,10 +436,10 @@ export const TabColumns = [
       { key: "isDistributionPrice", title: "配送价", type: "Input", },
       { key: "createByName", title: "创建人名称", type: "Input", },
       { key: "updateByName", title: "更新人名称", type: "Input", },
-      { key: "materialClassifyOneName", title: "物料一级分类名称", type: "Input", },
-      { key: "materialClassifyTwoName", title: "物料二级分类名称", type: "Input", },
-      { key: "materialClassifyThreeName", title: "物料三级分类名称", type: "Input", },
-      { key: "materialClassifyFourName", title: "物料四级分类名称", type: "Input", },
+      { key: "materialClassifyOneName", title: "物料一级分类名称", type: "Input", width: 180 },
+      { key: "materialClassifyTwoName", title: "物料二级分类名称", type: "Input", width: 180 },
+      { key: "materialClassifyThreeName", title: "物料三级分类名称", type: "Input", width: 180 },
+      { key: "materialClassifyFourName", title: "物料四级分类名称", type: "Input", width: 180 },
       { key: "price", title: "无税单价", type: "Input", }
     ]
   },
@@ -424,7 +447,7 @@ export const TabColumns = [
     title: '执行结果',
     key: 'puOrderExecuteList',
     tableColumns: [
-      { key: "orderId", title: "采购订单ID", type: "Input", },
+      { key: "orderId", title: "采购订单ID", type: "Input", width: 180 },
       { key: "rowno", title: "行号", type: "Input", },
       {
         key: "materialName",
@@ -435,20 +458,21 @@ export const TabColumns = [
           dataMapping: {
             material: "id",
             materialName: "name",
-            // materialCode: "code",
+            materialCode: "code",
           },
         },
+        width: 180
       },
       { key: "specification", title: "规格", type: "Input", },
       { key: "qty", title: "数量", type: "Input", },
-      { key: "stroageQty", title: "累计到货主数量", type: "Input", },
-      { key: "stockQty", title: "累计入库主数量", type: "Input", },
-      { key: "invoiceQty", title: "累计开票主数量", type: "Input", },
-      { key: "rollbackQty", title: "累计退货主数量", type: "Checkbox", },
-      { key: "backStockQty", title: "累计退库主数量", type: "Input", },
-      { key: "floatQty", title: "未到货数量", type: "Input", },
-      { key: "createByName", title: "创建人名称", type: "Input", },
-      { key: "updateByName", title: "更新人名称", type: "Input", },
+      { key: "stroageQty", title: "累计到货主数量", type: "Input", width: 120 },
+      { key: "stockQty", title: "累计入库主数量", type: "Input", width: 120 },
+      { key: "invoiceQty", title: "累计开票主数量", type: "Input", width: 120 },
+      { key: "rollbackQty", title: "累计退货主数量", type: "Input", width: 120 },
+      { key: "backStockQty", title: "累计退库主数量", type: "Input", width: 120 },
+      { key: "floatQty", title: "未到货数量", type: "Input", width: 120 },
+      { key: "createByName", title: "创建人名称", type: "Input", width: 120 },
+      { key: "updateByName", title: "更新人名称", type: "Input", width: 120 },
     ]
   },
 ];

+ 74 - 30
src/views/purchase/purchase-order/add/index.vue

@@ -41,6 +41,20 @@ export default {
   },
   computed: {},
   watch: {
+    'params.puOrderItemList': {
+      handler(nVal, oVal) {
+        this.handleSynchronousMaterial('puOrderItemList', 'puOrderExecuteList');
+      },
+      deep: true,
+      immediate: true
+    },
+    'params.puOrderExecuteList': {
+      handler(nVal, oVal) {
+        this.handleSynchronousMaterial('puOrderExecuteList', 'puOrderItemList');
+      },
+      deep: true,
+      immediate: true
+    },
 
   },
   methods: {
@@ -83,7 +97,23 @@ export default {
     },
     // 删行
     delTableRow(prop, index) {
-      prop.splice(index, 1);
+
+      for (const key in this.params) {
+
+        if (Array.isArray(this.params[key])) {
+          this.params[key].splice(index, 1);
+        }
+      }
+      // prop.splice(index, 1);
+    },
+    // 同步子表物料
+    handleSynchronousMaterial(key1, key2) {
+      // this.params[key1]-- -> this.params[key2]
+      this.params[key1].forEach((item, index) => {
+        this.params[key2][index].material = item.material;
+        this.params[key2][index].materialName = item.materialName;
+        this.params[key2][index].materialCode = item.materialCode;
+      })
     },
     // 取消
     handleCancel() {
@@ -92,8 +122,10 @@ export default {
     },
     // 保存
     async handleSava() {
-      // this.setVisible(false);
+      // orderAddForm
       console.log(this.params, 'params');
+      // this.$refs['orderAddForm'].validate(async (valid) => {
+      //   if (valid) {
       try {
         const { code, msg } = await orderApi.create(this.params);
         if (code === 200) {
@@ -107,35 +139,45 @@ export default {
       } finally {
         // this.setVisible(false);
       }
-
-
-
+      // } else {
+      //   console.log('error submit!!');
+      //   return false;
+      // }
+      // });
     },
     // 保存并新增
-    async handleSubmit() {
-      try {
-        const createById = this.params.buyer;
-        const createByName = this.params.buyerName;
-        const updateById = this.$store.state.user.id;
-        const updateByName = this.$store.state.user.name;
-        const { code, msg } = await orderApi.create({
-          createById,
-          createByName,
-          updateById,
-          updateByName,
-          ...this.params,
-        });
-        if (code === 200) {
-          this.$notify.success({ title: msg });
-          this.setVisible(false);
+    handleSubmit() {
+      this.$refs['orderAddForm'].validate(async (valid) => {
+        if (valid) {
+          try {
+            const createById = this.params.buyer;
+            const createByName = this.params.buyerName;
+            const updateById = this.$store.state.user.id;
+            const updateByName = this.$store.state.user.name;
+            const { code, msg } = await orderApi.create({
+              createById,
+              createByName,
+              updateById,
+              updateByName,
+              ...this.params,
+            });
+            if (code === 200) {
+              this.$notify.success({ title: msg });
+              this.setVisible(false);
+            } else {
+              this.$notify.warning({ title: msg });
+            }
+          } catch (err) {
+            this.$notify.error({ title: "error", message: err });
+          } finally {
+            // this.setVisible(false);
+          }
         } else {
-          this.$notify.warning({ title: msg });
+          console.log('error submit!!');
+          return false;
         }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        // this.setVisible(false);
-      }
+      });
+
     },
   },
   created() {
@@ -148,7 +190,7 @@ export default {
 <template>
   <el-drawer direction="btt" size="100%" :with-header="false" :visible.sync="visible" @open="beforeOpen"
     @close="$emit('close')">
-    <el-form size="mini" label-position="right" label-width="135px" :model="params" :rules="rules">
+    <el-form size="mini" label-position="right" ref="orderAddForm" label-width="135px" :model="params" :rules="rules">
       <el-card :body-style="{
         padding: '20px',
         display: 'flex',
@@ -170,6 +212,7 @@ export default {
         </div>
         <el-row>
           <el-col v-for="(column, index) in columns" :key="index" :span="column.span || 6">
+
             <el-form-item :prop="column.key" :label="column.title">
               <el-input v-if="column.type === 'Input'" v-model="params[column.key]" :placeholder="column.placeholder"
                 :clearable="column.clearable" :disabled="column.disabled" style="width: 100%"></el-input>
@@ -217,6 +260,7 @@ export default {
                 </div>
               </el-upload>
             </el-form-item>
+
           </el-col>
         </el-row>
       </el-card>
@@ -231,7 +275,7 @@ export default {
           <el-tab-pane v-for="(column, index) in tabColumns" :key="index" :label="column.title" :name="column.key">
             <el-table :data="params[column.key]" style="width: 100%">
               <el-table-column v-for="(cColumn, cIndex) in column.tableColumns" :key="cIndex" :prop="cColumn.key"
-                :label="cColumn.title" :width="cColumn.width">
+                :label="cColumn.title" :width="cColumn.width || 80">
                 <template slot-scope="scope">
                   <el-tag v-if="cColumn.key === 'index'">
                     {{ scope.$index + 1 }}
@@ -259,7 +303,7 @@ export default {
                     false-label="N"></el-checkbox>
                 </template>
               </el-table-column>
-              <el-table-column fixed="right" label="操作" width="120">
+              <el-table-column fixed="right" label="操作" width="80">
                 <template slot-scope="scope">
                   <el-button @click.native.prevent="
                     delTableRow(params[tabName], scope.$index)

+ 62 - 24
src/views/purchase/purchase-order/edit/index.vue

@@ -49,10 +49,34 @@ export default {
       const { id } = this.params;
       // this.fetchTable(id, newProp);
     },
+    'params.puOrderItemList': {
+      handler(nVal, oVal) {
+        this.handleSynchronousMaterial('puOrderItemList', 'puOrderExecuteList');
+      },
+      deep: true,
+      immediate: true
+    },
+    'params.puOrderExecuteList': {
+      handler(nVal, oVal) {
+        this.handleSynchronousMaterial('puOrderExecuteList', 'puOrderItemList');
+      },
+      deep: true,
+      immediate: true
+    },
   },
   methods: {
     setVisible(prop) {
       this.visible = prop;
+
+    },
+    // 同步子表物料
+    handleSynchronousMaterial(key1, key2) {
+      // this.params[key1]-- -> this.params[key2]
+      this.params[key1].forEach((item, index) => {
+        this.params[key2][index].material = item.material;
+        this.params[key2][index].materialName = item.materialName;
+        this.params[key2][index].materialCode = item.materialCode;
+      })
     },
     // 查询详细
     async fetchItem(prop) {
@@ -72,33 +96,40 @@ export default {
         this.loading = false;
       }
     },
-    // 查询详情关联TABLE
-    // async fetchTable(prop, name) {
-    //   try {
-    //     this.loading = true;
-    //     const { code, msg, rows } = await itemTableList({ id: prop }, name);
-    //     if (code === 200) {
-    //       this.params[name] = rows;
-    //       this.$notify.success({ title: msg });
-    //     } else {
-    //       this.$notify.warning({ title: msg });
-    //     }
-    //   } catch (err) {
-    //     this.$notify.error({ title: "error", message: err });
-    //   } finally {
-    //     this.loading = false;
-    //   }
-    // },
     // 新增行
     addTableRow(prop) {
-      const arr = this.tabColumns.find(
-        (element) => element.key === this.tabName
-      ).tableColumns;
-      prop.push(initParams(arr, "key", "value"));
+
+      for (const key in this.params) {
+
+        if (Array.isArray(this.params[key])) {
+
+          const arr = this.tabColumns.find(
+            (element) => element.key === key
+          ).tableColumns;
+
+          let rowData = initParams(arr, "key", "value");
+
+          'rowno' in rowData && (rowData['rowno'] = this.params[key].length + 1);
+          'rowNo' in rowData && (rowData['rowNo'] = this.params[key].length + 1);
+
+          this.params[key].push(rowData);
+        }
+      }
+
+      // const arr = this.tabColumns.find(
+      //   (element) => element.key === this.tabName
+      // ).tableColumns;
+      // prop.push(initParams(arr, "key", "value"));
     },
     // 删除行
     delTableRow(prop, index) {
-      prop.splice(index, 1);
+      // prop.splice(index, 1);
+      for (const key in this.params) {
+
+        if (Array.isArray(this.params[key])) {
+          this.params[key].splice(index, 1);
+        }
+      }
     },
     // 取消
     handleCancel() {
@@ -107,7 +138,8 @@ export default {
     },
     // 保存
     async handleSava() {
-
+      // this.$refs['orderEditForm'].validate(async (valid) => {
+      //   if (valid) {
       try {
         this.loading = true;
         const { code, msg } = await (this.handleIsRevise(this.params.status) ?
@@ -126,6 +158,11 @@ export default {
         this.loading = false;
       }
 
+      //   } else {
+      //     console.log('error submit!!');
+      //     return false;
+      //   }
+      // });
     },
     beforeOpen() {
     },
@@ -145,7 +182,8 @@ export default {
 <template>
   <el-drawer direction="btt" size="100%" :with-header="false" :visible.sync="visible" @open="beforeOpen"
     @close="$emit('close')">
-    <el-form v-loading="loading" :size="size" label-position="right" label-width="135px" :model="params" :rules="rules">
+    <el-form v-loading="loading" :size="size" ref="orderEditForm" label-position="right" label-width="135px"
+      :model="params" :rules="rules">
       <el-card :body-style="{
         padding: '20px',
         display: 'flex',

+ 31 - 3
src/views/purchase/purchase-order/index.vue

@@ -161,7 +161,6 @@ export default {
         const { code, msg, rows, total } = await orderApi.list(params, page);
         if (code === 200) {
           this.page.total = total;
-          console.log(this.page, 'this.page');
           this.tableData = rows;
           this.$notify.success({ title: msg });
         } else {
@@ -302,6 +301,29 @@ export default {
       this.checkedList = selection;
       console.log(this.checkedList, 'this.checkedList');
     },
+    // 判断状态
+    judgeStatus(status) {
+      // 单据状态0=自由态,1=审批中,2=已审核,3=已驳回
+      let statusName = '';
+      switch (status) {
+        case '0':
+          statusName = '自由态';
+          break;
+        case '1':
+          statusName = '审批中';
+          break;
+        case '2':
+          statusName = '已审核';
+          break;
+        case '3':
+          statusName = '已驳回';
+          break;
+        default:
+          break;
+      }
+
+      return statusName;
+    },
 
   },
 };
@@ -366,8 +388,14 @@ export default {
       highlight-current-row style="width: 100%; margin: 20px 0 0 0" @select="handleSelect" height="450">
       <el-table-column type="selection" width="45"></el-table-column>
       <el-table-column type="index" width="50" label="序号"></el-table-column>
-      <el-table-column v-for="(column, index) in tableColumns" :key="index" :prop="column.key" :label="column.title"
+      <el-table-column v-for="(column, index) in tableColumns" :key="index" :label="column.title"
         :width="column.width || 180" :show-overflow-tooltip="column.showOverflowTooltip || true">
+
+        <template slot-scope="scope">
+          {{ column.key == 'status' ? judgeStatus(scope.row[column.key]) : scope.row[column.key] }}
+        </template>
+
+
       </el-table-column>
       <el-table-column fixed="right" label="操作" width="120">
         <template slot-scope="scope">
@@ -392,7 +420,7 @@ export default {
     <el-tabs v-model="tabName" @tab-click="handleTabClick" style="width: 100%;padding: 20px 10px">
       <el-tab-pane v-for="(column, index) in tabColumns" :key="index" :label="column.title" :name="column.key">
         <el-table :data="tabTableDatas[column.key]" style="width: 100%" highlight-current-row
-          :height="tabTableDatas[column.key].length>5 ? 300 : ''">
+          :height="tabTableDatas[column.key].length ? 300 : 100">
           <el-table-column type="index" width="50" label="序号"></el-table-column>
           <el-table-column v-for="(cColumn, cIndex) in column.tableColumns" :key="cIndex" :prop="cColumn.key"
             :label="cColumn.title" :width="cColumn.width || 100" show-overflow-tooltip>