From 789d8f482de16b31b8ec05ccd886df28226c4fcc Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Tue, 30 May 2023 17:27:28 +0800 Subject: [PATCH] 2023-5-30 --- src/api/system/customForm.js | 7 +++++ src/components/XyTable/index.vue | 16 ++++++++-- src/const/addProps.js | 6 ++-- src/const/inputType.js | 4 +-- src/const/templateProps.js | 4 +++ src/views/component/dialog.vue | 29 +++++++------------ src/views/component/table.vue | 10 +++---- src/views/system/components/editPane.vue | 5 ++-- src/views/system/components/formEditor.vue | 15 ++-------- .../system/components/formSlotRender.vue | 7 ++--- 10 files changed, 52 insertions(+), 51 deletions(-) diff --git a/src/api/system/customForm.js b/src/api/system/customForm.js index 63a7b24..ba03a48 100644 --- a/src/api/system/customForm.js +++ b/src/api/system/customForm.js @@ -42,3 +42,10 @@ export function update(params) { isLoading:false }) } + +export function realTableIndex() { + return request({ + method: "get", + url: '/api/admin/custom-form/real-table-index' + }) +} diff --git a/src/components/XyTable/index.vue b/src/components/XyTable/index.vue index aa0ecac..de19889 100644 --- a/src/components/XyTable/index.vue +++ b/src/components/XyTable/index.vue @@ -196,6 +196,13 @@ export default { }, methods: { //方法 + calculateTextWidth(text) { + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + context.font = '14px Arial'; // Set the font size and family to match the table cell's font + const metrics = context.measureText(text); + return metrics.width; + }, initLoad() { let clientHeight = document.documentElement.clientHeight; let lxheader = document @@ -237,6 +244,7 @@ export default { this.totalData = res.data.total; setTimeout(() => { this.loading = false; + }, 300); }) .catch((err) => { @@ -255,6 +263,7 @@ export default { this.totalData = res.total; setTimeout(() => { this.loading = false; + }, 300); }) .catch((err) => { @@ -795,7 +804,7 @@ export default { column-key={String(Math.random())} label={item.label} prop={item.prop} - width={item.width ?? "auto"} + width={item.width || "auto"} min-width={item.minWidth} fixed={item.fixed ?? false} render-header={item.renderHeader} @@ -808,8 +817,9 @@ export default { show-overflow-tooltip={item.showOverflowTooltip ?? true} align={item.align ?? "center"} header-align={item.headerAlign ?? "center"} - class-name={`xy-table__row-fade ${item.className}`} - label-class-name={`xy-table__title-fade ${item.labelClassName}`} + class-name={`xy-table__row-fade ${item.className} body-cell-${index}`} + label-class-name={`xy-table__title-fade ${item.labelClassName} header-cell-${index}`} + selectable={item.selectable} reserve-selection={item.reserveSelection} filters={item.filters} diff --git a/src/const/addProps.js b/src/const/addProps.js index 03cb3d1..edd8a70 100644 --- a/src/const/addProps.js +++ b/src/const/addProps.js @@ -6,10 +6,12 @@ export const addPropsMap = new Map([ }], ["richtext",{}], ['radio',{ - + clearable: true }], ["checkbox", { - + collapseTags: true, + multiple: true, + clearable: true }], ["date", { clearable: true, diff --git a/src/const/inputType.js b/src/const/inputType.js index 032629c..91d8ebc 100644 --- a/src/const/inputType.js +++ b/src/const/inputType.js @@ -1,8 +1,8 @@ export const domMap = new Map([ ["text", "el-input"], ["richtext",'my-tinymce'], - ['radio','el-radio-group'], - ["checkbox", "el-checkbox-group"], + ['radio','el-select'], + ["checkbox", "el-select"], ["date", "el-date-picker"], ["datetime", "el-date-picker"], ["file","el-upload"], diff --git a/src/const/templateProps.js b/src/const/templateProps.js index 6576107..06b20c6 100644 --- a/src/const/templateProps.js +++ b/src/const/templateProps.js @@ -5,10 +5,14 @@ export const templatePropsMap = new Map([ clearable: true }], ["richtext",'my-tinymce'], + ['select', { + value: '选项1' + }], ['radio',{ value: '选项1' }], ["checkbox", { + multiple: true, value: ['选项1'] }], ["date", { diff --git a/src/views/component/dialog.vue b/src/views/component/dialog.vue index 31563f1..7de13eb 100644 --- a/src/views/component/dialog.vue +++ b/src/views/component/dialog.vue @@ -54,6 +54,7 @@ export default { props: { label: i.name, prop: i.field, + required: i.validation instanceof Array ? !!i.validation.find(i => i === 'required') : false, }, }, [ @@ -61,6 +62,9 @@ export default { domMap.get(i.edit_input), { ref: `elEdit_${i.field}`, + style: { + width: '100%' + }, props: { ...addPropsMap.get(i.edit_input), ...this.extraProps(i), @@ -152,26 +156,14 @@ export default { //渲染一些组件内部需要选项等 optionsRender(h, info) { - if (info.edit_input === "radio") { + if (info.edit_input === "checkbox" || info.edit_input === "radio") { return info._paramters && info._paramters instanceof Array ? info._paramters.map((i) => - h( - "el-radio", - { props: { label: i.id } }, - i.name || i.no || i.value || i.id - ) - ) - : []; - } - if (info.edit_input === "checkbox") { - return info._paramters && info._paramters instanceof Array - ? info._paramters.map((i) => - h( - "el-checkbox", - { props: { label: i.id } }, - i.name || i.no || i.value || i.id - ) + h( + "el-option", + { props: { label: i.name || i.no || i.value || i.id , value : i.id } } ) + ) : []; } if (info.edit_input === "file" || info.edit_input === "files") { @@ -330,7 +322,7 @@ export default { newVal.forEach((i) => { if (i.field) { this.form[i.field] = ""; - if (i.validation instanceof Array && i.validation.length > 0) { + if (i.validation instanceof Array && i.validation.length > 0 && !!i.validation.find(i => i === 'required')) { this.rules[i.field] = [ { required: true, message: `请填写${i.name}` }, ]; @@ -355,6 +347,7 @@ export default { this.$nextTick(() => this.getDetail()); } } else { + this.file = {}; this.id = ""; this.type = ""; this.init(); diff --git a/src/views/component/table.vue b/src/views/component/table.vue index 0113ce5..ac9a263 100644 --- a/src/views/component/table.vue +++ b/src/views/component/table.vue @@ -141,7 +141,7 @@