优化动态表单逻辑

dev
smallchill 6 years ago
parent 4cfafd538f
commit 4c1228bdd4
  1. 67
      src/views/authority/datascope.vue

@ -107,6 +107,7 @@
scopeMenuName: "菜单", scopeMenuName: "菜单",
scopeLoading: false, scopeLoading: false,
menu: true, menu: true,
watchMode: true,
option: { option: {
tip: false, tip: false,
dialogWidth: "60%", dialogWidth: "60%",
@ -429,38 +430,40 @@
}, },
methods: { methods: {
initScope() { initScope() {
const scopeType = this.formScope.scopeType; if (this.watchMode) {
let column = "-", name = "暂无"; const scopeType = this.formScope.scopeType;
if (scopeType === "1") { let column = "-", name = "暂无";
column = "-"; if (scopeType === "1") {
name = "全部可见"; column = "-";
} else if (scopeType === "2") { name = "全部可见";
column = "create_user"; } else if (scopeType === "2") {
name = "本人可见"; column = "create_user";
} else if (scopeType === "3") { name = "本人可见";
column = "create_dept"; } else if (scopeType === "3") {
name = "所在机构可见"; column = "create_dept";
} else if (scopeType === "4") { name = "所在机构可见";
column = "create_dept"; } else if (scopeType === "4") {
name = "所在机构可见及子级可见"; column = "create_dept";
} else if (scopeType === "5") { name = "所在机构可见及子级可见";
column = ""; } else if (scopeType === "5") {
name = "自定义"; column = "";
} name = "自定义";
this.$refs.crudScope.option.column.filter(item => {
if (item.prop === "scopeName") {
this.formScope.scopeName = `${this.scopeMenuName} [${name}]`;
}
if (item.prop === "resourceCode") {
this.formScope.resourceCode = this.scopeMenuCode;
}
if (item.prop === "scopeColumn") {
this.formScope.scopeColumn = column;
} }
if (item.prop === "scopeValue") { this.$refs.crudScope.option.column.filter(item => {
item.display = scopeType === '5'; if (item.prop === "scopeName") {
} this.formScope.scopeName = `${this.scopeMenuName} [${name}]`;
}); }
if (item.prop === "resourceCode") {
this.formScope.resourceCode = this.scopeMenuCode;
}
if (item.prop === "scopeColumn") {
this.formScope.scopeColumn = column;
}
if (item.prop === "scopeValue") {
item.display = scopeType === '5';
}
});
}
}, },
// //
rowSave(row, loading, done) { rowSave(row, loading, done) {
@ -655,9 +658,11 @@
}, },
beforeOpenScope(done, type) { beforeOpenScope(done, type) {
if (["add"].includes(type)) { if (["add"].includes(type)) {
this.watchMode = true;
this.initScope(); this.initScope();
} }
if (["edit", "view"].includes(type)) { if (["edit", "view"].includes(type)) {
this.watchMode = false;
getMenuDataScope(this.formScope.id).then(res => { getMenuDataScope(this.formScope.id).then(res => {
this.formScope = res.data.data; this.formScope = res.data.data;
}); });

Loading…
Cancel
Save