From 57c746aa1c682d96465b3fe5d2f95eeb1ed2c4c1 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期三, 09 七月 2025 19:54:01 +0800
Subject: [PATCH] art: 技术状态鉴定-基础代码生成

---
 src/components/jeecgbiz/modal/JSelectBaseFactoryModal.vue |  294 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 294 insertions(+), 0 deletions(-)

diff --git a/src/components/jeecgbiz/modal/JSelectBaseFactoryModal.vue b/src/components/jeecgbiz/modal/JSelectBaseFactoryModal.vue
new file mode 100644
index 0000000..2e839c9
--- /dev/null
+++ b/src/components/jeecgbiz/modal/JSelectBaseFactoryModal.vue
@@ -0,0 +1,294 @@
+<template>
+  <j-modal
+    title="璇风偣鍑婚�夋嫨EAM涓績"
+    :width="modalWidth"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @ok="handleSubmit"
+    @cancel="handleCancel"
+    @update:fullscreen="isFullscreen"
+    wrapClassName="j-repair-depart-select-modal"
+    switchFullscreen
+    cancelText="鍏抽棴">
+    <a-spin tip="Loading..." :spinning="false">
+      <a-input-search style="margin-bottom: 1px" placeholder="璇疯緭鍏ヤ腑蹇�/宸ュ尯/宸ユ鍚嶇О鎸夊洖杞﹁繘琛屾悳绱�" @search="onSearch" />
+      <a-tree
+        checkable
+        :class="treeScreenClass"
+        :treeData="treeData"
+        :checkStrictly="checkStrictly"
+        @check="onCheck"
+        @select="onSelect"
+        @expand="onExpand"
+        :autoExpandParent="autoExpandParent"
+        :expandedKeys="expandedKeys"
+        :checkedKeys="checkedKeys">
+
+        <template slot="title" slot-scope="{title}">
+          <span v-if="title.indexOf(searchValue) > -1">
+            {{title.substr(0, title.indexOf(searchValue))}}
+            <span style="color: #f50">{{searchValue}}</span>
+            {{title.substr(title.indexOf(searchValue) + searchValue.length)}}
+          </span>
+          <span v-else>{{title}}</span>
+        </template>
+      </a-tree>
+    </a-spin>
+  </j-modal>
+</template>
+
+<script>
+import {queryEamCenterTreeList} from '@/api/api'
+  export default {
+    name: 'JSelectBaseFactoryModal',
+    props:['modalWidth','multi','rootOpened','BaseFactoryId', 'store', 'text','treeBaseFactory'],
+    data(){
+      return {
+        visible:false,
+        confirmLoading:false,
+        treeData:[],
+        autoExpandParent:true,
+        expandedKeys:[],
+        dataList:[],
+        checkedKeys:[],
+        checkedRows:[],
+        searchValue:"",
+        checkStrictly: false,
+        fullscreen:false
+      }
+    },
+    created(){
+      this.loadDepart();
+    },
+    watch:{
+      BaseFactoryId(){
+        this.initDepartComponent()
+      },
+      visible: {
+        handler() {
+          this.initDepartComponent(true)
+        }
+      }
+    },
+    computed:{
+      treeScreenClass() {
+        return {
+          'my-dept-select-tree': true,
+          'fullscreen': this.fullscreen,
+        }
+      },
+    },
+    methods:{
+      show(){
+        this.visible=true
+        this.checkedRows=[]
+        this.checkedKeys=[]
+      },
+      loadDepart(){
+        // 杩欎釜鏂规硶鏄壘鍒版墍鏈夌殑閮ㄩ棬淇℃伅
+        queryEamCenterTreeList().then(res=>{
+          if(res.success){
+            let arr = [...res.result]
+            this.reWriterWithSlot(arr)
+            this.treeData = arr
+            this.initDepartComponent()
+            if(this.rootOpened){
+              this.initExpandedKeys(res.result)
+            }
+          }
+        })
+      },
+      initDepartComponent(flag){
+        let arr = []
+        //璇ユ柟娉曚袱涓湴鏂圭敤 1.visible鏀瑰彉浜嬩欢閲嶆柊璁剧疆閫変腑椤� 2.缁勪欢缂栬緫椤甸潰鍥炴樉
+        let fieldName = flag==true?'key':this.text
+        if(this.BaseFactoryId){
+          let arr2 = this.BaseFactoryId.split(',')
+          for(let item of this.dataList){
+            if(arr2.indexOf(item[this.store])>=0){
+              arr.push(item[fieldName])
+            }
+          }
+        }
+        if(flag==true){
+          this.checkedKeys = [...arr]
+        }else{
+          this.$emit("initComp", arr.join(','))
+        }
+      },
+      reWriterWithSlot(arr){
+        for(let item of arr){
+          if(item.children && item.children.length>0){
+            this.reWriterWithSlot(item.children)
+            let temp = Object.assign({},item)
+            temp.children = {}
+            this.dataList.push(temp)
+          }else{
+            this.dataList.push(item)
+            item.scopedSlots={ title: 'title' }
+          }
+        }
+      },
+      initExpandedKeys(arr){
+        if(arr && arr.length>0){
+          let keys = []
+          for(let item of arr){
+            if(item.children && item.children.length>0){
+              keys.push(item.id)
+            }
+          }
+          this.expandedKeys=[...keys]
+          //鍏ㄩ儴keys
+          //this.allTreeKeys = [...keys]
+        }else{
+          this.expandedKeys=[]
+          //this.allTreeKeys = []
+        }
+      },
+      onCheck (checkedKeys,info) {
+        if(!this.multi){
+          let arr = checkedKeys.checked.filter(item => this.checkedKeys.indexOf(item) < 0)
+          this.checkedKeys = [...arr]
+          this.checkedRows = (this.checkedKeys.length === 0) ? [] : [info.node.dataRef]
+        }else{
+          if(this.checkStrictly){
+            this.checkedKeys = checkedKeys.checked
+          }else{
+            this.checkedKeys = checkedKeys
+          }
+          this.checkedRows = this.getCheckedRows(this.checkedKeys)
+        }
+      },
+      onSelect(selectedKeys,info) {
+        //鍙栨秷鍏宠仈鐨勬儏鍐典笅鎵嶈蛋onSelect鐨勯�昏緫
+        if(this.checkStrictly){
+          let keys = []
+          keys.push(selectedKeys[0])
+          if(!this.checkedKeys || this.checkedKeys.length===0 || !this.multi){
+            this.checkedKeys = [...keys]
+            this.checkedRows=[info.node.dataRef]
+          }else{
+            let currKey = info.node.dataRef.key
+            if(this.checkedKeys.indexOf(currKey)>=0){
+              this.checkedKeys = this.checkedKeys.filter(item=> item !==currKey)
+            }else{
+              this.checkedKeys.push(...keys)
+            }
+          }
+          this.checkedRows = this.getCheckedRows(this.checkedKeys)
+        }
+      },
+      onExpand (expandedKeys) {
+        this.expandedKeys = expandedKeys
+        this.autoExpandParent = false
+      },
+      handleSubmit(){
+        if(!this.checkedKeys || this.checkedKeys.length==0){
+          this.$emit("ok",'')
+        }else{
+          let checkRow = this.getCheckedRows(this.checkedKeys)
+          let keyStr = this.checkedKeys.join(",")
+          this.$emit("ok", checkRow, keyStr)
+        }
+        this.handleClear()
+      },
+      handleCancel(){
+        this.handleClear()
+      },
+      handleClear(){
+        this.visible=false
+        this.checkedKeys=[]
+      },
+      getParentKey(currKey,treeData){
+        let parentKey
+        for (let i = 0; i < treeData.length; i++) {
+          const node = treeData[i]
+          if (node.children) {
+            if (node.children.some(item => item.key === currKey)) {
+              parentKey = node.key
+            } else if (this.getParentKey(currKey, node.children)) {
+              parentKey = this.getParentKey(currKey, node.children)
+            }
+          }
+        }
+        return parentKey
+      },
+      onSearch(value){
+        const expandedKeys = this.dataList.map((item) => {
+          if (item.title.indexOf(value) > -1) {
+            return this.getParentKey(item.key,this.treeData)
+          }
+          return null
+        }).filter((item, i, self) => item && self.indexOf(item) === i)
+
+        Object.assign(this, {
+          expandedKeys,
+          searchValue: value,
+          autoExpandParent: true,
+        })
+
+
+      },
+      // 鏍规嵁 checkedKeys 鑾峰彇 rows
+      getCheckedRows(checkedKeys) {
+        const forChildren = (list, key) => {
+          for (let item of list) {
+            if (item.id === key) {
+              return item
+            }
+            if (item.children instanceof Array) {
+              let value = forChildren(item.children, key)
+              if (value != null) {
+                return value
+              }
+            }
+          }
+          return null
+        }
+
+        let rows = []
+        for (let key of checkedKeys) {
+          let row = forChildren(this.treeData, key)
+          if (row != null) {
+            rows.push(row)
+          }
+        }
+        return rows
+      },
+      switchCheckStrictly (v) {
+        if(v==1){
+          this.checkStrictly = false
+        }else if(v==2){
+          this.checkStrictly = true
+        }
+      },
+      isFullscreen(val){
+        this.fullscreen=val
+      }
+    }
+  }
+
+</script>
+
+<style lang="less" scoped>
+// 闄愬埗閮ㄩ棬閫夋嫨鏍戦珮搴︼紝閬垮厤閮ㄩ棬澶鏃剁偣鍑荤‘瀹氫笉渚�
+.my-dept-select-tree{
+  height:350px;
+
+  &.fullscreen{
+    height: calc(100vh - 250px);
+  }
+  overflow-y: scroll;
+}
+.drawer-bootom-button {
+  position: absolute;
+  bottom: 0;
+  width: 100%;
+  border-top: 1px solid #e8e8e8;
+  padding: 10px 16px;
+  text-align: right;
+  left: 0;
+  background: #fff;
+  border-radius: 0 0 2px 2px;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3