提交 ca764835 编写于 作者: haochangdi's avatar haochangdi

优化代码逻辑

上级 00dbb42f
......@@ -80,25 +80,25 @@ export default {
},
created() {
vm = this;
this.initRange();
vm.initRange();
},
methods: {
//选择范围 初始化
initRange() {
console.log('====================initRange')
let projectId = this.projectId;
let projectId = vm.projectId;
if (projectId == null) {
//新建
} else {
//编辑
this.getAdministrative();
vm.getAdministrative();
}
},
//查询行政范围(树)
getAdministrative() {
console.log('=========================getAdministrative')
let req = {
projectId: this.projectId
projectId: vm.projectId
};
openLoading(vm);
vm.GET("portal/scope/v1/administrative", req).then(res => {
......@@ -107,22 +107,22 @@ export default {
//console.log(res.data);
let administrativeAll = res.data.administrativeAll;
let administrative = res.data.administrative;
this.treeData = [];
this.treeData[0] = administrativeAll;
this.setTreeData(administrative);
// this.getCheckedTree();
vm.treeData = [];
vm.treeData[0] = administrativeAll;
vm.setTreeData(administrative);
// vm.getCheckedTree();
}
});
},
//获取勾选树
getCheckedTree() {
console.log('=========================getCheckedTree')
if (this.idType != 2) {
let allTree = JSON.parse(JSON.stringify(this.treeData[0].children));
let changedTags = JSON.parse(JSON.stringify(this.tagsRegion));
if (vm.idType != 2) {
let allTree = JSON.parse(JSON.stringify(vm.treeData[0].children));
let changedTags = JSON.parse(JSON.stringify(vm.tagsRegion));
let organizationArea = operationData.treeHandler(allTree, changedTags);
console.log("多级树:", organizationArea);
this.organizationRegion = organizationArea;
vm.organizationRegion = organizationArea;
}
},
//初始化范围树
......@@ -137,8 +137,8 @@ export default {
checkList[i].key = administrative[i].id;
}
//console.log(treeIdList);
this.$refs.tree.setCheckedKeys(treeIdList);
this.tagsRegion = checkList;
vm.$refs.tree.setCheckedKeys(treeIdList);
vm.tagsRegion = checkList;
},
// 选择行政范围
onChecked(node, data) {
......@@ -146,20 +146,20 @@ export default {
vm.checkUpdate(node, data);
//重构归并树
let checkedTree = operationData.getSimpleCheckedNodes(
this.$refs.tree.store
vm.$refs.tree.store
);
let halfCheckedTree = this.$refs.tree.getHalfCheckedKeys();
let halfCheckedTree = vm.$refs.tree.getHalfCheckedKeys();
let allSelectedKeys = operationData.setSelectedKeys(
checkedTree,
halfCheckedTree
);
//重构内容
this.allSelectedKeys = allSelectedKeys;
this.initCheckList(allSelectedKeys);
vm.allSelectedKeys = allSelectedKeys;
vm.initCheckList(allSelectedKeys);
//console.log("allSelectedKeys", allSelectedKeys);
//改变行政范围后,更新设定机构和设定人员
// this.updateOrganizationAndPerson(allSelectedKeys);
this.updatedTree = true;
// vm.updateOrganizationAndPerson(allSelectedKeys);
vm.updatedTree = true;
},
//v2.2教培更新
checkUpdate(node, data) {
......@@ -171,16 +171,16 @@ export default {
vm.nowCheck = node;
vm.warnType = 0;
vm.dialogWarn = true;
// this.$refs.tree.setChecked(data,false)
// vm.$refs.tree.setChecked(data,false)
}
},
//列举选中地区
initCheckList(allSelectedKeys) {
console.log('=========================initCheckList')
this.tagsRegion = [];
vm.tagsRegion = [];
// console.log(allSelectedKeys);
// console.log(this.$refs.tree.getCheckedNodes());
let nodeData = this.$refs.tree.getCheckedNodes();
// console.log(vm.$refs.tree.getCheckedNodes());
let nodeData = vm.$refs.tree.getCheckedNodes();
for (let i = 0; i < nodeData.length; i++) {
for (let j = 0; j < allSelectedKeys.length; j++) {
if (
......@@ -190,7 +190,7 @@ export default {
let tagObj = {};
tagObj.name = nodeData[i].label;
tagObj.key = nodeData[i].id;
this.tagsRegion.push(tagObj);
vm.tagsRegion.push(tagObj);
}
}
}
......@@ -216,7 +216,7 @@ export default {
let administrative = res.data.administrative;
//console.log(administrative);
data.children = administrative;
this.appendCheck(administrative, node.checked);
vm.appendCheck(administrative, node.checked);
}
});
}
......@@ -226,23 +226,23 @@ export default {
console.log('====================appendCheck')
//console.log(checked,administrative)
let checkList = [];
checkList = this.$refs.tree.getCheckedKeys();
checkList = vm.$refs.tree.getCheckedKeys();
if (checked) {
for (let i = 0; i < administrative.length; i++) {
checkList.push(administrative[i].id);
// console.log(checkList);
}
}
this.$nextTick(function() {
this.$refs.tree.setCheckedKeys(checkList);
vm.$nextTick(function() {
vm.$refs.tree.setCheckedKeys(checkList);
});
},
//删除label节点 同步树结构
handleCloseTree(tag) {
console.log('=========================handleCloseTree')
if (this.status4Flag != 1) {
this.tagsRegion.splice(this.tagsRegion.indexOf(tag), 1);
this.setCheckedKeys(this.tagsRegion);
if (vm.status4Flag != 1) {
vm.tagsRegion.splice(vm.tagsRegion.indexOf(tag), 1);
vm.setCheckedKeys(vm.tagsRegion);
}
},
//通过key设置tree
......@@ -254,14 +254,14 @@ export default {
treeKeyList[index] = tagsRegion[index].key;
}
console.log(treeKeyList);
this.$refs.tree.setCheckedKeys(treeKeyList);
vm.$refs.tree.setCheckedKeys(treeKeyList);
},
//设定的行政范围内容(传给设定机构的范围)
getScope(type) {
let scope = "";
for (let i = 0; i < this.tagsRegion.length; i++) {
scope += this.tagsRegion[i].key;
if (i < this.tagsRegion.length - 1) {
for (let i = 0; i < vm.tagsRegion.length; i++) {
scope += vm.tagsRegion[i].key;
if (i < vm.tagsRegion.length - 1) {
scope += "|";
}
}
......@@ -272,18 +272,18 @@ export default {
},
//设定的行政范围内容(完成或是暂存时传给后台的数据格式)
setScope(type) {
let noChangeTree = this.getTreeCheck();
let noChangeTree = vm.getTreeCheck();
let scope = "";
if (this.allSelectedKeys.length > 0) {
for (let i = 0; i < this.allSelectedKeys.length; i++) {
if (vm.allSelectedKeys.length > 0) {
for (let i = 0; i < vm.allSelectedKeys.length; i++) {
scope +=
this.allSelectedKeys[i].key + ":" + this.allSelectedKeys[i].type;
if (i < this.allSelectedKeys.length - 1) {
vm.allSelectedKeys[i].key + ":" + vm.allSelectedKeys[i].type;
if (i < vm.allSelectedKeys.length - 1) {
scope += "|";
}
}
} else {
// let noChangeTree = this.getTreeCheck();
// let noChangeTree = vm.getTreeCheck();
console.log('noChangeTree值',noChangeTree);
if(noChangeTree.length > 0) {
for (let i = 0; i < noChangeTree.length; i++) {
......@@ -294,9 +294,9 @@ export default {
}
} else {
//选全国项目
if(this.tagsRegion.length > 0 && this.tagsRegion[0].key == '000') {
if(vm.tagsRegion.length > 0 && vm.tagsRegion[0].key == '000') {
scope = '000:1';
console.log(this.tagsRegion,'scope',scope);
console.log(vm.tagsRegion,'scope',scope);
}
}
}
......@@ -308,8 +308,8 @@ export default {
},
getTreeCheck() {
//重构归并树
let checkedTree = operationData.getSimpleCheckedNodes(this.$refs.tree.store);
let halfCheckedTree = this.$refs.tree.getHalfCheckedKeys()
let checkedTree = operationData.getSimpleCheckedNodes(vm.$refs.tree.store);
let halfCheckedTree = vm.$refs.tree.getHalfCheckedKeys()
let allSelectedKeys = operationData.setSelectedKeys(checkedTree,halfCheckedTree);
vm.allSelectedKeys = allSelectedKeys;
//重构内容
......
......@@ -246,32 +246,32 @@ export default {
created() {
vm = this;
vm.idType = localStorage.getItem("storageIdType");
// this.getOrganization();
this.getRegionOption();
this.listLevels();
// vm.getOrganization();
vm.getRegionOption();
vm.listLevels();
},
methods: {
//查询机构列表
getOrganization(r) {
this.regio = r;
this.formOrganization.administrativeIdList = ["0"];
vm.regio = r;
vm.formOrganization.administrativeIdList = ["0"];
let req = {
projectId: this.projectId,
projectId: vm.projectId,
administrativeId: "",
hospitalLevel: "",
hospitalLevel: "",
// scope: this.regio == '' ? null : this.regio,
// scope: vm.regio == '' ? null : vm.regio,
scope: r ? r : null,
pageNum: this.formOrganization.pageNum,
pageSize: this.formOrganization.pageSize
pageNum: vm.formOrganization.pageNum,
pageSize: vm.formOrganization.pageSize
};
openLoading(vm);
// vm.POST("portal/scope/v1/organization", req).then(res => {
vm.POST("portal/new/scope/org/v1/organization", req).then(res => {
closeLoading(vm);
if (res.code == "000000") {
this.tableOrganization = res.data.organizationList;
this.totalOrganization = res.data.total;
vm.tableOrganization = res.data.organizationList;
vm.totalOrganization = res.data.total;
vm.initOrganizationStatus();
} else {
......@@ -287,9 +287,9 @@ export default {
}
let scope = "";
if (type == "administrative") {
for (let i = 0; i < this.tagsRegion.length; i++) {
scope += this.tagsRegion[i].key;
if (i < this.tagsRegion.length - 1) {
for (let i = 0; i < vm.tagsRegion.length; i++) {
scope += vm.tagsRegion[i].key;
if (i < vm.tagsRegion.length - 1) {
scope += "|";
}
}
......@@ -316,11 +316,11 @@ export default {
// 初始化机构状态
initOrganizationStatus() {
console.log('=========================initOrganizationStatus')
let tableStatus = this.tableOrganization;
let tableStatus = vm.tableOrganization;
tableStatus.forEach(row => {
if (row.status == 1) {
this.$nextTick(function() {
this.$refs.multipleOrganization.toggleRowSelection(row);
vm.$nextTick(function() {
vm.$refs.multipleOrganization.toggleRowSelection(row);
});
}
});
......@@ -328,7 +328,7 @@ export default {
// 选择列表
selectableTableList(row, index) {
console.log('=========================selectableTableList')
// if (this.status4Flag == 1) {
// if (vm.status4Flag == 1) {
if (row.modifyFlag == 1) {
return false;
}
......@@ -339,8 +339,8 @@ export default {
//搜索机构
searchOrganization() {
console.log('=========================searchOrganization')
this.formOrganization.pageNum = 1;
let searchForm = this.formOrganization;
vm.formOrganization.pageNum = 1;
let searchForm = vm.formOrganization;
if (
searchForm.administrativeId == "0" &&
searchForm.administrativeIdList[
......@@ -349,11 +349,11 @@ export default {
searchForm.level == "-1" &&
searchForm.name == ""
) {
this.searchOrganizationType = "";
this.getOrganization();
vm.searchOrganizationType = "";
vm.getOrganization();
} else {
this.searchOrganizationType = "choose";
this.getOrganizationChoose();
vm.searchOrganizationType = "choose";
vm.getOrganizationChoose();
}
},
//重置机构、人员查询
......@@ -396,12 +396,12 @@ export default {
if (intersect.length > 0) {
typeStatus = 1;
}
// let = this.$refs.multipleTable.selection
// let = vm.$refs.multipleTable.selection
console.log(selection, setList, selectList);
if (setList.length > 0) {
let req = {
ids: setList,
projectId: this.projectId,
projectId: vm.projectId,
type: typeStatus
};
openLoading(vm);
......@@ -414,18 +414,18 @@ export default {
handleSizeOrganization(val) {
console.log('=========================handleSizeOrganization')
console.log(`每页 ${val} 条`);
this.formOrganization.pageSize = val;
this.searchOrganization();
vm.formOrganization.pageSize = val;
vm.searchOrganization();
},
//分页相关
handleCurrentOrganization(val) {
console.log('=========================handleCurrentOrganization')
//console.log(`当前页: ${val}`);
this.formOrganization.pageNum = val;
if (this.searchOrganizationType == "choose") {
this.getOrganizationChoose();
vm.formOrganization.pageNum = val;
if (vm.searchOrganizationType == "choose") {
vm.getOrganizationChoose();
} else {
this.getOrganization();
vm.getOrganization();
}
},
//机构table中勾选一个
......@@ -440,7 +440,7 @@ export default {
}
let req = {
ids: [row.id],
projectId: this.projectId,
projectId: vm.projectId,
type: flag === false ? 0 : 1
};
openLoading(vm);
......@@ -473,7 +473,7 @@ export default {
let req = {
fileArray: fileArray,
// scopeOfAdministrative: vm.getScope("administrative")
scopeOfAdministrative: this.regio
scopeOfAdministrative: vm.regio
};
let projectId = vm.projectId;
console.log("req", req);
......@@ -534,9 +534,9 @@ export default {
vm.GET("contents/courseDoctor/listLevels?sysCode=10", req).then(res => {
if (res.code == "000000") {
// console.log(res);
this.organizationRank = operationData.getLevelList(res.data.list);
vm.organizationRank = operationData.getLevelList(res.data.list);
} else {
this.organizationRank = [
vm.organizationRank = [
{
id: "0",
label: "全部医院等级"
......@@ -548,19 +548,19 @@ export default {
//机构搜索
getOrganizationChoose() {
console.log('=========================getOrganizationChoose')
// console.log('formOrganization',this.formOrganization);
// console.log('formOrganization',vm.formOrganization);
let administrativeIdItem = operationData.setAdministrativeId(
this.formOrganization.administrativeIdList
vm.formOrganization.administrativeIdList
);
let req = {
projectId: this.projectId,
projectId: vm.projectId,
administrativeId: administrativeIdItem,
hospitalLevel: this.formOrganization.level,
hospitalName: this.formOrganization.name,
pageNum: this.formOrganization.pageNum,
pageSize: this.formOrganization.pageSize,
// scope: this.getScope("administrative")
scope: this.regio
hospitalLevel: vm.formOrganization.level,
hospitalName: vm.formOrganization.name,
pageNum: vm.formOrganization.pageNum,
pageSize: vm.formOrganization.pageSize,
// scope: vm.getScope("administrative")
scope: vm.regio
// scope: '000'
};
openLoading(vm);
......@@ -569,8 +569,8 @@ export default {
closeLoading(vm);
console.log(res);
if (res.code == "000000") {
this.tableOrganization = res.data.organizationList;
this.totalOrganization = res.data.total;
vm.tableOrganization = res.data.organizationList;
vm.totalOrganization = res.data.total;
vm.initOrganizationStatus();
} else {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册