|
|
|
|
@ -3,42 +3,100 @@
|
|
|
|
|
<!-- 查询配置 -->
|
|
|
|
|
<div>
|
|
|
|
|
<div ref="lxHeader">
|
|
|
|
|
<LxHeader icon="md-apps" :text="title || customForm.tableName" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
|
|
|
|
|
<LxHeader
|
|
|
|
|
icon="md-apps"
|
|
|
|
|
:text="title || customForm.tableName"
|
|
|
|
|
style="margin-bottom: 10px; border: 0px; margin-top: 15px"
|
|
|
|
|
>
|
|
|
|
|
<div slot="content"></div>
|
|
|
|
|
<slot>
|
|
|
|
|
<header-content :auths="auths_auth_mixin">
|
|
|
|
|
<template #search>
|
|
|
|
|
<div style="display: flex">
|
|
|
|
|
<Select v-model="select.filter[0].key" style="width: 100px;" placeholder="搜索条目">
|
|
|
|
|
<Option v-for="item in form" :key="item.id" :value="item.field">{{ item.name }}</Option>
|
|
|
|
|
<Select
|
|
|
|
|
v-model="select.filter[0].key"
|
|
|
|
|
style="width: 100px"
|
|
|
|
|
placeholder="搜索条目"
|
|
|
|
|
>
|
|
|
|
|
<Option
|
|
|
|
|
v-for="item in form"
|
|
|
|
|
: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
|
|
|
|
|
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' && !columnArrTest(select.filter[0].key)">
|
|
|
|
|
<Input v-model="select.filter[0].value" style="width: 150px;margin-left: 10px;" placeholder="请填写关键词"/>
|
|
|
|
|
<template
|
|
|
|
|
v-if="
|
|
|
|
|
select.filter[0].op !== 'range' &&
|
|
|
|
|
!columnArrTest(select.filter[0].key)
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<Input
|
|
|
|
|
v-model="select.filter[0].value"
|
|
|
|
|
style="width: 150px; margin-left: 10px"
|
|
|
|
|
placeholder="请填写关键词"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="select.filter[0].op !== 'range' && columnArrTest(select.filter[0].key)">
|
|
|
|
|
<Select v-model="select.filter[0].value" style="width: 150px;margin-left: 10px;" placeholder="请选择关键词">
|
|
|
|
|
<Option v-for="item in getColumnParams(select.filter[0].key)" :key="item.id" :value="item.id">{{ item.value || item.name || item.no || item.id }}</Option>
|
|
|
|
|
<template
|
|
|
|
|
v-else-if="
|
|
|
|
|
select.filter[0].op !== 'range' &&
|
|
|
|
|
columnArrTest(select.filter[0].key)
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<Select
|
|
|
|
|
v-model="select.filter[0].value"
|
|
|
|
|
style="width: 150px; margin-left: 10px"
|
|
|
|
|
placeholder="请选择关键词"
|
|
|
|
|
>
|
|
|
|
|
<Option
|
|
|
|
|
v-for="item in getColumnParams(select.filter[0].key)"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
>{{
|
|
|
|
|
item.value || item.name || item.no || item.id
|
|
|
|
|
}}</Option
|
|
|
|
|
>
|
|
|
|
|
</Select>
|
|
|
|
|
</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])"/>
|
|
|
|
|
<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['xyTable'].getTableData(true)"
|
|
|
|
|
>查询</Button
|
|
|
|
|
>查询</Button
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<xy-selectors
|
|
|
|
|
@ -48,38 +106,103 @@
|
|
|
|
|
>
|
|
|
|
|
<template>
|
|
|
|
|
<div class="select">
|
|
|
|
|
<div class="select__item" v-for="(item,index) in select.filter" :key="`${item.value}-${index}`">
|
|
|
|
|
<p>条件{{index+1}}</p>
|
|
|
|
|
<Select v-model="item.key" style="width: 100px;" placeholder="搜索条目">
|
|
|
|
|
<Option v-for="item in form" :key="item.id" :value="item.field">{{ item.name }}</Option>
|
|
|
|
|
<div
|
|
|
|
|
class="select__item"
|
|
|
|
|
v-for="(item, index) in select.filter"
|
|
|
|
|
:key="`${item.value}-${index}`"
|
|
|
|
|
>
|
|
|
|
|
<p>条件{{ index + 1 }}</p>
|
|
|
|
|
<Select
|
|
|
|
|
v-model="item.key"
|
|
|
|
|
style="width: 100px"
|
|
|
|
|
placeholder="搜索条目"
|
|
|
|
|
>
|
|
|
|
|
<Option
|
|
|
|
|
v-for="item in form"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:value="item.field"
|
|
|
|
|
>{{ item.name }}</Option
|
|
|
|
|
>
|
|
|
|
|
</Select>
|
|
|
|
|
<Select v-model="item.op" style="width: 100px;margin-left: 10px;" placeholder="搜索条件">
|
|
|
|
|
<Option v-for="item in op" :key="item.value" :value="item.value">{{ item.label }}</Option>
|
|
|
|
|
<Select
|
|
|
|
|
v-model="item.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="item.op !== 'range' && !columnArrTest(item.key)">
|
|
|
|
|
<Input v-model="item.value" style="width: 150px;margin-left: 10px;" placeholder="请填写关键词"/>
|
|
|
|
|
<template
|
|
|
|
|
v-if="
|
|
|
|
|
item.op !== 'range' && !columnArrTest(item.key)
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<Input
|
|
|
|
|
v-model="item.value"
|
|
|
|
|
style="width: 150px; margin-left: 10px"
|
|
|
|
|
placeholder="请填写关键词"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.op !== 'range' && columnArrTest(item.key)">
|
|
|
|
|
<Select v-model="item.value" style="width: 150px;margin-left: 10px;" placeholder="请选择关键词">
|
|
|
|
|
<Option v-for="item in getColumnParams(item.key)" :key="item.id" :value="item.id">{{ item.value || item.name || item.no || item.id }}</Option>
|
|
|
|
|
<template
|
|
|
|
|
v-else-if="
|
|
|
|
|
item.op !== 'range' && columnArrTest(item.key)
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<Select
|
|
|
|
|
v-model="item.value"
|
|
|
|
|
style="width: 150px; margin-left: 10px"
|
|
|
|
|
placeholder="请选择关键词"
|
|
|
|
|
>
|
|
|
|
|
<Option
|
|
|
|
|
v-for="item in getColumnParams(item.key)"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
>{{
|
|
|
|
|
item.value || item.name || item.no || item.id
|
|
|
|
|
}}</Option
|
|
|
|
|
>
|
|
|
|
|
</Select>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<Input :value="item.value.split(',')[0]"
|
|
|
|
|
style="width: 150px;margin-left: 10px;"
|
|
|
|
|
placeholder="范围开始关键词"
|
|
|
|
|
@input="(e)=>inputStartHandler(e,item)"/>
|
|
|
|
|
<span style="margin-left: 10px;">至</span>
|
|
|
|
|
<Input :value="item.value.split(',')[1]"
|
|
|
|
|
style="width: 150px;margin-left: 10px;"
|
|
|
|
|
placeholder="范围结束关键词"
|
|
|
|
|
@input="(e)=>inputEndHandler(e,item)"/>
|
|
|
|
|
<Input
|
|
|
|
|
:value="item.value.split(',')[0]"
|
|
|
|
|
style="width: 150px; margin-left: 10px"
|
|
|
|
|
placeholder="范围开始关键词"
|
|
|
|
|
@input="(e) => inputStartHandler(e, item)"
|
|
|
|
|
/>
|
|
|
|
|
<span style="margin-left: 10px">至</span>
|
|
|
|
|
<Input
|
|
|
|
|
:value="item.value.split(',')[1]"
|
|
|
|
|
style="width: 150px; margin-left: 10px"
|
|
|
|
|
placeholder="范围结束关键词"
|
|
|
|
|
@input="(e) => inputEndHandler(e, item)"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<el-button v-if="index !== 0" size="small" type="danger" icon="el-icon-delete" circle style="margin-left: 10px;" @click="select.filter.splice(index,1)"></el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="index !== 0"
|
|
|
|
|
size="small"
|
|
|
|
|
type="danger"
|
|
|
|
|
icon="el-icon-delete"
|
|
|
|
|
circle
|
|
|
|
|
style="margin-left: 10px"
|
|
|
|
|
@click="select.filter.splice(index, 1)"
|
|
|
|
|
></el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="add-btn">
|
|
|
|
|
<el-button size="small" type="primary" icon="el-icon-plus" circle @click="select.filter.push({key: '',op: '',value: ''})"></el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
size="small"
|
|
|
|
|
type="primary"
|
|
|
|
|
icon="el-icon-plus"
|
|
|
|
|
circle
|
|
|
|
|
@click="
|
|
|
|
|
select.filter.push({ key: '', op: '', value: '' })
|
|
|
|
|
"
|
|
|
|
|
></el-button>
|
|
|
|
|
<span>新增一条</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
@ -89,22 +212,22 @@
|
|
|
|
|
<template #create>
|
|
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="$refs['dialog'].setType('add'),$refs['dialog'].show()"
|
|
|
|
|
>新增</Button
|
|
|
|
|
@click="
|
|
|
|
|
$refs['dialog'].setType('add'), $refs['dialog'].show()
|
|
|
|
|
"
|
|
|
|
|
>新增</Button
|
|
|
|
|
>
|
|
|
|
|
</template>
|
|
|
|
|
<template #import>
|
|
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="$refs['imports'].show()"
|
|
|
|
|
>导入</Button
|
|
|
|
|
<Button type="primary" @click="$refs['imports'].show()"
|
|
|
|
|
>导入</Button
|
|
|
|
|
>
|
|
|
|
|
</template>
|
|
|
|
|
<template #export>
|
|
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="exportExcel(new Date().getTime().toString())"
|
|
|
|
|
>导出</Button
|
|
|
|
|
>导出</Button
|
|
|
|
|
>
|
|
|
|
|
</template>
|
|
|
|
|
</header-content>
|
|
|
|
|
@ -120,30 +243,50 @@
|
|
|
|
|
ref="xyTable"
|
|
|
|
|
:border="true"
|
|
|
|
|
:action="index"
|
|
|
|
|
:req-opt="Object.assign(select,selectForm)"
|
|
|
|
|
:req-opt="select"
|
|
|
|
|
:destroy-req-opt="select"
|
|
|
|
|
:table-item="table"
|
|
|
|
|
@detail="row => {
|
|
|
|
|
$refs['drawer'].setId(row.id);
|
|
|
|
|
$refs['drawer'].show();
|
|
|
|
|
}"
|
|
|
|
|
@editor="row => {
|
|
|
|
|
$refs['dialog'].setId(row.id);
|
|
|
|
|
$refs['dialog'].setType('editor');
|
|
|
|
|
$refs['dialog'].show();
|
|
|
|
|
}">
|
|
|
|
|
@detail="
|
|
|
|
|
(row) => {
|
|
|
|
|
$refs['drawer'].setId(row.id);
|
|
|
|
|
$refs['drawer'].show();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
@editor="
|
|
|
|
|
(row) => {
|
|
|
|
|
$refs['dialog'].setId(row.id);
|
|
|
|
|
$refs['dialog'].setType('editor');
|
|
|
|
|
$refs['dialog'].show();
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
</xy-table>
|
|
|
|
|
|
|
|
|
|
<dialoger :table-name="customForm.tableName" :form-info="form" ref="dialog" @refresh="$refs['xyTable'].getTableData()"></dialoger>
|
|
|
|
|
<drawer :table-name="customForm.tableName" :form-info="form" ref="drawer"></drawer>
|
|
|
|
|
<imports :table-name="customForm.tableName" :form-info="form" ref="imports" @refresh="$refs['xyTable'].getTableData()"></imports>
|
|
|
|
|
<dialoger
|
|
|
|
|
:table-name="customForm.tableName"
|
|
|
|
|
:form-info="form"
|
|
|
|
|
ref="dialog"
|
|
|
|
|
@refresh="$refs['xyTable'].getTableData()"
|
|
|
|
|
>
|
|
|
|
|
</dialoger>
|
|
|
|
|
<drawer
|
|
|
|
|
:table-name="customForm.tableName"
|
|
|
|
|
:form-info="form"
|
|
|
|
|
ref="drawer"
|
|
|
|
|
></drawer>
|
|
|
|
|
<imports
|
|
|
|
|
:table-name="customForm.tableName"
|
|
|
|
|
:form-info="form"
|
|
|
|
|
ref="imports"
|
|
|
|
|
@refresh="$refs['xyTable'].getTableData()"
|
|
|
|
|
></imports>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { index as fieldIndex } from "@/api/system/customFormField";
|
|
|
|
|
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 { download } from "@/utils/downloadRequest";
|
|
|
|
|
import { getparameter } from "@/api/system/dictionary";
|
|
|
|
|
@ -151,20 +294,23 @@ import { show } from "@/api/system/customForm";
|
|
|
|
|
import * as XLSX from "xlsx";
|
|
|
|
|
import { saveAs } from "file-saver";
|
|
|
|
|
|
|
|
|
|
import dialoger from './dialog.vue';
|
|
|
|
|
import dialoger from "./dialog.vue";
|
|
|
|
|
import LxHeader from "@/components/LxHeader/index.vue";
|
|
|
|
|
import headerContent from "@/components/LxHeader/XyContent.vue";
|
|
|
|
|
import drawer from "@/views/component/drawer.vue";
|
|
|
|
|
import imports from "./imports.vue"
|
|
|
|
|
import imports from "./imports.vue";
|
|
|
|
|
export default {
|
|
|
|
|
components:{
|
|
|
|
|
components: {
|
|
|
|
|
LxHeader,
|
|
|
|
|
dialoger,
|
|
|
|
|
headerContent,
|
|
|
|
|
drawer,
|
|
|
|
|
imports
|
|
|
|
|
imports,
|
|
|
|
|
},
|
|
|
|
|
mixins: [authMixin],
|
|
|
|
|
provide: {
|
|
|
|
|
formStore: () => this.form,
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
title: "",
|
|
|
|
|
@ -175,183 +321,237 @@ export default {
|
|
|
|
|
{
|
|
|
|
|
key: "",
|
|
|
|
|
op: "",
|
|
|
|
|
value: ""
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
value: "",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
selectForm: [],
|
|
|
|
|
form: [],
|
|
|
|
|
table: [],
|
|
|
|
|
customForm: {
|
|
|
|
|
customFormId: "",
|
|
|
|
|
tableName: ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tableName: "",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
index,destroy,download,
|
|
|
|
|
index,
|
|
|
|
|
destroy,
|
|
|
|
|
download,
|
|
|
|
|
reset() {
|
|
|
|
|
this.select.filter.splice(1)
|
|
|
|
|
this.select.filter.splice(1);
|
|
|
|
|
this.select.filter[0] = {
|
|
|
|
|
key: "",
|
|
|
|
|
op: "",
|
|
|
|
|
value: ""
|
|
|
|
|
}
|
|
|
|
|
value: "",
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async exportExcel(sheetName) {
|
|
|
|
|
const res = await index(Object.assign(this.select,{ page: 1,page_size: 9999}))
|
|
|
|
|
if(res.data){
|
|
|
|
|
let headers = this.form.map(i => {
|
|
|
|
|
const res = await index(
|
|
|
|
|
Object.assign(this.select, { page: 1, page_size: 9999 })
|
|
|
|
|
);
|
|
|
|
|
if (res.data) {
|
|
|
|
|
let headers = this.form.map((i) => {
|
|
|
|
|
return {
|
|
|
|
|
key: i.field,
|
|
|
|
|
title: i.name
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const data = res.data.map(row => headers.map(header => row[header.key]));
|
|
|
|
|
data.unshift(headers.map(header => header.title));
|
|
|
|
|
title: i.name,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
const data = res.data.map((row) =>
|
|
|
|
|
headers.map((header) => row[header.key])
|
|
|
|
|
);
|
|
|
|
|
data.unshift(headers.map((header) => header.title));
|
|
|
|
|
const wb = XLSX.utils.book_new();
|
|
|
|
|
const ws = XLSX.utils.aoa_to_sheet(data);
|
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, sheetName);
|
|
|
|
|
const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
|
|
|
|
|
saveAs(new Blob([wbout], { type: 'application/octet-stream' }), `${sheetName}.xlsx`);
|
|
|
|
|
const wbout = XLSX.write(wb, {
|
|
|
|
|
bookType: "xlsx",
|
|
|
|
|
bookSST: true,
|
|
|
|
|
type: "array",
|
|
|
|
|
});
|
|
|
|
|
saveAs(
|
|
|
|
|
new Blob([wbout], { type: "application/octet-stream" }),
|
|
|
|
|
`${sheetName}.xlsx`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//target要为内存地址引用类型
|
|
|
|
|
inputStartHandler(e,target) {
|
|
|
|
|
let temp = target?.value.split(',')[1]
|
|
|
|
|
target.value = `${e},${temp ? temp : ""}`
|
|
|
|
|
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}`
|
|
|
|
|
inputEndHandler(e, target) {
|
|
|
|
|
let temp = target?.value.split(",")[0];
|
|
|
|
|
target.value = `${temp ? temp : ""},${e}`;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getFormDetail() {
|
|
|
|
|
const res = await show({ id: this.customForm.customFormId },false)
|
|
|
|
|
this.title = res.name
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getField() {
|
|
|
|
|
if(this.$route.meta.params?.custom_form) {
|
|
|
|
|
let decode = decodeURIComponent(this.$route.meta.params?.custom_form)
|
|
|
|
|
if (this.$route.meta.params?.custom_form) {
|
|
|
|
|
let decode = decodeURIComponent(this.$route.meta.params?.custom_form);
|
|
|
|
|
try {
|
|
|
|
|
let custom_form = JSON.parse(decode)
|
|
|
|
|
this.customForm.customFormId = custom_form.custom_form_id
|
|
|
|
|
this.customForm.tableName = custom_form.table_name
|
|
|
|
|
this.select.table_name = custom_form.table_name
|
|
|
|
|
}catch (err) {
|
|
|
|
|
console.warn(err)
|
|
|
|
|
let custom_form = JSON.parse(decode);
|
|
|
|
|
this.customForm.customFormId = custom_form.custom_form_id;
|
|
|
|
|
this.customForm.tableName = custom_form.table_name;
|
|
|
|
|
this.select.table_name = custom_form.table_name;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.warn(err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const res = await fieldIndex({
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 999,
|
|
|
|
|
custom_form_id: this.customForm.customFormId,
|
|
|
|
|
sort_name: 'sort',
|
|
|
|
|
sort_type: 'asc',
|
|
|
|
|
})
|
|
|
|
|
if(res.data && res.data instanceof Array) {
|
|
|
|
|
res.data.forEach(i => {
|
|
|
|
|
if (i.field) {
|
|
|
|
|
if (
|
|
|
|
|
(i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
|
|
|
|
|
i.parameter_id
|
|
|
|
|
) {
|
|
|
|
|
getparameter({ id: i.parameter_id }).then((res) => {
|
|
|
|
|
i._paramters = res.detail ?? [];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
(i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
|
|
|
|
|
i.link_table_name
|
|
|
|
|
) {
|
|
|
|
|
index({
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 999,
|
|
|
|
|
table_name: i.link_table_name,
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
i._paramters = res.data ?? [];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const res = await show({ id: this.customForm.customFormId }, false);
|
|
|
|
|
this.title = res.name;
|
|
|
|
|
|
|
|
|
|
//字段处理
|
|
|
|
|
let { fields, relation } = res;
|
|
|
|
|
if (
|
|
|
|
|
!fields ||
|
|
|
|
|
!relation ||
|
|
|
|
|
!fields instanceof Array ||
|
|
|
|
|
!relation instanceof Array
|
|
|
|
|
) {
|
|
|
|
|
throw new Error("fields或relation格式错误");
|
|
|
|
|
}
|
|
|
|
|
this.form = res.data
|
|
|
|
|
this.selectForm = ''
|
|
|
|
|
this.table = res.data.map(i => {
|
|
|
|
|
let linkOb = {}
|
|
|
|
|
fields.forEach((i, index) => {
|
|
|
|
|
i._relations = relation.find((j) => j.local_key === i.field);
|
|
|
|
|
i._params = {
|
|
|
|
|
value: [],
|
|
|
|
|
load: false,
|
|
|
|
|
get: () => i._params.value,
|
|
|
|
|
set: () => {
|
|
|
|
|
if(i._params.load) return
|
|
|
|
|
i._relations.parameter_id
|
|
|
|
|
? getparameter({ id: i._relations.parameter_id },false).then((res) => {
|
|
|
|
|
i._params.value = res.detail;
|
|
|
|
|
})
|
|
|
|
|
: this.index({
|
|
|
|
|
table_name: i._relations.link_table_name,
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 9999,
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
i._params.value = res.data;
|
|
|
|
|
});
|
|
|
|
|
i._params.load = true
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
this.form = fields;
|
|
|
|
|
console.log(111, this.form);
|
|
|
|
|
// if(res.fields && res.fields instanceof Array) {
|
|
|
|
|
// res.fields.forEach(i => {
|
|
|
|
|
// if (i.field) {
|
|
|
|
|
// if (
|
|
|
|
|
// (i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
|
|
|
|
|
// i.parameter_id
|
|
|
|
|
// ) {
|
|
|
|
|
// getparameter({ id: i.parameter_id }).then((res) => {
|
|
|
|
|
// i._paramters = res.detail ?? [];
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// if (
|
|
|
|
|
// (i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
|
|
|
|
|
// i.link_table_name
|
|
|
|
|
// ) {
|
|
|
|
|
// index({
|
|
|
|
|
// page: 1,
|
|
|
|
|
// page_size: 999,
|
|
|
|
|
// table_name: i.link_table_name,
|
|
|
|
|
// }).then((res) => {
|
|
|
|
|
// i._paramters = res.data ?? [];
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// this.form = res.fields
|
|
|
|
|
this.table = res.fields
|
|
|
|
|
?.filter((i) => i.list_show)
|
|
|
|
|
.map((i) => {
|
|
|
|
|
let linkOb = {};
|
|
|
|
|
|
|
|
|
|
if(i.parameter_id) {
|
|
|
|
|
linkOb.customFn = row => {
|
|
|
|
|
return (
|
|
|
|
|
<span>{ row[i.link_with_name]?.value }</span>
|
|
|
|
|
)
|
|
|
|
|
if (i.parameter_id) {
|
|
|
|
|
linkOb.customFn = (row) => {
|
|
|
|
|
return <span>{row[i.link_with_name]?.value}</span>;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(i.link_table_name) {
|
|
|
|
|
if(i.link_relation === 'hasOne') {
|
|
|
|
|
linkOb.customFn = row => {
|
|
|
|
|
if(i.edit_input === 'file') {
|
|
|
|
|
return (
|
|
|
|
|
<a download={row[i.link_with_name]?.original_name} href={ row[i.link_with_name]?.url }>{ row[i.link_with_name]?.original_name }</a>
|
|
|
|
|
)
|
|
|
|
|
}else{
|
|
|
|
|
return (
|
|
|
|
|
<span>{ row[i.link_with_name]?.name || row[i.link_with_name]?.no || row[i.link_with_name]?.value }</span>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
if (i.link_table_name) {
|
|
|
|
|
if (i.link_relation === "hasOne") {
|
|
|
|
|
linkOb.customFn = (row) => {
|
|
|
|
|
if (i.edit_input === "file") {
|
|
|
|
|
return (
|
|
|
|
|
<a
|
|
|
|
|
download={row[i.link_with_name]?.original_name}
|
|
|
|
|
href={row[i.link_with_name]?.url}
|
|
|
|
|
>
|
|
|
|
|
{row[i.link_with_name]?.original_name}
|
|
|
|
|
</a>
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<span>
|
|
|
|
|
{row[i.link_with_name]?.name ||
|
|
|
|
|
row[i.link_with_name]?.no ||
|
|
|
|
|
row[i.link_with_name]?.value}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(i.link_relation === 'hasMany') {
|
|
|
|
|
linkOb.customFn = row => {
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{ row[i.link_with_name]?.map(o => (<span>{ o?.name || o?.no || o?.value }</span>)) }
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
if (i.link_relation === "hasMany") {
|
|
|
|
|
linkOb.customFn = (row) => {
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{row[i.link_with_name]?.map((o) => (
|
|
|
|
|
<span>{o?.name || o?.no || o?.value}</span>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Object.assign({
|
|
|
|
|
prop: i.field,
|
|
|
|
|
label: i.name,
|
|
|
|
|
width: i.width,
|
|
|
|
|
fixed: i.is_fixed
|
|
|
|
|
},linkOb)
|
|
|
|
|
})
|
|
|
|
|
return Object.assign(
|
|
|
|
|
{
|
|
|
|
|
prop: i.field,
|
|
|
|
|
label: i.name,
|
|
|
|
|
width: i.width,
|
|
|
|
|
fixed: i.is_fixed,
|
|
|
|
|
},
|
|
|
|
|
linkOb
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
this.table.unshift({
|
|
|
|
|
type: 'index',
|
|
|
|
|
type: "index",
|
|
|
|
|
width: 60,
|
|
|
|
|
label: '序号'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
label: "序号",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
|
columnArrTest() {
|
|
|
|
|
return function (field) {
|
|
|
|
|
return this.form.find(i => i.field === field) ? this.form.find(i => i.field === field).search_input === 'checkbox' : false
|
|
|
|
|
}
|
|
|
|
|
return this.form.find((i) => i.field === field)
|
|
|
|
|
? this.form.find((i) => i.field === field).search_input === "checkbox"
|
|
|
|
|
: false;
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
getColumnParams() {
|
|
|
|
|
return function (field) {
|
|
|
|
|
return this.form.find(i => i.field === field) ? this.form.find(i => i.field === field)._paramters : []
|
|
|
|
|
}
|
|
|
|
|
return this.form.find((i) => i.field === field)
|
|
|
|
|
? this.form.find((i) => i.field === field)._paramters
|
|
|
|
|
: [];
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.getField()
|
|
|
|
|
this.getFormDetail()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.getFormDetail();
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.select {
|
|
|
|
|
&__item {
|
|
|
|
|
|
|
|
|
|
& > p {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
width: 80px;
|
|
|
|
|
@ -370,7 +570,6 @@ export default {
|
|
|
|
|
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
& > span {
|
|
|
|
|
|
|
|
|
|
padding: 0 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|