浏览代码

采购订单维护-整单退回、行退回接口结构修改,整单退回支持批量修改

002390 1 年之前
父节点
当前提交
454e05e435
共有 2 个文件被更改,包括 124 次插入4 次删除
  1. 17 4
      src/views/purchase/purchase-order/index.vue
  2. 107 0
      src/views/purchase/purchase-order/tui-hui/index.vue

+ 17 - 4
src/views/purchase/purchase-order/index.vue

@@ -38,6 +38,7 @@ export default {
     HdkButton: () => import("./close/itemOpen.vue"),
     CounterApprove: () => import("./fs/index.vue"),
     QueryScheme: () => import("@/components/query-scheme/index.vue"),
+    thButton: () => import("./tui-hui/index.vue"),
   },
   data() {
     const initTabColumns = () => TabColumns;
@@ -722,12 +723,17 @@ export default {
           style="margin-left: 10px"
           :key="checkedList.length + 1"
         >
-          <el-button
+          <!-- <el-button
             :size="size"
             @click="handleAllReturn"
             :disabled="judgeIsAllReturn()"
             >整单退回</el-button
-          >
+          > -->
+          <th-button
+            :size="size"
+            :main-data="checkedList"
+            @success="handleRefreshList"
+          ></th-button>
           <zdgb-button
             :select-data="checkedList"
             :size="size"
@@ -847,12 +853,19 @@ export default {
 
     <div style="position: relative" v-loading="tabLoading">
       <el-row style="position: absolute; top: 5px; right: 20px; z-index: 10">
-        <el-button
+        <th-button
+          :size="size"
+          type="line"
+          :main-data="[...primaryResource]"
+          :subtabulation="checkedTabList"
+          @success="handleRefreshList"
+        ></th-button>
+        <!-- <el-button
           :size="size"
           @click="handleLineReturn"
           :disabled="judgeIsLineReturn()"
           >行退回</el-button
-        >
+        > -->
         <hgb-button
           :select-data="checkedTabList"
           :size="size"

+ 107 - 0
src/views/purchase/purchase-order/tui-hui/index.vue

@@ -0,0 +1,107 @@
+<script>
+import orderApi from "@/api/business/purchase/purchase-order";
+export default {
+  name: "TuiHui",
+  props: {
+    // 主表
+    mainData: {
+      type: Array,
+      require: true,
+    },
+    // 子表
+    subtabulation: {
+      type: Array,
+      default: () => [],
+    },
+    // 退回类型 all-整单退回;line-行退回
+    type: {
+      type: String,
+      default: "all",
+    },
+  },
+  data() {
+    return {};
+  },
+  computed: {
+    title: {
+      get() {
+        let { type } = this.$props;
+        if (type === "line") return "行退回";
+        return "整单退回";
+      },
+      set() {},
+    },
+    disabled: {
+      get() {
+        let { mainData, subtabulation, type } = this.$props;
+        if (type === "line") {
+          // 行退回
+          if (subtabulation.length > 0) {
+            return this.judgeNot(mainData[0]);
+          }
+          return true;
+        }
+        // 整单退回
+        if (mainData.length > 0) {
+          let notList = mainData.filter((item) => this.judgeNot(item));
+          return notList.length > 0;
+        }
+        return true;
+      },
+      set() {},
+    },
+  },
+  methods: {
+    onClick() {
+      this.$prompt("请输入退回原因", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        inputPattern: /\s*\S+?/,
+        inputErrorMessage: "退回原因不能为空",
+      })
+        .then(async ({ value }) => {
+          try {
+            this.$modal.loading("处理中......");
+            let { mainData, subtabulation } = this.$props;
+
+            let data = mainData.map((item) => ({
+              ...item,
+              documentIds: subtabulation.map((sub) => Number(sub.id)),
+              baskCause: value,
+            }));
+
+            let { code, msg } = await orderApi.documentsReturn(data);
+
+            if (code === 200) {
+              this.$emit("success");
+              this.$notify.success({
+                message: msg,
+              });
+            }
+          } catch (error) {
+          } finally {
+            this.$modal.closeLoading();
+          }
+        })
+        .catch(() => {});
+    },
+    judgeNot(source) {
+      // status: 0=自由态,1=审批中,2=已审核,3=已驳回 4=提交中 9=已回退
+      // source: 1=自动协议直采,2=协议直采,3=手工
+      // isEnd:整单关闭标识
+      return !(
+        source.source != 3 &&
+        source.isEnd === "N" &&
+        (source.status == 0 || source.status == 3 || source.status == "9")
+      );
+    },
+  },
+  created() {},
+};
+</script>
+
+<template>
+  <el-button :size="$attrs.size" :disabled="disabled" @click="onClick">{{
+    title
+  }}</el-button>
+</template>