update addform回显问题

This commit is contained in:
赵霄
2023-09-18 16:13:40 +08:00
parent bae308459b
commit 7048725ae4
4 changed files with 136 additions and 44 deletions
+3
View File
@@ -38,6 +38,9 @@ export default {
this.checkedValue = []
document.getElementById(this.fieldName).children[0].children[0].value = ''
this.$emit('change', '')
} else {
this.checkedValue = val.split(',')
document.getElementById(this.fieldName).children[0].children[0].value = val
}
}
},
+51 -18
View File
@@ -210,13 +210,13 @@
</div>
<a-form-model-item class="item-model" :prop="item.dbFieldName">
<a-tree-select
tree-node-filter-prop="title"
v-model="formInline[item.dbFieldName]"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
style="width: 100%"
:tree-data="optionsData[item.dbFieldName]"
tree-checkable
treeCheckStrictly
:label-in-value="false"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
/>
</a-form-model-item>
@@ -234,11 +234,29 @@
v-model="formInline[item.dbFieldName]"
:default-value="defaultValue[item.dbFieldName]"
date-format="YYYY"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"/>
:placeholder="$t('pleaseSelect')+item.dbFieldTxt" />
</a-form-model-item>
</div>
</a-col>
<!-- 15, 树选择单选 -->
<a-col :span="12" v-else-if="item.fieldShowType === FieldType.TREE_SINGLE.value">
<div class="box-title-text" :title="item.dbFieldTxt">
<div class="title-text">
<span class="required" v-if="item.fieldMustInput === '1'">*</span>
<span class="title-text-text">{{ item.dbFieldTxt }}</span>
</div>
<a-form-model-item class="item-model" :prop="item.dbFieldName">
<a-tree-select
v-model="formInline[item.dbFieldName]"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
style="width: 100%"
:tree-data="optionsData[item.dbFieldName]"
:label-in-value="false"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
/>
</a-form-model-item>
</div>
</a-col>
</div>
</a-row>
</div>
@@ -358,7 +376,22 @@ export default {
}
this.getDocumentInfoFunc({ id: item.id }).then((res) => {
if (res.success) {
// 处理树结构多选回显
const formList = Object.values(this.dataList).reduce((acc, cur) => acc.concat(cur), [])
const treeMultipleField = formList.filter(tt => tt.fieldShowType === FieldType.TREE.value)
this.formInline = res.result
treeMultipleField.forEach(field => {
const valueArr = []
if (this.formInline[field.dbFieldName]) {
const values = this.formInline[field.dbFieldName].split(',')
for (let i = 0; i < values.length; i++) {
valueArr[i] = {
value: values[i]
}
}
this.formInline[field.dbFieldName] = valueArr
}
})
this.loading = false
} else {
this.loading = false
@@ -381,7 +414,6 @@ export default {
this.dataList = res.result
this.ruleList = res.result
this.integrateData()
console.log(JSON.parse(JSON.stringify(this.dataList)))
this.getOptionsData() // 获取下拉数据
callBack && callBack()
}
@@ -391,7 +423,6 @@ export default {
integrateData () {
this.isFormInline = false
const ruleList = []
console.log(this.ruleList)
for (const item in this.ruleList) {
this.ruleList[item].forEach(ol => {
ruleList.push(ol)
@@ -429,19 +460,21 @@ export default {
getOptionsData () {
const formList = Object.values(this.dataList).reduce((acc, cur) => acc.concat(cur), [])
formList.forEach(item => {
// 展示类型是树选择,且有接口的
if (item.fieldShowType === FieldType.TREE.value && item.fieldHref) {
getAction(item.fieldHref).then(res => {
if (res.success) {
this.$set(this.optionsData, item.dbFieldName, res.result)
}
})
} else if (item.fieldShowType === FieldType.TREE.value && item.dictId) {
getFormDictTreeList({ dictId: item.dictId }).then(res => {
if (res.success) {
this.$set(this.optionsData, item.dbFieldName, res.result)
}
})
if (item.fieldShowType === FieldType.TREE.value || item.fieldShowType === FieldType.TREE_SINGLE.value) {
// 展示类型是树选择,且有接口的
if (item.fieldHref) {
getAction(item.fieldHref).then(res => {
if (res.success) {
this.$set(this.optionsData, item.dbFieldName, res.result)
}
})
} else if (item.dictId) {
getFormDictTreeList({ dictId: item.dictId }).then(res => {
if (res.success) {
this.$set(this.optionsData, item.dbFieldName, res.result)
}
})
}
}
})
},
+79 -24
View File
@@ -1,26 +1,42 @@
<template>
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :md="(24 / (minLength + 1))" :sm="(24 / minLength)" v-for="(item) in searchList.slice(0, minLength)" :key="item.id" style="line-height: 48px">
<a-col :md="(24 / (minLength + 1))"
:sm="(24 / minLength)"
v-for="(item) in searchList.slice(0, minLength)"
:key="item.id"
style="line-height: 48px">
<!-- 树形选择器 -->
<!-- <template v-if="item.fieldShowType === FieldType.TREE.value">-->
<!-- <a-form-item :label="item.dbFieldTxt" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!-- <a-tree-select-->
<!-- tree-node-filter-prop="title"-->
<!-- v-model="queryParam[item.dbFieldName]"-->
<!-- :maxTagCount="1"-->
<!-- :getPopupContainer="triggerNode=> triggerNode.parentNode"-->
<!-- :tree-data="item.tree"-->
<!-- tree-checkable-->
<!-- :placeholder="$t('pleaseSelect')+item.dbFieldTxt"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </template>-->
<template v-if="item.fieldShowType === FieldType.TREE.value">
<a-form-item :label="item.dbFieldTxt" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-tree-select
tree-node-filter-prop="title"
v-model="queryParam[item.dbFieldName]"
:maxTagCount="1"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
:tree-data="item.tree"
tree-checkable
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
/>
</a-form-item>
</template>
<!-- 树形选择器单选 -->
<template v-if="item.fieldShowType === FieldType.TREE_SINGLE.value">
<a-form-item :label="item.dbFieldTxt" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-tree-select
tree-node-filter-prop="title"
v-model="queryParam[item.dbFieldName]"
:maxTagCount="1"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
:tree-data="item.tree"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
/>
</a-form-item>
</template>
<!-- 输入框 -->
<template
v-if="[FieldType.TEXT_BOX.value, FieldType.TEXTAREA.value,FieldType.USER_SINGLE.value,
FieldType.ORGAN_SINGLE.value, FieldType.STANDARD_MORE.value, FieldType.ORGAN_MORE.value,
FieldType.YEAR_PICKER.value]
FieldType.ORGAN_SINGLE.value, FieldType.STANDARD_MORE.value, FieldType.ORGAN_MORE.value]
.includes(item.fieldShowType)">
<a-form-item :label="item.dbFieldTxt" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter')+item.dbFieldTxt"
@@ -57,7 +73,7 @@
<j-dict-select-tag v-model="queryParam[item.dbFieldName]"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
:type="'select'"
:triggerChange="false" :dictCode="item.dictField"/>
:triggerChange="false" :dictCode="item.dictField" />
</a-form-item>
</template>
<!-- 组织机构选择 -->
@@ -83,12 +99,16 @@
<j-date show-type="year"
v-model="queryParam[item.dbFieldName]"
date-format="YYYY"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"/>
:placeholder="$t('pleaseSelect')+item.dbFieldTxt" />
</a-form-item>
</template>
</a-col>
</a-col>
<template v-if="searchList.length > minLength && toggleSearchStatus">
<a-col :md="(24 / (minLength + 1))" :sm="(24 / minLength)" v-for="(item) in searchList.slice(minLength)" :key="item.id" style="line-height: 48px">
<a-col :md="(24 / (minLength + 1))"
:sm="(24 / minLength)"
v-for="(item) in searchList.slice(minLength)"
:key="item.id"
style="line-height: 48px">
<!-- 树形选择器 -->
<template v-if="item.fieldShowType === FieldType.TREE.value">
<a-form-item :label="item.dbFieldTxt" :labelCol="labelCol" :wrapperCol="wrapperCol">
@@ -99,6 +119,20 @@
:getPopupContainer="triggerNode=> triggerNode.parentNode"
:tree-data="item.tree"
tree-checkable
treeCheckStrictly
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
/>
</a-form-item>
</template>
<!-- 树形选择器(单选) -->
<template v-if="item.fieldShowType === FieldType.TREE_SINGLE.value">
<a-form-item :label="item.dbFieldTxt" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-tree-select
tree-node-filter-prop="title"
v-model="queryParam[item.dbFieldName]"
:maxTagCount="1"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
:tree-data="item.tree"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt"
/>
</a-form-item>
@@ -145,15 +179,25 @@
:triggerChange="false" :dictCode="item.dictField" />
</a-form-item>
</template>
<!-- 年份选择 -->
<template
v-if="item.fieldShowType === FieldType.YEAR_PICKER.value">
<a-form-item :label="item.dbFieldTxt" :labelCol="labelCol" :wrapperCol="wrapperCol">
<j-date show-type="year"
v-model="queryParam[item.dbFieldName]"
date-format="YYYY"
:placeholder="$t('pleaseSelect')+item.dbFieldTxt" />
</a-form-item>
</template>
</a-col>
</template>
<div style="float: right;overflow: hidden;margin-right: 11px" class="table-page-search-submitButtons">
<a @click="handleToggleSearch" v-if="searchList.length > minLength">
{{ !toggleSearchStatus ? $t('open') : $t('putAway') }}
<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
<a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
</a>
<a-button type="primary" @click="searchQuery" style="margin-left: 8px" v-has="searchHas">{{$t('query')}}</a-button>
<a-button style="margin-left: 8px" @click="searchReset">{{$t('reset')}}</a-button>
<a-button type="primary" @click="searchQuery" style="margin-left: 8px" v-has="searchHas">{{ $t('query') }}</a-button>
<a-button style="margin-left: 8px" @click="searchReset">{{ $t('reset') }}</a-button>
</div>
</a-row>
</a-form>
@@ -220,7 +264,18 @@ export default {
},
methods: {
searchQuery () {
this.$emit('search', JSON.parse(JSON.stringify(this.queryParam)))
const formInline = JSON.parse(JSON.stringify(this.queryParam))
Object.keys(formInline).forEach(res => {
if (formInline[res] instanceof Array) {
if (formInline[res][0] instanceof Object) {
// 说明是树选择
formInline[res] = formInline[res].map(item => item.value).join(',')
} else {
formInline[res] = formInline[res].join(',')
}
}
})
this.$emit('search', JSON.parse(JSON.stringify(formInline)))
eventBus.$emit('searchQuery', JSON.parse(JSON.stringify(this.queryParam)))
},
searchReset () {