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 1/2] 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 @@
-
+
diff --git a/src/views/component/imports.vue b/src/views/component/imports.vue
index 3ed0977..fd62748 100644
--- a/src/views/component/imports.vue
+++ b/src/views/component/imports.vue
@@ -43,7 +43,7 @@
import * as XLSX from "xlsx";
import { saveAs } from "file-saver";
import { getToken } from "@/utils/auth";
-import { imports } from "@/api/system/baseForm"
+import { imports } from "@/api/system/baseForm";
export default {
props: {
formInfo: {
diff --git a/src/views/component/table.vue b/src/views/component/table.vue
index ac9a263..da64d49 100644
--- a/src/views/component/table.vue
+++ b/src/views/component/table.vue
@@ -283,6 +283,7 @@ export default {
this.selectForm = ''
this.table = res.data.map(i => {
let linkOb = {}
+
if(i.parameter_id) {
linkOb.customFn = row => {
return (
@@ -293,9 +294,15 @@ export default {
if(i.link_table_name) {
if(i.link_relation === 'hasOne') {
linkOb.customFn = row => {
- return (
- { row[i.link_with_name]?.name || row[i.link_with_name]?.no || row[i.link_with_name]?.value }
- )
+ if(i.edit_input === 'file') {
+ return (
+ { row[i.link_with_name]?.original_name }
+ )
+ }else{
+ return (
+ { row[i.link_with_name]?.name || row[i.link_with_name]?.no || row[i.link_with_name]?.value }
+ )
+ }
}
}
if(i.link_relation === 'hasMany') {
@@ -311,8 +318,15 @@ export default {
return Object.assign({
prop: i.field,
label: i.name,
+ width: i.width,
+ fixed: i.is_fixed
},linkOb)
})
+ this.table.unshift({
+ type: 'index',
+ width: 60,
+ label: '序号'
+ })
}
},
computed: {
@@ -360,4 +374,15 @@ export default {
padding: 0 10px;
}
}
+
+a {
+ color: red;
+ text-decoration: none;
+ transition: all 0.2s;
+}
+
+a:hover {
+ color: red;
+ text-decoration: underline;
+}
diff --git a/src/views/system/components/editPane.vue b/src/views/system/components/editPane.vue
index fb19b18..2fdd4aa 100644
--- a/src/views/system/components/editPane.vue
+++ b/src/views/system/components/editPane.vue
@@ -15,7 +15,7 @@
>
-
+
+
+
+
+
+
+
+
+
保存
-
+
diff --git a/src/views/system/components/formEditor.vue b/src/views/system/components/formEditor.vue
index 0fa48a1..b56794a 100644
--- a/src/views/system/components/formEditor.vue
+++ b/src/views/system/components/formEditor.vue
@@ -205,6 +205,8 @@ export default {
list_show: 1,
link_table_name: "",
link_relation: "",
+ is_fix: "",
+ width: ""
};
this.$store.commit("form/SPLICE_FORM_LIST", {
diff --git a/src/views/system/form.vue b/src/views/system/form.vue
index f5ad469..f2e3967 100644
--- a/src/views/system/form.vue
+++ b/src/views/system/form.vue
@@ -69,13 +69,13 @@ export default {
{
prop:'table_name',
label:'表名',
- width:180,
+ //width:180,
sortable:'custom',
},
{
prop:'name',
label:'名称',
- width:200,
+ // width:200,
sortable:'custom',
},
]