master
xy 3 years ago
parent 7636cb02ab
commit 789d8f482d

@ -42,3 +42,10 @@ export function update(params) {
isLoading:false isLoading:false
}) })
} }
export function realTableIndex() {
return request({
method: "get",
url: '/api/admin/custom-form/real-table-index'
})
}

@ -196,6 +196,13 @@ export default {
}, },
methods: { 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() { initLoad() {
let clientHeight = document.documentElement.clientHeight; let clientHeight = document.documentElement.clientHeight;
let lxheader = document let lxheader = document
@ -237,6 +244,7 @@ export default {
this.totalData = res.data.total; this.totalData = res.data.total;
setTimeout(() => { setTimeout(() => {
this.loading = false; this.loading = false;
}, 300); }, 300);
}) })
.catch((err) => { .catch((err) => {
@ -255,6 +263,7 @@ export default {
this.totalData = res.total; this.totalData = res.total;
setTimeout(() => { setTimeout(() => {
this.loading = false; this.loading = false;
}, 300); }, 300);
}) })
.catch((err) => { .catch((err) => {
@ -795,7 +804,7 @@ export default {
column-key={String(Math.random())} column-key={String(Math.random())}
label={item.label} label={item.label}
prop={item.prop} prop={item.prop}
width={item.width ?? "auto"} width={item.width || "auto"}
min-width={item.minWidth} min-width={item.minWidth}
fixed={item.fixed ?? false} fixed={item.fixed ?? false}
render-header={item.renderHeader} render-header={item.renderHeader}
@ -808,8 +817,9 @@ export default {
show-overflow-tooltip={item.showOverflowTooltip ?? true} show-overflow-tooltip={item.showOverflowTooltip ?? true}
align={item.align ?? "center"} align={item.align ?? "center"}
header-align={item.headerAlign ?? "center"} header-align={item.headerAlign ?? "center"}
class-name={`xy-table__row-fade ${item.className}`} class-name={`xy-table__row-fade ${item.className} body-cell-${index}`}
label-class-name={`xy-table__title-fade ${item.labelClassName}`} label-class-name={`xy-table__title-fade ${item.labelClassName} header-cell-${index}`}
selectable={item.selectable} selectable={item.selectable}
reserve-selection={item.reserveSelection} reserve-selection={item.reserveSelection}
filters={item.filters} filters={item.filters}

@ -6,10 +6,12 @@ export const addPropsMap = new Map([
}], }],
["richtext",{}], ["richtext",{}],
['radio',{ ['radio',{
clearable: true
}], }],
["checkbox", { ["checkbox", {
collapseTags: true,
multiple: true,
clearable: true
}], }],
["date", { ["date", {
clearable: true, clearable: true,

@ -1,8 +1,8 @@
export const domMap = new Map([ export const domMap = new Map([
["text", "el-input"], ["text", "el-input"],
["richtext",'my-tinymce'], ["richtext",'my-tinymce'],
['radio','el-radio-group'], ['radio','el-select'],
["checkbox", "el-checkbox-group"], ["checkbox", "el-select"],
["date", "el-date-picker"], ["date", "el-date-picker"],
["datetime", "el-date-picker"], ["datetime", "el-date-picker"],
["file","el-upload"], ["file","el-upload"],

@ -5,10 +5,14 @@ export const templatePropsMap = new Map([
clearable: true clearable: true
}], }],
["richtext",'my-tinymce'], ["richtext",'my-tinymce'],
['select', {
value: '选项1'
}],
['radio',{ ['radio',{
value: '选项1' value: '选项1'
}], }],
["checkbox", { ["checkbox", {
multiple: true,
value: ['选项1'] value: ['选项1']
}], }],
["date", { ["date", {

@ -54,6 +54,7 @@ export default {
props: { props: {
label: i.name, label: i.name,
prop: i.field, 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), domMap.get(i.edit_input),
{ {
ref: `elEdit_${i.field}`, ref: `elEdit_${i.field}`,
style: {
width: '100%'
},
props: { props: {
...addPropsMap.get(i.edit_input), ...addPropsMap.get(i.edit_input),
...this.extraProps(i), ...this.extraProps(i),
@ -152,24 +156,12 @@ export default {
// //
optionsRender(h, info) { 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 return info._paramters && info._paramters instanceof Array
? info._paramters.map((i) => ? info._paramters.map((i) =>
h( h(
"el-checkbox", "el-option",
{ props: { label: i.id } }, { props: { label: i.name || i.no || i.value || i.id , value : i.id } }
i.name || i.no || i.value || i.id
) )
) )
: []; : [];
@ -330,7 +322,7 @@ export default {
newVal.forEach((i) => { newVal.forEach((i) => {
if (i.field) { if (i.field) {
this.form[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] = [ this.rules[i.field] = [
{ required: true, message: `请填写${i.name}` }, { required: true, message: `请填写${i.name}` },
]; ];
@ -355,6 +347,7 @@ export default {
this.$nextTick(() => this.getDetail()); this.$nextTick(() => this.getDetail());
} }
} else { } else {
this.file = {};
this.id = ""; this.id = "";
this.type = ""; this.type = "";
this.init(); this.init();

@ -141,7 +141,7 @@
</template> </template>
<script> <script>
import { index as fieldIndex } from "@/api/system/customFormField" import { index as fieldIndex } from "@/api/system/customFormField";
import { authMixin } from "@/mixin/authMixin"; import { authMixin } from "@/mixin/authMixin";
import { index,destroy } from "@/api/system/baseForm"; import { index,destroy } from "@/api/system/baseForm";
import { op } from "@/const/op"; import { op } from "@/const/op";
@ -216,8 +216,6 @@ export default {
const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' }); const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
saveAs(new Blob([wbout], { type: 'application/octet-stream' }), `${sheetName}.xlsx`); saveAs(new Blob([wbout], { type: 'application/octet-stream' }), `${sheetName}.xlsx`);
} }
// download('/api/admin/base-form/index','get',Object.assign(select,{ page: 1,page_size: 9999,is_export: 1 }),`${new Date().getTime()}.xlsx`)
}, },
//target //target
@ -259,7 +257,7 @@ export default {
res.data.forEach(i => { res.data.forEach(i => {
if (i.field) { if (i.field) {
if ( if (
(i.edit_input === "checkbox" || i.edit_input === "radio") && (i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
i.parameter_id i.parameter_id
) { ) {
getparameter({ id: i.parameter_id }).then((res) => { getparameter({ id: i.parameter_id }).then((res) => {
@ -267,7 +265,7 @@ export default {
}); });
} }
if ( if (
(i.edit_input === "checkbox" || i.edit_input === "radio") && (i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
i.link_table_name i.link_table_name
) { ) {
index({ index({
@ -312,7 +310,7 @@ export default {
} }
return Object.assign({ return Object.assign({
prop: i.field, prop: i.field,
label: i.name label: i.name,
},linkOb) },linkOb)
}) })
} }

@ -186,7 +186,7 @@
</template> </template>
<script> <script>
import { index as formIndex } from "@/api/system/customForm"; import { index as formIndex, realTableIndex } from "@/api/system/customForm";
import { listparameter } from "@/api/system/dictionary"; import { listparameter } from "@/api/system/dictionary";
import { translate } from "@/api/system/customFormField"; import { translate } from "@/api/system/customFormField";
import { debounce } from "@/utils"; import { debounce } from "@/utils";
@ -229,8 +229,9 @@ export default {
}, },
async getForms() { async getForms() {
const resReal = await realTableIndex();
const res = await formIndex({ page: 1, page_size: 999 }); const res = await formIndex({ page: 1, page_size: 999 });
this.forms = res.data; this.forms = [...res.data,...resReal.map(i => { return { name: i,table_name: i } })];
}, },
async getParameters() { async getParameters() {
const res = await listparameter({ page: 1, page_size: 999 }); const res = await listparameter({ page: 1, page_size: 999 });

@ -63,6 +63,7 @@
> >
<template> <template>
<el-form <el-form
style="min-height: 200px;"
label-width="80px" label-width="80px"
label-position="right" label-position="right"
size="small" size="small"
@ -75,7 +76,7 @@
<el-form-item <el-form-item
:label="i.name || '字段名称'" :label="i.name || '字段名称'"
:required=" :required="
!!i.validation && i.validation.length > 0 i.validation instanceof Array ? !!i.validation.find(i => i === 'required') : false
" "
v-for="(i, index) in formList" v-for="(i, index) in formList"
@click.native="selectPick(i, index)" @click.native="selectPick(i, index)"
@ -112,10 +113,8 @@
</template> </template>
<script> <script>
import { listparameter } from "@/api/system/dictionary";
import { index, config } from "@/api/system/customFormField"; import { index, config } from "@/api/system/customFormField";
import { mapState } from "vuex"; import { mapState } from "vuex";
import { index as formIndex } from "@/api/system/customForm";
import { deepCopy } from "@/utils"; import { deepCopy } from "@/utils";
import { update } from "@/api/system/customForm"; import { update } from "@/api/system/customForm";
@ -176,14 +175,6 @@ export default {
}, },
// //
async getForms() {
const res = await formIndex({ page: 1, page_size: 999 });
this.forms = res.data;
},
async getParameters() {
const res = await listparameter({ page: 1, page_size: 999 });
this.parameters = res.data;
},
async getConfig() { async getConfig() {
const { edit_to_migration, validation_rules } = await config(false); const { edit_to_migration, validation_rules } = await config(false);
this.types = edit_to_migration; this.types = edit_to_migration;
@ -216,8 +207,6 @@ export default {
link_relation: "", link_relation: "",
}; };
console.log(newItem);
this.$store.commit("form/SPLICE_FORM_LIST", { this.$store.commit("form/SPLICE_FORM_LIST", {
index: newIndex, index: newIndex,
length: 0, length: 0,

@ -12,11 +12,8 @@ export default {
}, },
methods: { methods: {
optionsRender(h) { optionsRender(h) {
if (this.config.edit_input === "radio") { if(this.config.edit_input === "checkbox" || this.config.edit_input === "radio") {
return ['选项1','选项2','选项3'].map(i => h('el-radio',{ label: i }, i)) return ['选项1','选项2','选项3'].map(i => h('el-option',{ props: { value: i,label: i } }))
}
if(this.config.edit_input === "checkbox") {
return ['选项1','选项2','选项3'].map(i => h('el-checkbox',{ label: i }, i))
} }
if(this.config.edit_input === "file" || this.config.edit_input === "files") { if(this.config.edit_input === "file" || this.config.edit_input === "files") {
return [ return [

Loading…
Cancel
Save