Skip to content

Commit fd1035c

Browse files
committed
perf(FormDesignerModule): some change
1 parent b9f003d commit fd1035c

File tree

1 file changed

+83
-75
lines changed

1 file changed

+83
-75
lines changed

src/views/devTools/FormDesignerModule.vue

Lines changed: 83 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</template>
2424
</CrudTable>
2525
<el-dialog v-if="visible" ref="dialog" fullscreen class="dialog" :visible.sync="visible" append-to-body>
26-
<FormDesigner ref="formDesigner" :getFormKey="getFormKey" :allTables="allTables">
26+
<FormDesigner ref="formDesigner" :dictType="dictType" :getFormKey="getFormKey" :allTables="allTables">
2727
<template #custom-btn>
2828
<el-button type="normal" size="small" @click="btnSaveOnClick" :loading="btnSaveIsLoading">保存</el-button>
2929
</template>
@@ -54,90 +54,98 @@ export default class FormDesignerModule extends Vue {
5454
5555
formValues = {};
5656
57-
created() {
58-
getTables().then((res) => {
59-
this.allTables = res.data.map(item => ({
60-
label: item.TABLE_NAME,
61-
value: item.TABLE_NAME,
62-
}));
63-
});
64-
}
57+
dictType = [];
6558
66-
getFormKey(tablename) {
67-
return getFormKey(tablename);
68-
}
59+
created() {
60+
crud(DML.SELECT, 'ad_codelist_type').then((res) => {
61+
this.dictType = res.data.list.map(item => ({
62+
label: item.typeName,
63+
value: item.id,
64+
}));
65+
});
66+
getTables().then((res) => {
67+
this.allTables = res.data.map(item => ({
68+
label: item.TABLE_NAME,
69+
value: item.TABLE_NAME,
70+
}));
71+
});
72+
}
6973
70-
// 添加按钮点击事件
71-
btnAddOnClick() {
72-
this.formValues = {};
73-
this.visible = true;
74-
}
74+
getFormKey(tablename) {
75+
return getFormKey(tablename);
76+
}
7577
76-
// 编辑按钮点击事件
77-
btnEditOnClick(row) {
78-
this.formValues = { ...row };
79-
this.visible = true;
80-
this.$nextTick(() => {
81-
this.$refs.formDesigner.setJSON(JSON.parse(row.formJson));
78+
// 添加按钮点击事件
79+
btnAddOnClick() {
80+
this.formValues = {};
81+
this.visible = true;
82+
}
83+
84+
// 编辑按钮点击事件
85+
btnEditOnClick(row) {
86+
this.formValues = { ...row };
87+
this.visible = true;
88+
this.$nextTick(() => {
89+
this.$refs.formDesigner.setJSON(JSON.parse(row.formJson));
90+
});
91+
}
92+
93+
// 复制表单设计json
94+
btnCopyOnClick(row) {
95+
const r = { ...row };
96+
r.tableName += '_复制';
97+
delete r.id;
98+
crud(DML.INSERT, 'form', r).then((res) => {
99+
if (res.code !== 200) {
100+
this.$message({
101+
type: 'error',
102+
message: `保存失败,原因:${res.message}`,
103+
});
104+
return;
105+
}
106+
this.$message({
107+
type: 'success',
108+
message: '复制成功',
82109
});
83-
}
110+
this.$refs.table.tableReload();
111+
});
112+
}
84113
85-
// 复制表单设计json
86-
btnCopyOnClick(row) {
87-
const r = { ...row };
88-
r.tableName += '_复制';
89-
delete r.id;
90-
crud(DML.INSERT, 'form', r).then((res) => {
91-
if (res.code !== 200) {
92-
this.$message({
93-
type: 'error',
94-
message: `保存失败,原因:${res.message}`,
95-
});
96-
return;
97-
}
114+
// 保存设计
115+
btnSaveOnClick() {
116+
const formValues = this.$refs.formDesigner.getData();
117+
this.btnSaveIsLoading = true;
118+
// 调用此方法验证表单数据和获取表单数据
119+
let type;
120+
let msg;
121+
// 根据对话框状态判断保存或编辑
122+
if (this.dialogStatus === STATUS.CREATE) {
123+
type = DML.INSERT;
124+
msg = '添加成功';
125+
} else {
126+
type = DML.UPDATE;
127+
msg = '编辑成功';
128+
}
129+
// 如果有代理的保存方法
130+
crud(type, 'form', {
131+
...this.formValues,
132+
formJson: JSON.stringify(formValues),
133+
tableName: formValues.config.name,
134+
position: formValues.config.position,
135+
})
136+
.then(() => {
137+
this.btnSaveIsLoading = false;
98138
this.$message({
99139
type: 'success',
100-
message: '复制成功',
140+
message: msg,
101141
});
142+
this.visible = false;
102143
this.$refs.table.tableReload();
103-
});
104-
}
105-
106-
// 保存设计
107-
btnSaveOnClick() {
108-
const formValues = this.$refs.formDesigner.getData();
109-
this.btnSaveIsLoading = true;
110-
// 调用此方法验证表单数据和获取表单数据
111-
let type;
112-
let msg;
113-
// 根据对话框状态判断保存或编辑
114-
if (this.dialogStatus === STATUS.CREATE) {
115-
type = DML.INSERT;
116-
msg = '添加成功';
117-
} else {
118-
type = DML.UPDATE;
119-
msg = '编辑成功';
120-
}
121-
// 如果有代理的保存方法
122-
crud(type, 'form', {
123-
...this.formValues,
124-
formJson: JSON.stringify(formValues),
125-
tableName: formValues.config.name,
126-
position: formValues.config.position,
127144
})
128-
.then(() => {
129-
this.btnSaveIsLoading = false;
130-
this.$message({
131-
type: 'success',
132-
message: msg,
133-
});
134-
this.visible = false;
135-
this.$refs.table.tableReload();
136-
})
137-
.catch(() => {
138-
this.btnSaveIsLoading = false;
139-
});
140-
}
145+
.catch(() => {
146+
this.btnSaveIsLoading = false;
147+
});
148+
}
141149
}
142150
</script>
143151
<style lang="scss" scoped>

0 commit comments

Comments
 (0)