cz hace 1 año
padre
commit
51952859ab

+ 26 - 20
src/components/testForm/index.vue

@@ -336,7 +336,7 @@
       </div>
 
       <!-- 按钮 -->
-      <div class="btn-box" v-if="btnConfigCopy.isNeed">
+      <div class="btn-box" v-if="formOption.btnConfig.isNeed">
         <van-button
           :plain="btnConfigCopy.plain ? btnConfigCopy.plain : false"
           :type="btnConfigCopy.itemType ? btnConfigCopy.itemType : 'primary'"
@@ -599,26 +599,32 @@ formDataInit();
 
 // 选择框  确定事件
 const onConfirmPicker = (option, item, index) => {
-  switch (item.itemType) {
-    case "onePicker": {
-      formData.value[item.prop + "Name"] =
-        option.selectedOptions[0][
-          item.fieldNames.text ? item.fieldNames.text : onePickerFieldNames.text
-        ];
-      formData.value[item.prop] =
-        option.selectedOptions[0][
-          item.fieldNames.value
-            ? item.fieldNames.value
-            : onePickerFieldNames.value
-        ];
-      formConfig.value[index].showPicker = false;
-    }
-    case "datePicker": {
-      formData.value[item.prop] = option.selectedValues.join(
-        item.split ? item.split : "-"
-      );
-      formConfig.value[index].showPicker = false;
+  if (option.selectedOptions[0]) {
+    switch (item.itemType) {
+      case "onePicker": {
+        formData.value[item.prop + "Name"] =
+          option.selectedOptions[0][
+            item.fieldNames.text
+              ? item.fieldNames.text
+              : onePickerFieldNames.text
+          ];
+        formData.value[item.prop] =
+          option.selectedOptions[0][
+            item.fieldNames.value
+              ? item.fieldNames.value
+              : onePickerFieldNames.value
+          ];
+        formConfig.value[index].showPicker = false;
+      }
+      case "datePicker": {
+        formData.value[item.prop] = option.selectedValues.join(
+          item.split ? item.split : "-"
+        );
+        formConfig.value[index].showPicker = false;
+      }
     }
+  } else {
+    formConfig.value[index].showPicker = false;
   }
 };
 const currentIndex = ref(-1);

+ 65 - 43
src/views/JXSK/salesContract/add.vue

@@ -28,13 +28,18 @@ const route = useRoute();
 const formDom = ref(null);
 const formData = reactive({
   data: {
-    list: [],
+    salesContractDetailsList: [],
   },
 });
 const rules = {
-  warehouseName: [{ required: true, message: "仓库名称不能为空" }],
-  productName: [{ required: true, message: "物品名称不能为空" }],
-  quantity: [{ required: true, message: "入库数量不能为空" }],
+  customerId: [{ required: true, message: "请选择客户名称" }],
+  deliveryDate: [{ required: true, message: "请选择交货期限" }],
+  payMethod: [{ required: true, message: "请选择付款方式" }],
+  freightPayer: [{ required: true, message: "请选择运费支付方" }],
+  productId: [{ required: true, message: "请选择产品名称" }],
+  isCustomized: [{ required: true, message: "请选择是否定制" }],
+  unitPrice: [{ required: true, message: "请输入单价" }],
+  quantity: [{ required: true, message: "请输入数量" }],
 };
 const formOption = reactive({
   readonly: false, //用于控制整个表单是否只读
@@ -42,9 +47,10 @@ const formOption = reactive({
   labelAlign: "top",
   scroll: true,
   labelWidth: "62pk",
+  hiddenSubmitBtn: false,
   btnConfig: {
     isNeed: true,
-    prop: "list",
+    prop: "salesContractDetailsList",
     plain: true,
     listTitle: "合同明细",
     listConfig: [
@@ -64,7 +70,7 @@ const formOption = reactive({
       {
         type: "picker",
         label: "是否定制",
-        prop: "productId",
+        prop: "isCustomized",
         itemType: "onePicker",
         showPicker: false,
         readonly: false,
@@ -79,7 +85,7 @@ const formOption = reactive({
           },
           {
             label: "否",
-            value: "2",
+            value: "0",
           },
         ],
       },
@@ -87,7 +93,7 @@ const formOption = reactive({
         type: "input",
         itemType: "number",
         label: "单价",
-        prop: "quantity",
+        prop: "unitPrice",
         clearable: true,
         changeFn: (index, val) => {
           changeAmount(index);
@@ -97,7 +103,7 @@ const formOption = reactive({
         type: "input",
         itemType: "number",
         label: "数量",
-        prop: "quantity1",
+        prop: "quantity",
         clearable: true,
         changeFn: (index, val) => {
           changeAmount(index);
@@ -107,19 +113,22 @@ const formOption = reactive({
         type: "input",
         itemType: "number",
         label: "金额小计",
-        prop: "quantity2",
+        prop: "total",
         placeholder: "根据单价、数量自动计算",
         readonly: true,
       },
     ],
     clickFn: () => {
-      if (formData.data.list && formData.data.list.length > 0) {
-        formData.data.list.push({
+      if (
+        formData.data.salesContractDetailsList &&
+        formData.data.salesContractDetailsList.length > 0
+      ) {
+        formData.data.salesContractDetailsList.push({
           productId: "",
           quantity: "",
         });
       } else {
-        formData.data.list = [
+        formData.data.salesContractDetailsList = [
           {
             productId: "",
             quantity: "",
@@ -133,7 +142,7 @@ const formConfig = reactive([
   {
     type: "picker",
     label: "客户名称",
-    prop: "warehouseId",
+    prop: "customerId",
     itemType: "onePicker",
     showPicker: false,
     fieldNames: {
@@ -145,7 +154,7 @@ const formConfig = reactive([
   {
     type: "picker",
     label: "交货期限",
-    prop: "date",
+    prop: "deliveryDate",
     itemType: "datePicker",
     showPicker: false,
     split: "-",
@@ -154,7 +163,7 @@ const formConfig = reactive([
   {
     type: "picker",
     label: "付款方式",
-    prop: "warehouseId",
+    prop: "payMethod",
     itemType: "onePicker",
     showPicker: false,
     fieldNames: {
@@ -165,8 +174,8 @@ const formConfig = reactive([
   },
   {
     type: "picker",
-    label: "费支付方",
-    prop: "warehouseId",
+    label: "费支付方",
+    prop: "freightPayer",
     itemType: "onePicker",
     showPicker: false,
     fieldNames: {
@@ -176,11 +185,11 @@ const formConfig = reactive([
     data: [
       {
         label: "甲方",
-        value: "1",
+        value: "0",
       },
       {
         label: "乙方",
-        value: "2",
+        value: "1",
       },
     ],
   },
@@ -188,7 +197,7 @@ const formConfig = reactive([
     type: "input",
     itemType: "textarea",
     label: "备注",
-    prop: "reamlke",
+    prop: "remark",
   },
   {
     type: "input",
@@ -229,41 +238,54 @@ const getDict = () => {
 };
 
 const getDetails = (id) => {
-  proxy.post("/stockJournal/detail", { id }).then((res) => {
+  proxy.post("/salesContract/detail", { id }).then((res) => {
     formData.data = res.data;
+    changeAmount();
   });
 };
 
 onMounted(() => {
   getDict();
-  if (route.query.id) getDetails(route.query.id);
+  if (route.query.id) {
+    getDetails(route.query.id);
+    formOption.readonly = true; //全部只读
+    formOption.hiddenSubmitBtn = true; //隐藏提交按钮
+    formOption.btnConfig.isNeed = false;
+  }
 });
 
 const onSubmit = () => {
-  if (!formData.data.list.length > 0) return showFailToast("请添加合同明细!");
-  proxy.post("/stock/add", formData.data).then(
-    () => {
-      showSuccessToast("操作成功");
-      setTimeout(() => {
-        onClickLeft();
-        // proxy.$router.push("/main/manualInbound");
-      }, 500);
-    },
-    (err) => {
-      return showFailToast(err.message);
-    }
-  );
+  if (formData.data.salesContractDetailsList.length > 0) {
+    proxy
+      .post("/flowProcess/initiate", {
+        flowKey: "jxst_sales_contract_flow",
+        data: formData.data,
+      })
+      .then(
+        () => {
+          showSuccessToast("操作成功");
+          setTimeout(() => {
+            onClickLeft();
+          }, 500);
+        },
+        (err) => {
+          return showFailToast(err.message);
+        }
+      );
+  } else {
+    return showFailToast("请添加合同明细!");
+  }
 };
 
 const changeAmount = (index) => {
   let total = 0;
-  for (let i = 0; i < formData.data.list.length; i++) {
-    const element = formData.data.list[i];
-    if (element.quantity && element.quantity1) {
-      element.quantity2 = parseFloat(
-        element.quantity * element.quantity1
-      ).toFixed(2);
-      total += Number(element.quantity2);
+  for (let i = 0; i < formData.data.salesContractDetailsList.length; i++) {
+    const element = formData.data.salesContractDetailsList[i];
+    if (element.unitPrice && element.quantity) {
+      element.total = parseFloat(element.unitPrice * element.quantity).toFixed(
+        2
+      );
+      total += Number(element.total);
     }
   }
   if (total) {

+ 14 - 48
src/views/JXSK/salesContract/index.vue

@@ -19,6 +19,7 @@
         v-model:loading="loading"
         :finished="finished"
         finished-text="没有更多了"
+        :offset="300"
         @load="onLoad"
         style="margin-bottom: 60px"
       >
@@ -35,7 +36,6 @@
 import { ref, getCurrentInstance } from "vue";
 import commonList from "@/components/common-list.vue";
 import { useRoute } from "vue-router";
-
 const loading = ref(false);
 const router = useRoute();
 const req = ref({
@@ -46,19 +46,18 @@ const req = ref({
 const finished = ref(false);
 const proxy = getCurrentInstance().proxy;
 const listData = ref([]);
-const classification = ref([]);
 const listConfig = ref([
   {
     label: "客户名称",
-    prop: "productClassifyName",
+    prop: "customerName",
   },
   {
     label: "合同金额",
-    prop: "code",
+    prop: "contractAmount",
   },
   {
     label: "签订时间",
-    prop: "name",
+    prop: "createTime",
   },
 ]);
 const onRefresh = () => {
@@ -67,7 +66,7 @@ const onRefresh = () => {
   getList("refresh");
 };
 const onLoad = () => {
-  getClassification();
+  getList();
 };
 const onClickLeft = () => proxy.$router.push("/main/working");
 const onClickRight = () => {
@@ -78,54 +77,21 @@ const onClickRight = () => {
     },
   });
 };
+
 const toDtl = (row) => {
-  // proxy.$router.push({
-  //   path: "productLibraryAdd",
-  //   query: {
-  //     id: row.id,
-  //     type: "edit",
-  //   },
-  // });
-};
-const treeToList = (arr) => {
-  let res = []; // 用于存储递归结果(扁平数据)
-  // 递归函数
-  let fn = (source) => {
-    source.forEach((el) => {
-      res.push(el);
-      el.children && el.children.length > 0 ? fn(el.children) : ""; // 子级递归
-    });
-  };
-  fn(arr);
-  return res;
-};
-const getClassification = () => {
-  if (classification.value && classification.value.length > 0) {
-    getList();
-  } else {
-    proxy
-      .post("/productClassify/tree", {
-        parentId: "",
-        name: "",
-        definition: "1",
-      })
-      .then((res) => {
-        classification.value = treeToList(res.data);
-        getList();
-      });
-  }
+  proxy.$router.push({
+    path: "jxskSalesContractAdd",
+    query: {
+      id: row.id,
+    },
+  });
 };
+
 const getList = (type) => {
   loading.value = true;
   proxy
-    .post("/productInfo/page", req.value)
+    .post("/salesContract/page", req.value)
     .then((res) => {
-      res.data.rows = res.data.rows.map((item) => {
-        return {
-          ...item,
-          productClassifyName: item.classifyNameGroup.join(" / "),
-        };
-      });
       listData.value =
         type === "refresh"
           ? res.data.rows