瀏覽代碼

物料申请单-增加批量删除功能

002390 1 年之前
父節點
當前提交
0832e8562b

+ 8 - 0
src/api/requisition/basic.js

@@ -201,4 +201,12 @@ export function getDiCode(dicode) {
     url: `/system/apply/material/getDiCode/${dicode}`,
     method: 'get',
   })
+}
+
+export function deleteApplies(data) {
+  return request({
+    url: `/system/apply/material/deleteApplies`,
+    method: "POST",
+    data: data,
+  })
 }

+ 67 - 0
src/views/material/requisition/fun-button/pi-liang-shan-chu/index.vue

@@ -0,0 +1,67 @@
+<script>
+import { deleteApplies } from "@/api/requisition/basic";
+export default {
+  name: "PiLiangShanChu",
+  props: {
+    selectData: {
+      type: Array,
+      default: () => [],
+    },
+  },
+  data() {
+    return {
+      title: "批量删除",
+    };
+  },
+  computed: {
+    disabled: {
+      get() {
+        let { selectData } = this.$props;
+        // 单据状态:0-自由态;3-已驳回;9-已回退
+        let delStatus = ["0", "3", "9"];
+        if (selectData.length > 0) {
+          let del = selectData.filter(
+            (item) => delStatus.findIndex((d) => d == item.status) === -1
+          );
+          return del.length > 0;
+        }
+        return true;
+      },
+      set() {},
+    },
+  },
+  methods: {
+    async onClick() {
+      this.$confirm("确认批量删除?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          try {
+            this.$modal.loading("处理中...");
+            let ids = this.$props.selectData.map((item) => item.id);
+            console.log(ids, "ids");
+            let { code, msg } = await deleteApplies({ ids });
+            if (code == 200) {
+              this.$notify.success({ message: msg });
+              this.$emit("success");
+            }
+          } catch (error) {
+          } finally {
+            this.$modal.closeLoading();
+          }
+        })
+        .catch(() => {
+          // this.$emit("success");
+        });
+    },
+  },
+  created() {},
+};
+</script>
+<template>
+  <el-button @click="onClick" :disabled="disabled" :size="$attrs.size">
+    {{ title }}
+  </el-button>
+</template>

+ 6 - 0
src/views/material/requisition/index.vue

@@ -21,6 +21,7 @@ export default {
     ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
     ElSuperSearch: () => import("@/components/super-search/index.vue"),
     BatchImport: () => import("@/components/BatchImport/index.vue"),
+    plscButton: () => import("./fun-button/pi-liang-shan-chu/index.vue"),
   },
   data() {
     const { SearchColumns, TableColumns } = useColumns();
@@ -279,6 +280,11 @@ export default {
           @temDownload="handleTemDownload"
           :fileSize="2"
         ></BatchImport>
+        <plsc-button
+          :size="size"
+          :select-data="selectData"
+          @success="useQuery(params, page)"
+        ></plsc-button>
       </el-col>
     </el-row>