From fd307873b67f5a71817fe54226b2a104b6081d48 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期六, 16 八月 2025 23:20:06 +0800
Subject: [PATCH] 修改文字

---
 src/views/basesetting/machine.vue |  319 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 229 insertions(+), 90 deletions(-)

diff --git a/src/views/basesetting/machine.vue b/src/views/basesetting/machine.vue
index 21e1c63..41711d1 100644
--- a/src/views/basesetting/machine.vue
+++ b/src/views/basesetting/machine.vue
@@ -1,40 +1,66 @@
 <template>
-  <basic-container>
-    <avue-crud
-      :addBtn="false"
-      :option="option"
-      :table-loading="loading"
-      :data="data"
-      ref="crud"
-      v-model:search="search"
-      v-model:page="mypage"
-      @search-change="searchChange"
-      @search-reset="searchReset"
-      @current-change="currentChange"
-      @size-change="sizeChange"
-      @refresh-change="refreshChange"
-      @on-load="onLoad"
-    >
-      <template #menu-left>
-        <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">瀵煎嚭</el-button>
-        <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleView">瀵煎叆</el-button>
-        <!-- <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleAdd">鏂板</el-button> -->
-      </template>
-      <template #menu="scope">
-        <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleEdit(scope.row, scope.index)">缂栬緫</el-button>
-        <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleDel(scope.row, scope.index)">鍒犻櫎</el-button>
-        <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleView(scope.row, scope.index)">浜х敓鏈哄簥鍥炰紶鏈烘瀯鏍�</el-button>
-      </template>
+  <el-row>
+    <el-col :span="5">
+      <div class="box">
+        <el-scrollbar>
+          <basic-container>
+            <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
+          </basic-container>
+        </el-scrollbar>
+      </div>
+    </el-col>
+    <el-col :span="19">
+      <basic-container>
+        <avue-crud
+          :addBtn="false"
+          :option="option"
+          :table-loading="loading"
+          :data="data"
+          ref="crud"
+          v-model:search="search"
+          v-model:page="mypage"
+          @search-change="searchChange"
+          @search-reset="searchReset"
+          @current-change="currentChange"
+          @size-change="sizeChange"
+          @refresh-change="refreshChange"
+          @on-load="onLoad"
+        >
+          <template #menu-left>
+            <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">瀵煎嚭</el-button>
 
-      <template #status="{ row }">
-        <span>{{ row.status=="1"?"鍚敤":"绂佺敤" }}</span>
-      </template>
-    </avue-crud>
 
-    <el-dialog :title="machineTitle" append-to-body v-model="editBox" width="60%">
-      <avue-form ref="editFormModal1" :option="editFormModal" v-model="editForm" @submit="formSubmit" @resetForm="resetForm"/>
-    </el-dialog>
-  </basic-container>
+            <el-upload :show-file-list="false" class="upload-demo"
+                action="/api/blade-mdm/machine/import"
+                       :on-change="handleChange">
+              <el-button type="primary" plain size="default">瀵煎叆</el-button>
+            </el-upload>
+
+
+
+            <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleAdd">鏂板</el-button>
+          </template>
+          <template #menu="scope">
+            <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleEdit(scope.row, scope.index)">缂栬緫</el-button>
+            <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleDel(scope.row, scope.index)">鍒犻櫎</el-button>
+            <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleUp(scope.row, scope.index)">浜х敓鏈哄簥鍥炰紶鏈烘瀯鏍�</el-button>
+          </template>
+
+          <template #status="{ row }">
+            <span>{{ row.status=="1"?"鍚敤":"绂佺敤" }}</span>
+          </template>
+        </avue-crud>
+
+        <el-dialog :title="machineTitle" append-to-body v-model="editBox" width="60%">
+          <avue-form ref="editFormModal1" :option="editFormModal" v-model="editForm" @submit="formSubmit" @resetForm="resetForm">
+            <template #ownerDept="{}">
+              <el-tree-select v-model="editForm.ownerDept" :data="organizationTreeList" :props="treePropsConfig"/>
+            </template>
+          </avue-form>
+        </el-dialog>
+      </basic-container>
+    </el-col>
+  </el-row>
 </template>
 
 <script>
@@ -43,10 +69,44 @@
 import NProgress from 'nprogress';
 import { downloadXls } from '@/utils/util';
 import 'nprogress/nprogress.css';
+import { getDeptLazyTree } from '@/api/system/dept';
 export default {
   data() {
     var that = this;
     return {
+      treeOption: {
+        nodeKey: 'id',
+        lazy: true,
+        treeLoad: function (node, resolve) {
+          const parentId = node.level === 0 ? 0 : node.data.id;
+          getDeptLazyTree(parentId).then(res => {
+            resolve(
+              res.data.data.map(item => {
+                return {
+                  ...item,
+                  leaf: !item.hasChildren,
+                };
+              })
+            );
+          });
+        },
+        addBtn: false,
+        menu: false,
+        size: 'small',
+        props: {
+          labelText: '鏍囬',
+          label: 'title',
+          value: 'value',
+          children: 'children',
+        },
+      },
+      treeData: [],
+      treePropsConfig: {
+        value:  'id',
+        label: 'title',
+        children: 'children'
+      },
+      organizationTreeList: [],
       machineTitle: "鏂板",
       isAdd: true,
       editBox: false,
@@ -75,7 +135,8 @@
             type: 'input',
             prop: 'keyword',
             search: true,
-            hide: true
+            hide: true,
+            showColumn: false
           },
           {
             label: '鏈哄簥缂栧彿',
@@ -128,6 +189,13 @@
             type: 'input',
             span: 12,
             dataType: 'string',
+            rules: [
+              {
+                required: true,
+                message: '璇疯緭鍏ユ満搴婄紪鍙�',
+                trigger: 'blur'
+              }
+            ]
           },
           {
             label: '鏈哄簥鍨嬪彿',
@@ -135,6 +203,13 @@
             type: 'input',
             span: 12,
             dataType: 'string',
+            rules: [
+              {
+                required: true,
+                message: '璇疯緭鍏ユ満搴婂瀷鍙�',
+                trigger: 'blur'
+              }
+            ]
           },
           {
             label: '鏈哄簥绫诲瀷',
@@ -145,7 +220,14 @@
             props: {
               label: 'dictValue',
               value: 'dictKey',
-            }
+            },
+            rules: [
+              {
+                required: true,
+                message: '璇烽�夋嫨鏈哄簥绫诲瀷',
+                trigger: 'change'
+              }
+            ]
           },
           {
             label: '鎵�灞炴満搴婄粍',
@@ -156,7 +238,14 @@
             props: {
               label: 'dictValue',
               value: 'dictKey',
-            }
+            },
+            rules: [
+              {
+                required: true,
+                message: '璇烽�夋嫨鎵�灞炴満搴婄粍',
+                trigger: 'change'
+              }
+            ]
           },
           {
             label: '鎿嶄綔鍛�',
@@ -170,22 +259,17 @@
             prop: 'ownerDept',
             type: 'tree',
             span: 12,
-            props: {
-              label: 'deptName',
-              value: 'id'
-            },
-            dicUrl: `/blade-system/dept/lazy-list`
+            rules: [
+              {
+                required: true,
+                message: '璇烽�夋嫨鎵�灞炵粍缁�',
+                trigger: 'click'
+              }
+            ]
           },
           {
             label: '鐢熶骇鍟�',
             prop: 'manufacturer',
-            type: 'input',
-            span: 12,
-            dataType: 'string',
-          },
-          {
-            label: '杞鏃堕棿锛堝皬鏃讹級',
-            prop: 'pollingHours',
             type: 'input',
             span: 12,
             dataType: 'string',
@@ -225,6 +309,13 @@
             span: 12,
             dataType: 'string',
           },
+		  {
+            label: '绋嬪簭涓存椂鐩綍',
+            prop: 'progTempDir',
+            type: 'input',
+            span: 12,
+            dataType: 'string',
+          },
           {
             label: '澶囨敞',
             prop: 'remark',
@@ -238,6 +329,14 @@
     };
   },
   methods: {
+    handleChange(a,b,c) {
+      console.log(a,b,c);
+    },
+    nodeClick(data) {
+      this.treeDeptId = data.id;
+      this.mypage.current = 1;
+      this.onLoad(this.page);
+    },
     handleAdd() {
       this.machineTitle = "鏂板";
       this.isAdd = true;
@@ -258,7 +357,7 @@
           this.editBox = true;
         },
         error => {
-            
+          this.loading = false;
         }
       );
     },
@@ -279,7 +378,28 @@
           done();
         },
         error => {
-            
+          this.loading = false;
+        }
+      );
+    },
+    handleUp(row,index) {
+      this.loading = true;
+      axios({
+        url: '/blade-mdm/machine/gen-fileback-dirs',
+        method: 'post',
+        params: {id: row.id},
+      }).then(
+        res => {
+          this.loading = false;
+          this.$message({
+            type: 'success',
+            message: '鎿嶄綔鎴愬姛!',
+          });
+          this.onLoad();
+          done();
+        },
+        error => {
+          this.loading = false;
         }
       );
     },
@@ -311,25 +431,17 @@
         var url = '/blade-mdm/machine/update';
       }
       this.loading = true;
-      axios({
-        url: url,
-        method: 'post',
-        data: obj,
-      }).then(
-        res => {
-          this.loading = false;
-          this.$message({
-            type: 'success',
-            message: '鎿嶄綔鎴愬姛!',
-          });
+      axios({url: url,method: 'post',data: obj}).then(res => {
+        this.loading = false;
+        if(res,res.data.success) {
           this.editBox = false;
+          this.$message({type: 'success',message: '鎿嶄綔鎴愬姛!'});
           this.onLoad();
-          done();
-        },
-        error => {
-            
+        }else {
+          this.$message({type: 'error',message: res.data.msg});
         }
-      );
+        done();
+      });
     },
     handleView() {
 
@@ -352,34 +464,61 @@
       
     },
     onLoad() {
-      this.loading = true;
-      var obj = {
-        keyword: this.search.keyword,
-        machineGroupCode: this.search.machineGroupCode,
-        current: this.mypage.current,
-        size: this.mypage.size,
-      }
-      axios({
-        url: '/blade-mdm/machine/page',
-        method: 'get',
-        date: obj,
-      }).then(
-        res => {
-          const data = res.data.data;
-          this.mypage.total = data.total;
-          this.data = data.records;
-          this.loading = false;
-        },
-        error => {
-            
+      this.$nextTick(()=> {
+        this.loading = true;
+        var obj = {
+          keyword: this.search.keyword,
+          machineGroupCode: this.search.machineGroupName,
+          current: this.mypage.current,
+          size: this.mypage.size,
+          deptId: this.treeDeptId
         }
-      );
-
+        axios({
+          url: '/blade-mdm/machine/page',
+          method: 'get',
+          params: obj,
+        }).then(
+          res => {
+            const data = res.data.data;
+            this.mypage.total = data.total;
+            this.data = data.records;
+            this.loading = false;
+          },
+          error => {
+              
+          }
+        );
+      })
+    },
+    traversalLabelValueToTree(tree) {  //閬嶅巻鏁扮粍
+      return tree.map(node => {
+        // 1. 娣诲姞 label 鍜� value 瀛楁
+        const newNode = {
+          ...node,
+          label: node.fullName,
+          value: node.id,
+        };
+        // 2. 濡傛灉鏈� children锛岄�掑綊澶勭悊
+        if (node.children && node.children.length > 0) {
+          newNode.children = this.traversalLabelValueToTree(node.children);
+        }
+        return newNode;
+      });
     }
   },
+  mounted() { 
+    //鎵�灞炵粍缁� /api/blade-system/dept/tree
+    axios({url: '/blade-system/dept/tree',method: 'get'}).then(resp => {
+      this.organizationTreeList = this.traversalLabelValueToTree(resp.data.data);
+    })
+  }
 };
 </script>
 
 <style lang="scss">
-
+.upload-demo {
+  display: inline-block;
+  margin-left: 6px;
+  margin-right: 6px;
+}
 </style>

--
Gitblit v1.9.3