Commit 83c6887f authored by liang's avatar liang

表单配置修改

parent c156c399
...@@ -12,13 +12,6 @@ export function getFieldPage(params = {}) { ...@@ -12,13 +12,6 @@ export function getFieldPage(params = {}) {
params, params,
}) })
} }
export function getFieldList(params = {}) {
return request({
url: "/cloud-upms/field/dict/list/table",
method: "get",
params,
})
}
export function delField(id) { export function delField(id) {
return request({ return request({
......
<template>
<el-row class="page-container dict">
<el-container class="page-main" :gutter="20">
<el-aside width="250px" class="left-content">
<el-col :span="24" class="left-search">
<el-input
v-model.trim="searchVal"
clearable
:placeholder="placeholder"
>
</el-input>
</el-col>
<el-col class="dict-list" ref="dict">
<el-col
v-for="(item, index) in tableList"
:key="item.id"
class="dict-item"
>
<span
@click="handClick(index, item)"
:class="{ active: index == isActive }"
style="cursor: pointer"
>
<strong>
{{ item.label }}
</strong>
- {{ item.value }}
</span>
</el-col>
</el-col>
</el-aside>
<el-main>
<div style="text-align: right">
<el-input
v-model.trim="keyWord"
clearable
placeholder="关键字"
style="width: 220px; margin-right: 5px"
>
</el-input>
<el-button type="primary" @click="handleSave" :loading="loading"
>保存配置</el-button
>
</div>
<el-table-self
style="margin-top: 10px"
ref="table"
:table-data="fields"
:columns="columns"
:list-loading="listLoading"
/>
</el-main>
</el-container>
</el-row>
</template>
<script>
import { setExportFields, getTableFields, getExportConfigFields } from "@/api/coop-group"
export default {
name: "ExportFieldConfig",
props: {
groupId: String,
},
data() {
return {
isActive: -1,
placeholder: "搜索数据库",
name: "",
searchVal: "",
keyWord: "",
typeId: "",
fieldList: [],
configuredFieldList: [],
tableCode: "",
loading: false,
listLoading: false,
columns: [
{
label: "字段名称",
minWidth: 120,
value: "fieldName",
},
{
label: "字段code",
minWidth: 200,
value: "fieldCode",
},
{
operType: "checkbox",
label: "是否导出",
minWidth: 100,
value: "isExport",
tabType: "selection",
},
{
operType: "checkbox",
label: "是否脱敏",
minWidth: 100,
value: "isDesensitized",
tabType: "selection",
},
{
operType: "input",
type: "number",
label: "排序号",
width: 120,
inputWidth: 108,
value: "sort",
showInput: true,
},
],
}
},
watch: {
groupId(groupId) {
if (groupId) {
this.getTableFields()
this.getFields()
}
},
},
computed: {
// 数据库表过滤
tableList() {
const dictTable = this.dictMap["table"] || []
const list = dictTable.filter(
(_) =>
!this.searchVal ||
_.label.includes(this.searchVal) ||
_.value.includes(this.searchVal)
)
this.isActive = this.getListIdx(list, this.typeId)
return list
},
// 全部字段和已配置字段
fieldValue() {
return this.fieldList.map((field) => {
let configuredField = this.configuredFieldList.find(
(_) => _.fieldCode === field.fieldCode
)
return {
...field,
sort: (configuredField && configuredField.sort) || undefined,
isExport: Boolean(configuredField),
isDesensitized: Boolean(
configuredField && configuredField.isDesensitized
),
}
})
},
fields() {
return this.fieldValue.filter(
(_) =>
!this.keyWord ||
_.fieldName.includes(this.keyWord) ||
_.fieldCode.includes(this.keyWord)
)
},
},
methods: {
// 点击左侧列表
handClick(index, { type, label, id, value }) {
if (!this.groupId) {
this.$message.warning("请先选择协作组")
return
}
this.name = label
this.tableCode = value
this.isActive = index
this.typeId = id
this.fieldList = []
this.getTableFields()
this.getFields()
},
// 全部字段
getTableFields() {
getTableFields({ tableCode: this.tableCode, groupId: this.groupId }).then(
(res) => {
this.fieldList = res.data
}
)
},
// 已配置字段
getFields() {
getExportConfigFields({ tableCode: this.tableCode, groupId: this.groupId })
.then((res) => {
this.configuredFieldList = res.data
})
.catch((e) => {
this.configuredFieldList = []
})
},
handleSave() {
if (!this.groupId) {
this.$message.warning("请先选择协作组")
return
}
if (!this.fieldValue.length) {
this.$message.warning("没有可保存的数据")
return
}
const list = this.fieldValue
.filter((_) => _.isExport)
.map((_) => {
delete _.isExport
return {
..._,
isDesensitized: _.isDesensitized ? 1 : 0,
}
})
const table = {
tableCode: this.tableCode,
tableName: this.name,
groupId: this.groupId,
}
this.loading = true
setExportFields(table, list)
.then((res) => {
this.$message.success("配置成功")
})
.finally(() => {
this.loading = false
})
},
getListIdx(list = [], id) {
let listIdx = -1
for (var i = 0; i < list.length; i++) {
if (list[i].id === id) {
listIdx = i
break
}
}
return listIdx
},
},
}
</script>
<style lang="scss" scoped>
::v-deep .el-main {
padding: 0px 0 0 10px;
}
</style>
This diff is collapsed.
...@@ -38,15 +38,6 @@ ...@@ -38,15 +38,6 @@
<el-tab-pane label="表单管理" name="second"> <el-tab-pane label="表单管理" name="second">
<GroupForm :group-id="groupId"></GroupForm> <GroupForm :group-id="groupId"></GroupForm>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="导出字段配置" name="third">
<ExportFieldConfig :group-id="groupId"></ExportFieldConfig>
</el-tab-pane>
<el-tab-pane label="质控配置" name="fourth">
<QualityControlConfig
:group-id="groupId"
:group-name="groupName"
></QualityControlConfig>
</el-tab-pane>
<el-tab-pane label="参数配置" name="fifth"> <el-tab-pane label="参数配置" name="fifth">
<ParameterConfig :group-id="groupId"></ParameterConfig> <ParameterConfig :group-id="groupId"></ParameterConfig>
</el-tab-pane> </el-tab-pane>
...@@ -65,18 +56,14 @@ ...@@ -65,18 +56,14 @@
</template> </template>
<script> <script>
import ExportFieldConfig from "./ExportFieldConfig.vue"
import GroupUser from "./GroupUser" import GroupUser from "./GroupUser"
import GroupForm from "./GroupForm" import GroupForm from "./GroupForm"
import QualityControlConfig from "./QualityControlConfig.vue"
import ParameterConfig from "./ParameterConfig.vue" import ParameterConfig from "./ParameterConfig.vue"
import { translateListToTree } from "@/utils/handleRoutes" import { translateListToTree } from "@/utils/handleRoutes"
import { getCoopGroupList, addCoopGroup } from "@/api/coop-group.js" import { getCoopGroupList, addCoopGroup } from "@/api/coop-group.js"
export default { export default {
name: "CollaGroup", name: "CollaGroup",
components: { components: {
ExportFieldConfig,
QualityControlConfig,
GroupUser, GroupUser,
GroupForm, GroupForm,
ParameterConfig, ParameterConfig,
......
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
<script> <script>
import WidgetConfig from "packages/WidgetConfig.vue" import WidgetConfig from "packages/WidgetConfig.vue"
import { getFieldList, addField, delField } from "@/api/field.js" import { getFieldListByCode, addField, delField } from "@/api/field.js"
// 新增所需字段 // 新增所需字段
const fields = [ const fields = [
"id", "id",
...@@ -264,9 +264,9 @@ export default { ...@@ -264,9 +264,9 @@ export default {
this.widgetVisible = true this.widgetVisible = true
}, },
handleConfirm(form) { handleConfirm(form) {
if (!/^[a-z]+([a-z0-9]*([_]?[a-z]+)*)*$/.test(form.prop)) { if (!/^[a-zA-Z]+([a-zA-Z0-9]*([_-]?[a-zA-Z0-9]+)*)*$/.test(form.prop)) {
this.$message.error( this.$message.error(
"只能包含字母、数字、下划线。必须以字母开始,下划线不可连续重复,下划线后不可紧跟着数字,不能以数字、下划线结束" "只能包含大小字母、数字、下划线。必须以字母开始,下划线不可连续重复,下划线后不可紧跟着数字,不能以数字、下划线结束"
) )
return return
} }
...@@ -325,6 +325,7 @@ export default { ...@@ -325,6 +325,7 @@ export default {
this.handleSearch(form) this.handleSearch(form)
}, },
handleSearch(form) { handleSearch(form) {
if (!this.tableCode) return
this.cacheForm = Object.assign(this.cacheForm, form) this.cacheForm = Object.assign(this.cacheForm, form)
this.listLoading = true this.listLoading = true
const params = Object.assign( const params = Object.assign(
...@@ -338,7 +339,7 @@ export default { ...@@ -338,7 +339,7 @@ export default {
delete params[key] delete params[key]
} }
} }
getFieldList(params).then((res) => { getFieldListByCode(params).then((res) => {
this.listLoading = false this.listLoading = false
this.tableData = res.data || [] this.tableData = res.data || []
}) })
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
@change="tableCodeChange" @change="tableCodeChange"
> >
<el-option <el-option
v-for="opt in dictMap['table']" v-for="opt in tableList"
:key="opt.value" :key="opt.code"
:label="opt.label" :label="opt.name"
:value="opt.value" :value="opt.code"
> >
</el-option> </el-option>
</el-select> </el-select>
...@@ -50,15 +50,19 @@ import { ...@@ -50,15 +50,19 @@ import {
getFormDetail, getFormDetail,
getHistoryInfo, getHistoryInfo,
} from "@/api/field" } from "@/api/field"
import { getTableList } from "@/api/database"
export default { export default {
name: "FormAdd", name: "FormAdd",
props: { props: {
formEdit: { formEdit: {
type: Object, type: Object,
}, },
dbId: {},
}, },
data() { data() {
return { return {
tableList: [],
disabled: false, disabled: false,
name: "", name: "",
options: {}, options: {},
...@@ -70,11 +74,17 @@ export default { ...@@ -70,11 +74,17 @@ export default {
}, },
methods: { methods: {
getTableList() {
if (!this.dbId) return
getTableList(this.dbId).then((res) => {
this.tableList = res.data
})
},
// 获取数据表字段 // 获取数据表字段
tableCodeChange(tableCode) { tableCodeChange(tableCode) {
if (!tableCode) return if (!tableCode) return
this.$refs.form.customFieldsLoading = this.disabled = true this.$refs.form.customFieldsLoading = this.disabled = true
const tableList = this.dictMap["table"] const tableList = this.tableList
this.tableName = this.tableName =
tableList.find((_) => _.value === tableCode) && tableList.find((_) => _.value === tableCode) &&
tableList.find((_) => _.value === tableCode).label tableList.find((_) => _.value === tableCode).label
...@@ -84,6 +94,7 @@ export default { ...@@ -84,6 +94,7 @@ export default {
const customOldFields = [] const customOldFields = []
const d = res.data const d = res.data
d.forEach((item) => { d.forEach((item) => {
if (!item.jsonStr) return
const field = JSON.parse(item.jsonStr) const field = JSON.parse(item.jsonStr)
if (field.id) delete field.id if (field.id) delete field.id
customOldFields.push({ customOldFields.push({
...@@ -120,6 +131,7 @@ export default { ...@@ -120,6 +131,7 @@ export default {
id: this.formEdit.id, id: this.formEdit.id,
formJson: "", formJson: "",
name: this.name, name: this.name,
dbId: this.dbId,
} }
let fieldList = [] let fieldList = []
form["formJson"] = await this.$refs.form.getData("string") form["formJson"] = await this.$refs.form.getData("string")
...@@ -202,6 +214,7 @@ export default { ...@@ -202,6 +214,7 @@ export default {
}, },
created() { created() {
this.initForm() this.initForm()
this.getTableList()
}, },
} }
</script> </script>
......
<template> <template>
<div class="container"> <div class="container">
<form-add v-if="isAdd" @back="back" :form-edit="formEdit"></form-add> <form-add
v-if="isAdd"
@back="back"
:form-edit="formEdit"
:dbId="dbId"
></form-add>
<form-history <form-history
v-else-if="isHistory" v-else-if="isHistory"
@back="back" @back="back"
:source-id="sourceId" :source-id="sourceId"
></form-history> ></form-history>
<div v-else> <div v-else>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane
:label="item.name"
:name="'index' + index"
v-for="(item, index) in dbList"
:key="item.id"
>{{
}}</el-tab-pane>
</el-tabs>
<direct-search <direct-search
ref="form" ref="form"
:forms="searchList" :forms="searchList"
...@@ -40,6 +54,7 @@ import paginationMixin from "@/components/TabComponents/mixin" ...@@ -40,6 +54,7 @@ import paginationMixin from "@/components/TabComponents/mixin"
import FormAdd from "./FormAdd" import FormAdd from "./FormAdd"
import FormHistory from "./FormHistory.vue" import FormHistory from "./FormHistory.vue"
import { getFormPage, delForm, copyForm } from "@/api/field.js" import { getFormPage, delForm, copyForm } from "@/api/field.js"
import { getDbList } from "@/api/database"
export default { export default {
components: { components: {
FormAdd, FormAdd,
...@@ -48,6 +63,9 @@ export default { ...@@ -48,6 +63,9 @@ export default {
name: "FormConfig", name: "FormConfig",
data() { data() {
return { return {
activeName: "index0",
dbList: [],
dbId: null,
listLoading: false, listLoading: false,
isAdd: false, isAdd: false,
isHistory: false, isHistory: false,
...@@ -174,6 +192,11 @@ export default { ...@@ -174,6 +192,11 @@ export default {
mixins: [paginationMixin], mixins: [paginationMixin],
methods: { methods: {
handleTabClick({ index }) {
this.dbId = this.dbList[index].id
this.handleFormSearch()
},
handleHistory({ id, version }) { handleHistory({ id, version }) {
this.sourceId = id || "" this.sourceId = id || ""
this.isHistory = true this.isHistory = true
...@@ -233,7 +256,12 @@ export default { ...@@ -233,7 +256,12 @@ export default {
handleSearch(form) { handleSearch(form) {
this.cacheForm = Object.assign(this.cacheForm, form) this.cacheForm = Object.assign(this.cacheForm, form)
this.listLoading = true this.listLoading = true
const params = Object.assign({}, this.cacheForm) const params = Object.assign(
{
dbId: this.dbId,
},
this.cacheForm
)
for (let key in params) { for (let key in params) {
if (params[key] === "") { if (params[key] === "") {
delete params[key] delete params[key]
...@@ -250,9 +278,19 @@ export default { ...@@ -250,9 +278,19 @@ export default {
} }
}) })
}, },
getDbList() {
getDbList().then((res) => {
this.dbList = res.data
if (this.dbList[0]) {
this.dbId = this.dbList[0].id
}
this.handleFormSearch()
})
},
}, },
created() { created() {
this.handleFormSearch() this.getDbList()
}, },
} }
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment