695593266@qq.com пре 5 часа
родитељ
комит
71deacc389

+ 77 - 1
src/views/material/product/components/index-data.vue

@@ -83,6 +83,16 @@
           :loading="exportLoading"
           >导出</el-button
         >
+        <el-button
+          v-if="!isBatchPublish"
+          size="small"
+          type="primary"
+          icon="el-icon-s-promotion"
+          class="ele-btn-icon"
+          @click="batchPublish"
+        >
+          批量发布
+        </el-button>
         <el-button
           size="small"
           :disabled="selection.length == 0"
@@ -361,6 +371,7 @@
   import mouldDialog from './mouldDialog';
   import linkMaterialDialog from './link-material-dialog.vue';
   import goodsAllocation from './goodsAllocation.vue';
+  import { parameterGetByCode } from '@/api/system/dictionary/index.js';
 
   import BomDetailsPop from '../../BOMmanage/detailsPop.vue';
   import dictMixins from '@/mixins/dictMixins';
@@ -778,7 +789,8 @@
 
         rowCurrent: null,
         isLoading: false,
-        pageSize: this.$store.state.tablePageSize
+        pageSize: this.$store.state.tablePageSize,
+        isBatchPublish: true
       };
     },
 
@@ -788,6 +800,9 @@
           this.attributeList = res.data;
         }
       });
+
+      this.getCategoryNeedApprove();
+
       // this.requestDict('生产类型');
       this.requestDict('物品机型');
       this.requestDict('物品颜色');
@@ -795,7 +810,20 @@
       this.getFieldModel();
     },
 
+    activated() {
+      this.getCategoryNeedApprove();
+    },
+
     methods: {
+      getCategoryNeedApprove() {
+        return parameterGetByCode({
+          code: 'category_need_approve'
+        }).then((res) => {
+          console.log(res.value, 'category_need_approve');
+          this.isBatchPublish = res.value == 1 ? true : false;
+        });
+      },
+
       async changeEnable(row) {
         const res = await changeOnOff(row.id);
         if (res.code == 0) {
@@ -979,6 +1007,54 @@
       },
 
       /* 显示编辑 */
+      batchPublish() {
+        if (!this.selection.length) {
+          this.$message.warning('请先勾选要发布的数据');
+          return;
+        }
+
+        const publishedList = this.selection.filter((item) => item.isPublished == 1);
+        if (publishedList.length) {
+          const publishedNames = publishedList
+            .map((item) => item.name || item.code || item.categoryId || item.id)
+            .filter(Boolean)
+            .join('、');
+          this.$message.warning(
+            `勾选的数据中【${publishedNames}】已发布,不能继续发布`
+          );
+          return;
+        }
+
+        const categoryIds = this.selection
+          .map((item) => item.categoryId || item.id)
+          .filter((id) => id !== undefined && id !== null && id !== '');
+
+        if (!categoryIds.length) {
+          this.$message.warning('未获取到可发布数据');
+          return;
+        }
+
+        this.$confirm(`确定要发布选中的 ${categoryIds.length} 条数据吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+          .then(() => {
+            const loading = this.$loading({ lock: true });
+            publishCategory({ categoryIds })
+              .then((res) => {
+                this.$message.success(res.message || '发布成功');
+                this.reloadNew();
+              })
+              .finally(() => {
+                loading.close();
+              });
+          })
+          .catch(() => {
+            // 用户取消发布
+          });
+      },
+
       openEdit(row, status) {
         console.log(status, this.currentData, 'status');
         let isUpdate;

+ 4 - 1
src/views/material/product/oneProduct.vue

@@ -168,7 +168,10 @@
     activated() {
       // this.getTreeData();
       this.$nextTick(() => {
-        this.$refs.listData.reloadNew(this.where);
+        if (this.$refs.listData) {
+          this.$refs.listData.getCategoryNeedApprove();
+          this.$refs.listData.reloadNew(this.where);
+        }
       });
     },
     computed: {