提交 b605c3f2 编写于 作者: zhentian.jia's avatar zhentian.jia

重构拼接树

上级 498038d4
...@@ -30,7 +30,7 @@ export const envConfig = { ...@@ -30,7 +30,7 @@ export const envConfig = {
reportUrl: 'https://dev-sc-report.yunqueyi.com/', reportUrl: 'https://dev-sc-report.yunqueyi.com/',
// reportUrl: 'https://test1-sc-report.yunqueyi.com/', // reportUrl: 'https://test1-sc-report.yunqueyi.com/',
// reportUrl: 'https://uat-sc-report.yunqueyi.com/', // reportUrl: 'https://uat-sc-report.yunqueyi.com/',
excelUrl: 'https://test-file.yunqueyi.com/File/template/onlineExam/', excelUrl: 'https://test-file.yunqueyi.com/File/template/portal/',
}, },
dev: { dev: {
baseUrl: 'https://dev-sc.yunqueyi.com/', baseUrl: 'https://dev-sc.yunqueyi.com/',
...@@ -46,7 +46,7 @@ export const envConfig = { ...@@ -46,7 +46,7 @@ export const envConfig = {
workApiUrl: 'https://dev-work.yunqueyi.com/web', workApiUrl: 'https://dev-work.yunqueyi.com/web',
workApiSrc: 'https://dev-work.yunqueyi.com', workApiSrc: 'https://dev-work.yunqueyi.com',
reportUrl: 'https://dev-sc-report.yunqueyi.com/', reportUrl: 'https://dev-sc-report.yunqueyi.com/',
excelUrl: 'https://test-file.yunqueyi.com/File/template/onlineExam/', excelUrl: 'https://test-file.yunqueyi.com/File/template/portal/',
}, },
test: { test: {
baseUrl: 'https://test1-sc.yunqueyi.com/', baseUrl: 'https://test1-sc.yunqueyi.com/',
...@@ -62,7 +62,7 @@ export const envConfig = { ...@@ -62,7 +62,7 @@ export const envConfig = {
workApiUrl: 'https://test1-work.yunqueyi.com/web', workApiUrl: 'https://test1-work.yunqueyi.com/web',
workApiSrc: 'https://test1-work.yunqueyi.com', workApiSrc: 'https://test1-work.yunqueyi.com',
reportUrl: 'https://test1-sc-report.yunqueyi.com/', reportUrl: 'https://test1-sc-report.yunqueyi.com/',
excelUrl: 'https://test-file.yunqueyi.com/File/template/onlineExam/', excelUrl: 'https://test-file.yunqueyi.com/File/template/portal/',
}, },
test2: { test2: {
baseUrl: 'https://test2-work.yunqueyi.com/sc/', baseUrl: 'https://test2-work.yunqueyi.com/sc/',
...@@ -77,7 +77,7 @@ export const envConfig = { ...@@ -77,7 +77,7 @@ export const envConfig = {
workApiUrl: 'https://test2-work.yunqueyi.com/web', workApiUrl: 'https://test2-work.yunqueyi.com/web',
workApiSrc: 'https://test2-work.yunqueyi.com', workApiSrc: 'https://test2-work.yunqueyi.com',
reportUrl: 'https://test2-sc-report.yunqueyi.com/', reportUrl: 'https://test2-sc-report.yunqueyi.com/',
excelUrl: 'https://test-file.yunqueyi.com/File/template/onlineExam/', excelUrl: 'https://test-file.yunqueyi.com/File/template/portal/',
}, },
uat: { uat: {
baseUrl: 'https://uat-sc.yunqueyi.com/', baseUrl: 'https://uat-sc.yunqueyi.com/',
...@@ -93,7 +93,7 @@ export const envConfig = { ...@@ -93,7 +93,7 @@ export const envConfig = {
workApiUrl: 'https://uat-work.yunqueyi.com/web', workApiUrl: 'https://uat-work.yunqueyi.com/web',
workApiSrc: 'https://uat-work.yunqueyi.com', workApiSrc: 'https://uat-work.yunqueyi.com',
reportUrl: 'https://uat-sc-report.yunqueyi.com/', reportUrl: 'https://uat-sc-report.yunqueyi.com/',
excelUrl: 'https://test-file.yunqueyi.com/File/template/onlineExam/', excelUrl: 'https://test-file.yunqueyi.com/File/template/portal/',
}, },
pro: { pro: {
baseUrl: 'https://sc.yunqueyi.com/', baseUrl: 'https://sc.yunqueyi.com/',
...@@ -109,6 +109,6 @@ export const envConfig = { ...@@ -109,6 +109,6 @@ export const envConfig = {
workApiUrl: 'https://work.yunqueyi.com/web', workApiUrl: 'https://work.yunqueyi.com/web',
workApiSrc: 'https://work.yunqueyi.com', workApiSrc: 'https://work.yunqueyi.com',
reportUrl: 'https://sc-report.yunqueyi.com/', reportUrl: 'https://sc-report.yunqueyi.com/',
excelUrl: 'https://test-file.yunqueyi.com/File/template/onlineExam/', excelUrl: 'https://test-file.yunqueyi.com/File/template/portal/',
} }
} }
...@@ -588,4 +588,39 @@ export function getComponent(data) { ...@@ -588,4 +588,39 @@ export function getComponent(data) {
list.push(data[i].value); list.push(data[i].value);
} }
return list; return list;
}
export function getSimpleCheckedNodes(store) {
const checkedNodes = [];
const traverse = function(node) {
const childNodes = node.root ? node.root.childNodes : node.childNodes;
childNodes.forEach(child => {
if (child.checked) {
checkedNodes.push(child.data);
}
if (child.indeterminate) {
traverse(child);
}
});
};
traverse(store)
return checkedNodes;
}
export function setSelectedKeys(checkedKeys,halfCheckedKeys) {
let selected = [];
for(let i=0;i<checkedKeys.length;i++) {
let obj = {
key: checkedKeys[i].id,
type: 1,
};
selected.push(obj);
}
for(let j=0;j<halfCheckedKeys.length;j++) {
let obj = {
key: halfCheckedKeys[j],
type: 2,
};
selected.push(obj);
}
return selected;
} }
\ No newline at end of file
...@@ -290,6 +290,7 @@ import { openLoading, closeLoading } from "../../utils/utils"; ...@@ -290,6 +290,7 @@ import { openLoading, closeLoading } from "../../utils/utils";
import * as commonUtil from "../../utils/utils"; import * as commonUtil from "../../utils/utils";
import { getExeclUrl } from "@/utils/index"; import { getExeclUrl } from "@/utils/index";
import { uploadExcel } from "@/utils/education/educationApi"; import { uploadExcel } from "@/utils/education/educationApi";
import * as operationData from "../../utils/operation";
let vm = null; let vm = null;
export default { export default {
components: { components: {
...@@ -393,7 +394,7 @@ export default { ...@@ -393,7 +394,7 @@ export default {
let downloadUrl = ""; let downloadUrl = "";
if (type == "model") { if (type == "model") {
downloadUrl = getExeclUrl( downloadUrl = getExeclUrl(
"%E5%AF%BC%E5%85%A5%E9%A2%98%E7%9B%AE%E6%A8%A1%E6%9D%BF.xlsx" "%E6%95%99%E5%9F%B9%E9%A1%B9%E7%9B%AE%E8%A7%92%E8%89%B2%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx"
); );
} else if (type == "fail") { } else if (type == "fail") {
downloadUrl = vm.failExcelUrl; downloadUrl = vm.failExcelUrl;
...@@ -634,30 +635,23 @@ export default { ...@@ -634,30 +635,23 @@ export default {
}, },
addArea(row) { addArea(row) {
vm.dialogArea = true; vm.dialogArea = true;
vm.treeData = [];
vm.tagsRegion = [];
vm.getAdministrative(row); vm.getAdministrative(row);
}, },
getAdministrative(row) { getAdministrative(row) {
vm.doctorId = row.userId; vm.doctorId = row.userId;
// let req = {
// projectId: vm.formInline.portalProjectId
// };
let req = { let req = {
projectId: vm.formInline.portalProjectId
};
openLoading(vm);
// vm.GET("portal/scope/v1/administrative", req).then(res => {
// closeLoading(vm);
// if (res.code == "000000") {
// let administrativeAll = res.data.administrativeAll;
// let administrative = res.data.administrative;
// this.treeData = [];
// this.treeData[0] = administrativeAll;
// this.setTreeData(administrative);
// }
// });
let req2 = {
projectId: vm.formInline.portalProjectId, projectId: vm.formInline.portalProjectId,
doctorId: row.userId doctorId: row.userId
}; };
vm.GET("portal/portalProjectOrRole/getAttachRegion", req2).then(res => { openLoading(vm);
vm.GET("portal/portalProjectOrRole/getAttachRegion", req).then(res => {
closeLoading(vm);
if (res.code == "000000") { if (res.code == "000000") {
let administrativeAll = res.data.administrativeAll; let administrativeAll = res.data.administrativeAll;
let administrative = res.data.administrative; let administrative = res.data.administrative;
...@@ -702,76 +696,83 @@ export default { ...@@ -702,76 +696,83 @@ export default {
} }
}, },
onChecked() { onChecked() {
let cData = [], // let cData = [],
oldData = (this.treeData.length && this.treeData.slice()) || [], // oldData = (this.treeData.length && this.treeData.slice()) || [],
checkedKeys = this.$refs.tree.getCheckedKeys(), // checkedKeys = this.$refs.tree.getCheckedKeys(),
halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(), // halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(),
savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map( // savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map(
key => { // key => {
return { type: 1, key: key }; // return { type: 1, key: key };
} // }
), // ),
savedHalfCheckedKeys = halfCheckedKeys.map(key => { // savedHalfCheckedKeys = halfCheckedKeys.map(key => {
return { type: 2, key: key }; // return { type: 2, key: key };
}), // }),
allSelectedKeys = savedCheckedKeys.concat(savedHalfCheckedKeys); // allSelectedKeys = savedCheckedKeys.concat(savedHalfCheckedKeys);
vm.allSelectedKeys = allSelectedKeys; // vm.allSelectedKeys = allSelectedKeys;
console.log('getHalfCheckedKeys():',this.$refs.tree.getHalfCheckedKeys());
console.log('getSimpleCheckedNodes():',operationData.getSimpleCheckedNodes(this.$refs.tree.store));
let checkedTree = operationData.getSimpleCheckedNodes(this.$refs.tree.store);
let halfCheckedTree = this.$refs.tree.getHalfCheckedKeys()
vm.allSelectedKeys = operationData.setSelectedKeys(checkedTree,halfCheckedTree);
console.log('vm.allSelectedKeys',vm.allSelectedKeys); console.log('vm.allSelectedKeys',vm.allSelectedKeys);
vm.initCheckList(allSelectedKeys); vm.initCheckList(vm.allSelectedKeys);
}, },
getTreeCheck() { getTreeCheck() {
let cData = [], // let cData = [],
oldData = (this.treeData.length && this.treeData.slice()) || [], // oldData = (this.treeData.length && this.treeData.slice()) || [],
checkedKeys = this.$refs.tree.getCheckedKeys(), // checkedKeys = this.$refs.tree.getCheckedKeys(),
halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(), // halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(),
savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map( // savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map(
key => { // key => {
return { type: 1, key: key }; // return { type: 1, key: key };
} // }
), // ),
savedHalfCheckedKeys = halfCheckedKeys.map(key => { // savedHalfCheckedKeys = halfCheckedKeys.map(key => {
return { type: 2, key: key }; // return { type: 2, key: key };
}), // }),
allSelectedKeys = savedCheckedKeys.concat(savedHalfCheckedKeys); // allSelectedKeys = savedCheckedKeys.concat(savedHalfCheckedKeys);
// console.log('allSelectedKeys值:',allSelectedKeys) let checkedTree = operationData.getSimpleCheckedNodes(this.$refs.tree.store);
let halfCheckedTree = this.$refs.tree.getHalfCheckedKeys()
let allSelectedKeys = operationData.setSelectedKeys(checkedTree,halfCheckedTree);
return allSelectedKeys; return allSelectedKeys;
}, },
// 递归删除列表中所有子节点 // // 递归删除列表中所有子节点
delSubKeysByNode(node, checkedKeys) { // delSubKeysByNode(node, checkedKeys) {
let idIndex; // let idIndex;
if (node.children && node.children.length) { // if (node.children && node.children.length) {
if (node.children && node.children.length) { // if (node.children && node.children.length) {
node.children.forEach(elm => { // node.children.forEach(elm => {
idIndex = checkedKeys.findIndex(id => { // idIndex = checkedKeys.findIndex(id => {
return id === elm.id; // return id === elm.id;
}); // });
if (idIndex > -1) { // if (idIndex > -1) {
checkedKeys.splice(idIndex, 1); // checkedKeys.splice(idIndex, 1);
} // }
if (elm.children && elm.children.length) { // if (elm.children && elm.children.length) {
this.delSubKeysByNode(elm, checkedKeys); // this.delSubKeysByNode(elm, checkedKeys);
} // }
}); // });
} // }
} // }
}, // },
// 去除子节点 // // 去除子节点
handlerCheckedData(oldData, checkedKeys) { // handlerCheckedData(oldData, checkedKeys) {
oldData.forEach(element => { // oldData.forEach(element => {
for (let i = 0; i < checkedKeys.length; i++) { // for (let i = 0; i < checkedKeys.length; i++) {
// 如果此节点被选中,则删除所有子节点 // // 如果此节点被选中,则删除所有子节点
if (element.id === checkedKeys[i]) { // if (element.id === checkedKeys[i]) {
this.delSubKeysByNode(element, checkedKeys); // this.delSubKeysByNode(element, checkedKeys);
} else { // } else {
if (element.children && element.children.length) { // if (element.children && element.children.length) {
this.handlerCheckedData(element.children, checkedKeys); // this.handlerCheckedData(element.children, checkedKeys);
} // }
} // }
} // }
}); // });
return checkedKeys; // return checkedKeys;
}, // },
//添加子节点 //添加子节点
append(data, node) { append(data, node) {
console.log("data:", data); console.log("data:", data);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册