From 78bdb5114382f006fb53fd461c7b90f4f43afc39 Mon Sep 17 00:00:00 2001
From: “linengliang” <vanSuperEnergy@163.com>
Date: 星期二, 29 八月 2023 11:59:30 +0800
Subject: [PATCH] 设备分类

---
 src/views/eam/modules/equipmentCategory/EquipmentCategory2List.vue |   76 +++++++---
 src/views/eam/modules/equipmentCategory/EquipmentCategoryLeft.vue  |   84 +++++++++++
 src/views/eam/modules/equipmentCategory/EquipmentCategoryModel.vue |  240 ++++++++++++++++++++++++++++++++-
 3 files changed, 361 insertions(+), 39 deletions(-)

diff --git a/src/views/eam/modules/equipmentCategory/EquipmentCategory2List.vue b/src/views/eam/modules/equipmentCategory/EquipmentCategory2List.vue
index 370a5a9..fe67830 100644
--- a/src/views/eam/modules/equipmentCategory/EquipmentCategory2List.vue
+++ b/src/views/eam/modules/equipmentCategory/EquipmentCategory2List.vue
@@ -58,15 +58,15 @@
         @click="searchReset"
         icon="reload"
       >閲嶇疆</a-button>
-      <a-button
+      <!-- <a-button
         @click="handleAdd"
         type="primary"
         icon="plus"
-      >鏂板</a-button>
+      >鏂板</a-button> -->
       <a-button
         type="primary"
         icon="download"
-        @click="handleExportXls('宸ュ巶')"
+        @click="handleExportXls('璁惧鍒嗙被鎶ヨ〃')"
       >瀵煎嚭</a-button>
       <a-dropdown v-if="selectedRowKeys.length > 0">
         <a-button style="margin-left: 8px">
@@ -92,7 +92,7 @@
       :loading="loading"
       :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, getCheckboxProps:getCheckboxProps}"
       @change="handleTableChange"
-      :scroll="{ x: 'calc(1200px + 50%)', y: 900 }"
+      :scroll="{ x: true, y: 900 }"
     >
 
       <!--鐘舵�佹爮涓�у睍绀�-->
@@ -134,9 +134,9 @@
             <a-icon type="down" />
           </a>
           <a-menu slot="overlay">
-            <a-menu-item>
+            <!-- <a-menu-item>
               <a @click="handleEdit(record)">缂栬緫</a>
-            </a-menu-item>
+            </a-menu-item> -->
 
             <a-menu-item v-if="record.equipmentCategoryDtlList.length==0">
               <a-popconfirm
@@ -173,10 +173,10 @@
       </span>
 
     </a-table>
-    <equipment-category-model
+    <!-- <equipment-category-model
       ref="modalForm"
       @ok="modalFormOk"
-    ></equipment-category-model>
+    ></equipment-category-model> -->
   </a-card>
 </template>
 
@@ -191,7 +191,7 @@
   name: 'EquipmentCategory2List.',
   mixins: [JeecgListMixin],
   components: {
-    EquipmentCategoryModel,
+    // EquipmentCategoryModel,
     JInput,
     JEllipsis,
   },
@@ -236,43 +236,71 @@
           dataIndex: 'parentName',
         }, */
         {
-          title: '璁惧鍒嗙被缂栫爜',
+          title: '鍒嗙被缂栫爜',
           align: "center",
           dataIndex: 'num',
+          width: 200 ,
           // scopedSlots: {
           //   customRender: 'num',
           // },
           // sorter: true,
         },
         {
-          title: '璁惧鍒嗙被鍚嶇О',
+          title: '鍒嗙被鍚嶇О',
 
           align: "center",
           dataIndex: 'name',
+          width: 200 ,
           // scopedSlots: {
           //   customRender: 'name',
           // },
           // sorter: true,
         },
         {
+          title: '鍒嗙被鏍囪瘑',
+
+          align: "center",
+          dataIndex: 'equipmentCategoryUda1_dictText',
+          // scopedSlots: {
+          //   customRender: 'name',
+          // },
+          // sorter: true,
+          width: 200 ,
+        },
+        {
+          title: '鎶�鏈姸鎬侀壌瀹氬懆鏈�',
+
+          align: "center",
+          dataIndex: 'equipmentCategoryUda2_dictText',
+          // scopedSlots: {
+          //   customRender: 'name',
+          // },
+          // sorter: true,
+          width: 200 ,
+        },
+        {
           title: '鍒涘缓浜�',
           align: "center",
           dataIndex: 'createBy',
+          width: 200 ,
         },
         {
           title: '鍒涘缓鏃堕棿',
           align: "center",
           dataIndex: 'createTime',
+          width: 200 ,
         },
         {
           title: '淇敼浜�',
           align: "center",
           dataIndex: 'updateBy',
+          width: 200 ,
         },
         {
           title: '淇敼鏃堕棿',
           align: "center",
           dataIndex: 'updateTime',
+          width: 200 ,
         },
 
         // {
@@ -285,16 +313,14 @@
         //   sorter: true,
         //   width: 100,
         // },
-        {
-          title: '鎿嶄綔',
-          align: "center",
-          dataIndex: 'action',
-          scopedSlots: {
-            customRender: 'action',
-          },
-          width: 150,
-          fixed: 'right',
-        },
+        // {
+        //   title: '鎿嶄綔',
+        //   align: "center",
+        //   dataIndex: 'action',
+        //   scopedSlots: {
+        //     customRender: 'action',
+        //   },
+        // },
       ],
       url: {
         list: "/eam/equipmentCategory/list",
@@ -424,8 +450,12 @@
     this.queryParam = {};
     this.queryParam.id = this.nodeSelected.key;
     this.loadData(1);
-  }
-
+  },
+  mounted() {
+    this.$bus.$on('loadData', (data) => {
+      this.loadData();
+    })
+  },
 
 }
 </script>
diff --git a/src/views/eam/modules/equipmentCategory/EquipmentCategoryLeft.vue b/src/views/eam/modules/equipmentCategory/EquipmentCategoryLeft.vue
index cbe5b81..d0bf837 100644
--- a/src/views/eam/modules/equipmentCategory/EquipmentCategoryLeft.vue
+++ b/src/views/eam/modules/equipmentCategory/EquipmentCategoryLeft.vue
@@ -66,7 +66,51 @@
         @select="onSelect"
         @expand="onExpand"
       >
+      <template
+          slot="title"
+          slot-scope="{key,entity,title,leaf}"
+        >
+        <span>{{ title }}</span>
+          <a-dropdown
+            v-if="entity"
+            :trigger="['click']"
+            placement="bottomCenter"
+          >
+            <a-menu slot="overlay">
+              <a-menu-item v-if="key!=-1">
+                <a
+                  href="javascript:;"
+                  @click="handleEdit(entity)"
+                >缂栬緫</a>
+              </a-menu-item>
+              <a-menu-item>
+                <a
+                  href="javascript:;"
+                  @click="handleAdd(entity)"
+                >
+               娣诲姞瀛愮被鍒�
+                </a>
+              </a-menu-item>
+              <a-menu-item v-if="key!=-1&&leaf">
+                <a-popconfirm
+                  title="纭畾鍒犻櫎鍚�?"
+                  @confirm="() => handleDelete(entity.id)"
+                >
+                  <a>鍒犻櫎</a>
+                </a-popconfirm>
+              </a-menu-item>
+            </a-menu>
+            <span :style="{position: 'absolute',right: 0}">
+              <a-icon type="down" />
+            </span>
+          </a-dropdown>
+        </template>
       </a-tree>
+      <equipment-category-model
+      ref="modalForm"
+      @ok="modalFormOk"
+      :mainId="mainId"
+    ></equipment-category-model>
     </a-spin>
   </a-card>
 </template>
@@ -75,24 +119,33 @@
 import { getAction } from '@/api/manage'
 import Tooltip from 'ant-design-vue/es/tooltip'
 import JEllipsis from "@/components/jeecg/JEllipsis"
+import EquipmentCategoryModel from './EquipmentCategoryModel'
+import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+import { deleteAction } from '../../../../api/manage'
 
 export default {
   name: 'EquipmentCategoryLeft',
+  mixins: [JeecgListMixin],
   components: {
     Tooltip,
-    JEllipsis
+    JEllipsis,
+    EquipmentCategoryModel,
   },
   props: ['value'],
   data() {
     return {
       searchInput: '',
+      disableMixinCreated:true,
       cardLoading: false,
       loading: false,
       treeDataSource: [],
       selectedKeys: [],
       expandedKeys: [],
+      mainId:'',
       url: {
-        equipmentCategoryTreeList: '/eam/equipmentCategory/loadTree'
+        equipmentCategoryTreeList: '/eam/equipmentCategory/loadTree',
+        delete: "/eam/equipmentCategory/delete",
+        list: "/eam/equipmentCategory/getAllChildren",
       },
       searchValue: '',
       dataList: [],
@@ -111,6 +164,12 @@
     getCurrSelectedTitle() {
       return !this.currSelected.title ? '' : this.currSelected.title;
     },
+    handleAdd: function (record) {
+      this.$refs.modalForm.add({ parentNum: record.num, parentName: record.name });
+      this.$refs.modalForm.title = "鏂板";
+      this.$refs.modalForm.disableSubmit = false;
+      this.$refs.modalForm.parentId = record.id;
+    },
     onClearSelected() {
       this.hiding = true;
       this.currSelected = {};
@@ -121,6 +180,7 @@
       let record = e.node.dataRef;
       this.currSelected = Object.assign({}, record);
       this.selectedKeys = [record.key];
+      this.mainId = record.key;
     },
     onExpand(expandedKeys) {
       this.expandedKeys = expandedKeys;
@@ -190,7 +250,25 @@
       }
       return parentKey;
     },
-
+    handleDelete(id) {
+      if (!this.url.delete) {
+        this.$message.error("璇疯缃畊rl.delete灞炴��!")
+        return
+      }
+      var that = this;
+      deleteAction(that.url.delete, { id: id }).then((res) => {
+        if (res.success) {
+          //閲嶆柊璁$畻鍒嗛〉闂
+          that.reCalculatePage(1)
+          that.$message.success(res.message);
+          that.queryTreeData();
+          that.$bus.$emit('loadData')
+          that.alterFlag = new Date();
+        } else {
+          that.$message.warning(res.message);
+        }
+      });
+    },
     generateList(data) {
       for (let i = 0; i < data.length; i++) {
         const node = data[i];
diff --git a/src/views/eam/modules/equipmentCategory/EquipmentCategoryModel.vue b/src/views/eam/modules/equipmentCategory/EquipmentCategoryModel.vue
index b5a207e..b4a26f0 100644
--- a/src/views/eam/modules/equipmentCategory/EquipmentCategoryModel.vue
+++ b/src/views/eam/modules/equipmentCategory/EquipmentCategoryModel.vue
@@ -1,7 +1,7 @@
 <template>
   <a-modal
     :title="title"
-    :width="1050"
+    :width="1250"
     :visible="visible"
     :maskClosable="false"
     :confirmLoading="confirmLoading"
@@ -46,7 +46,7 @@
         </a-row>-->
 
         <a-row :gutter="24">
-          <a-col :span="12">
+          <a-col :span="24">
             <a-form-item
               label="璁惧鍒嗙被缂栧彿"
               :labelCol="labelCol"
@@ -60,7 +60,9 @@
               />
             </a-form-item>
           </a-col>
-          <a-col :span="12">
+        </a-row>
+        <a-row :gutter="24" v-if="parentId!='-1'">
+          <a-col :span="24">
             <a-form-item
               label="璁惧鍒嗙被鍚嶇О"
               :labelCol="labelCol"
@@ -75,12 +77,66 @@
             </a-form-item>
           </a-col>
         </a-row>
-
+       <a-row :gutter="24" v-if="parentId=='-1'">
+          <a-col :span="24">
+            <a-form-item
+              label="璁惧鍒嗙被鍚嶇О"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+            >
+            <j-dict-select-tag
+                allow-clear
+                :disabled="disableSubmit"
+                :placeholder="disableSubmit?'':'璇烽�夋嫨鍒嗙被鍚嶇О'"
+                :triggerChange="true"
+                dictCode="sys_dict_item,item_text,item_text,dict_id ='1695985281980776449'"
+                v-decorator="['name', validatorRules.name ]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        
         <a-row :gutter="24">
           <a-col :span="24">
             <a-form-item
-              :labelCol="{span:3}"
-              :wrapperCol="{span:21}"
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鍒嗙被鏍囪瘑"
+            >
+              <j-dict-select-tag
+                allow-clear
+                :disabled="disableSubmit"
+                :placeholder="disableSubmit?'':'璇烽�夋嫨鍒嗙被鏍囪瘑'"
+                :triggerChange="true"
+                dictCode="equipment_category"
+                v-decorator="['equipmentCategoryUda1', validatorRules.equipmentCategoryUda1]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鎶�鏈姸鎬侀壌瀹氬懆鏈�"
+            >
+            <j-dict-select-tag
+                allow-clear
+                :disabled="disableSubmit"
+                :placeholder="disableSubmit?'':'璇烽�夋嫨鎶�鏈姸鎬侀壌瀹氬懆鏈�'"
+                :triggerChange="true"
+                dictCode="appraisal_cycle"
+                v-decorator="['equipmentCategoryUda2', validatorRules.equipmentCategoryUda2]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
               label="澶囨敞"
             >
               <a-textarea
@@ -92,8 +148,39 @@
             </a-form-item>
           </a-col>
         </a-row>
-
+        
       </a-form>
+      <a-divider  v-if="title!='鏂板'" orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 閫夋嫨瀛愯澶囧垎绫讳娇鍏惰窡闅忕埗璁惧鍒嗙被灞炴�� </a-divider>
+      <a-tabs
+        type="card"
+        defaultActiveKey="1"
+        v-if="title!='鏂板'"
+      >
+      <a-tab-pane
+          tab='瀛愯澶囧垎绫�'
+          key='1'
+          
+        >
+      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
+        <i class="anticon anticon-info-circle ant-alert-icon"></i> 宸查�夋嫨 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>椤�
+        <a style="margin-left: 24px" @click="onClearSelected">娓呯┖</a>
+      </div>
+      <a-table
+      ref="table"
+      bordered
+      size="middle"
+      rowKey="id"
+      :columns="columns"
+      :dataSource="dataSource"
+      :pagination="ipagination"
+      :loading="loading"
+      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
+      @change="handleTableChange"
+      :scroll="{ x: true, y: 900 }"
+     ></a-table>
+    </a-tab-pane>
+    </a-tabs>
+    
     </a-spin>
 
     <template slot="footer">
@@ -126,9 +213,19 @@
 import pick from 'lodash.pick'
 import { postAction, requestPut } from '@/api/manage'
 import { duplicateCheck } from '@/api/api'
+import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+
 
 export default {
   name: 'EquipmentCategoryModel',
+  mixins:[JeecgListMixin],
+  props:{
+    mainId:{
+        type:String,
+        default:'',
+        required:false
+    },
+  },
   data() {
     return {
       title: "鎿嶄綔",
@@ -138,12 +235,10 @@
       parentId: '',
       model: {},
       labelCol: {
-        xs: { span: 24 },
-        sm: { span: 6 },
+        span:3
       },
       wrapperCol: {
-        xs: { span: 24 },
-        sm: { span: 18 },
+        span:21
       },
       confirmLoading: false,
       form: this.$form.createForm(this),
@@ -162,16 +257,109 @@
             { validator: this.validateName },
           ]
         },
+        equipmentCategoryUda1:{
+          rules: [
+            { required: true, message: '璇烽�夋嫨绫诲埆鏍囪瘑!' },
+          ]
+        },
         remark: {
           rules: [
             { min: 0, max: 100, message: '闀垮害涓嶈秴杩� 100 涓瓧绗�', trigger: 'blur' },
+          ]
+        },
+        equipmentCategoryUda2:{
+          rules: [
+            { required: true, message: '璇烽�夋嫨鎶�鏈姸鎬侀壌瀹氬懆鏈�!' },
           ]
         }
       },
       url: {
         add: "/eam/equipmentCategory/add",
-        edit: "/eam/equipmentCategory/edit"
+        edit: "/eam/equipmentCategory/edit",
+        list:"/eam/equipmentCategory/getAllChildren"
       },
+      columns: [
+        {
+          title: '#',
+          dataIndex: '',
+          key: 'rowIndex',
+          align: 'center',
+          customRender: function (t, r, index) {
+            return parseInt(index) + 1
+          },
+          width: 50,
+        },
+      /*   {
+          title: '涓婄骇璁惧鍒嗙被缂栫爜',
+          align: "center",
+          dataIndex: 'parentNum',
+          customRender:function(text, record){
+              return record.parentName+text;
+            }
+          },
+
+        {
+          title: '涓婄骇璁惧鍒嗙被鍚嶇О',
+          align: "center",
+          dataIndex: 'parentName',
+        }, */
+        {
+          title: '鍒嗙被缂栫爜',
+          align: "center",
+          dataIndex: 'num',
+          width: 220,
+          // scopedSlots: {
+          //   customRender: 'num',
+          // },
+          // sorter: true,
+        },
+        {
+          title: '鍒嗙被鍚嶇О',
+
+          align: "center",
+          dataIndex: 'name',
+          width: 220,
+          // scopedSlots: {
+          //   customRender: 'name',
+          // },
+          // sorter: true,
+        },
+        {
+          title: '鍒嗙被鏍囪瘑',
+
+          align: "center",
+          dataIndex: 'equipmentCategoryUda1_dictText',
+          // scopedSlots: {
+          //   customRender: 'name',
+          // },
+          // sorter: true,
+          width: 220,
+        },
+        {
+          title: '鍒涘缓浜�',
+          align: "center",
+          dataIndex: 'createBy',
+          width: 220,
+        },
+        {
+          title: '鍒涘缓鏃堕棿',
+          align: "center",
+          dataIndex: 'createTime',
+          width: 220,
+        },
+        {
+          title: '淇敼浜�',
+          align: "center",
+          dataIndex: 'updateBy',
+          width: 220,
+        },
+        {
+          title: '淇敼鏃堕棿',
+          align: "center",
+          dataIndex: 'updateTime',
+          width: 220,
+        },
+      ],
       //鏂板銆佺紪杈戙�佸垹闄ゃ�佹壒閲忓垹闄ゆ搷浣滄敼鍙樻暟鎹悗鍒锋柊鍏宠仈鐨勭粍浠剁殑鐩戝惉灞炴��
       alterFlag: ""
     }
@@ -190,7 +378,7 @@
       this.visible = true;
       this.disableSubmit = false;
       this.$nextTick(() => {
-        this.form.setFieldsValue(pick(this.model, 'parentNum', 'parentName', 'num', 'name', 'remark'))
+        this.form.setFieldsValue(pick(this.model, 'parentNum','equipmentCategoryUda1','equipmentCategoryUda2', 'parentName', 'num', 'name', 'remark'))
       });
       if (record.id) {
         this.codeDisable = true;
@@ -202,6 +390,14 @@
     close() {
       this.$emit('close');
       this.visible = false;
+    },
+    onSelectChange(selectedRowKeys, selectionRows) {
+        this.selectedRowKeys = selectedRowKeys;
+        this.selectionRows = selectionRows;
+    },
+    onClearSelected() {
+        this.selectedRowKeys = [];
+        this.selectionRows = [];
     },
 
     //淇濆瓨骞舵柊澧炴寜閽Е鍙�
@@ -244,6 +440,7 @@
             formData.parentId = this.parentId
             obj = postAction(this.url.add, formData);
           } else {
+            formData.equipmentCategoryDtlList = this.selectionRows;
             obj = requestPut(this.url.edit, formData, { id: this.model.id });
           }
           obj.then((res) => {
@@ -256,6 +453,7 @@
             }
           }).finally(() => {
             that.confirmLoading = false;
+            that.$bus.$emit('loadData')
             that.close();
           })
         }
@@ -303,12 +501,28 @@
         }
       })
     },
+    clearList(){
+        this.dataSource=[]
+        this.selectedRowKeys=[]
+        this.ipagination.current = 1
+    }
 
   },
   watch: {
     alterFlag() {
       this.$bus.$emit('queryTreeData');
     },
+    mainId:{
+       immediate:true,
+       handler(val) {
+          if(!this.mainId){
+            this.clearList()
+          }else{
+            this.queryParam['parentId'] = val
+            this.loadData(1);
+          }
+        }
+     },
   }
 }
 </script>

--
Gitblit v1.9.3