From c9ce5e7f9a9ef52c66baf4f8a6e8d9e48b7cb251 Mon Sep 17 00:00:00 2001
From: lzhe <181968431@qq.com>
Date: 星期五, 24 五月 2024 23:59:27 +0800
Subject: [PATCH] 1

---
 src/views/console/tooling/Tray.vue |  398 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 343 insertions(+), 55 deletions(-)

diff --git a/src/views/console/tooling/Tray.vue b/src/views/console/tooling/Tray.vue
index 7234ccd..659d4d5 100644
--- a/src/views/console/tooling/Tray.vue
+++ b/src/views/console/tooling/Tray.vue
@@ -1,7 +1,7 @@
 <!--
  * @Date: 2024-05-12 20:02:31
  * @LastEditors: Sneed
- * @LastEditTime: 2024-05-12 21:34:13
+ * @LastEditTime: 2024-05-19 13:57:46
  * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/tooling/Tray.vue
 -->
 <template>
@@ -14,15 +14,26 @@
                         disabled: 'isGroup'
                     }" @node-click="nodeClick">
                         <template #default="{ node, data }">
-                            <span :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
-                                <span>{{
-                                    node.label || data.code }}</span>
-                            </span>
+                            <div :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
+                                <span>{{ node.label || data.code }}</span>
+                                <el-icon class="icon" @click.stop="renameArea(data)" v-if="data.id > 200"
+                                    style="margin-left: auto;margin-right: 4px;">
+                                    <ElIconEditPen />
+                                </el-icon>
+                                <el-popconfirm title="纭畾鍒犻櫎鍚楋紵" @confirm="delArea(data)">
+                                    <template #reference>
+                                        <el-icon class="icon" v-if="data.id > 200">
+                                            <ElIconDelete />
+                                        </el-icon>
+                                    </template>
+                                </el-popconfirm>
+
+                            </div>
                         </template>
                     </el-tree>
                 </el-main>
                 <el-footer>
-                    <el-button>娣诲姞鎵樼洏缁�</el-button>
+                    <el-button type="primary" @click="addTrayGroup">娣诲姞鎵樼洏缁�</el-button>
                 </el-footer>
             </el-container>
         </el-aside>
@@ -30,14 +41,15 @@
         <el-container v-if="selectNode.id">
             <el-header>
                 <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button>
-                <import-table style="margin:0 8px" :exportUrl="exportUrl" :uploadUrl="uploadUrl"></import-table>
+                <import-table style="margin:0 8px" exportUrl="/api/blade-cps/tray/excel/template"
+                    uploadUrl="/api/blade-cps/tray/import-tray"></import-table>
                 <el-button type="danger" plain icon="el-icon-delete" @click="batchDel"></el-button>
-                <el-input v-model="params.keyWord" style="width: 240px;margin-left: auto;" placeholder="璇疯緭鍏ユ绱㈠唴瀹�"
+                <el-input v-model="params.keyword" style="width: 240px;margin-left: auto;" placeholder="璇疯緭鍏ユ绱㈠唴瀹�"
                     clearable></el-input>
                 <el-button @click="search" type="primary" icon="el-icon-search"></el-button>
             </el-header>
             <el-main>
-                <el-row>
+                <el-row :gutter="20">
                     <el-col :span="10">
                         <scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick" ref="table"
                             :params="params" :apiObj="apiObj" @selection-change="selectionChange" stripe>
@@ -60,49 +72,163 @@
                             </el-table-column>
                         </scTable>
                     </el-col>
-                    <el-col :span="14">
+                    <el-col :span="14" v-loading="showLoading">
                         <h2>鎵樼洏淇℃伅</h2>
-                        <el-container>
-                            <el-main>
-                                <div class="tuopan-info">
-                                    <div>
-                                        tup
-                                    </div>
-                                    <el-row>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                        <el-col :span="12">
-                                            鎵樼洏闈㈡暟: {{ }}
-                                        </el-col>
-                                    </el-row>
-                                </div>
+                        <div class="tuopan-info">
+                            <el-row>
+                                <el-col :span="12">
+                                    鎵樼洏缂栧彿: {{ info.code }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鎵樼洏鍚嶇О: {{ info.name || '-' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鎵樼洏闈㈡暟: {{ info.faceNumber || '-' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鍙敤鐘舵��: {{ info.availability === 1 ? '鍙敤' : '鍐荤粨' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鎵樼洏鎻忚堪: {{ info.description || '-' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鎵樼洏绫诲埆: {{ info.category || '-' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鎵樼洏瑙勬牸: {{ info.standardModel || '-' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鎵樼洏缁�: {{ info.groupName || '-' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    鎵樼洏鐘舵��: {{ info.trayStatus === 1 ? '绌鸿浇' : '璐熻浇' }}
+                                </el-col>
+                                <el-col :span="12">
+                                    澶囨敞: {{ info.remark || '-' }}
+                                </el-col>
+                            </el-row>
+                        </div>
 
-                            </el-main>
-                        </el-container>
+                        <h2 style="margin:14px 0;">鎵樼洏闈㈠垪琛�</h2>
+                        <div>
+                            <el-button type="primary" size="small" @click="addTray">鏂板缓鎵樼洏闈�</el-button>
+                        </div>
+                        <el-table :data="infoList" style="width: 100%" stripe>
+                            <el-table-column label="鎵樼洏闈㈢紪鍙�" prop="code"></el-table-column>
+                            <el-table-column label="鎵樼洏闈㈠悕绉�" prop="name"></el-table-column>
+                            <el-table-column label="鍏宠仈澶瑰叿" prop="fixtureNum"></el-table-column>
+                            <el-table-column label="鍋忕Щ绋嬪簭缂栧彿" prop="programCode"></el-table-column>
+                            <el-table-column label="鎿嶄綔" fixed="right" align="right" width="160">
+                                <template #default="scope">
+                                    <el-button-group>
+                                        <el-button text type="primary" size="small"
+                                            @click="table_edit1(scope.row, scope.$index)">缂栬緫</el-button>
+                                        <el-popconfirm title="纭畾鍒犻櫎鍚楋紵" @confirm="table_del1(scope.row, '0')">
+                                            <template #reference>
+                                                <el-button text type="primary" size="small">鍒犻櫎</el-button>
+                                            </template>
+                                        </el-popconfirm>
+                                    </el-button-group>
+                                </template>
+                            </el-table-column>
+                        </el-table>
                     </el-col>
                 </el-row>
             </el-main>
         </el-container>
-        <!-- </el-main> -->
+        <el-dialog v-model="visible" title="鎵樼洏闈�" width="500">
+            <el-form :model="form" :rules="rules" ref="dialogForm" label-width="120px" label-position="center">
+                <el-form-item label="鎵樼洏闈㈢紪鍙�" prop="code">
+                    <el-input :disabled="form.id" v-model="form.code" />
+                </el-form-item>
+                <el-form-item label="鎵樼洏闈㈠悕绉�" prop="name">
+                    <el-input v-model="form.name" />
+                </el-form-item>
+                <el-form-item label="鍋忕Щ绋嬪簭缂栧彿" prop="programCode">
+                    <el-input :disabled="form.id" v-model="form.programCode" />
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <div class="dialog-footer">
+                    <el-button type="primary" @click="saveTray">
+                        纭畾
+                    </el-button>
+                </div>
+            </template>
+        </el-dialog>
+        <el-dialog v-model="visibleGroup" title="鎵樼洏缁�" width="500">
+            <el-form :model="formGroup" :rules="rulesGroup" ref="dialogForm" label-width="120px"
+                label-position="center">
+                <el-form-item v-if="!formGroup.id" label="涓婄骇鐩綍">
+                    <el-input disabled v-model="selectNode.name" />
+                </el-form-item>
+                <el-form-item label="鎵樼洏缁勫悕绉�">
+                    <el-input v-model="formGroup.name" />
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <div class="dialog-footer">
+                    <el-button type="primary" @click="saveGroup">
+                        纭畾
+                    </el-button>
+                </div>
+            </template>
+        </el-dialog>
+        <el-drawer v-model="dialog" title="鎵樼洏淇℃伅" class="demo-drawer">
+            <el-container>
+                <el-main>
+                    <el-form :model="trayForm" :rules="rulesTray" ref="trayForm" label-width="120px">
+                        <el-form-item label="鎵樼洏缁�" prop="groupId">
+                            <el-tree-select v-model="trayForm.groupId" @node-click="groupIdClick" node-key="id"
+                                :data="treeData" filterable style="width: 240px" :props="{
+                                    label: 'name',
+                                }" />
+                        </el-form-item>
+                        <el-form-item v-if="trayForm.code" label="鎵樼洏缂栧彿" prop="code">
+                            <el-input style="width: 240px" v-model="trayForm.code" />
+                        </el-form-item>
+                        <el-form-item label="鎵樼洏鍚嶇О" prop="name">
+                            <el-input style="width: 240px" v-model="trayForm.name" />
+                        </el-form-item>
+                        <el-form-item label="鍙敤鐘舵��" prop="availability">
+                            <el-select style="width: 240px" v-model="trayForm.availability" placeholder="">
+                                <el-option label="婵�娲�" :value="1" />
+                                <el-option label="鍐荤粨" :value="0" />
+                            </el-select>
+                        </el-form-item>
+                        <el-form-item label="鎵樼洏鎻忚堪" prop="description">
+                            <el-input style="width: 240px" type="textarea" v-model="trayForm.description" />
+                        </el-form-item>
+                        <el-form-item label="鎵樼洏绫诲埆" prop="category">
+                            <el-select style="width: 240px" v-model="trayForm.category" placeholder="">
+                                <el-option v-for="item in tray_category" :key="item.value" :label="item.label"
+                                    :value="item.value" />
+                            </el-select>
+                        </el-form-item>
+                        <el-form-item label="鎵樼洏瑙勬牸" prop="standardModel">
+                            <el-input style="width: 240px" v-model="trayForm.standardModel" />
+                        </el-form-item>
+                        <el-form-item label="鎵樼洏鐘舵��" prop="trayStatus">
+                            <el-select style="width: 240px" v-model="trayForm.trayStatus" placeholder="">
+                                <el-option label="绌鸿浇" :value="1" />
+                                <el-option label="璐熻浇" :value="0" />
+                            </el-select>
+                        </el-form-item>
+                        <el-form-item label="澶囨敞" prop="remark">
+                            <el-input style="width: 240px" type="textarea" v-model="trayForm.remark" />
+                        </el-form-item>
+                        <el-form-item label="鍥剧墖" prop="picture">
+                            <scUpload v-model="form.picture" title=""></scUpload>
+                        </el-form-item>
+                    </el-form>
+                </el-main>
+                <el-footer style="text-align: right">
+                    <el-button type="primary" @click="confirm">
+                        纭畾
+                    </el-button>
+                </el-footer>
+            </el-container>
+        </el-drawer>
     </el-container>
 </template>
 
@@ -115,38 +241,146 @@
     data() {
         return {
             treeData: [],
+            visibleGroup: false,
+            formGroup: {},
+            rulesGroup: {
+                name: [
+                    { required: true, message: '蹇呭~' }
+                ],
+            },
             params: {
                 keyword: ''
             },
             info: {},
+            infoList: [],
             selectNode: {},
             apiObj: {
                 get: async (data) => {
                     let params = {
-                        ...data
+                        ...data,
+                        ...this.params
                     }
-                    return await this.$HTTP.get(`/api/blade-cps/tray/page/${this.selectNode.id}`, { keyword: this.params.keyword }, { params }).then(res => {
+                    return await this.$HTTP.get(`/api/blade-cps/tray/page/${this.selectNode.id}`, {}, { params }).then(res => {
                         return res
                     })
                 }
             },
+            showLoading: false,
+            visible: false,
+            form: {},
+            rules: {
+                code: [
+                    { required: true, message: '蹇呭~' }
+                ],
+                name: [
+                    { required: true, message: '蹇呭~' }
+                ],
+                programCode: [
+                    { required: true, message: '蹇呭~' }
+                ],
+            },
+            dialog: false,
+            trayForm: {},
+            rulesTray: {
+                groupId: [
+                    { required: true, message: '蹇呭~' }
+                ],
+                availability: [
+                    { required: true, message: '蹇呭~' }
+                ],
+            },
+            tray_category: []
         }
     },
     watch: {
         'selectNode.id': {
             handler(val) {
+                this.info = {}
+                this.infoList = []
                 if (val) {
                     this.queryInfo()
-                } else {
-                    this.info = {}
                 }
             }
         }
     },
     created() {
         this.init()
+        this.$HTTP.get(`/api/blade-system/dict/dictionary?code=tray_category`).then(res => {
+            this.tray_category = res.data.map(v => ({
+                label: v.dictValue,
+                value: v.dictKey
+            }))
+        })
     },
     methods: {
+        addTrayGroup() {
+            console.log(this.selectNode)
+            this.formGroup = {}
+            this.visibleGroup = true
+        },
+        renameArea(data) {
+            this.formGroup = {
+                ...data
+            }
+            this.visibleGroup = true
+        },
+        delArea(data) {
+            this.$HTTP.delete(`/api/blade-cps/tray/remove-tree?id=${data.id}`).then(res => {
+                this.init()
+            })
+        },
+        saveGroup() {
+            if (!this.formGroup.id) {
+                this.$HTTP.post(`/api/blade-cps/group`, {
+                    groupCategory: 1,
+                    groupType: "group_tray",
+                    parentId: this.selectNode.id,
+                    ...this.formGroup
+                }).then(res => {
+                    this.visibleGroup = false
+                    this.init()
+                })
+            } else {
+                this.$HTTP.put(`/api/blade-cps/group`, {
+                    groupCategory: 1,
+                    groupType: "group_tray",
+                    parentId: this.selectNode.id,
+                    ...this.formGroup
+                }).then(res => {
+                    this.visibleGroup = false
+                    this.init()
+                })
+            }
+
+        },
+        search() {
+            this.$refs.table.reload(this.params)
+        },
+        table_add() {
+            this.trayForm = {
+                groupId: this.selectNode.id,
+                availability: 1,
+                trayStatus: 1,
+            }
+            this.dialog = true
+        },
+        table_edit(row) {
+            this.trayForm = {
+                ...row
+            }
+            this.dialog = true
+        },
+        groupIdClick(node) {
+            this.trayForm.groupId = node.id
+        },
+        confirm() {
+            this.$HTTP.post(`/api/blade-cps/tray/save`, {
+                ...this.trayForm
+            }).then(res => {
+                this.dialog = false
+                this.queryInfo()
+            })
+        },
         init() {
             this.$HTTP.post(`/api/blade-cps/tray/tooling-tree`, {
                 groupCategory: 1,
@@ -166,17 +400,56 @@
             //     this.info = res.data
             // })
         },
-        queryChildInfo() {
-            if (!this.selectNode.id) return
-            this.$HTTP.get(`/api/blade-cps/tray/${this.selectNode.id}`).then(res => {
+        dataChange(res, data) {
+            data?.[0] && this.rowClick(data?.[0])
+        },
+        rowClick(row) {
+            console.log(row.id)
+            this.queryChildInfo(row.id)
+        },
+        async queryChildInfo(id) {
+            if (!id) return
+            this.showLoading = true
+            await this.$HTTP.get(`/api/blade-cps/tray/${id}`).then(res => {
                 this.info = res.data
             })
-            this.$HTTP.get(`/api/blade-cps/tray-surface/list/${this.selectNode.id}`).then(res => {
-                this.info = res.data
+            await this.$HTTP.get(`/api/blade-cps/tray-surface/list/${id}`).then(res => {
+                this.infoList = res.data
             })
+            this.showLoading = false
         },
         nodeClick(node) {
             this.selectNode = node
+        },
+        addTray() {
+            this.form = {
+                trayId: this.info.id
+            }
+            this.visible = true
+        },
+        table_edit1(row) {
+            this.form = {
+                ...row
+            }
+            this.visible = true
+        },
+        table_del1(row) {
+            this.$HTTP.delete(`/api/blade-cps/tray-surface/remove-face/${this.info.id}?faceId=${row.id}`).then(res => {
+                this.$message.success('鎿嶄綔鎴愬姛')
+                this.queryChildInfo(this.info.id)
+            })
+        },
+        saveTray() {
+            if (this.form.id) {
+                return this.$HTTP.put(`/api/blade-cps/tray-surface/update`, this.form).then(res => {
+                    this.visible = false
+                    this.queryChildInfo(this.info.id)
+                })
+            }
+            this.$HTTP.post(`/api/blade-cps/tray-surface/save`, this.form).then(res => {
+                this.visible = false
+                this.queryChildInfo(this.info.id)
+            })
         }
     }
 }
@@ -187,6 +460,21 @@
     color: #ccc;
 }
 
+.custom-tree-node {
+    width: 100%;
+    display: flex;
+
+    .icon {
+        visibility: hidden;
+    }
+}
+
+.custom-tree-node:hover {
+    .icon {
+        visibility: visible;
+    }
+}
+
 .empty {
     justify-content: center;
 }

--
Gitblit v1.9.3