lph пре 1 година
родитељ
комит
cc86e17775
2 измењених фајлова са 162 додато и 45 уклоњено
  1. 25 1
      zkqy-ui/src/api/tablelist/commonTable.js
  2. 137 44
      zkqy-ui/src/views/orderMange/index.vue

+ 25 - 1
zkqy-ui/src/api/tablelist/commonTable.js

@@ -379,4 +379,28 @@ export function queryMaterielList(data) {
     method: 'get',
     //baseURL: process.env.VUE_APP_BASE_API1
   })
-}
+}
+
+// 订单管理  新的获取产品数据
+
+export function getSaleOrderProductionListDistinct(data) {
+  return request({
+    url: '/system/production/getSaleOrderProductionListDistinct',
+    method: 'get',
+    //baseURL: process.env.VUE_APP_BASE_API1
+  })
+}
+
+
+// 订单管理  获取规格数据
+
+export function getProductSpecificationsByProductName(data) {
+  return request({
+    url: '/system/production/getProductSpecificationsByProductName',
+    method: 'get',
+    //baseURL: process.env.VUE_APP_BASE_API1
+    params: data
+  })
+}
+
+// d

+ 137 - 44
zkqy-ui/src/views/orderMange/index.vue

@@ -296,7 +296,7 @@
                 <el-input size="small" v-model="formData.lotNumber"></el-input>
               </el-form-item>
             </el-col> -->
-            <el-col :span="12">
+            <!-- <el-col :span="12">
               <el-form-item prop="saleDate" label="日期:">
                 <el-date-picker
                   size="small"
@@ -308,7 +308,7 @@
                 >
                 </el-date-picker>
               </el-form-item>
-            </el-col>
+            </el-col> -->
             <el-col :span="12">
               <el-form-item prop="saleCustomNo" label="客户名称:">
                 <el-select
@@ -389,7 +389,7 @@
               sum-text="小计"
               style="width: 100%"
             >
-              <el-table-column prop="productNo" label="品名" width="180">
+              <el-table-column prop="productName" label="品名" width="180">
                 <template slot-scope="scope">
                   <!-- <el-input
                 v-model="scope.row.productName"
@@ -397,39 +397,65 @@
                 clearable
               ></el-input> -->
                   <el-form-item
-                    :prop="'productNo-' + scope.$index"
-                    :name="'productNo-' + scope.$index"
+                    :prop="'productName-' + scope.$index"
+                    :name="'productName-' + scope.$index"
                     style="margin: 0px; padding: 0px"
                   >
+                    <!-- @change="
+                        handleProductChange(scope.row.productNo, scope.row)
+                        :filter-method="(val) => mySelectFilter(val, scope.row)"
+                      " -->
                     <el-select
-                      v-model="scope.row.productNo"
+                      v-model="scope.row.productName"
                       placeholder=""
-                      :filter-method="(val) => mySelectFilter(val, scope.row)"
-                      clearable
                       filterable
                       @change="
-                        handleProductChange(scope.row.productNo, scope.row)
+                        newProductChange(scope.row.productName, scope.row)
                       "
-                      @blur="handleProductBlur(scope.row.productNo, scope.row)"
                     >
                       <el-option
                         v-for="item in productionOptions"
                         :key="item.productNo"
                         :label="item.productName"
-                        :value="item.productNo"
+                        :value="item.productName"
                       >
                         <span class="discribe" style="float: left">{{
                           item.productName
                         }}</span>
-                        <span
+                        <!-- <span
                           style="float: right; color: #8492a6; font-size: 13px"
                           >{{ item.productSpecifications }}</span
-                        >
+                        > -->
                       </el-option>
                     </el-select>
                   </el-form-item>
                 </template>
               </el-table-column>
+              <el-table-column prop="productSpecifications" label="规格">
+                <template slot-scope="scope">
+                  <el-select
+                    v-model="scope.row.productSpecifications"
+                    @change="handleSpecificationsChange(scope.row)"
+                    placeholder=""
+                    filterable
+                  >
+                    <el-option
+                      v-for="item in scope.row.specificationsList"
+                      :key="item.productSpecifications"
+                      :label="item.productSpecifications"
+                      :value="item.productSpecifications"
+                    >
+                      <span class="discribe" style="float: left">{{
+                        item.productSpecifications
+                      }}</span>
+                      <span
+                        style="float: right; color: #8492a6; font-size: 13px"
+                        >{{ item.productType }}</span
+                      >
+                    </el-option>
+                  </el-select>
+                </template>
+              </el-table-column>
               <el-table-column prop="productType" label="类型">
               </el-table-column>
               <el-table-column prop="productNumber" label="数量/kg">
@@ -796,6 +822,8 @@ import {
   updateProductInvoice,
   saleOrderList,
   queryMaterielList,
+  getSaleOrderProductionListDistinct,
+  getProductSpecificationsByProductName,
 } from "@/api/tablelist/commonTable";
 import { listData } from "@/api/system/tenant/data";
 import { getToken } from "@/utils/auth";
@@ -907,13 +935,13 @@ export default {
         // },
       ],
       rules: {
-        deliveryDate: [
-          {
-            required: true,
-            message: "请选择交货日期",
-            trigger: "change",
-          },
-        ],
+        // deliveryDate: [
+        //   {
+        //     required: true,
+        //     message: "请选择交货日期",
+        //     trigger: "change",
+        //   },
+        // ],
         salePayType: [
           {
             required: true,
@@ -953,20 +981,20 @@ export default {
             trigger: "change",
           },
         ],
-        saleOrderEstimatedTime: [
-          {
-            required: true,
-            message: "请选择预计下单时间",
-            trigger: "change",
-          },
-        ],
-        saleLeadTime: [
-          {
-            required: true,
-            message: "请输入交货天数",
-            trigger: "blur",
-          },
-        ],
+        // saleOrderEstimatedTime: [
+        //   {
+        //     required: true,
+        //     message: "请选择预计下单时间",
+        //     trigger: "change",
+        //   },
+        // ],
+        // saleLeadTime: [
+        //   {
+        //     required: true,
+        //     message: "请输入交货天数",
+        //     trigger: "blur",
+        //   },
+        // ],
         earnestMoney: [
           {
             validator: this.validateEarnestMoney,
@@ -1112,6 +1140,59 @@ export default {
     }),
   },
   methods: {
+    // 规格变化回调
+    handleSpecificationsChange(row) {
+      let { productSpecifications, specificationsList } = row;
+      if (productSpecifications) {
+        let targetItem = specificationsList.find(
+          (item) => item.productSpecifications == productSpecifications
+        );
+        console.log(targetItem);
+        row.productNo = targetItem?.productNo;
+        row.productType = targetItem?.productType;
+      } else {
+        row.productNo = "";
+        row.productType = "";
+      }
+    },
+    // 新的产品改变回调
+    async newProductChange(productName, row) {
+      // 发请求获取对应的规格数据
+      if (!productName) {
+        row.specificationsList = [];
+        (row.productNo = ""), (row.productType = "");
+        row.productSpecifications = "";
+        return;
+      }
+      // let targetItem = this.productionOptions.find(
+      //   (item) => item.productNo == productNo
+      // );
+      // row.productName = targetItem?.productName;
+      // row.productType = targetItem?.productType;
+      // 获取规格数据
+      let res = await getProductSpecificationsByProductName({
+        productName: productName,
+      });
+      if (res.code == 200) {
+        row.specificationsList = res.data;
+        console.log(row.specificationsList);
+        let defaultItem = row.specificationsList.find(
+          (item) => item.isDefaultSpecifications
+        );
+        if (defaultItem) {
+          row.productSpecifications = defaultItem.productSpecifications;
+          row.productNo = defaultItem.productNo;
+          row.productType = defaultItem.productType;
+        } else {
+          row.productSpecifications =
+            row.specificationsList[0]?.productSpecifications || "";
+          row.productNo = row.specificationsList[0]?.productNo || "";
+          row.productType = row.specificationsList[0]?.productType || "";
+        }
+      } else {
+        row.specificationsList = [];
+      }
+    },
     // 自定义筛选方法
     mySelectFilter(value, row) {
       console.log(value);
@@ -1186,14 +1267,22 @@ export default {
     orderTypeChange(type) {
       this.getList(false, type);
     },
+    // 生成合同号
+    getSaleNo() {
+      let timeStr = moment().format("YYYYMMDD");
+      for (var i = 0; i < 5; i++) {
+        timeStr += parseInt(Math.random() * 10);
+      }
+      return timeStr;
+    },
     // 重置审计表单数据
     resetFormData() {
       Object.assign(this.formData, {
         //订单表数据
-        saleNo: "", //合同号
+        saleNo: this.getSaleNo(), //合同号
         saleCustomNo: "", //客户编号
-        saleDate: "", //销售单日期
-        saleOrderEstimatedTime: "", //预计下单时间
+        saleDate: moment(new Date()).format("YYYY-MM-DD"), //销售单日期
+        saleOrderEstimatedTime: moment(new Date()).format("YYYY-MM-DD"), //预计下单时间
         saleLeadTime: "", //交货周期
         deliveryDate: "",
         saleAmounts: "", //合计金额 小写
@@ -1246,10 +1335,11 @@ export default {
         const values = data.map((item) => Number(item[column.property]));
         if (
           index === 1 ||
-          index === 5 ||
+          index === 2 ||
           index === 6 ||
           index === 7 ||
-          index === 8
+          index === 8 ||
+          index === 9
         ) {
           sums[index] = "";
         } else if (!values.every((value) => isNaN(value))) {
@@ -1294,6 +1384,7 @@ export default {
         colourNumberLabel: "",
         colourNumber: "", //色号
         remark: "", //备注
+        specificationsList: [],
       });
       // 添加校验规则
       this.initTableValidate();
@@ -1412,13 +1503,15 @@ export default {
         } else {
           throw Error("获取下拉框数据失败");
         }
-        let proRes = await getSaleOrderProductionList();
+        let proRes = await getSaleOrderProductionListDistinct();
+        console.log("proRes", proRes);
         if (proRes.code == 200) {
           console.log(proRes.data);
           // let { production, customer } = proRes.data.resultMap;
-          this.allProductionOptions = proRes.data || [];
-          this.productionOptions =
-            this.allProductionOptions.slice(0, 500) || [];
+          // this.allProductionOptions = proRes.data || [];
+          // this.productionOptions =
+          //   this.allProductionOptions.slice(0, 500) || [];
+          this.productionOptions = proRes.data;
         } else {
           throw Error("获取下拉框数据失败");
         }
@@ -3102,7 +3195,7 @@ export default {
           let productData = this.allProductionOptions.find(
             (pro) => pro.productNo == item.productNo
           );
-          console.log("item", item);
+          console.log(item.productNo, productData, this.allProductionOptions);
           item.sliceTypeLabel =
             this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
               ?.materielName || "";