dev
xy 2 years ago
parent c1966c586e
commit 529aca4ca7

@ -140,14 +140,60 @@ export default {
]; ];
Promise.all(promiseAll).then(res => { Promise.all(promiseAll).then(res => {
let dataTable = this.allTables.find(t => t.table_name === res[1].relation[0].link_table_name); if (item.edit_input !== 'files') {
formShow({ id: dataTable.id }).then(res1 => { let dataTable = this.allTables.find(t => t.table_name === res[1].relation[0].link_table_name);
formShow({ id: dataTable.id }).then(res1 => {
this.linkTableList.push({
value: res[0].data?.map(o => o[res[1]?.relation[0]?.link_with_name]),
field: this.formatColumn(res1),
title: res[1]?.name
})
})
} else {
this.linkTableList.push({ this.linkTableList.push({
value: res[0].data?.map(o => o[res[1]?.relation[0]?.link_with_name]), value: res[0].data?.map(o => o[res[1]?.relation[0]?.link_with_name]),
field: this.formatColumn(res1), field: [
{
type: 'index',
label: '序号',
width: 50
},
{
prop: 'original_name',
label: '文件名'
},
{
label: '操作',
width: 100,
customFn:row => {
return (
<div>
<el-button
type="primary"
icon="el-icon-download"
circle
size="mini"
on={{
['click']:_ => this.down(row)
}}
></el-button>
<el-button
type="primary"
icon="el-icon-search"
circle
size="mini"
on={{
['click']:_ => this.open(row.url)
}}
></el-button>
</div>
)
}
}
],
title: res[1]?.name title: res[1]?.name
}) })
}) }
}) })
} }
}, },

@ -505,9 +505,9 @@ export default {
} }
} }
if (copyForm[info._relations?.link_with_name]?.length > 0) { // if (copyForm[info._relations?.link_with_name]?.length > 0) {
delete copyForm[info.field]; // delete copyForm[info.field];
} // }
if ( if (
info._relations?.link_relation === "newHasMany" || info._relations?.link_relation === "newHasMany" ||
info._relations?.link_relation === "hasMany" info._relations?.link_relation === "hasMany"
@ -516,33 +516,22 @@ export default {
copyForm[info._relations.link_with_name] = this.file[ copyForm[info._relations.link_with_name] = this.file[
info.field info.field
]?.map((i) => { ]?.map((i) => {
let copyRelation = i?.response ? deepCopy(i?.response) : "";
delete copyRelation.id;
return { return {
upload_id: i?.response?.id, upload_id: i?.response?.id,
...copyRelation, original_name: i?.response?.original_name
}; };
}); });
} else { } else {
copyForm[info._relations.link_with_name] = copyForm[ copyForm[info._relations.link_with_name] = copyForm[
info.field info.field
] instanceof Array ? copyForm[
info.field
]?.map((i) => { ]?.map((i) => {
// let copyRelation = info._params.find(
// (param) => param[info._relations?.foreign_key] === i
// )
// ? deepCopy(
// info._params.find(
// (param) => param[info._relations?.foreign_key] === i
// )
// )
// : "";
// delete copyRelation.id;
return { return {
[info._relations.custom_form_field]: i, [info._relations.custom_form_field]: i,
//...copyRelation, //...copyRelation,
}; };
}); }) : '';
} }
delete copyForm[info.field]; delete copyForm[info.field];
@ -552,7 +541,7 @@ export default {
info._relations?.link_relation === "hasOne" info._relations?.link_relation === "hasOne"
) { ) {
if (info.edit_input === "file") { if (info.edit_input === "file") {
copyForm[info.field] = this.file[info.field][0]?.response?.id; copyForm[info.field] = this.file[info.field] ? this.file[info.field][0]?.response?.id : '';
} else { } else {
// let copyRelation = deepCopy( // let copyRelation = deepCopy(
// info._params.find( // info._params.find(
@ -648,6 +637,7 @@ export default {
this.$nextTick(() => this.getDetail()); this.$nextTick(() => this.getDetail());
} }
} else { } else {
this.originalForm = {};
this.file = {}; this.file = {};
this.id = ""; this.id = "";
this.type = ""; this.type = "";

@ -2,6 +2,57 @@
<div> <div>
<el-dialog :visible.sync="dialogVisible"> <el-dialog :visible.sync="dialogVisible">
<template> <template>
<div class="select">
<Select
v-model="select.filter[0].key"
style="width: 100px"
placeholder="搜索条目"
>
<Option v-for="item in fields" :key="item.id" :value="item.field">{{
item.name
}}</Option>
</Select>
<Select
v-model="select.filter[0].op"
style="width: 100px; margin-left: 10px"
placeholder="搜索条件"
>
<Option v-for="item in op" :key="item.value" :value="item.value">{{
item.label
}}</Option>
</Select>
<template v-if="select.filter[0].op !== 'range'">
<Input
clearable
v-model="select.filter[0].value"
style="width: 150px; margin-left: 10px"
placeholder="请填写关键词"
/>
</template>
<template v-else>
<Input
:value="select.filter[0].value.split(',')[0]"
style="width: 150px; margin-left: 10px"
placeholder="范围开始关键词"
@input="(e) => inputStartHandler(e, select.filter[0])"
/>
<span style="margin-left: 10px; display: flex; align-items: center"
></span
>
<Input
:value="select.filter[0].value.split(',')[1]"
style="width: 150px; margin-left: 10px"
placeholder="范围结束关键词"
@input="(e) => inputEndHandler(e, select.filter[0])"
/>
</template>
<Button
style="margin-left: 10px"
type="primary"
@click="$refs['table'].getTableData(true)"
>查询</Button
>
</div>
<xy-table <xy-table
:is-first-req="false" :is-first-req="false"
ref="table" ref="table"
@ -31,6 +82,7 @@
</template> </template>
<script> <script>
import { op } from '@/const/op'
import { index } from "@/api/system/baseForm"; import { index } from "@/api/system/baseForm";
import { index as customFormIndex, show } from "@/api/system/customForm"; import { index as customFormIndex, show } from "@/api/system/customForm";
export default { export default {
@ -45,12 +97,21 @@ export default {
}, },
data() { data() {
return { return {
op,
tempRow: {}, tempRow: {},
dialogVisible: false, dialogVisible: false,
select: { select: {
table_name: "", table_name: "",
table_id: "", table_id: "",
filter: [
{
key: '',
op: '',
value: ''
}
]
}, },
fields: [],
columns: [], columns: [],
originalRowIds: [], originalRowIds: [],
}; };
@ -64,6 +125,16 @@ export default {
this.dialogVisible = false; this.dialogVisible = false;
}, },
//target
inputStartHandler(e, target) {
let temp = target?.value.split(",")[1];
target.value = `${e},${temp ? temp : ""}`;
},
inputEndHandler(e, target) {
let temp = target?.value.split(",")[0];
target.value = `${temp ? temp : ""},${e}`;
},
async getDataTableName() { async getDataTableName() {
if (this.linkType === "hasMany" || this.linkType === "newHasMany") { if (this.linkType === "hasMany" || this.linkType === "newHasMany") {
const tables = ( const tables = (
@ -110,6 +181,7 @@ export default {
); );
console.log(res); console.log(res);
this.fields = res.fields;
this.columns = res.fields this.columns = res.fields
?.filter((i) => i.list_show) ?.filter((i) => i.list_show)
.map((i) => { .map((i) => {
@ -168,16 +240,21 @@ export default {
rowPick({ row }) { rowPick({ row }) {
this.tempRow = row; this.tempRow = row;
}, },
selectBk (selections, row) { selectBk(selections, row) {
if (!selections.find(i => i.id === row.id)) { if (!selections.find((i) => i.id === row.id)) {
this.originalRowIds.splice(this.originalRowIds.indexOf(row.id),1) this.originalRowIds.splice(this.originalRowIds.indexOf(row.id), 1);
} }
}, },
confirm() { confirm() {
this.linkType === "hasMany" || this.linkType === "newHasMany" this.linkType === "hasMany" || this.linkType === "newHasMany"
? this.$emit("confirm", { ? this.$emit("confirm", {
field: this.field, field: this.field,
value: Array.from(new Set([...this.$refs["table"].getSelection()?.map(i => i.id),...this.originalRowIds])), value: Array.from(
new Set([
...this.$refs["table"].getSelection()?.map((i) => i.id),
...this.originalRowIds,
])
),
}) })
: this.$emit("confirm", { : this.$emit("confirm", {
field: this.field, field: this.field,
@ -195,19 +272,22 @@ export default {
}, },
dialogVisible(newVal) { dialogVisible(newVal) {
if (newVal) { if (newVal) {
} else { } else {
this.tempRow = {}; this.tempRow = {};
this.$refs['table'].clearSelection(); this.$refs["table"].clearSelection();
} }
}, },
originalRows (newVal) { originalRows(newVal) {
this.originalRowIds = newVal.map(i => i[this.field]) this.originalRowIds = newVal.map((i) => i[this.field]);
this.selectRows(); this.selectRows();
} },
}, },
}; };
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss">
.select {
margin-bottom: 10px;
}
</style>

@ -54,7 +54,7 @@ export default {
value={ row.custom_form_field } value={ row.custom_form_field }
on={{ on={{
['change']:e => { ['change']:e => {
row.custom_form_field = e this.$set(row,'custom_form_field',e);
} }
}}> }}>
{ {

Loading…
Cancel
Save