yijing 1 rok temu
rodzic
commit
22934cd496
1 zmienionych plików z 214 dodań i 225 usunięć
  1. 214 225
      src/views/material/BOMmanage/components/standardOutput.vue

+ 214 - 225
src/views/material/BOMmanage/components/standardOutput.vue

@@ -1,46 +1,21 @@
 <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-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' }"
-      >
+      <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>
+          <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 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>
@@ -53,226 +28,240 @@
 </template>
 
 <script>
-  import ProductSearch from '@/components/select/bom/product-search.vue';
-  import { getMaterialList } from '@/api/material/list.js';
-  import { sourceBomVersion } from '@/api/material/BOM';
-  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',
-            selectable: (row, index) => {
+import ProductSearch from '@/components/select/bom/product-search.vue';
+import { getMaterialList } from '@/api/material/list.js';
+import { sourceBomVersion } from '@/api/material/BOM';
+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',
+          selectable: (row, index) => {
+            if (this.selectList.length) {
               return !this.selectList.some((it) => row.id == it.id);
-            },
-            reserveSelection: true,
-          },
-          {
-            columnKey: 'index',
-            type: 'index',
-            width: 45,
-            align: 'center',
-            reserveSelection: true
-          },
-          {
-            prop: 'code',
-            label: '编码'
-          },
-          {
-            prop: 'name',
-            label: '名称',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'brandNum',
-            label: '牌号'
-          },
+            } else {
+              return;
+            }
 
-          {
-            prop: 'modelType',
-            label: '型号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'specification',
-            label: '规格',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'measuringUnit',
-            label: '计量单位',
-            showOverflowTooltip: true,
-            minWidth: 90
           },
+          reserveSelection: true,
+        },
+        {
+          columnKey: 'index',
+          type: 'index',
+          width: 45,
+          align: 'center',
+          reserveSelection: true
+        },
+        {
+          prop: 'code',
+          label: '编码'
+        },
+        {
+          prop: 'name',
+          label: '名称',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'brandNum',
+          label: '牌号'
+        },
 
-          {
-            prop: 'weightUnit',
-            label: '重量单位',
-            showOverflowTooltip: true,
-            minWidth: 90
-          },
+        {
+          prop: 'modelType',
+          label: '型号',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'specification',
+          label: '规格',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'measuringUnit',
+          label: '计量单位',
+          showOverflowTooltip: true,
+          minWidth: 90
+        },
 
-          {
-            prop: 'roughWeight',
-            label: '毛重',
-            showOverflowTooltip: true,
-            minWidth: 90
-          },
+        {
+          prop: 'weightUnit',
+          label: '重量单位',
+          showOverflowTooltip: true,
+          minWidth: 90
+        },
 
-          {
-            prop: 'netWeight',
-            label: '净重',
-            showOverflowTooltip: true,
-            minWidth: 90
-          },
+        {
+          prop: 'roughWeight',
+          label: '毛重',
+          showOverflowTooltip: true,
+          minWidth: 90
+        },
 
-          {
-            prop: 'packingUnit',
-            align: 'center',
-            label: '包装单位',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'categoryLevelPath',
-            label: '分类',
-            align: 'center',
-            showOverflowTooltip: true
-          },
+        {
+          prop: 'netWeight',
+          label: '净重',
+          showOverflowTooltip: true,
+          minWidth: 90
+        },
 
-          {
-            action: 'action',
-            slot: 'action',
-            align: 'center',
-            label: '选择'
-          }
-        ],
-        title: null,
-        categoryLevelId: null,
-        radio: null,
-        idx: null,
+        {
+          prop: 'packingUnit',
+          align: 'center',
+          label: '包装单位',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'categoryLevelPath',
+          label: '分类',
+          align: 'center',
+          showOverflowTooltip: true
+        },
 
-        isCategory: true,
+        {
+          action: 'action',
+          slot: 'action',
+          align: 'center',
+          label: '选择'
+        }
+      ],
+      title: null,
+      categoryLevelId: null,
+      radio: null,
+      idx: null,
 
-        current: {},
+      isCategory: true,
 
-        treeList: [],
-        treeLoading: false,
+      current: {},
 
-        defaultProps: {
-          children: 'children',
-          label: 'name'
-        }
-      };
-    },
+      treeList: [],
+      treeLoading: false,
 
-    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(list) {
-        this.selectList = list;
-        this.getTreeData();
-        this.visible = true;
-      },
+      defaultProps: {
+        children: 'children',
+        label: 'name'
+      }
+    };
+  },
 
-      async getTreeData() {
-        try {
-          this.treeLoading = true;
+  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(list) {
+      if (list.length) {
+        this.selectList = list;
+      } else {
+        this.type = type;
+      }
+      this.getTreeData();
+      this.visible = true;
+    },
 
-          const res = await  getTreeByGroup({ type: 1 });
-          this.treeLoading = false;
-          if (res?.code === '0') {
-            this.treeList = res.data;
+    async getTreeData() {
+      try {
+        this.treeLoading = true;
 
-            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) {}
+        const res = await getTreeByGroup({ type: 1 });
         this.treeLoading = false;
-      },
-      handleClose() {
-        this.visible = false;
-        this.current = null;
-        this.radio = '';
-      },
+        if (res?.code === '0') {
+          this.treeList = res.data;
 
-      selected() {
-        if (this.selection.length <= 0) {
-          return this.$message.warning('请至少选择一条数据');
+          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;
         }
-        console.log(this.selection,'我是选择数据');
-        this.$emit('selection',this.selection);
-        this.handleClose();
+      } catch (error) { }
+      this.treeLoading = false;
+    },
+    handleClose() {
+      this.visible = false;
+      this.current = null;
+      this.radio = '';
+    },
+
+    selected() {
+      if (this.selection.length <= 0) {
+        return this.$message.warning('请至少选择一条数据');
       }
+      console.log(this.selection, '我是选择数据');
+
+      if (this.selection.length > 0) {
+        this.$emit('selection', this.selection);
+      } else {
+        this.$emit('selection', this.type, 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;
-  }
+.tree_col {
+  border: 1px solid #eee;
+  padding: 10px 0;
+  box-sizing: border-box;
+  height: 500px;
+  overflow: auto;
+}
 
-  .table_col {
-    padding-left: 10px;
+.table_col {
+  padding-left: 10px;
 
-    ::v-deep .el-table th.el-table__cell {
-      background: #f2f2f2;
-    }
+  ::v-deep .el-table th.el-table__cell {
+    background: #f2f2f2;
   }
+}
 
-  .pagination {
-    text-align: right;
-    padding: 10px 0;
-  }
+.pagination {
+  text-align: right;
+  padding: 10px 0;
+}
 
-  .btns {
-    text-align: center;
-    padding: 10px 0;
-  }
+.btns {
+  text-align: center;
+  padding: 10px 0;
+}
 
-  .topsearch {
-    margin-bottom: 15px;
-  }
+.topsearch {
+  margin-bottom: 15px;
+}
 </style>