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

重构拼接树

上级 498038d4
......@@ -30,7 +30,7 @@ export const envConfig = {
reportUrl: 'https://dev-sc-report.yunqueyi.com/',
// reportUrl: 'https://test1-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: {
baseUrl: 'https://dev-sc.yunqueyi.com/',
......@@ -46,7 +46,7 @@ export const envConfig = {
workApiUrl: 'https://dev-work.yunqueyi.com/web',
workApiSrc: 'https://dev-work.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: {
baseUrl: 'https://test1-sc.yunqueyi.com/',
......@@ -62,7 +62,7 @@ export const envConfig = {
workApiUrl: 'https://test1-work.yunqueyi.com/web',
workApiSrc: 'https://test1-work.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: {
baseUrl: 'https://test2-work.yunqueyi.com/sc/',
......@@ -77,7 +77,7 @@ export const envConfig = {
workApiUrl: 'https://test2-work.yunqueyi.com/web',
workApiSrc: 'https://test2-work.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: {
baseUrl: 'https://uat-sc.yunqueyi.com/',
......@@ -93,7 +93,7 @@ export const envConfig = {
workApiUrl: 'https://uat-work.yunqueyi.com/web',
workApiSrc: 'https://uat-work.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: {
baseUrl: 'https://sc.yunqueyi.com/',
......@@ -109,6 +109,6 @@ export const envConfig = {
workApiUrl: 'https://work.yunqueyi.com/web',
workApiSrc: 'https://work.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) {
list.push(data[i].value);
}
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";
import * as commonUtil from "../../utils/utils";
import { getExeclUrl } from "@/utils/index";
import { uploadExcel } from "@/utils/education/educationApi";
import * as operationData from "../../utils/operation";
let vm = null;
export default {
components: {
......@@ -393,7 +394,7 @@ export default {
let downloadUrl = "";
if (type == "model") {
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") {
downloadUrl = vm.failExcelUrl;
......@@ -634,30 +635,23 @@ export default {
},
addArea(row) {
vm.dialogArea = true;
vm.treeData = [];
vm.tagsRegion = [];
vm.getAdministrative(row);
},
getAdministrative(row) {
vm.doctorId = row.userId;
// let req = {
// projectId: vm.formInline.portalProjectId
// };
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,
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") {
let administrativeAll = res.data.administrativeAll;
let administrative = res.data.administrative;
......@@ -702,76 +696,83 @@ export default {
}
},
onChecked() {
let cData = [],
oldData = (this.treeData.length && this.treeData.slice()) || [],
checkedKeys = this.$refs.tree.getCheckedKeys(),
halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(),
savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map(
key => {
return { type: 1, key: key };
}
),
savedHalfCheckedKeys = halfCheckedKeys.map(key => {
return { type: 2, key: key };
}),
allSelectedKeys = savedCheckedKeys.concat(savedHalfCheckedKeys);
// let cData = [],
// oldData = (this.treeData.length && this.treeData.slice()) || [],
// checkedKeys = this.$refs.tree.getCheckedKeys(),
// halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(),
// savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map(
// key => {
// return { type: 1, key: key };
// }
// ),
// savedHalfCheckedKeys = halfCheckedKeys.map(key => {
// return { type: 2, key: key };
// }),
// 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);
vm.initCheckList(allSelectedKeys);
vm.initCheckList(vm.allSelectedKeys);
},
getTreeCheck() {
let cData = [],
oldData = (this.treeData.length && this.treeData.slice()) || [],
checkedKeys = this.$refs.tree.getCheckedKeys(),
halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(),
savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map(
key => {
return { type: 1, key: key };
}
),
savedHalfCheckedKeys = halfCheckedKeys.map(key => {
return { type: 2, key: key };
}),
allSelectedKeys = savedCheckedKeys.concat(savedHalfCheckedKeys);
// console.log('allSelectedKeys值:',allSelectedKeys)
// let cData = [],
// oldData = (this.treeData.length && this.treeData.slice()) || [],
// checkedKeys = this.$refs.tree.getCheckedKeys(),
// halfCheckedKeys = this.$refs.tree.getHalfCheckedKeys(),
// savedCheckedKeys = this.handlerCheckedData(oldData, checkedKeys).map(
// key => {
// return { type: 1, key: key };
// }
// ),
// savedHalfCheckedKeys = halfCheckedKeys.map(key => {
// return { type: 2, key: key };
// }),
// allSelectedKeys = savedCheckedKeys.concat(savedHalfCheckedKeys);
let checkedTree = operationData.getSimpleCheckedNodes(this.$refs.tree.store);
let halfCheckedTree = this.$refs.tree.getHalfCheckedKeys()
let allSelectedKeys = operationData.setSelectedKeys(checkedTree,halfCheckedTree);
return allSelectedKeys;
},
// 递归删除列表中所有子节点
delSubKeysByNode(node, checkedKeys) {
let idIndex;
if (node.children && node.children.length) {
if (node.children && node.children.length) {
node.children.forEach(elm => {
idIndex = checkedKeys.findIndex(id => {
return id === elm.id;
});
if (idIndex > -1) {
checkedKeys.splice(idIndex, 1);
}
if (elm.children && elm.children.length) {
this.delSubKeysByNode(elm, checkedKeys);
}
});
}
}
},
// 去除子节点
handlerCheckedData(oldData, checkedKeys) {
oldData.forEach(element => {
for (let i = 0; i < checkedKeys.length; i++) {
// 如果此节点被选中,则删除所有子节点
if (element.id === checkedKeys[i]) {
this.delSubKeysByNode(element, checkedKeys);
} else {
if (element.children && element.children.length) {
this.handlerCheckedData(element.children, checkedKeys);
}
}
}
});
return checkedKeys;
},
// // 递归删除列表中所有子节点
// delSubKeysByNode(node, checkedKeys) {
// let idIndex;
// if (node.children && node.children.length) {
// if (node.children && node.children.length) {
// node.children.forEach(elm => {
// idIndex = checkedKeys.findIndex(id => {
// return id === elm.id;
// });
// if (idIndex > -1) {
// checkedKeys.splice(idIndex, 1);
// }
// if (elm.children && elm.children.length) {
// this.delSubKeysByNode(elm, checkedKeys);
// }
// });
// }
// }
// },
// // 去除子节点
// handlerCheckedData(oldData, checkedKeys) {
// oldData.forEach(element => {
// for (let i = 0; i < checkedKeys.length; i++) {
// // 如果此节点被选中,则删除所有子节点
// if (element.id === checkedKeys[i]) {
// this.delSubKeysByNode(element, checkedKeys);
// } else {
// if (element.children && element.children.length) {
// this.handlerCheckedData(element.children, checkedKeys);
// }
// }
// }
// });
// return checkedKeys;
// },
//添加子节点
append(data, node) {
console.log("data:", data);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册