Просмотр исходного кода

增加批量添加至本站、全选并添加至本站功能

NULL1222 2 недель назад
Родитель
Сommit
d83b6320eb

+ 20 - 0
src/bgj/headquartersServiceMaterial/index.vue

@@ -41,6 +41,22 @@
                     @examineSuccess="onSuccess"
                 ></counterExamine>
                 <!-- v-if="tool.checkAuth($route.name, 'reverseReview')" -->
+                <batchAddToSite
+                    class="inline-16"
+                    :rowData="rowData"
+                    :disabled="rowData.length === 0"
+                    @addSuccess="onSuccess"
+                ></batchAddToSite>
+                <!-- v-if="tool.checkAuth($route.name, 'batchAddToSite')" -->
+                <selectAllAddToSite
+                    v-if="$refs.list"
+                    class="inline-16"
+                    :basicLayout="$refs.list"
+                    :where="$refs.list.param.content.where"
+                    :queryApiId="2026051508534106"
+                    @addSuccess="onSuccess"
+                ></selectAllAddToSite>
+                <!-- v-if="tool.checkAuth($route.name, 'selectAllAddToSite')" -->
                 <importImage
                     class="inline-16"
                     ref="importImage"
@@ -261,6 +277,8 @@ import toExamine from "./modules/toExamine";
 import counterExamine from "./modules/counterExamine";
 import importImage from "./modules/importImage";
 import previewImage from "@/components/previewImage/index";
+import batchAddToSite from "./modules/batchAddToSite";
+import selectAllAddToSite from "./modules/selectAllAddToSite";
 export default {
     data() {
         return {
@@ -278,6 +296,8 @@ export default {
         counterExamine,
         importImage,
         previewImage,
+        batchAddToSite,
+        selectAllAddToSite,
     },
     methods: {
         async fieldData() {

+ 96 - 0
src/bgj/headquartersServiceMaterial/modules/batchAddToSite.vue

@@ -0,0 +1,96 @@
+<template>
+    <div>
+        <el-button
+            type="primary"
+            :size="btn_size ? btn_size : 'small'"
+            @click="onshow"
+            :disabled="disabled"
+            >{{ btnName ? $t(btnName) : $t(`批量添加至本站`) }}</el-button
+        >
+    </div>
+</template>
+
+<script>
+export default {
+    props: ["rowData", "disabled", "btnName", "btn_size"],
+    name: "counterExamine",
+    data() {
+        return {
+            flag: false,
+        };
+    },
+    methods: {
+        onshow() {
+            // 统一处理 单个对象 / 数组
+            const dataList = this.btnName ? [this.rowData] : this.rowData;
+            this.flag = false;
+            // 统一用 dataList 遍历
+            dataList.forEach((e) => {
+                if (e.shelf === 0) {
+                    this.flag = true;
+                }
+            });
+            if (this.flag) {
+                this.$alert(
+                    this.$t("所选数据中有数据还未上架,请检查后再进行操作"),
+                    this.$t("提示"),
+                    {
+                        confirmButtonText: this.$t("确定"),
+                        callback: (action) => {
+                            this.$message({
+                                type: "info",
+                                message: this.$t(`请检查所选数据`),
+                            });
+                        },
+                    }
+                );
+            } else {
+                this.onCounter();
+            }
+        },
+        onCounter() {
+            //根据是否传入 btnName 切换 单数/批量 文案
+            const isSingle = !!this.btnName;
+            const confirmText = isSingle
+                ? this.$t("是否确定将此物料添加至本站")
+                : this.$t("是否确定将所选物料添加至本站");
+            const cancelText = isSingle
+                ? this.$t("已取消添加至本站")
+                : this.$t("已取消批量添加至本站");
+            // 统一兼容数据格式
+            const dataList = this.btnName ? [this.rowData] : this.rowData;
+            this.$confirm(confirmText + "?", this.$t("提示"), {
+                confirmButtonText: this.$t("确定"),
+                cancelButtonText: this.$t("取消"),
+                type: "warning",
+            })
+                .then(async () => {
+                    let row = [];
+                    dataList.forEach(function (item, index) {
+                        row[index] = item.sc_itemid;
+                    });
+                    // 把数组转成 逗号分隔的字符串 "1,2,3"
+                    const sc_itemids_str = row.join(",");
+                    const res = await this.$api.requested({
+                        id: 2026051511000001,
+                        content: {
+                            sc_itemids: sc_itemids_str,
+                        },
+                    });
+                    this.tool.showMessage(res, () => {
+                        this.$emit("addSuccess");
+                    });
+                })
+                .catch(async () => {
+                    this.$message({
+                        type: "info",
+                        message: cancelText,
+                    });
+                });
+        },
+    },
+};
+</script>
+
+<style scoped>
+</style>

+ 12 - 0
src/bgj/headquartersServiceMaterial/modules/detail.vue

@@ -17,6 +17,7 @@
             <div slot="tags"></div>
             <template slot="customOperation">
                 <Edit
+                    v-if="mainData.status === 1"
                     class="inline-16"
                     title_btn="编辑"
                     title_drawer="编辑服务物料"
@@ -24,6 +25,15 @@
                     :data="mainData"
                     @onSuccess="queryMainData"
                 ></Edit>
+                <batchAddToSite
+                    v-if="mainData.shelf === 1"
+                    class="inline-16"
+                    :rowData="mainData"
+                    btnName="添加至本站"
+                    btn_size="mini"
+                    @addSuccess="onSuccess"
+                ></batchAddToSite>
+                <!-- v-if="tool.checkAuth($route.name, 'addToSite')" -->
                 <batchUp
                     v-if="mainData.status === 2 && mainData.shelf === 0"
                     class="inline-16"
@@ -114,6 +124,7 @@ import batchUp from "./batchUp";
 import batchDown from "./batchDown";
 import toExamine from "./toExamine";
 import counterExamine from "./counterExamine";
+import batchAddToSite from "./batchAddToSite";
 export default {
     name: "detail",
     data() {
@@ -132,6 +143,7 @@ export default {
         batchDown,
         toExamine,
         counterExamine,
+        batchAddToSite,
     },
     methods: {
         async queryMainData() {

+ 80 - 0
src/bgj/headquartersServiceMaterial/modules/selectAllAddToSite.vue

@@ -0,0 +1,80 @@
+<template>
+    <div>
+        <el-button type="primary" size="small" @click="onshow">{{
+            $t(`全选并添加至本站`)
+        }}</el-button>
+    </div>
+</template>
+
+<script>
+export default {
+    name: "selectAllAddToSite",
+    props: ["where", "queryApiId", "basicLayout"],
+    methods: {
+        onshow() {
+            this.onSelectAllAddToSite();
+        },
+        async onSelectAllAddToSite() {
+            const hasUnreviewed = this.basicLayout.list.some(
+                (row) => row.shelf === 0
+            );
+            if (hasUnreviewed) {
+                this.$alert(
+                    this.$t("所选数据中有数据还未上架,请检查后再进行操作"),
+                    this.$t("提示"),
+                    {
+                        confirmButtonText: this.$t("确定"),
+                        callback: () => {
+                            this.$message({
+                                type: "info",
+                                message: this.$t("请检查所选数据"),
+                            });
+                        },
+                    }
+                );
+                return;
+            }
+            const elTable = this.basicLayout.$refs.table.$refs.tables;
+            this.basicLayout.list.forEach((row) => {
+                elTable.toggleRowSelection(row, true);
+            });
+            this.$confirm(
+                this.$t("是否确定将全部物料添加至本站") + "?",
+                this.$t("提示"),
+                {
+                    confirmButtonText: this.$t("确定"),
+                    cancelButtonText: this.$t("取消"),
+                    type: "warning",
+                }
+            )
+                .then(async () => {
+                    const queryRes = await this.$api.requested({
+                        id: this.queryApiId,
+                        content: {
+                            pageNumber: 1,
+                            pageSize: 99999,
+                            where: this.where,
+                        },
+                    });
+                    const ids = queryRes.data.map((item) => item.sc_itemid);
+                    const res = await this.$api.requested({
+                        id: 2026051511000002,
+                        content: {
+                            sc_itemids: ids.join(","),
+                        },
+                    });
+                    this.tool.showMessage(res, () => {
+                        this.$emit("addSuccess");
+                    });
+                })
+                .catch(async () => {
+                    elTable.clearSelection();
+                    this.$message({
+                        type: "info",
+                        message: this.$t("已取消全选并添加至本站"),
+                    });
+                });
+        },
+    },
+};
+</script>