Forráskód Böngészése

服务物料优化

NULL1222 1 hete
szülő
commit
f09893598b

+ 27 - 17
src/Form/headquartersServiceMaterial/add.vue

@@ -238,7 +238,11 @@
                             </div>
 
                             <small
-                                style="display: block; margin-top: 20px"
+                                style="
+                                    display: block;
+                                    margin-top: 20px;
+                                    margin-bottom: 80px;
+                                "
                                 class="info"
                                 >{{ $t(`注:建议上传图片大小`) }}1024x1024px,{{
                                     $t("大小不超过")
@@ -293,11 +297,11 @@ export default {
             currentData: {},
             form: {
                 sc_itemid: 0,
-                code: "ITEM001", //物料编号
-                name: "测试物料", //物料名称
-                erpitemno: "品号", // 品号
-                erpitemname: "品名", // 品名
-                marketprice: "32", // 牌价
+                code: "", //物料编号
+                name: "", //物料名称
+                erpitemno: "", // 品号
+                erpitemname: "", // 品名
+                marketprice: "", // 牌价
                 isauxunit: 0, //是否启用辅助单位
                 unit: "", //主单位
                 auxunit: "", // 辅助单位
@@ -455,17 +459,23 @@ export default {
                     id: 2026051508523606,
                     content: this.form,
                 });
-                this.tool.showMessage(res, () => {
+                if (res.code === 0) {
                     this.loading = false;
-                    this.bindData = {
-                        ownertable: "sc_item",
-                        ownerid: res.data.sc_itemid,
-                        usetype: "default",
-                    };
-                    this.$refs["upload"].toUpload();
-                    this.$emit("onSuccess");
-                    this.dialogFormVisible = false;
-                    this.$refs["form"].resetFields();
+                    this.$message.error(res.msg || "新建失败");
+                    return;
+                }
+                this.loading = false;
+                this.$message.success("新建成功");
+                this.bindData = {
+                    ownertable: "sc_item",
+                    ownerid: res.data.sc_itemid,
+                    usetype: "default",
+                };
+                this.$refs["upload"].toUpload();
+                this.$emit("onSuccess");
+                this.dialogFormVisible = false;
+                this.$refs["form"].resetFields();
+                setTimeout(() => {
                     this.$router.push({
                         path: "/headquartersServiceMaterialDetail",
                         query: {
@@ -474,7 +484,7 @@ export default {
                         },
                     });
                     this.$store.dispatch("changeDetailDrawer", true);
-                });
+                }, 500);
             });
         },
         onCancel() {

+ 28 - 17
src/Form/ourServiceMaterial/add.vue

@@ -232,7 +232,11 @@
                             </div>
 
                             <small
-                                style="display: block; margin-top: 20px"
+                                style="
+                                    display: block;
+                                    margin-top: 20px;
+                                    margin-bottom: 80px;
+                                "
                                 class="info"
                                 >{{ $t(`注:建议上传图片大小`) }}1024x1024px,{{
                                     $t("大小不超过")
@@ -287,11 +291,11 @@ export default {
             currentData: {},
             form: {
                 sc_item_localid: 0,
-                code: "ITEM001", //物料编号
-                name: "测试物料本站", //物料名称
-                erpitemno: "品号", // 品号
-                erpitemname: "品名", // 品名
-                marketprice: "32", // 牌价
+                code: "", //物料编号
+                name: "", //物料名称
+                erpitemno: "", // 品号
+                erpitemname: "", // 品名
+                marketprice: "", // 牌价
                 isauxunit: 0, //是否启用辅助单位
                 unit: "", //主单位
                 auxunit: "", // 辅助单位
@@ -304,6 +308,7 @@ export default {
                 remarks: "", // 备注
                 pic: "", // 图片
                 shelf: 0, // 是否上架
+                isenable: 1, // 是否启用
                 unitid: "", //主单位id
             },
             rules: {
@@ -446,17 +451,23 @@ export default {
                     id: 2026051510000001,
                     content: this.form,
                 });
-                this.tool.showMessage(res, () => {
+                if (res.code === 0) {
                     this.loading = false;
-                    this.bindData = {
-                        ownertable: "sc_item_local",
-                        ownerid: res.data.sc_item_localid,
-                        usetype: "default",
-                    };
-                    this.$refs["upload"].toUpload();
-                    this.$emit("onSuccess");
-                    this.dialogFormVisible = false;
-                    this.$refs["form"].resetFields();
+                    this.$message.error(res.msg || "新建失败");
+                    return;
+                }
+                this.loading = false;
+                this.$message.success("新建成功");
+                this.bindData = {
+                    ownertable: "sc_item_local",
+                    ownerid: res.data.sc_item_localid,
+                    usetype: "default",
+                };
+                this.$refs["upload"].toUpload();
+                this.$emit("onSuccess");
+                this.dialogFormVisible = false;
+                this.$refs["form"].resetFields();
+                setTimeout(() => {
                     this.$router.push({
                         path: "/ourServiceMaterialDetail",
                         query: {
@@ -465,7 +476,7 @@ export default {
                         },
                     });
                     this.$store.dispatch("changeDetailDrawer", true);
-                });
+                }, 500);
             });
         },
         onCancel() {

+ 11 - 1
src/bgj/headquartersServiceMaterial/index.vue

@@ -252,7 +252,9 @@
                     <previewImage
                         v-if="scope.data.column.data.attinfos[0]"
                         class="image"
-                        :image="scope.data.column.data.attinfos[0]"
+                        :image="
+                            getThumbImage(scope.data.column.data.attinfos[0])
+                        "
                         :list="scope.data.column.data.attinfos"
                         :deletebtn="false"
                     ></previewImage>
@@ -429,6 +431,14 @@ export default {
             this.$refs.list.param.content.where = this.selectParam;
             this.$refs.list.listData();
         },
+        // 优先获取 subfiles 里的缩略图
+        getThumbImage(item) {
+            // 1. 先找 subfiles 里的 thumbnail 图
+            const thumb = item.subfiles?.find((f) => f.type === "thumbnail");
+            if (thumb) return thumb;
+            // 2. 找不到就返回原图片
+            return item;
+        },
     },
     mounted() {
         this.fieldData();

+ 4 - 1
src/bgj/headquartersServiceMaterial/modules/batchAddToSite.vue

@@ -5,6 +5,7 @@
             :size="btn_size ? btn_size : 'small'"
             @click="onshow"
             :disabled="disabled"
+            :loading="loading"
             >{{ btnName ? $t(btnName) : $t(`批量添加至本站`) }}</el-button
         >
     </div>
@@ -17,6 +18,7 @@ export default {
     data() {
         return {
             flag: false,
+            loading: false,
         };
     },
     methods: {
@@ -65,11 +67,11 @@ export default {
                 type: "warning",
             })
                 .then(async () => {
+                    this.loading = true;
                     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,
@@ -77,6 +79,7 @@ export default {
                             sc_itemids: sc_itemids_str,
                         },
                     });
+                    this.loading = false;
                     this.tool.showMessage(res, () => {
                         this.$emit("addSuccess");
                     });

+ 8 - 1
src/bgj/headquartersServiceMaterial/modules/batchDown.vue

@@ -5,6 +5,7 @@
             :size="btn_size ? btn_size : 'small'"
             @click="onshow"
             :disabled="disabled"
+            :loading="loading"
         >
             {{ btnName ? $t(btnName) : $t(`批量下架`) }}
         </el-button>
@@ -15,6 +16,11 @@
 export default {
     name: "batchDown",
     props: ["rowData", "disabled", "btnName", "btn_size"],
+    data() {
+        return {
+            loading: false,
+        };
+    },
     methods: {
         onshow() {
             this.onBatchDown();
@@ -36,11 +42,11 @@ export default {
                 type: "warning",
             })
                 .then(async () => {
+                    this.loading = true;
                     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: 2026051518000002,
@@ -48,6 +54,7 @@ export default {
                             sc_itemids: sc_itemids_str,
                         },
                     });
+                    this.loading = false;
                     this.tool.showMessage(res, () => {
                         this.$emit("batchUpSuccess");
                     });

+ 8 - 1
src/bgj/headquartersServiceMaterial/modules/batchUp.vue

@@ -5,6 +5,7 @@
             :size="btn_size ? btn_size : 'small'"
             @click="onshow"
             :disabled="disabled"
+            :loading="loading"
             >{{ btnName ? $t(btnName) : $t(`批量上架`) }}</el-button
         >
     </div>
@@ -14,6 +15,11 @@
 export default {
     name: "batchUp",
     props: ["rowData", "disabled", "btnName", "btn_size"],
+    data() {
+        return {
+            loading: false,
+        };
+    },
     methods: {
         onshow() {
             this.onBatchUp();
@@ -35,11 +41,11 @@ export default {
                 type: "warning",
             })
                 .then(async () => {
+                    this.loading = true;
                     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: 2026051518000001,
@@ -47,6 +53,7 @@ export default {
                             sc_itemids: sc_itemids_str,
                         },
                     });
+                    this.loading = false;
                     this.tool.showMessage(res, () => {
                         this.$emit("batchUpSuccess");
                     });

+ 4 - 1
src/bgj/headquartersServiceMaterial/modules/counterExamine.vue

@@ -5,6 +5,7 @@
             :size="btn_size ? btn_size : 'small'"
             @click="onshow"
             :disabled="disabled"
+            :loading="loading"
             >{{ $t(`反 审`) }}</el-button
         >
     </div>
@@ -17,6 +18,7 @@ export default {
     data() {
         return {
             flag: false,
+            loading: false,
         };
     },
     methods: {
@@ -62,11 +64,11 @@ export default {
                 type: "warning",
             })
                 .then(async () => {
+                    this.loading = true;
                     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: 2026051518000004,
@@ -74,6 +76,7 @@ export default {
                             sc_itemids: sc_itemids_str,
                         },
                     });
+                    this.loading = false;
                     this.tool.showMessage(res, () => {
                         this.$emit("examineSuccess");
                     });

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

@@ -87,6 +87,7 @@
                     type="danger"
                     @click="onDelete"
                     size="mini"
+                    :loading="deleteLoading"
                     v-if="mainData.status === 1"
                     >{{ $t(`删 除`) }}</el-button
                 >
@@ -144,6 +145,7 @@ export default {
             mainData: {},
             mainAreaData: {},
             detailInfo: "",
+            deleteLoading: false,
         };
     },
     components: {
@@ -362,12 +364,14 @@ export default {
                 }
             )
                 .then(async () => {
+                    this.deleteLoading = true;
                     const res = await this.$api.requested({
                         id: "2026051509000002",
                         content: {
                             sc_itemid: this.$route.query.id,
                         },
                     });
+                    this.deleteLoading = false;
                     if (res.code === 0) {
                         this.$message.error(res.data[0].errmsg);
                     } else {

+ 4 - 1
src/bgj/headquartersServiceMaterial/modules/toExamine.vue

@@ -5,6 +5,7 @@
             :size="btn_size ? btn_size : 'small'"
             @click="onshow"
             :disabled="disabled"
+            :loading="loading"
             >{{ $t(`审 核`) }}</el-button
         >
     </div>
@@ -17,6 +18,7 @@ export default {
     data() {
         return {
             flag: false,
+            loading: false,
         };
     },
     methods: {
@@ -62,11 +64,11 @@ export default {
                 type: "warning",
             })
                 .then(async () => {
+                    this.loading = true;
                     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: 2026051518000003,
@@ -74,6 +76,7 @@ export default {
                             sc_itemids: sc_itemids_str,
                         },
                     });
+                    this.loading = false;
                     this.tool.showMessage(res, () => {
                         this.$emit("examineSuccess");
                     });

+ 11 - 1
src/bgj/ourServiceMaterial/index.vue

@@ -108,7 +108,9 @@
                     <previewImage
                         v-if="scope.data.column.data.attinfos[0]"
                         class="image"
-                        :image="scope.data.column.data.attinfos[0]"
+                        :image="
+                            getThumbImage(scope.data.column.data.attinfos[0])
+                        "
                         :list="scope.data.column.data.attinfos"
                         :deletebtn="false"
                     ></previewImage>
@@ -244,6 +246,14 @@ export default {
             this.$refs.list.param.content.where = this.selectParam;
             this.$refs.list.listData();
         },
+        // 优先获取 subfiles 里的缩略图
+        getThumbImage(item) {
+            // 1. 先找 subfiles 里的 thumbnail 图
+            const thumb = item.subfiles?.find((f) => f.type === "thumbnail");
+            if (thumb) return thumb;
+            // 2. 找不到就返回原图片
+            return item;
+        },
     },
     mounted() {
         this.fieldData();

+ 6 - 0
src/bgj/ourServiceMaterial/modules/detail.vue

@@ -55,6 +55,7 @@
                     type="danger"
                     @click="onDelete"
                     size="mini"
+                    :loading="deleteLoading"
                     >{{ $t(`移 除`) }}</el-button
                 >
             </template>
@@ -83,6 +84,7 @@ export default {
             mainAreaData: {},
             detailInfo: "",
             btnLoading: false,
+            deleteLoading: false,
         };
     },
     components: { Edit, BaseInfo, saleClass },
@@ -252,12 +254,14 @@ export default {
                     beforeClose: async (action, instance, done) => {
                         if (action === "confirm") {
                             instance.confirmButtonLoading = true;
+                            this.btnLoading = true;
                             const res = await this.$api.requested({
                                 id: id,
                                 content: {
                                     sc_item_localids: this.$route.query.id,
                                 },
                             });
+                            this.btnLoading = false;
                             this.tool.showMessage(res, () => {
                                 setTimeout(() => {
                                     instance.confirmButtonLoading = false;
@@ -283,12 +287,14 @@ export default {
                 }
             )
                 .then(async () => {
+                    this.deleteLoading = true;
                     const res = await this.$api.requested({
                         id: "2026051510000004",
                         content: {
                             sc_item_localid: this.$route.query.id,
                         },
                     });
+                    this.deleteLoading = false;
                     if (res.code === 0) {
                         this.$message.error(res.data[0].errmsg);
                     } else {