GitBucket
4.6.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull Requests
Labels
Milestones
Wiki
08335
/
hivui-platform-template
hivui平台项目模板
Browse code
birt cmps版本升级
master
1 parent
5e74b81
commit
7bf64ee2c5d4cad2c5362a2d22a88b2ae9a9f4f4
hhb
authored
on 8 Feb 2022
Showing
2 changed files
package.json
project/hivuiBirt/templates/compose/tree-edit-filter.jsx
Ignore Space
Show notes
View
package.json
{ "name": "hi-vui-template", "version": "1.1.5", "description": "A hi-vui-template project", "author": "zhcTeam", "scripts": { "rm:vite": "rimraf node_modules/.vite && rimraf node_modules/.cache", "pm2:start": "pm2 start processes.json", "dev": "vite --host", "build": "node build/copyBaseAssets.js && cross-env NODE_ENV=production node build/webpack.prod.conf.js", "build:modules": "node build/webpack.prod.conf.js", "build1": "webpack --mode production --config build/webpack.prod.conf.js", "debug": "webpack --mode development --config build/webpack.dll.conf.js", "dll": "webpack --config build/webpack.dll.conf.js", "start": "webpack-dev-server --config build/webpack.dev.conf.js", "copyassets": "node build/copyBaseAssets.js" }, "devDependencies": { "@babel/core": "^7.1.2", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", "@babel/plugin-proposal-optional-chaining": "^7.16.7", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/preset-env": "^7.1.0", "@vitejs/plugin-vue-jsx": "^1.3.3", "@vue/babel-helper-vue-jsx-merge-props": "^1.2.1", "@vue/babel-preset-jsx": "^1.2.4", "add-asset-html-webpack-plugin": "^3.2.0", "autoprefixer": "^9.1.5", "babel-loader": "^8.0.4", "babel-plugin-component": "^1.1.1", "babel-plugin-transform-vite-meta-env": "^1.0.3", "chalk": "^5.0.0", "clean-webpack-plugin": "^0.1.19", "copy-webpack-plugin": "^4.5.3", "cross-env": "^7.0.3", "css-loader": "^1.0.0", "dotenv": "^10.0.0", "file-loader": "^2.0.0", "happypack": "^5.0.1", "html-webpack-plugin": "^4.5.2", "less": "^4.1.2", "less-loader": "^5.0.0", "mini-css-extract-plugin": "^1.6.2", "node-sass": "^4.9.3", "optimize-css-assets-webpack-plugin": "^5.0.1", "parallel-webpack": "^2.6.0", "postcss-import": "^11.1.0", "postcss-loader": "^2.1.6", "postcss-url": "^7.3.2", "progress-bar-webpack-plugin": "^2.1.0", "sass": "^1.49.0", "sass-loader": "^7.1.0", "style-loader": "^0.23.0", "uglifyjs-webpack-plugin": "^2.0.1", "url-loader": "^1.1.1", "vite": "2.3.7", "vite-plugin-html": "^2.1.1", "vite-plugin-imp": "^2.0.11", "vite-plugin-pagedata": "^1.0.4", "vite-plugin-vue2": "^1.9.0", "vue-loader": "^15.4.2", "vue-template-compiler": "^2.5.17", "webpack": "^4.20.2", "webpack-cli": "^3.1.1", "webpack-dev-server": "^3.1.9", "webpack-merge": "^4.1.4" }, "dependencies": { "axios": "^0.24.0", "babel-polyfill": "^6.26.0", "classnames": "^2.3.1", "deep-lu-trans": "^1.0.5", "element-ui": "^2.15.6", "enquire.js": "^2.1.6", "font-awesome": "^4.7.0", "hi-taskcenter": "^1.0.9", "hi-ui": "^1.1.922", "js-cookie": "^3.0.1", "js-pinyin": "^0.1.9", "lodash": "^4.17.11", "md5": "^2.3.0", "screenfull": "^6.0.0", "sortablejs": "^1.14.0", "v-clipboard": "^2.2.3", "vue": "^2.5.17", "vue-draggable-resizable": "^2.3.0", "vue-gemini-scrollbar": "^2.0.1", "vue-jstree": "^2.1.6", "vue-router": "^3.0.1", "vuex": "^3.6.2", "zhc-birt-cmps": "^2.3.18" } }
{ "name": "hi-vui-template", "version": "1.1.5", "description": "A hi-vui-template project", "author": "zhcTeam", "scripts": { "rm:vite": "rimraf node_modules/.vite && rimraf node_modules/.cache", "pm2:start": "pm2 start processes.json", "dev": "vite --host", "build": "node build/copyBaseAssets.js && cross-env NODE_ENV=production node build/webpack.prod.conf.js", "build:modules": "node build/webpack.prod.conf.js", "build1": "webpack --mode production --config build/webpack.prod.conf.js", "debug": "webpack --mode development --config build/webpack.dll.conf.js", "dll": "webpack --config build/webpack.dll.conf.js", "start": "webpack-dev-server --config build/webpack.dev.conf.js", "copyassets": "node build/copyBaseAssets.js" }, "devDependencies": { "@babel/core": "^7.1.2", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", "@babel/plugin-proposal-optional-chaining": "^7.16.7", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/preset-env": "^7.1.0", "@vitejs/plugin-vue-jsx": "^1.3.3", "@vue/babel-helper-vue-jsx-merge-props": "^1.2.1", "@vue/babel-preset-jsx": "^1.2.4", "add-asset-html-webpack-plugin": "^3.2.0", "autoprefixer": "^9.1.5", "babel-loader": "^8.0.4", "babel-plugin-component": "^1.1.1", "babel-plugin-transform-vite-meta-env": "^1.0.3", "chalk": "^5.0.0", "clean-webpack-plugin": "^0.1.19", "copy-webpack-plugin": "^4.5.3", "cross-env": "^7.0.3", "css-loader": "^1.0.0", "dotenv": "^10.0.0", "file-loader": "^2.0.0", "happypack": "^5.0.1", "html-webpack-plugin": "^4.5.2", "less": "^4.1.2", "less-loader": "^5.0.0", "mini-css-extract-plugin": "^1.6.2", "node-sass": "^4.9.3", "optimize-css-assets-webpack-plugin": "^5.0.1", "parallel-webpack": "^2.6.0", "postcss-import": "^11.1.0", "postcss-loader": "^2.1.6", "postcss-url": "^7.3.2", "progress-bar-webpack-plugin": "^2.1.0", "sass": "^1.49.0", "sass-loader": "^7.1.0", "style-loader": "^0.23.0", "uglifyjs-webpack-plugin": "^2.0.1", "url-loader": "^1.1.1", "vite": "2.3.7", "vite-plugin-html": "^2.1.1", "vite-plugin-imp": "^2.0.11", "vite-plugin-pagedata": "^1.0.4", "vite-plugin-vue2": "^1.9.0", "vue-loader": "^15.4.2", "vue-template-compiler": "^2.5.17", "webpack": "^4.20.2", "webpack-cli": "^3.1.1", "webpack-dev-server": "^3.1.9", "webpack-merge": "^4.1.4" }, "dependencies": { "axios": "^0.24.0", "babel-polyfill": "^6.26.0", "classnames": "^2.3.1", "deep-lu-trans": "^1.0.5", "element-ui": "^2.15.6", "enquire.js": "^2.1.6", "font-awesome": "^4.7.0", "hi-taskcenter": "^1.0.9", "hi-ui": "^1.1.922", "js-cookie": "^3.0.1", "js-pinyin": "^0.1.9", "lodash": "^4.17.11", "md5": "^2.3.0", "screenfull": "^6.0.0", "sortablejs": "^1.14.0", "v-clipboard": "^2.2.3", "vue": "^2.5.17", "vue-draggable-resizable": "^2.3.0", "vue-gemini-scrollbar": "^2.0.1", "vue-jstree": "^2.1.6", "vue-router": "^3.0.1", "vuex": "^3.6.2", "zhc-birt-cmps": "^2.3.17" } }
Ignore Space
Show notes
View
project/hivuiBirt/templates/compose/tree-edit-filter.jsx
/** * 树型组件编辑:新增、修改、删除,根据名称过滤节点操作 * @param {*} dlgId 对话框随机id,防止id冲突与数据集id统一命名引用 * @param {*} dsId 绑定过滤数据集ID * @param {*} option 扩展选项 * @returns */ import { $CONST } from "@birt/funclib/ConstUtil"; import { JsonUtil } from "@birt/funclib/JsonUtil" import pinyin from "js-pinyin"; export function treeEditFilter(dlgId, dsId, option) { let filterField = option.hcTree.labelField; let lazy = option.hcTree.lazy; let fireAction = lazy ? "" : "keyup"; let treeId = "HcTree_" + dlgId; // 过滤编辑器 let inputFilter = { controlName: "HcInputFilter", controlId: "HcInputFilter_" + dlgId, size: "small", fireAction: fireAction, events: { filterChange: function (filterKey) { this.getRefCompt(treeId).filter( filterKey ); // if (filterKey) { // ds.addFilterCdion({ // sign: "pinyin", // name: filterField, // dataType: "string", // value: filterKey, // enable: true, // }); // // this.getRefCompt(treeId).filter( // // filterKey // // ); // } else { // ds.removeFilterCdion(filterField); // } }, } }; // 添加 let btnAddMenuId = "HcLookup_" + dlgId; let HcDropdownId = "HcDropdown_" + dlgId; let buttonAddMenu = { controlName: "HcLookup", controlId: btnAddMenuId, dataset: dsId, lookDialog: { footer: ["cancel", "save"], events: { saved:function() { var command = this.getWorkBook().param.command var dataset = this.getContent().dataset var data = getFisrt(dataset).getData() var _this = this.getWorkBook().dataset[dsId] var vm = this setDatas(_this, vm, command,data) }, }, }, children: [{ controlName: "HcDropdown", controlId: HcDropdownId, style: "float:left;width:90p;", vshow: false, events: { command: function (command) { this.getWorkBook().param.command = command let treeMenu = this.getRefCompt(treeId); let currentRow = treeMenu.elTree().getCurrentNode(); if (!currentRow) { this.$message({ message: '请选择树节点要添加的位置', type: 'warning' }); return; } // 获取树当前选中记录,特殊处理虚拟根节点情况 let curtRecd; if (command == $CONST.BROTHER && currentRow._isVirtualRoot) { curtRecd = currentRow.children[currentRow.children.length - 1]; } else { curtRecd = currentRow; } let btnAddMenu = this.getRefCompt(btnAddMenuId); let pushRecd = btnAddMenu.getPushAddMapRecds(curtRecd); let pushParam = { pushType: "add", command: command, dataset: btnAddMenu.lookDataset.dataset, data: [pushRecd] }; btnAddMenu.openLookDialog({ __push: pushParam }) }, }, children: [ { controlName: "HcButton", controlId: "HcButton_02", size: "mini", title: "添加", children: [ { controlName: "HcIcon", controlId: "HcIcon_02_1", slot: "prev", className: "el-icon-plus el-icon--left", }, { controlName: "HcIcon", controlId: "HcIcon_02_2", className: "el-icon-arrow-down el-icon--right", }, ], }, { controlName: "HcDropdownMenu", controlId: "HcDropdownMenu_02", slot: "dropdown", children: [ { controlName: "HcDropdownItem", controlId: "HcDropdownItem_02_1", command: $CONST.BROTHER, title: "同 级", style: "width:80px;" }, { controlName: "HcDropdownItem", controlId: "HcDropdownItem_02_2", command: $CONST.CHILD, title: "子 级", }, ], }, ], }] } function add(node,data,_this, type){ debugger _this.getWorkBook().param.node = node if(type == 'brother'){ _this.getWorkBook().param.treeData = node.parent.data }else{ _this.getWorkBook().param.treeData = data } if(data.fresguid && type =='child' && !(data.FRESTYPE.toLocaleLowerCase() == 'dir' || data.FRESTYPE.toLocaleLowerCase() == '.dir' || data.fresguid == '-1')){ _this.$message({ message: '非目录节点不能新增子节点', type: 'warning' }); return } // if(type =='child'){ // node.loaded = false // node.expand() // } _this.getWorkBook().param.command = type let btnAddMenu = _this.getRefCompt(btnAddMenuId); var pushRecd = data; var pushParam = { pushType: "add", command: type, dataset: btnAddMenu.lookDataset.dataset, data: [pushRecd] }; btnAddMenu.openLookDialog({ __push: pushParam }) } // 修改 let btnEditId = "HcLookup_edit_" + dlgId; let buttonEdit = { controlName: "HcLookup", controlId: btnEditId, dataset: dsId, lookDialog: { footer: ["cancel", "save"], events: { saved:function() { debugger var _this = this.getWorkBook().dataset[dsId] var dataset = this.getContent().dataset var data = getFisrt(dataset).getData() var vm = this setDatas(_this, vm, 'edit',data) }, }, }, children: [ { controlName: "HcButton", title: "修改", icon: "el-icon-edit", size: "mini", style: "float:left;margin-left:5px;width:80px;", vshow: false, events: { click: function () { let treeMenu = this.getRefCompt(treeId); let currentRow = treeMenu.elTree().getCurrentNode(); if (!currentRow || currentRow._isVirtualRoot) { this.$message({ message: '请选择要修改的节点', type: 'warning' }); return; } let btnEdit = this.getRefCompt(btnEditId); let pushRecd = btnEdit.getPushAddMapRecds(currentRow); let pushParam = { pushType: "edit", dataset: btnEdit.lookDataset.dataset, data: [pushRecd] }; btnEdit.openLookDialog({ __push: pushParam }) }, }, } ] } function edit(node,data,store,_this){ _this.getWorkBook().param.node = node _this.getWorkBook().param.treeData = data let btnEdit = _this.getRefCompt(btnEditId); var pushRecd = data; var pushParam = { pushType: "edit", dataset: btnEdit.lookDataset.dataset, data: [pushRecd] }; btnEdit.openLookDialog({ __push: pushParam }) } // 删除 let btnDeleteId = "HcLookup_delete_" + dlgId; let buttonDelete = { controlName: "HcLookup", controlId: btnDeleteId, dataset: dsId, lookDialog: { footer: ["cancel", "delete"], events: { deleted:function() { var _this = this.getWorkBook().dataset[dsId] var vm = this setDatas(_this, vm, 'delete') }, // confirm(){ // var _this = this.getWorkBook().dataset[dsId], // curData = _this.getCurtRecord(), // vm = this, // data = {}, // url = '' // if(curData.FROLEGUID){ // data = { // FROLEGUID: curData.FROLEGUID // } // url = '/sys/role/delete?pn=' + pn // }else if(curData.FORGGUID){ // data = { // FORGGUID: curData.FORGGUID // } // url = '/sys/org/delete?pn=' + pn // }else if(curData.FRESGUID){ // data = { // FRESGUID: curData.FRESGUID // } // url = '/sys/menu/delete?pn=' + pn // } // delTree(data,url).then((res) =>{ // console.log('删除', res) // if(res.status == 200){ // Message.success('删除成功') // setDatas(_this, vm, 'delete') // }else{ // Message.error(res.msg) // } // }) // } }, }, children: [ { controlName: "HcButton", title: "删除", icon: "el-icon-delete", size: "mini", style: "float:left;margin-left:5px;width:80px;", vshow: false, events: { click: function () { debugger let treeMenu = this.getRefCompt(treeId); let currentRow = treeMenu.elTree().getCurrentNode(); if (!currentRow || currentRow._isVirtualRoot) { this.$message({ message: '请选择要删除的节点', type: 'warning' }); return; } let btnDelete = this.getRefCompt(btnDeleteId); let pushRecd = btnDelete.getPushAddMapRecds(currentRow); let pushParam = { pushType: "delete", dataset: btnDelete.lookDataset.dataset, // data: [pushRecd] }; Object.assign(pushParam,pushRecd); btnDelete.openLookDialog({ __push: pushParam }) }, }, } ] } function remove(node,data,store,_this){ debugger let wb = _this.getWorkBook(); wb.param.node = node wb.param.treeData = data let btnDelete = _this.getRefCompt(btnDeleteId); var pushRecd = data; var pushParam = { pushType: "delete", dataset: btnDelete.lookDataset.dataset, data: [pushRecd] }; Object.assign(pushParam,pushRecd); btnDelete.openLookDialog({ __push: pushParam }) } function getFisrt(obj){ var n=0; for(var key in obj){ return obj[key] } } // 应用树个性化配置 JsonUtil.deepMerge(buttonAddMenu, option.hcLookupAdd); JsonUtil.deepMerge(buttonEdit, option.hcLookupEdit); JsonUtil.deepMerge(buttonDelete, option.hcLookupDelete); JsonUtil.deepMerge(buttonAddMenu, option.hcLookup); JsonUtil.deepMerge(buttonEdit, option.hcLookup); JsonUtil.deepMerge(buttonDelete, option.hcLookup); // 查询数据集,set数据 function setDatas(_this, vm, type,data){ debugger let treeData = vm.getWorkBook().param.treeData let node = vm.getWorkBook().param.node if(type == 'edit'){ let treeMenu = vm.getRefCompt(treeId); let id = treeMenu.nodeKey const parent = node.parent; const children = parent.data.children || parent.data; const index = children.findIndex(d => d[id] === node.data[id]); children[index] = data[0] node.data = data[0] _this.setCurtRecord(data[0]); }else if (type == 'delete'){ let treeMenu = vm.getRefCompt(treeId); let id = treeMenu.nodeKey const parent = node.parent; const children = parent.data.children || parent.data; const index = children.findIndex(d => d[id] === node.data[id]); children.splice(index, 1); const nodeParent = node.parent.childNodes; const nodeIndex = nodeParent.findIndex(d => d.key === node.key); nodeParent.splice(nodeIndex, 1); _this.setCurtRecord(parent.data); }else{ const newChild = data[data.length -1]; if (!treeData.children) { vm.$set(treeData, 'children', []); } treeData.children.push(newChild); _this.setCurtRecord(newChild); } } // 编辑树型按钮工具条 let treeEditToolbar = { controlName: "HcRow", style: "margin-top:5px;", children: [ buttonAddMenu, buttonEdit, buttonDelete, ] } // 编辑树组件 let hcTree = { controlName: "HcTree", controlId: treeId, dataset: dsId, labelField: filterField, // defaultExpandAll: true, // accordion: true, highlightCurrent: true, expandOnClickNode: false, lazy: false, filterNodeMethod:function(value, data,node) { if (!value){ return true }else{ // let res = variableDeepSearch(data.children, value.trim(),filterField) // res是过滤后得到的数据 let key =node.label +"_" + pinyin.getCamelChars(node.label); return key.indexOf(value.toUpperCase()) !== -1; } }, height: function (parentHeight) { return parentHeight - 80; }, renderContent(h, { node, data, store}) { var _this = this var iconClass = '' var title = '' var disabled = false // if(node.isLeaf){ // iconClass = 'el-icon-document' // }else{ // if(node.expanded){ // iconClass = 'el-icon-folder-opened' // }else{ // iconClass = 'el-icon-folder' // } // } if(data.FROLEKIND || data.FROLEGUID){ if( data.FROLEKIND&&data.FROLEKIND.toLocaleLowerCase() == '.root' || data.FROLEKIND.toLocaleLowerCase() == 'root' || data.FROLEGUID == '-1'){ iconClass = 'iconfont icon-root' title = '根节点' disabled = true }else if( data.FROLEKIND.toLocaleLowerCase() == '.dir' || data.FROLEKIND.toLocaleLowerCase() == 'dir'){ iconClass = 'el-icon-folder' title = '文件夹' }else{ iconClass = 'iconfont icon-ptm' title = '岗位' } }else if(data.FRESTYPE || data.FRESGUID){ if(data.FRESTYPE&&data.FRESTYPE.toLocaleLowerCase() == '.root' || data.FRESTYPE.toLocaleLowerCase() == 'root' || data.FRESGUID == '-1'){ iconClass = 'iconfont icon-root' title = '根节点' disabled = true }else if(data.FRESTYPE.toLocaleLowerCase() == '.dir' || data.FRESTYPE.toLocaleLowerCase() == 'dir'){ iconClass = 'el-icon-folder' title = '文件夹' }else if(data.FRESTYPE.toLocaleLowerCase() == '.func' || data.FRESTYPE.toLocaleLowerCase() == 'func'){ iconClass = 'iconfont icon-func' title = '功能' }else if(data.FRESTYPE.toLocaleLowerCase() == '.flow' || data.FRESTYPE.toLocaleLowerCase() == 'flow'){ iconClass = 'iconfont icon-flow' title = '流程' } }else if(data.FLEVELKIND || data.FLEVELGUID){ if( data.FLEVELKIND && data.FLEVELKIND.toLocaleLowerCase() == '.root' || data.FLEVELKIND.toLocaleLowerCase() == 'root' || data.FLEVELGUID == '-1'){ iconClass = 'iconfont icon-root' title = '根节点' disabled = true }else if(data.FLEVELKIND.toLocaleLowerCase() == '.dir' || data.FLEVELKIND.toLocaleLowerCase() == 'dir'){ iconClass = 'el-icon-folder' title = '文件夹' }else{ iconClass = 'iconfont icon-ptm' title = '职级' } }else { iconClass = 'el-icon-document' } return ( <span class="custom-tree-node"> <span title={title}> <i class={iconClass}></i> {node.label} </span> <span class="btn"> <el-button size="large" title="新增同级" type="text" disabled={disabled} icon="el-icon-folder-add" on-click={ () => add(node,data,_this, 'brother') }></el-button> <el-button size="large" title="新增子级" type="text" icon="el-icon-circle-plus-outline" on-click={ () => add(node,data,_this,'child') }></el-button> <el-button size="large" title="编辑" type="text" disabled={disabled} icon="el-icon-edit" on-click={ () => edit(node,data,store,_this) }></el-button> <el-button size="large" title="删除" type="text" disabled={disabled} icon="el-icon-delete" on-click={ () => remove(node,data,store,_this) }></el-button> </span> </span>); }, style: "overflow: auto;border:1px solid rgb(235, 238, 245);margin-top: 5px;", }; // 应用树个性化配置 Object.assign(hcTree, option.hcTree); // 返回布局结构 return { controlName: "HcCol", span: 6, children: [ inputFilter, treeEditToolbar, hcTree ] } }
/** * 树型组件编辑:新增、修改、删除,根据名称过滤节点操作 * @param {*} dlgId 对话框随机id,防止id冲突与数据集id统一命名引用 * @param {*} dsId 绑定过滤数据集ID * @param {*} option 扩展选项 * @returns */ import { $CONST } from "@birt/funclib/ConstUtil"; import { JsonUtil } from "@birt/funclib/JsonUtil" import pinyin from "js-pinyin"; export function treeEditFilter(dlgId, dsId, option) { let filterField = option.hcTree.labelField; let lazy = option.hcTree.lazy; let fireAction = lazy ? "" : "keyup"; let treeId = "HcTree_" + dlgId; // 过滤编辑器 let inputFilter = { controlName: "HcInputFilter", controlId: "HcInputFilter_" + dlgId, size: "small", fireAction: fireAction, events: { filterChange: function (filterKey) { this.getRefCompt(treeId).filter( filterKey ); // if (filterKey) { // ds.addFilterCdion({ // sign: "pinyin", // name: filterField, // dataType: "string", // value: filterKey, // enable: true, // }); // // this.getRefCompt(treeId).filter( // // filterKey // // ); // } else { // ds.removeFilterCdion(filterField); // } }, } }; // 添加 let btnAddMenuId = "HcLookup_" + dlgId; let HcDropdownId = "HcDropdown_" + dlgId; let buttonAddMenu = { controlName: "HcLookup", controlId: btnAddMenuId, dataset: dsId, lookDialog: { footer: ["cancel", "save"], events: { saved:function() { var command = this.getWorkBook().param.command var dataset = this.getContent().dataset var data = getFisrt(dataset).getData() var _this = this.getWorkBook().dataset[dsId] var vm = this setDatas(_this, vm, command,data) }, }, }, children: [{ controlName: "HcDropdown", controlId: HcDropdownId, style: "float:left;width:90p;", vshow: false, events: { command: function (command) { this.getWorkBook().param.command = command let treeMenu = this.getRefCompt(treeId); let currentRow = treeMenu.elTree().getCurrentNode(); if (!currentRow) { this.$message({ message: '请选择树节点要添加的位置', type: 'warning' }); return; } // 获取树当前选中记录,特殊处理虚拟根节点情况 let curtRecd; if (command == $CONST.BROTHER && currentRow._isVirtualRoot) { curtRecd = currentRow.children[currentRow.children.length - 1]; } else { curtRecd = currentRow; } let btnAddMenu = this.getRefCompt(btnAddMenuId); let pushRecd = btnAddMenu.getPushAddMapRecds(curtRecd); let pushParam = { pushType: "add", command: command, dataset: btnAddMenu.lookDataset.dataset, data: [pushRecd] }; btnAddMenu.openLookDialog({ __push: pushParam }) }, }, children: [ { controlName: "HcButton", controlId: "HcButton_02", size: "mini", title: "添加", children: [ { controlName: "HcIcon", controlId: "HcIcon_02_1", slot: "prev", className: "el-icon-plus el-icon--left", }, { controlName: "HcIcon", controlId: "HcIcon_02_2", className: "el-icon-arrow-down el-icon--right", }, ], }, { controlName: "HcDropdownMenu", controlId: "HcDropdownMenu_02", slot: "dropdown", children: [ { controlName: "HcDropdownItem", controlId: "HcDropdownItem_02_1", command: $CONST.BROTHER, title: "同 级", style: "width:80px;" }, { controlName: "HcDropdownItem", controlId: "HcDropdownItem_02_2", command: $CONST.CHILD, title: "子 级", }, ], }, ], }] } function add(node,data,_this, type){ debugger _this.getWorkBook().param.node = node if(type == 'brother'){ _this.getWorkBook().param.treeData = node.parent.data }else{ _this.getWorkBook().param.treeData = data } if(data.fresguid && type =='child' && !(data.FRESTYPE.toLocaleLowerCase() == 'dir' || data.FRESTYPE.toLocaleLowerCase() == '.dir' || data.fresguid == '-1')){ _this.$message({ message: '非目录节点不能新增子节点', type: 'warning' }); return } // if(type =='child'){ // node.loaded = false // node.expand() // } _this.getWorkBook().param.command = type let btnAddMenu = _this.getRefCompt(btnAddMenuId); var pushRecd = data; var pushParam = { pushType: "add", command: type, dataset: btnAddMenu.lookDataset.dataset, data: [pushRecd] }; btnAddMenu.openLookDialog({ __push: pushParam }) } // 修改 let btnEditId = "HcLookup_edit_" + dlgId; let buttonEdit = { controlName: "HcLookup", controlId: btnEditId, dataset: dsId, lookDialog: { footer: ["cancel", "save"], events: { saved:function() { debugger var _this = this.getWorkBook().dataset[dsId] var dataset = this.getContent().dataset var data = getFisrt(dataset).getData() var vm = this setDatas(_this, vm, 'edit',data) }, }, }, children: [ { controlName: "HcButton", title: "修改", icon: "el-icon-edit", size: "mini", style: "float:left;margin-left:5px;width:80px;", vshow: false, events: { click: function () { let treeMenu = this.getRefCompt(treeId); let currentRow = treeMenu.elTree().getCurrentNode(); if (!currentRow || currentRow._isVirtualRoot) { this.$message({ message: '请选择要修改的节点', type: 'warning' }); return; } let btnEdit = this.getRefCompt(btnEditId); let pushRecd = btnEdit.getPushAddMapRecds(currentRow); let pushParam = { pushType: "edit", dataset: btnEdit.lookDataset.dataset, data: [pushRecd] }; btnEdit.openLookDialog({ __push: pushParam }) }, }, } ] } function edit(node,data,store,_this){ _this.getWorkBook().param.node = node _this.getWorkBook().param.treeData = data let btnEdit = _this.getRefCompt(btnEditId); var pushRecd = data; var pushParam = { pushType: "edit", dataset: btnEdit.lookDataset.dataset, data: [pushRecd] }; btnEdit.openLookDialog({ __push: pushParam }) } // 删除 let btnDeleteId = "HcLookup_delete_" + dlgId; let buttonDelete = { controlName: "HcLookup", controlId: btnDeleteId, dataset: dsId, lookDialog: { footer: ["cancel", "delete"], events: { deleted:function() { var _this = this.getWorkBook().dataset[dsId] var vm = this setDatas(_this, vm, 'delete') }, // confirm(){ // var _this = this.getWorkBook().dataset[dsId], // curData = _this.getCurtRecord(), // vm = this, // data = {}, // url = '' // if(curData.FROLEGUID){ // data = { // FROLEGUID: curData.FROLEGUID // } // url = '/sys/role/delete?pn=' + pn // }else if(curData.FORGGUID){ // data = { // FORGGUID: curData.FORGGUID // } // url = '/sys/org/delete?pn=' + pn // }else if(curData.FRESGUID){ // data = { // FRESGUID: curData.FRESGUID // } // url = '/sys/menu/delete?pn=' + pn // } // delTree(data,url).then((res) =>{ // console.log('删除', res) // if(res.status == 200){ // Message.success('删除成功') // setDatas(_this, vm, 'delete') // }else{ // Message.error(res.msg) // } // }) // } }, }, children: [ { controlName: "HcButton", title: "删除", icon: "el-icon-delete", size: "mini", style: "float:left;margin-left:5px;width:80px;", vshow: false, events: { click: function () { debugger let treeMenu = this.getRefCompt(treeId); let currentRow = treeMenu.elTree().getCurrentNode(); if (!currentRow || currentRow._isVirtualRoot) { this.$message({ message: '请选择要删除的节点', type: 'warning' }); return; } let btnDelete = this.getRefCompt(btnDeleteId); let pushRecd = btnDelete.getPushAddMapRecds(currentRow); let pushParam = { pushType: "delete", dataset: btnDelete.lookDataset.dataset, // data: [pushRecd] }; Object.assign(pushParam,pushRecd); btnDelete.openLookDialog({ __push: pushParam }) }, }, } ] } function remove(node,data,store,_this){ debugger let wb = _this.getWorkBook(); wb.param.node = node wb.param.treeData = data let btnDelete = _this.getRefCompt(btnDeleteId); var pushRecd = data; var pushParam = { pushType: "delete", dataset: btnDelete.lookDataset.dataset, data: [pushRecd] }; Object.assign(pushParam,pushRecd); btnDelete.openLookDialog({ __push: pushParam }) } function getFisrt(obj){ var n=0; for(var key in obj){ return obj[key] } } // 应用树个性化配置 JsonUtil.deepMerge(buttonAddMenu, option.hcLookupAdd); JsonUtil.deepMerge(buttonEdit, option.hcLookupEdit); JsonUtil.deepMerge(buttonDelete, option.hcLookupDelete); JsonUtil.deepMerge(buttonAddMenu, option.hcLookup); JsonUtil.deepMerge(buttonEdit, option.hcLookup); JsonUtil.deepMerge(buttonDelete, option.hcLookup); // 查询数据集,set数据 function setDatas(_this, vm, type,data){ debugger let treeData = vm.getWorkBook().param.treeData let node = vm.getWorkBook().param.node if(type == 'edit'){ node.data = data[0] _this.setCurtRecord(data[0]); }else if (type == 'delete'){ let treeMenu = vm.getRefCompt(treeId); let id = treeMenu.nodeKey const parent = node.parent; const children = parent.data.children || parent.data; const index = children.findIndex(d => d[id] === node.data[id]); children.splice(index, 1); const nodeParent = node.parent.childNodes; const nodeIndex = nodeParent.findIndex(d => d.key === node.key); nodeParent.splice(nodeIndex, 1); _this.setCurtRecord(parent.data); }else{ const newChild = data[data.length -1]; if (!treeData.children) { vm.$set(treeData, 'children', []); } treeData.children.push(newChild); _this.setCurtRecord(newChild); } } // 编辑树型按钮工具条 let treeEditToolbar = { controlName: "HcRow", style: "margin-top:5px;", children: [ buttonAddMenu, buttonEdit, buttonDelete, ] } // 编辑树组件 let hcTree = { controlName: "HcTree", controlId: treeId, dataset: dsId, labelField: filterField, // defaultExpandAll: true, // accordion: true, highlightCurrent: true, expandOnClickNode: false, lazy: false, filterNodeMethod:function(value, data,node) { if (!value){ return true }else{ // let res = variableDeepSearch(data.children, value.trim(),filterField) // res是过滤后得到的数据 let key =node.label +"_" + pinyin.getCamelChars(node.label); return key.indexOf(value.toUpperCase()) !== -1; } }, height: function (parentHeight) { return parentHeight - 80; }, renderContent(h, { node, data, store}) { var _this = this var iconClass = '' var title = '' var disabled = false // if(node.isLeaf){ // iconClass = 'el-icon-document' // }else{ // if(node.expanded){ // iconClass = 'el-icon-folder-opened' // }else{ // iconClass = 'el-icon-folder' // } // } if(data.FROLEKIND || data.FROLEGUID){ if( data.FROLEKIND&&data.FROLEKIND.toLocaleLowerCase() == '.root' || data.FROLEKIND.toLocaleLowerCase() == 'root' || data.FROLEGUID == '-1'){ iconClass = 'iconfont icon-root' title = '根节点' disabled = true }else if( data.FROLEKIND.toLocaleLowerCase() == '.dir' || data.FROLEKIND.toLocaleLowerCase() == 'dir'){ iconClass = 'el-icon-folder' title = '文件夹' }else{ iconClass = 'iconfont icon-ptm' title = '岗位' } }else if(data.FRESTYPE || data.FRESGUID){ if(data.FRESTYPE&&data.FRESTYPE.toLocaleLowerCase() == '.root' || data.FRESTYPE.toLocaleLowerCase() == 'root' || data.FRESGUID == '-1'){ iconClass = 'iconfont icon-root' title = '根节点' disabled = true }else if(data.FRESTYPE.toLocaleLowerCase() == '.dir' || data.FRESTYPE.toLocaleLowerCase() == 'dir'){ iconClass = 'el-icon-folder' title = '文件夹' }else if(data.FRESTYPE.toLocaleLowerCase() == '.func' || data.FRESTYPE.toLocaleLowerCase() == 'func'){ iconClass = 'iconfont icon-func' title = '功能' }else if(data.FRESTYPE.toLocaleLowerCase() == '.flow' || data.FRESTYPE.toLocaleLowerCase() == 'flow'){ iconClass = 'iconfont icon-flow' title = '流程' } }else if(data.FLEVELKIND || data.FLEVELGUID){ if( data.FLEVELKIND && data.FLEVELKIND.toLocaleLowerCase() == '.root' || data.FLEVELKIND.toLocaleLowerCase() == 'root' || data.FLEVELGUID == '-1'){ iconClass = 'iconfont icon-root' title = '根节点' disabled = true }else if(data.FLEVELKIND.toLocaleLowerCase() == '.dir' || data.FLEVELKIND.toLocaleLowerCase() == 'dir'){ iconClass = 'el-icon-folder' title = '文件夹' }else{ iconClass = 'iconfont icon-ptm' title = '职级' } }else { iconClass = 'el-icon-document' } return ( <span class="custom-tree-node"> <span title={title}> <i class={iconClass}></i> {node.label} </span> <span class="btn"> <el-button size="large" title="新增同级" type="text" disabled={disabled} icon="el-icon-folder-add" on-click={ () => add(node,data,_this, 'brother') }></el-button> <el-button size="large" title="新增子级" type="text" icon="el-icon-circle-plus-outline" on-click={ () => add(node,data,_this,'child') }></el-button> <el-button size="large" title="编辑" type="text" icon="el-icon-edit" on-click={ () => edit(node,data,store,_this) }></el-button> <el-button size="large" title="删除" type="text" disabled={disabled} icon="el-icon-delete" on-click={ () => remove(node,data,store,_this) }></el-button> </span> </span>); }, style: "overflow: auto;border:1px solid rgb(235, 238, 245);margin-top: 5px;", }; // 应用树个性化配置 Object.assign(hcTree, option.hcTree); // 返回布局结构 return { controlName: "HcCol", span: 6, children: [ inputFilter, treeEditToolbar, hcTree ] } }
Show line notes below