ysy 2 tahun lalu
induk
melakukan
e9246b3b9d

+ 143 - 0
src/views/material/product/components/mouldChoose.vue

@@ -0,0 +1,143 @@
+<!-- 角色权限分配弹窗 -->
+<template>
+    <ele-modal width="460px" title="选择模具" :visible="visible" :append-to-body="true" @update:visible="updateVisible">
+        <el-scrollbar style="height: 60vh" wrap-style="overflow-x: hidden;">
+            <el-tree :data="treeList" :props="defaultProps" v-loading="treeLoading" :node-key="nodeKey" ref="tree"
+                :highlight-current="true" :expand-on-click-node="false" @check-change="handleCheckChange" v-bind="$attrs"
+                :default-expand-all="defaultExpandAll" show-checkbox :default-checked-keys="checkedKeys" check-strictly>
+            </el-tree>
+        </el-scrollbar>
+        <template v-slot:footer>
+            <el-button type="primary" @click="save">确定</el-button>
+            <el-button @click="updateVisible(false)">取消</el-button>
+        </template>
+    </ele-modal>
+</template>
+  
+<script>
+import { getTreeByPid } from '@/api/classifyManage';
+
+export default {
+    props: {
+
+
+
+        // treeList私有化处理
+        treeFormate: {
+            type: Function,
+            default: null
+        },
+        defaultProps: {
+            type: Object,
+            default: function () {
+                return {
+                    children: 'children',
+                    value: 'id',
+                    label: 'name'
+                };
+            }
+        },
+        defaultExpandAll: {
+            type: Boolean,
+            default: function () {
+                return true;
+            }
+        },
+
+        id: {
+            type: String,
+            default: '0'
+        },
+        nodeKey: {
+            type: String,
+            default: 'id'
+        }
+
+    },
+    data() {
+        return {
+            treeList: [],
+            treeLoading: false,
+
+            current: null,
+            checkedKeys: [],
+            visible: false,
+            idx: null
+        };
+    },
+    mounted() {
+
+    },
+    methods: {
+ 
+        open(item,idx) {
+            this.getTreeData();
+            this.current= {
+             id: item.modelCategoryLevelId,
+             code: item.modelCategoryLevelCode,
+             name: item.modelCategoryLevelName,
+            }
+            this.checkedKeys.push(item.modelCategoryLevelId)
+            this.idx = idx
+            this.visible = true
+        },
+
+        // 获取树结构数据
+        async getTreeData() {
+            try {
+                this.treeLoading = true;
+
+                const res = await getTreeByPid(this.id);
+                this.treeLoading = false;
+                if (res?.code === '0') {
+                    this.treeList = res.data;
+                    if (this.treeFormate) {
+                        this.treeList = this.treeFormate(this.treeList);
+                    }
+
+                    return this.treeList;
+                }
+            } catch (error) { }
+            this.treeLoading = false;
+        },
+
+        handleCheckChange(data, checked) {
+            if (checked) {
+                this.current = data
+                this.$refs.tree.setCheckedKeys([data.id])
+            }
+        },
+
+
+        // 获取树的选中状态
+        getSelectList() {
+            const selectList = this.$refs.tree.getCurrentNode();
+            return selectList;
+        },
+
+        /* 更新visible */
+        updateVisible(value) {
+           this.visible = value
+        },
+
+        save() {
+            this.$emit('saveMould', this.current, this.idx)
+            this.updateVisible(false)
+        },
+    },
+
+};
+</script>
+  
+<style lang="scss" scoped>
+.tree-wrapper {
+    width: 100%;
+    height: 100%;
+    overflow: auto;
+
+    :deep(.el-tree) {
+        display: inline-block;
+        min-width: 100%;
+    }
+}
+</style>

+ 25 - 137
src/views/material/product/components/mouldDialog.vue

@@ -52,19 +52,19 @@
                         @click="openEdit">新增</el-button>
                 </template>
 
-                <template v-slot:palletBomCode="{ row }">
-                    <el-input v-model="row.palletBomCode" placeholder="请输入模具BOM编码"></el-input>
+                <template v-slot:modelCategoryLevelCode="{ row, $index }">
+                    <el-input v-model="row.modelCategoryLevelCode" placeholder="请输入模具BOM编码"
+                        @click.native="openMould(row, $index)"></el-input>
                 </template>
 
-                <template v-slot:palletBomName="{ row }">
-                    <el-input v-model="row.palletBomName" placeholder="请输入模具BOM名称"></el-input>
+                <template v-slot:modelCategoryLevelName="{ row, $index }">
+                    <el-input v-model="row.modelCategoryLevelName" placeholder="请输入模具BOM名称"
+                        @click.native="openMould(row, $index)"></el-input>
                 </template>
 
                 <!-- 操作列 -->
                 <template v-slot:action="{ row, $index }">
-                    <el-link type="primary" @click="openMould(row)" :underline="false">
-                        配置模具
-                    </el-link>
+
 
                     <el-popconfirm class="ele-action" title="确定要删除当前工序吗?" @confirm="handleDel(row, $index)">
                         <template v-slot:reference>
@@ -75,26 +75,7 @@
                     </el-popconfirm>
                 </template>
 
-                <template v-slot:expand="{ row }">
-                    <div style="width: 100%; min-height: 60px" v-if="row.palletList">
-                        <ele-pro-table :toolbar="false" toolsTheme="none" ref="table2" :need-page="false"
-                            :datasource="row.palletList" :columns="columns2" row-key="id">
-
-                            <!-- 操作列 -->
-                            <template v-slot:action="{ row }">
-                                <el-popconfirm class="ele-action" title="确定要删除当前模具吗?" @confirm="remove2(row)">
-                                    <template v-slot:reference>
-                                        <el-link type="danger" :underline="false" icon="el-icon-delete">
-                                            删除
-                                        </el-link>
-                                    </template>
-                                </el-popconfirm>
-                            </template>
-
-
-                        </ele-pro-table>
-                    </div>
-                </template>
+
             </ele-pro-table>
         </el-form>
 
@@ -105,20 +86,20 @@
 
         <processModal ref="processRefs" @chooseProcess="chooseProcess"></processModal>
 
-        <!-- 选择模具 -->
-        <SelectProduct ref="productRefs" @chooseProcess="chooseModal"></SelectProduct>
+        <mouldChoose id="5" ref="mouldRef" @saveMould="saveMould"></mouldChoose>
+
     </ele-modal>
 </template>
   
 <script>
 import processModal from '@/views/technology/productParam/components/processModal.vue';
-import SelectProduct from '@/components/select/SelectProduct';
-
 import { categoryTaskPallet, getCategoryTaskPallet } from '@/api/material/list';
+import mouldChoose from './mouldChoose.vue'
 export default {
     components: {
         processModal,
-        SelectProduct
+        mouldChoose
+
     },
     props: {
         // 弹窗是否打开
@@ -154,16 +135,9 @@ export default {
             // 提交状态
             loading: false,
             current: null,
+        
 
             columns: [
-                {
-                    width: 45,
-                    type: 'expand',
-                    columnKey: 'palletList',
-                    align: 'center',
-                    slot: 'expand'
-                },
-
 
 
                 {
@@ -197,17 +171,17 @@ export default {
                 },
 
                 {
-                    prop: 'palletBomCode',
+                    prop: 'modelCategoryLevelCode',
                     label: '模具BOM编码',
                     align: 'center',
-                    slot: 'palletBomCode',
+                    slot: 'modelCategoryLevelCode',
                     minWidth: 150
                 },
                 {
-                    prop: 'palletBomName',
+                    prop: 'modelCategoryLevelName',
                     label: '模具BOM名称',
                     align: 'center',
-                    slot: 'palletBomName',
+                    slot: 'modelCategoryLevelName',
                     minWidth: 150
                 },
 
@@ -223,46 +197,7 @@ export default {
             ],
 
 
-            // 表格列配置
-            columns2: [
-
-                {
-                    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
-                },
-
 
-                {
-                    columnKey: 'action',
-                    label: '操作',
-                    align: 'center',
-                    resizable: false,
-                    slot: 'action',
-                    showOverflowTooltip: true
-                }
-            ],
 
             removeList: [],
             categoryId: null
@@ -317,41 +252,18 @@ export default {
             }
         },
 
-        openMould(row) {
-            this.$refs.productRefs.open([], '模具', '5', row);
-        },
 
-        chooseModal(data, current) {
-            data.map((m => {
-                m.parentId = current.produceTaskId
-                return {
-                    ...m,
-                }
-            }))
-
-            let tableList = [];
-            tableList = this.$refs.table.getData();
-            tableList.forEach((e) => {
-                if (e.produceTaskId == current.produceTaskId) {
-                    e.palletList = data;
-                }
-            });
-            this.$refs.table.setData([...tableList]);
+        openMould(row,index) {
+            this.$refs.mouldRef.open(row, index)
         },
 
-        remove2(row) {
-            const data = this.$refs.table.getData() ?? [];
-            data.forEach((e) => {
-                if (row.parentId == e.produceTaskId) {
-                    e.palletList = e.palletList.filter((d) => d.id !== row.id);
-                }
-            })
-
-            this.$refs.table.setData([...data])
-
+        saveMould(row,idx) {
+            this.$set('')
+            console.log(row)
         },
 
 
+
         async getCategoryTaskDetail() {
             const res = await getCategoryTaskPallet(this.categoryId);
             this.$refs.table.setData(res);
@@ -360,32 +272,8 @@ export default {
         save() {
             let _arr = this.$refs.table.getData();
 
-            console.log(_arr)
-
-            let result = true
-            for(let i =0; i < _arr.length; i++) {
-             
-               if(_arr[i].hasOwnProperty('palletList') || e.palletList.length  == 0) {
-                result = false
-                break;
-               }
-            }
-
-            console.log(result)
-
-
-
-   
-
-
-            if (!result) {
-                this.$message.success('请先配磨具信息');
-                return false
-            }
-
-
+       
 
-            return false
 
             let param = {
                 categoryId: this.categoryId,