diff --git a/src/views/component/dialog.vue b/src/views/component/dialog.vue
index 8c398fa..e0ff0cf 100644
--- a/src/views/component/dialog.vue
+++ b/src/views/component/dialog.vue
@@ -41,111 +41,108 @@ export default {
},
(() => {
let dom = [];
- this.formInfo.forEach((i, index) => {
- if (i.list_show) {
- dom.push(
- h(
- "el-form-item",
- {
- ref: `elFormItem${i.field}`,
- style: {
- width: "100%",
- },
- props: {
- label: i.name,
- prop: i.field,
- required:
- i.validation instanceof Array
- ? !!i.validation.find((i) => i === "required")
- : false,
- },
+ this.formInfo.filter(i => i.form_show).forEach((i, index) => {
+ dom.push(
+ h(
+ "el-form-item",
+ {
+ ref: `elFormItem${i.field}`,
+ style: {
+ width: "100%",
},
- this.$scopedSlots[i.field]
- ? this.$scopedSlots[i.field]({ fieldInfo: i, form: this.form })
- : [
- h(
- domMap.get(i.edit_input),
- {
- ref: `elEdit_${i.field}`,
- style: {
- width: "100%",
- },
- props: {
- ...addPropsMap.get(i.edit_input),
- ...this.extraProps(i),
- placeholder: i.help,
- value: this.form[i.field],
- },
- attrs: {
- placeholder: i.help || `请填写${i.name}`,
- },
- on: {
- [this.getEventType(i.edit_input)]: (e) => {
- if (i.field) {
- this.form[i.field] = e;
- this.form = Object.assign({}, this.form);
- }
- },
- ['visible-change']:_ => i._params.set()
- },
- scopedSlots:
- i.edit_input === "file" ||
- i.edit_input === "files"
- ? {
- file: (scope) => {
- let { file } = scope;
- return [
- h("div", {}, [
- h("i", {
- class: {
- "el-icon-circle-check":
- file.status === "success",
- "el-icon-loading":
- file.status === "uploading",
- },
- style: {
- color:
- file.status === "success"
- ? "green"
- : "",
- },
- }),
- h(
- "a",
- {
- attrs: {
- href: file.url,
- download: file.name,
- },
- class: {
- "uploaded-a":
- file.status === "success",
- },
- },
- file.name
- ),
- ]),
- h("i", {
- class: "el-icon-close",
- on: {
- ["click"]: () =>
- this.fileRemoveHandler(
- file,
- i.field
- ),
- },
- }),
- ];
- },
- }
- : "",
+ props: {
+ label: i.name,
+ prop: i.field,
+ required:
+ i.validation instanceof Array
+ ? !!i.validation.find((i) => i === "required")
+ : false,
+ },
+ },
+ this.$scopedSlots[i.field]
+ ? this.$scopedSlots[i.field]({ fieldInfo: i, form: this.form })
+ : [
+ h(
+ domMap.get(i.edit_input),
+ {
+ ref: `elEdit_${i.field}`,
+ style: {
+ width: "100%",
+ },
+ props: {
+ ...addPropsMap.get(i.edit_input),
+ ...this.extraProps(i),
+ placeholder: i.help,
+ value: this.form[i.field],
+ },
+ attrs: {
+ placeholder: i.help || `请填写${i.name}`,
+ },
+ on: {
+ [this.getEventType(i.edit_input)]: (e) => {
+ if (i.field) {
+ this.form[i.field] = e;
+ this.form = Object.assign({}, this.form);
+ }
},
- this.optionsRender(h, i)
- ),
- ]
- )
- );
- }
+ },
+ scopedSlots:
+ i.edit_input === "file" ||
+ i.edit_input === "files"
+ ? {
+ file: (scope) => {
+ let { file } = scope;
+ return [
+ h("div", {}, [
+ h("i", {
+ class: {
+ "el-icon-circle-check":
+ file.status === "success",
+ "el-icon-loading":
+ file.status === "uploading",
+ },
+ style: {
+ color:
+ file.status === "success"
+ ? "green"
+ : "",
+ },
+ }),
+ h(
+ "a",
+ {
+ attrs: {
+ href: file.url,
+ download: file.name,
+ },
+ class: {
+ "uploaded-a":
+ file.status === "success",
+ },
+ },
+ file.name
+ ),
+ ]),
+ h("i", {
+ class: "el-icon-close",
+ on: {
+ ["click"]: () =>
+ this.fileRemoveHandler(
+ file,
+ i.field
+ ),
+ },
+ }),
+ ];
+ },
+ }
+ : "",
+ },
+ this.optionsRender(h, i)
+ ),
+ ]
+ )
+ );
});
return dom;
})()
@@ -215,12 +212,12 @@ export default {
//渲染一些组件内部需要选项等
optionsRender(h, info) {
if (info.edit_input === "checkbox" || info.edit_input === "radio") {
- return info._params.get() && info._params.get() instanceof Array
- ? info._params.get().map((i) =>
+ return info._params && info._params instanceof Array
+ ? info._params.map((i) =>
h("el-option", {
props: {
- label: i.name || i.no || i.value || i.id,
- value: i[info._relations.foreign_key],
+ label: i.key || i.name || i.no || i.value || i.id,
+ value: info._relations ? i[info._relations.foreign_key] : i.value,
},
})
)
diff --git a/src/views/component/table.vue b/src/views/component/table.vue
index f8df830..6135c74 100644
--- a/src/views/component/table.vue
+++ b/src/views/component/table.vue
@@ -63,9 +63,9 @@
@@ -160,9 +160,9 @@
@@ -414,26 +414,28 @@ export default {
}
fields.forEach((i, index) => {
i._relations = relation.find((j) => j.local_key === i.field);
- i._params = {
- value: [],
- load: false,
- get: () => i._params.value,
- set: () => {
- if(i._params.load) return
- i._relations.parameter_id
- ? getparameter({ id: i._relations.parameter_id },false).then((res) => {
- i._params.value = res.detail;
- })
- : this.index({
- table_name: i._relations.link_table_name,
- page: 1,
- page_size: 9999,
- }).then((res) => {
- i._params.value = res.data;
- });
- i._params.load = true
- },
- };
+ if (i.select_item && typeof i.select_item === 'object') {
+ let keys = Object.keys(i.select_item)
+ i._params = keys.map(key => {
+ return {
+ key,
+ value: i.select_item[key]
+ }
+ })
+ }
+ if (i._relations) {
+ i._params = i._relations.parameter_id
+ ? getparameter({ id: i._relations.parameter_id },false).then((res) => {
+ i._params = res.detail;
+ })
+ : this.index({
+ table_name: i._relations.link_table_name,
+ page: 1,
+ page_size: 9999,
+ }).then((res) => {
+ i._params = res.data;
+ });
+ }
});
this.form = fields;
console.log(111, this.form);
@@ -469,6 +471,21 @@ export default {
.map((i) => {
let linkOb = {};
+ if (i.select_item && typeof i.select_item === 'object') {
+ let keys = Object.keys(i.select_item)
+ linkOb.customFn = row => {
+ let paramMap = new Map()
+ keys.forEach(key => {
+ paramMap.set(i.select_item[key],key)
+ })
+
+ return (
+
+ { paramMap.get(row[i.field].toString()) }
+
+ )
+ }
+ }
if (i._relations) {
let { link_relation, foreign_key, link_with_name } = i._relations
if (link_relation === 'newHasOne' || link_relation === 'hasOne') {
@@ -485,9 +502,9 @@ export default {
} else {
return (
- {row[link_with_name]?.name ||
+ { row[link_with_name]?.name ||
row[link_with_name]?.no ||
- row[link_with_name]?.value}
+ row[link_with_name]?.value }
);
}
@@ -528,17 +545,24 @@ export default {
columnArrTest() {
return function (field) {
return this.form.find((i) => i.field === field)
- ? this.form.find((i) => i.field === field).search_input === "checkbox"
+ ? this.form.find((i) => i.field === field).search_input === "checkbox" || this.form.find((i) => i.field === field).search_input === "radio"
: false;
};
},
+ getColumnField() {
+ return function (field) {
+ return this.form.find((i) => i.field === field)
+ ? this.form.find((i) => i.field === field)
+ : {};
+ };
+ },
getColumnParams() {
return function (field) {
return this.form.find((i) => i.field === field)
- ? this.form.find((i) => i.field === field)._paramters
+ ? this.form.find((i) => i.field === field)._params
: [];
};
- },
+ }
},
created() {
this.getFormDetail();