Procházet zdrojové kódy

记录规则关联产品api替换

lucw před 8 měsíci
rodič
revize
5d49271827

+ 9 - 0
src/api/classifyManage/itemInformation.js

@@ -68,3 +68,12 @@ export async function getListAndBom(body) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// /main/category/getListAndInProduceTask
+export async function getListAndInProduceTask(body) {
+  const res = await request.post('/main/category/getListAndInProduceTask', body);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 225 - 0
src/views/rulesManagement/releaseRules/components/ProductModal.vue

@@ -0,0 +1,225 @@
+<template>
+  <el-dialog
+    title="选择产品"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="80%"
+  >
+    <el-card shadow="never">
+      <seekPage :seekList="seekList" @search="reload" />
+      <ele-split-layout
+        width="244px"
+        allow-collapse
+        :right-style="{ overflow: 'hidden' }"
+      >
+        <div class="ele-border-lighter split-layout-right-content">
+          <AssetTree
+            ref="assetTreeRef"
+            id="9"
+            @handleNodeClick="handleNodeClick"
+          />
+        </div>
+        <!-- 表格 -->
+        <template v-slot:content>
+          <ele-pro-table
+            ref="table"
+            :columns="columns"
+            :datasource="datasource"
+            height="calc(100vh - 450px)"
+            class="dict-table"
+            :selection.sync="selection"
+            @cell-click="cellClick"
+          >
+          </ele-pro-table>
+        </template>
+      </ele-split-layout>
+    </el-card>
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import AssetTree from '@/components/AssetTree';
+
+  import { getListAndInProduceTask } from '@/api/classifyManage/itemInformation';
+  export default {
+    components: { AssetTree },
+    props: {
+      // 是否 多选
+      multiple: {
+        type: Boolean,
+        default: false
+      }
+    },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '产品编码',
+            value: 'code',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '产品名称',
+            value: 'name',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '型号',
+            value: 'modelType',
+            type: 'input',
+            placeholder: '请输入'
+          }
+        ];
+      }
+    },
+    data() {
+      return {
+        visible: false,
+        // 表格列配置
+        columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center'
+          },
+          {
+            columnKey: 'index',
+            type: 'index',
+            width: 45,
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            prop: 'code',
+            label: '产品编码'
+          },
+          {
+            prop: 'name',
+            label: '产品名称',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'brandNum',
+            label: '牌号'
+          },
+          {
+            prop: 'modelType',
+            label: '型号'
+          },
+          {
+            prop: 'measuringUnit',
+            label: '计量单位'
+          },
+          {
+            prop: 'packingUnit',
+            label: '包装单位'
+          }
+        ],
+        categoryLevelId: '9',
+        // 表格选中数据
+        selection: []
+      };
+    },
+    watch: {},
+    methods: {
+      /* 表格数据源 */
+      datasource({ page, where, limit }) {
+        return getListAndInProduceTask({
+          ...where,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.categoryLevelId,
+          isProduct: true,
+          produceTaskCode: this.produceTaskCode
+        });
+      },
+      handleNodeClick(data) {
+        this.categoryLevelId = data.id;
+        this.reload();
+      },
+      /* 刷新表格 */
+      reload(where = {}) {
+        this.$refs.table.reload({ page: 1, where: where });
+      },
+      open(rows, produceTaskCode) {
+        this.produceTaskCode = produceTaskCode;
+        console.log('rows', rows, this.produceTaskCode);
+        this.visible = true;
+        if (rows) {
+          this.selection = rows;
+          this.$nextTick(() => {
+            this.$refs.table.setSelectedRows(rows);
+          });
+        } else {
+          this.selection = [];
+          this.$nextTick(() => {
+            this.$refs.table.setSelectedRows([]);
+          });
+        }
+        console.log('this.selection', this.selection);
+      },
+      handleClose() {
+        this.visible = false;
+        this.selection = [];
+      },
+      selected() {
+        console.log('this.selection', this.selection);
+        if (!this.selection.length) {
+          return this.$message.warning('请选择产品');
+        }
+
+        if (!this.multiple && this.selection.length > 1) {
+          return this.$message.warning('只能选择一个产品');
+        }
+
+        this.$emit(
+          'changeProduct',
+          this.multiple ? this.selection : this.selection[0]
+        );
+        this.handleClose();
+      },
+      cellClick(row) {
+        console.log('cellClick', row);
+        this.selection.push(row);
+        this.$refs.table.setSelectedRows(this.selection);
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .tree_col {
+    border: 1px solid #eee;
+    padding: 10px 0;
+    box-sizing: border-box;
+    height: 500px;
+    overflow: auto;
+  }
+  .table_col {
+    padding-left: 10px;
+    ::v-deep .el-table th.el-table__cell {
+      background: #f2f2f2;
+    }
+  }
+  .pagination {
+    text-align: right;
+    padding: 10px 0;
+  }
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
+  .topsearch {
+    margin-bottom: 15px;
+  }
+</style>

+ 15 - 6
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -494,11 +494,11 @@
       @changeProduct="changeProduct"
     ></ProductModal>
 
-    <ProductModal
+    <ProductModalCorrelation
       ref="ProductModalCorrelationRef"
       @changeProduct="changeRelateProduct"
       multiple
-    ></ProductModal>
+    ></ProductModalCorrelation>
 
     <processModal
       ref="processModalRef"
@@ -529,6 +529,8 @@
   import ProductModal from '@/components/selectProduct/ProductModal.vue';
   import { getTreeByPid } from '@/api/classifyManage';
   import processModal from './processModal.vue';
+  import ProductModalCorrelation from './ProductModal.vue';
+  import productionAPI from '@/api/technology/production/index.js';
 
   export default {
     components: {
@@ -538,7 +540,8 @@
       ProductModal,
       MaterialAdd,
       toolModal,
-      processModal
+      processModal,
+      ProductModalCorrelation
     },
     mixins: [dictMixins],
     computed: {
@@ -804,7 +807,8 @@
         ],
         // 产品分类
         productCategory: [],
-        loading: false
+        loading: false,
+        produceTaskCode: ''
       };
     },
     mounted() {
@@ -1435,8 +1439,13 @@
         row.productCode = '';
       },
       // 关联产品
-      relateProductSelect() {
-        this.$refs.ProductModalCorrelationRef.open();
+      async relateProductSelect() {
+        // 查询工序详情
+        const productTaskInfo = await productionAPI.getById(
+          this.formData.produceTaskConfigBatchSavePo.produceTaskId
+        );
+        console.log('productTaskInfo', productTaskInfo);
+        this.$refs.ProductModalCorrelationRef.open([], productTaskInfo.code);
       },
       changeRelateProduct(array) {
         console.log('this.formData.categories ', array);

+ 6 - 1
src/views/technology/production/components/user-setting-matter-process-drawer.vue

@@ -295,6 +295,10 @@
         )?.label;
 
         this.drawer = true;
+
+        this.$nextTick(() => {
+          this.$refs.productTableRef?.reload();
+        });
       },
       handleClose(done) {
         this.$refs.productTableRef.reload();
@@ -310,7 +314,8 @@
           pageNum: page,
           size: limit,
           categoryLevelId: 9,
-          bomTypes: [1, 2, 3]
+          bomTypes: [1, 2, 3],
+          produceTaskCode: this.currentProcessData.code
         });
         data.list.forEach((item) => {
           item.bomType = '';