huang_an 1 год назад
Родитель
Сommit
e9ab6428ab

+ 269 - 0
src/views/material/BOMmanage/components/ProductModalMultiple.vue

@@ -0,0 +1,269 @@
+<template>
+  <el-dialog
+    :title="title"
+    :visible.sync="visible"
+    v-if="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="75%"
+  >
+    <el-card shadow="never">
+      <ProductSearch @search="reload" ref="searchRef" />
+
+      <ele-split-layout
+        width="244px"
+        allow-collapse
+        :right-style="{ overflow: 'hidden' }"
+      >
+        <div class="ele-border-lighter split-layout-right-content">
+          <el-tree
+            :data="treeList"
+            :props="defaultProps"
+            ref="treeRef"
+            :default-expanded-keys="current && current.id ? [current.id] : []"
+            :highlight-current="true"
+            node-key="id"
+            @node-click="handleNodeClick"
+          ></el-tree>
+        </div>
+        <!-- 表格 -->
+        <template v-slot:content>
+          <ele-pro-table
+            ref="table"
+            :columns="columns"
+            :datasource="datasource"
+            :selection.sync="selection"
+            row-key="id"
+            height="calc(100vh - 350px)"
+            class="dict-table"
+          >
+          </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 ProductSearch from '@/components/select/bom/product-search.vue';
+  import { getMaterialList } from '@/api/material/list.js';
+  import { getTreeByGroup } from '@/api/classifyManage';
+  export default {
+    components: { ProductSearch },
+    data() {
+      return {
+        visible: false,
+        type: 1,
+        selection: [],
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            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: '型号',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'measuringUnit',
+            label: '计量单位',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'weightUnit',
+            label: '重量单位',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'roughWeight',
+            label: '毛重',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'netWeight',
+            label: '净重',
+            showOverflowTooltip: true,
+            minWidth: 90
+          },
+
+          {
+            prop: 'packingUnit',
+            align: 'center',
+            label: '包装单位',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'categoryLevelPath',
+            label: '分类',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+
+          {
+            action: 'action',
+            slot: 'action',
+            align: 'center',
+            label: '选择'
+          }
+        ],
+        title: null,
+        categoryLevelId: null,
+        radio: null,
+        idx: null,
+
+        isCategory: true,
+
+        current: {},
+
+        treeList: [],
+        treeLoading: false,
+
+        defaultProps: {
+          children: 'children',
+          label: 'name'
+        }
+      };
+    },
+
+    watch: {},
+    methods: {
+      /* 表格数据源 */
+      datasource({ page, where, limit }) {
+        return getMaterialList({
+          ...where,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.isCategory ? this.categoryLevelId : null
+        });
+      },
+      handleNodeClick(data) {
+        this.isCategory = true;
+        this.categoryLevelId = data.id;
+        this.$refs.table.reload({ pageNum: 1, where: {} });
+        this.$refs.searchRef.reset2();
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.isCategory = false;
+        this.$refs.table.reload({ pageNum: 1, where: where });
+      },
+      open(type) {
+        this.type = type;
+        this.getTreeData();
+        this.visible = true;
+      },
+
+      async getTreeData() {
+        try {
+          this.treeLoading = true;
+
+          const res = await getTreeByGroup({ type: this.type });
+          this.treeLoading = false;
+          if (res?.code === '0') {
+            this.treeList = res.data;
+
+            this.$nextTick(() => {
+              // 默认高亮第一级树节点
+              if (this.treeList[0]) {
+                this.rootTreeId = this.treeList[0].id;
+                this.$nextTick(() => {
+                  this.$refs.treeRef.setCurrentKey(this.treeList[0].id);
+                });
+              }
+            });
+            return this.treeList;
+          }
+        } catch (error) {}
+        this.treeLoading = false;
+      },
+      handleClose() {
+        this.visible = false;
+        this.current = null;
+        this.radio = '';
+      },
+      selected() {
+        if (this.selection.length <= 0) {
+          return this.$message.warning('请至少选择一条数据');
+        }
+        this.$emit('selection', this.selection);
+        this.handleClose();
+      }
+    }
+  };
+</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>

+ 79 - 3
src/views/material/BOMmanage/components/workingProcedure.vue

@@ -969,7 +969,6 @@
           </ele-pro-table>
           </ele-pro-table>
         </el-tab-pane>
         </el-tab-pane>
 
 
-
         <el-tab-pane label="" name="工艺文件">
         <el-tab-pane label="" name="工艺文件">
           <ele-pro-table
           <ele-pro-table
             ref="fileTable"
             ref="fileTable"
@@ -1074,6 +1073,11 @@
     <jobDialog ref="jobRef" @chooseModal="chooseJob"></jobDialog>
     <jobDialog ref="jobRef" @chooseModal="chooseJob"></jobDialog>
     <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
     <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
     <ProductModal ref="productRefs" @changeProduct="determineChoose" />
     <ProductModal ref="productRefs" @changeProduct="determineChoose" />
+    <ProductModalMultiple
+      ref="productMultipleRefs"
+      @selection="addProductList"
+    ></ProductModalMultiple>
+
     <div class="btns">
     <div class="btns">
       <el-button type="primary" size="small" @click="save">{{
       <el-button type="primary" size="small" @click="save">{{
         isView ? '确定' : '保存'
         isView ? '确定' : '保存'
@@ -1091,6 +1095,7 @@
   import { workingProcedureUpdate } from '@/api/material/BOM';
   import { workingProcedureUpdate } from '@/api/material/BOM';
   import ParamModal from '@/views/technology/productParam/components/ParamModal.vue';
   import ParamModal from '@/views/technology/productParam/components/ParamModal.vue';
   import ProductModal from '@/components/select/bom/ProductModal.vue';
   import ProductModal from '@/components/select/bom/ProductModal.vue';
+  import ProductModalMultiple from './ProductModalMultiple.vue';
   import userSearch from './user-search.vue';
   import userSearch from './user-search.vue';
   import jobDialog from './jobDialog.vue';
   import jobDialog from './jobDialog.vue';
   export default {
   export default {
@@ -1099,7 +1104,8 @@
       ParamModal,
       ParamModal,
       fileUpload,
       fileUpload,
       ProductModal,
       ProductModal,
-      jobDialog
+      jobDialog,
+      ProductModalMultiple
     },
     },
     mixins: [dictMixins],
     mixins: [dictMixins],
     data() {
     data() {
@@ -1519,11 +1525,81 @@
         }
         }
         this.tableData.taskParam[this.currentIndex][type].splice(index, 1);
         this.tableData.taskParam[this.currentIndex][type].splice(index, 1);
       },
       },
+      addProductList(list) {
+        console.log(list);
+        let subCode = 0;
+        let array = [];
+        list.map((item, index) => {
+          // let max = '';
+          // if (
+          //   this.tableData.taskParam[this.currentIndex]['materialQuota']
+          //     .length > 0
+          // ) {
+          //   max = Number(
+          //     Math.max(
+          //       ...this.tableData.taskParam[this.currentIndex][
+          //         'materialQuota'
+          //       ].map((i) => i.subCode)
+          //     )
+          //   );
+          //   subCode = max + index + 1;
+          // } else {
+          //   max = 1;
+          //   subCode = max + index;
+          // }
+          let max = '';
+          if (
+            this.tableData.taskParam[this.currentIndex]['materialQuota']
+              .length > 0
+          ) {
+            max =
+              Math.max(
+                ...this.tableData.taskParam[this.currentIndex][
+                  'materialQuota'
+                ].map((i) => i.subCode)
+              ) +
+              10 * ++index +
+              '';
+            console.log(max);
+            if (max.length < 4) {
+              max = new Array(4 - max.length).fill('0').join('') + max;
+            }
+          } else {
+            max = 10 * ++index + '';
+            if (max.length < 4) {
+              max = new Array(4 - max.length).fill('0').join('') + max;
+            }
+          }
+          subCode = max.substring(0, max.length - 1) + '0';
+          array.push({
+            subCode,
+            categoryId: item.categoryId,
+            categoryName: item.name,
+            categoryCode: item.categoryCode,
+            isReworkBom: 0,
+            brandNum: item.brandNum,
+            weightUnit: item.weightUnit,
+            count: '',
+            modelType: item.modelType,
+            unit: item.measuringUnit
+          });
+        });
+        console.log(array);
+        this.tableData.taskParam[this.currentIndex].materialQuota =
+          this.tableData.taskParam[this.currentIndex].materialQuota.concat(
+            array
+          );
+        console.log(this.tableData.taskParam[this.currentIndex].materialQuota);
+        this.$refs.materialTable.setData(
+          this.tableData.taskParam[this.currentIndex].materialQuota
+        );
+      },
       add() {
       add() {
         let subCode = '0010';
         let subCode = '0010';
         let type = '';
         let type = '';
         if (this.activeName === '材料定额') {
         if (this.activeName === '材料定额') {
-          type = 'materialQuota';
+          this.$refs.productMultipleRefs.open(1);
+          return;
         } else if (this.activeName === '制造资源') {
         } else if (this.activeName === '制造资源') {
           type = 'resource';
           type = 'resource';
         } else if (this.activeName === '替代料') {
         } else if (this.activeName === '替代料') {