Browse Source

1.保存时进行询价校验,有询价未成功的不能保存
2.列表查询排序

002390 2 years ago
parent
commit
818237ca8a

+ 1 - 0
src/api/business/purchase/purchase-order.js

@@ -11,6 +11,7 @@ const list = (data, page) => {
   });
 }
 
+
 // 采购订单详情
 const details = (id, params) => {
   return request({

+ 1 - 1
src/utils/init/index.js

@@ -33,4 +33,4 @@ export const initRules = (prop) => {
   return rules;
 };
 
-export const initPage = () => ({ pageNum: 1, pageSize: 10, total: 0,isAsc:"desc" });
+export const initPage = () => ({ pageNum: 1, pageSize: 10, total: 0, });

+ 48 - 8
src/views/purchase/purchase-order/add/column.js

@@ -777,14 +777,54 @@ export const TabColumns = [
         width: 120,
         require: true,
       },
-      { key: "stroageQty", title: "累计到货主数量", inputType: "Input", width: 120 },
-      { key: "stockQty", title: "累计入库主数量", inputType: "Input", width: 120 },
-      { key: "invoiceQty", title: "累计开票主数量", inputType: "Input", width: 120 },
-      { key: "rollbackQty", title: "累计退货主数量", inputType: "Input", width: 120 },
-      { key: "backStockQty", title: "累计退库主数量", inputType: "Input", width: 120 },
-      { key: "floatQty", title: "未到货数量", inputType: "Input", width: 120 },
-      { key: "createByName", title: "创建人名称", inputType: "Input", width: 120 },
-      { key: "updateByName", title: "更新人名称", inputType: "Input", width: 120 },
+      { 
+        key: "stroageQty", 
+        title: "累计到货主数量", 
+        inputType: "Input", 
+        width: 120 
+      },
+      { 
+        key: "stockQty", 
+        title: "累计入库主数量", 
+        inputType: "Input", 
+        width: 120 
+      },
+      { 
+        key: "invoiceQty", 
+        title: "累计开票主数量", 
+        inputType: "Input", 
+        width: 120 
+      },
+      { 
+        key: "rollbackQty", 
+        title: "累计退货主数量", 
+        inputType: "Input", 
+        width: 120 
+      },
+      { 
+        key: "backStockQty", 
+        title: "累计退库主数量", 
+        inputType: "Input", 
+        width: 120 
+      },
+      { 
+        key: "floatQty", 
+        title: "未到货数量", 
+        inputType: "Input", 
+        width: 120 
+      },
+      { 
+        key: "createByName", 
+        title: "创建人名称", 
+        inputType: "Input", 
+        width: 120 
+      },
+      { 
+        key: "updateByName", 
+        title: "更新人名称", 
+        inputType: "Input", 
+        width: 120 
+      },
     ]
   },
 ];

+ 34 - 19
src/views/purchase/purchase-order/add/index.vue

@@ -37,9 +37,7 @@ export default {
         puOrderItemList: [],
         puOrderExecuteList: [],
       },
-
       tabColumns: NewTabColumns,
-
       tabName: "puOrderItemList",
     };
   },
@@ -224,11 +222,8 @@ export default {
         puOrderExecuteList: [],
       };
     },
-    // 保存
-    async handleSava() {
-      // orderAddForm
-      console.log(this.params, "params");
-
+    // 判断保存条件
+    judgeSaveCondition(cb){
       this.$refs['orderAddForm'].validate(async (valid) => {
         if (valid) {
 
@@ -237,7 +232,29 @@ export default {
             this.$message.error('请填写订单行!');
             return false;
           }
-          try {
+
+          // puOrderItemList
+         let isPrice =  this.params.puOrderItemList.filter(item => !item.whetherCompleteInquiry);
+
+         if(isPrice.length){
+
+            this.$message.error('询价失败!');
+            return false
+
+         }
+         console.log(isPrice,'isPrice');
+          cb();
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    // 保存
+     handleSava() {
+      this.judgeSaveCondition(async()=>{
+        try {
+            this.loading = true;
             const { code, msg } = await orderApi.create(this.params);
             if (code === 200) {
               this.handleCancel();
@@ -245,13 +262,9 @@ export default {
           } catch (err) {
             //
           } finally {
-            // this.setVisible(false);
+            this.loading = false;
           }
-        } else {
-          console.log('error submit!!');
-          return false;
-        }
-      });
+      })
     },
     // 保存并新增
     async handleSubmit() {
@@ -284,7 +297,7 @@ export default {
       });
     },
     // 子表参照改变之后
-    handleReferChange(val, type, source) {
+    handleReferChange(val, source, type) {
       console.log(val, "val");
       console.log(source, "source");
       console.log(type, "type");
@@ -380,9 +393,11 @@ export default {
           <h3>新增</h3>
           <div style="text-align: right">
             <el-button size="mini" @click="handleCancel">取消</el-button>
-            <el-button size="mini" type="danger" @click="handleSava"
-              >保存</el-button
-            >
+            <el-button 
+              size="mini" 
+              type="danger"
+              @click="handleSava"
+            >保存</el-button>
             <!-- <el-button size="mini" type="info" @click="handleSubmit">
               保存并新增
             </el-button> -->
@@ -537,7 +552,7 @@ export default {
                   <el-form-item 
                     label-width="0" 
                     :prop="`${column.key}.${scope.$index}.${[cColumn.key]}`"
-                    :rules="{ required: cColumn.require, message: `${cColumn.title}不能为空`, trigger: 'change' }"
+                    :rules="{ required: cColumn.require || false, message: `${cColumn.title}不能为空`, trigger: 'change' }"
                   >
                     <el-tag v-if="cColumn.key === 'index'" >
                       {{ scope.$index + 1 }}

+ 28 - 10
src/views/purchase/purchase-order/edit/index.vue

@@ -159,16 +159,38 @@ export default {
         puOrderExecuteList: [],
       }
     },
-    // 保存
-    async handleSava() {
+    // 判断保存条件
+    judgeSaveCondition(cb){
       this.$refs['orderEditForm'].validate(async (valid) => {
         if (valid) {
+
           if(!this.params['puOrderItemList'].length || !this.params['puOrderExecuteList'].length){
 
             this.$message.error('请填写订单行!');
             return false;
           }
-          try {
+
+          let isPrice =  this.params.puOrderItemList.filter(item => !item.whetherCompleteInquiry);
+
+         if(isPrice.length){
+
+            this.$message.error('询价失败!');
+            return false
+
+         }
+         console.log(isPrice,'isPrice');
+          cb();
+
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    // 保存
+     handleSava() {
+      this.judgeSaveCondition(async()=>{
+        try {
             this.loading = true;
             const { code, msg } = await (this.handleIsRevise(this.params.status) ?
               orderApi.revision(this.params)
@@ -182,16 +204,12 @@ export default {
           } finally {
             this.loading = false;
           }
-        } else {
-          console.log('error submit!!');
-          return false;
-        }
-      });
+      })
     },
     beforeOpen() {
     },
     // 子表参照改变之后
-    handleReferChange(val,  type,source) {
+    handleReferChange(val, source, type) {
       console.log(val, 'val');
       console.log(source, 'source');
       console.log(type, 'type');
@@ -428,7 +446,7 @@ export default {
                   <el-form-item 
                     label-width="0" 
                     :prop="`${column.key}.${scope.$index}.${[cColumn.key]}`"
-                    :rules="{ required: cColumn.require, message: `${cColumn.title}不能为空`, trigger: 'change' }"
+                    :rules="{ required: cColumn.require || false, message: `${cColumn.title}不能为空`, trigger: 'change' }"
                   >
 
                   <span v-if="!cColumn.inputType">

+ 5 - 6
src/views/purchase/purchase-order/index.vue

@@ -50,14 +50,13 @@ export default {
     this.fetchList(this.params, this.page);
   },
   methods: {
-    async fetchList(params, page) {
+    async fetchList(data, params) {
       try {
         this.loading = true;
-        // const { pageNum, pageSize } = page;
-        console.log(
-          page,'page'
-        );
-        const { code, msg, rows, total } = await orderApi.list(params, page);
+        params['isAsc'] = 'desc';
+        params['orderByColumn'] = 'createTime';
+        
+        const { code, msg, rows, total } = await orderApi.list(data, params);
         if (code === 200) {
           this.page.total = total;
           this.tableData = rows;