master
xy 3 years ago
parent d5ef591186
commit 669aa8cc11

@ -464,44 +464,41 @@ export default {
// }) // })
// } // }
// this.form = res.fields // this.form = res.fields
this.table = res.fields this.table = this.form
?.filter((i) => i.list_show) ?.filter((i) => i.list_show)
.map((i) => { .map((i) => {
let linkOb = {}; let linkOb = {};
if (i.parameter_id) { if (i._relations) {
linkOb.customFn = (row) => { let { link_relation, foreign_key, link_with_name } = i._relations
return <span>{row[i.link_with_name]?.value}</span>; if (link_relation === 'newHasOne' || link_relation === 'hasOne') {
}; linkOb.customFn = row => {
}
if (i.link_table_name) {
if (i.link_relation === "hasOne") {
linkOb.customFn = (row) => {
if (i.edit_input === "file") { if (i.edit_input === "file") {
return ( return (
<a <a
download={row[i.link_with_name]?.original_name} download={row[link_with_name]?.original_name}
href={row[i.link_with_name]?.url} href={row[link_with_name]?.url}
> >
{row[i.link_with_name]?.original_name} {row[link_with_name]?.original_name}
</a> </a>
); );
} else { } else {
return ( return (
<span> <span>
{row[i.link_with_name]?.name || {row[link_with_name]?.name ||
row[i.link_with_name]?.no || row[link_with_name]?.no ||
row[i.link_with_name]?.value} row[link_with_name]?.value}
</span> </span>
); );
} }
};
} }
if (i.link_relation === "hasMany") { }
if (link_relation === "hasMany" || link_relation === 'newHasMany') {
linkOb.customFn = (row) => { linkOb.customFn = (row) => {
return ( return (
<div> <div>
{row[i.link_with_name]?.map((o) => ( {row[link_with_name]?.map((o) => (
<span>{o?.name || o?.no || o?.value}</span> <span>{o?.name || o?.no || o?.value}</span>
))} ))}
</div> </div>

@ -23,6 +23,36 @@
placeholder="请输入帮助文字" placeholder="请输入帮助文字"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="select_item" label="下拉框选项">
<div class="select-item">
<div class="select-item__header">
<span></span>
<span></span>
</div>
<div class="select-item__body" v-for="(i, index) in selectItem">
<div><el-input v-model="i.key" size="mini"></el-input></div>
<div><el-input v-model="i.value" size="mini"></el-input></div>
<div>
<el-button
type="danger"
size="mini"
circle
icon="el-icon-delete"
@click="selectItem.splice(index, 1)"
></el-button>
</div>
</div>
<el-button
type="primary"
size="mini"
circle
icon="el-icon-plus"
@click="selectItem.push({ key: '', value: '' })"
></el-button>
</div>
</el-form-item>
<el-form-item prop="validation" label="校验规则"> <el-form-item prop="validation" label="校验规则">
<el-select <el-select
v-model="selectedForm.validation" v-model="selectedForm.validation"
@ -64,7 +94,10 @@
style="width: 100%" style="width: 100%"
> >
<el-option <el-option
v-for="item in [{ value: 'left',label: '左' }, { value: 'right',label: '右' }]" v-for="item in [
{ value: 'left', label: '左' },
{ value: 'right', label: '右' },
]"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
></el-option> ></el-option>
@ -140,7 +173,6 @@
<script> <script>
import { index as formIndex, realTableIndex } from "@/api/system/customForm"; import { index as formIndex, realTableIndex } from "@/api/system/customForm";
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";
@ -164,6 +196,7 @@ export default {
], ],
}, },
selectItem: [], //
parameters: [], // parameters: [], //
forms: [], // forms: [], //
}; };
@ -184,11 +217,20 @@ export default {
async getForms() { async getForms() {
const resReal = await realTableIndex(); 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,...resReal.map(i => { return { name: i,table_name: i } })]; this.forms = [
...res.data,
...resReal.map((i) => {
return { name: i, table_name: i };
}),
];
}, },
saveField() { saveField() {
this.selectItem.forEach(i => {
this.selectedForm.select_item = {}
this.selectedForm.select_item[i.key] = i.value;
})
this.$store.commit("form/SPLICE_FORM_LIST", { this.$store.commit("form/SPLICE_FORM_LIST", {
index: this.selectedIndex, index: this.selectedIndex,
length: 1, length: 1,
@ -201,6 +243,21 @@ export default {
computed: { computed: {
...mapState("form", ["selectedForm", "formList", "selectedIndex"]), ...mapState("form", ["selectedForm", "formList", "selectedIndex"]),
}, },
watch: {
selectedForm(newVal) {
if(newVal) {
this.selectItem = [];
if(newVal.select_item && typeof newVal.select_item === "object") {
for(let key in newVal.select_item) {
this.selectItem.push({
key,
value: newVal.select_item[key]
})
}
}
}
}
},
created() { created() {
this.getForms(); this.getForms();
@ -225,4 +282,32 @@ export default {
::v-deep .el-input-number.is-without-controls .el-input__inner { ::v-deep .el-input-number.is-without-controls .el-input__inner {
text-align: left; text-align: left;
} }
.select-item {
text-align: center;
&__header {
font-weight: 600;
display: flex;
& > span {
flex-basis: 30%;
& + span {
margin-left: 10px;
}
}
}
&__body {
display: flex;
& > div {
flex-basis: 30%;
& + div {
margin-left: 10px;
}
}
}
}
</style> </style>

@ -201,7 +201,7 @@ export default {
sort: newIndex, sort: newIndex,
help: "", help: "",
validation: "", validation: "",
select_item: "", select_item: {},
list_show: 1, list_show: 1,
form_show: 1, form_show: 1,
is_fix: "", is_fix: "",

Loading…
Cancel
Save