Browse Source

Merge branch 'master' of http://git.cc-lotus.info/sckj/mz-cloud

nanMing 2 years ago
parent
commit
0707fb85f0

+ 170 - 0
ruoyi-web/src/components/OrgTreeSel/index.vue

@@ -0,0 +1,170 @@
+<template>
+  <el-button text @click="dialogVisible = true"
+  >{{title}}</el-button
+  >
+  <el-dialog
+      v-model="dialogVisible"
+      title="行政区划选取"
+      width="30%"
+      :before-close="handleClose"
+  >
+    <el-scrollbar wrapClass="scroll-wrap">
+      <el-tree
+          node-key="code"
+          :props="defaultProps"
+          :default-expanded-keys="expands"
+          :expand-on-click-node="false"
+          lazy
+          :load="loadNode"
+          ref="tree"
+          :check-strictly="true"
+          highlight-current
+          @check="checkGroupNode"
+          @node-click="handleNodeClick"
+      />
+    </el-scrollbar>
+    <template #footer>
+      <span class="dialog-footer">
+        <el-button type="primary" @click="dialogVisible = false"
+        >关闭</el-button
+        >
+      </span>
+    </template>
+  </el-dialog>
+</template>
+<script>
+import {defineComponent} from "vue";
+import { ElMessageBox } from 'element-plus'
+import {gettreedata} from "@/api/home";
+import {mapState} from 'vuex'
+export default defineComponent({
+      props:{
+        //是否只显示吉林的数据 true显示吉林省的数据, false显示全国的数据
+        title:{
+          type:String,
+          default:"qubau",
+        },
+        isJl:{
+          type:Boolean,
+          default:true,
+        },
+        isLoad:{
+          type:Boolean,
+          default:true,
+        },
+
+      },
+      data(){
+        return{
+          dialogVisible:false,
+          defaultProps: {
+            childre: 'children',
+            label: 'label',
+            isLeaf: 'leaf',
+          },
+          expands:[],
+          treenode:[],
+          resolve:{},
+
+        }
+      },
+      computed: {
+        ...mapState(['user']),
+      },
+      methods:{
+        updatetree()
+        {
+          if (this.treenode) {
+            this.treenode.childNodes = [] // 清空子节点
+            this.loadNode(this.treenode, this.resolve) // 再次执行 load 的方法
+          }
+        },
+        treeClear(){
+          console.log('重置了');
+          this.$refs.tree.setCheckedKeys([]);
+        },
+        check (data, checked, indeterminate) {
+          this.$refs.tree.setCheckedKeys([data.id])
+        },
+        handleNodeClick(data,node,root) {
+          let retdata=[];
+          retdata.push(node.data);
+          let pp=node.parent;
+          while (pp)
+          {
+            retdata.push(pp.data);
+            pp=pp.parent;
+          }
+          this.$emit('handleNodeClick',retdata);
+          this.dialogVisible = false;
+        },
+        checkGroupNode(a, b){
+          if (b.checkedKeys.length > 0) {
+            this.$refs.tree.setCheckedKeys([a.id]);
+            this.$emit('handleNodeClick',a)
+          }else {
+            this.$emit('handleNodeClick',{code:null})
+          }
+        },
+        async getdata(level, cs2, cs3, resolve) {
+
+          var para = {};
+          para.dictType = "xzqhall";
+          para.outType = '0';
+          para.para1 = level;
+          para.para2 = cs2;
+          para.para3 = cs3;
+          let data = await gettreedata(para);
+          var treedata = [];
+          if (data.code == 200) {
+            for (let i = 0; i < data.data[0].recordCount; i++) {
+              treedata[i] = {};
+              for (let j = 0; j < data.data[0].columnLabelList.length; j++) {
+                treedata[i][data.data[0].columnLabelList[j].toLowerCase()] = data.data[0].rowList[i][j];
+              }
+            }
+            ;
+            treedata.forEach((item) => {
+              item.isleaf == '0' ? (item.leaf = false) : (item.leaf = true)
+            })
+            resolve(treedata);
+
+          }
+        },
+        async loadNode(node, resolve) {
+
+          if (node.level === 0) {
+            this.treenode=node;
+            this.resolve=resolve;
+            // if (this.isLoad==false) return ;
+            return this.getdata(node.level, 'sj', '', resolve);
+          } else if (node.level >= 1) {
+            //  if (this.isLoad==false) return ;
+            return this.getdata(node.level, node.data.nextlevel, node.data.id, resolve);
+          }
+        },
+        // handleNodeClick(data) {
+        //   this.$emit('handleNodeClick',data)
+        // },
+      },
+      watch: {
+        isLoad(newVal) {
+          this.updatetree();
+        },
+      }
+      ,
+
+    }
+)
+
+</script>
+
+<style scoped>
+.dialog-footer button:first-child {
+  margin-right: 10px;
+}
+::v-deep .scroll-wrap{
+  height: 62vh;
+  padding-right: 10px;
+}
+</style>

+ 2 - 0
ruoyi-web/src/main.js

@@ -20,6 +20,7 @@ import ImageUpload from "@/components/ImageUpload"
 // 图片预览组件
 import ImagePreview from "@/components/ImagePreview"
 import Org_tree from '@/components/Org_tree'
+import OrgTreeSel from "@/components/OrgTreeSel"
 import * as ElIcon from '@element-plus/icons-vue'
 
 const app = createApp(App)
@@ -36,6 +37,7 @@ app.config.globalProperties.resetForm = resetForm
 app.component('FileUpload', FileUpload)
 app.component('ImageUpload', ImageUpload)
 app.component('ImagePreview', ImagePreview)
+app.component('OrgTreeSel', OrgTreeSel)
 app.component('Pagination', Pagination)
 app.use(Org_tree)
 app.use(store)

+ 4 - 0
ruoyi-web/src/views/yldt/index.vue

@@ -144,6 +144,7 @@
 				</div>
 			</div>
 		</div>
+    <OrgTreeSel :isTj="true" :title="'王立生'" :isLoad="true"  :ref="'dztree'" @handleNodeClick="NodeClick($event)"  ></OrgTreeSel>
 	</div>
 </template>
 
@@ -255,6 +256,9 @@ function handleFullScreen() {
 		exitFullscreen(document.getElementById("iframeTest"))
 	}
 }
+function NodeClick( data) {
+  alert(JSON.stringify(data))
+}
 function launchFullScreen(element) {
 	if (element.requestFullscreen) {
 		element.requestFullscreen()