Commit d289a0ae authored by 田翔's avatar 田翔

fix: 关联选择一个选项自动赋值

parent c4907700
{
"name": "panda-xform",
"version": "6.0.25",
"description": "6.0.25 下拉框搜索优化",
"version": "6.0.26",
"description": "6.0.26 关联选择一个选项自动赋值",
"keywords": [
"panda-xform"
],
......@@ -138,4 +138,4 @@
"publishConfig": {
"registry": "https://g.civnet.cn:4873"
}
}
}
\ No newline at end of file
......@@ -415,6 +415,20 @@ export function ExportAccountData({ accountName, ids, exportAll }) {
});
}
//下载文件流
export function DownloadFiles({ filePath }) {
return request({
url: `/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${filePath}`,
method: 'get',
headers: {
// 'Civ-Site': window?.globalConfig?.userInfo?.site,
'Content-Type': 'application/json; charset=UTF-8',
},
responseType: 'arraybuffer'
});
}
//导出模板
export function ExportAccountModel({ accountName, exportAll }) {
return request({
......
......@@ -194,10 +194,27 @@ const formFieldHide = async (params) => {
}
}
const getSelectItemList = async (params) => {
const { sourcePath, form, targetPath, dictionary, currentValue } = params
//只读情况下不做处理
const { formDisabled } = form.getSchemaByPath(targetPath)
if (!formDisabled) {
const { code, data, msg } = await GetSelectItemList({ nodeName: dictionary })
if (code === 0) {
let array = data.filter(v => v.nodeName === currentValue)
if (Array.isArray(array) && array.length === 1) {
form.setValueByPath(targetPath, array[0].nodeValue)
}
}
}
}
const Automatic = debounce(formAutomatic)
const fieldHide = debounce(formFieldHide)
const getSelect = debounce(getSelectItemList)
const getFieldValue = (formValue, fieldName) => {
let value = ''
Object.keys(formValue).map(k => {
......@@ -274,25 +291,19 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
RelevanceSelect.forEach(v => {
let path = getPath(schema, v.fieldParent)
if (path) {
watch[path] = (value) => {
if (value) {
let params = {
startTime,
sourcePath: path,
targetPath: v.targetPath,
form: form,
dictionary: v.dictionary,
value
}
debounce(getSelectItemList)(params)
}
}
let someType = paths.find(s => s.path === path)?.type
paths.push({
type: someType?.length ? [...someType, 'RelevanceSelect'] : ['RelevanceSelect'],
dictionary: v.dictionary,
path,
targetPath: v.targetPath,
})
}
})
}
if (Array.isArray(paths)) {
paths.forEach(v => {
watch[v.path] = () => {
watch[v.path] = (currentValue) => {
let params = {
...v,
tableName: schema.tableName,
......@@ -303,6 +314,7 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
schema: schema,
startTime,
initField,
currentValue,
}
if (v.type.includes('AutoCalculate')) {
Automatic(params)
......@@ -310,24 +322,11 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
if (v.type.includes('HiddenWidget')) {
fieldHide(params)
}
if (v.type.includes('RelevanceSelect')) {
getSelect(params)
}
}
})
}
return watch
}
const getSelectItemList = async (params) => {
if ((new Date().getTime() - params.startTime) < 2000) return
const { sourcePath, form, targetPath, dictionary, value } = params
//只读情况下不做处理
const { disabled } = form.getSchemaByPath(targetPath)
if (!disabled) {
const { code, data, msg } = await GetSelectItemList({ nodeName: dictionary })
if (code === 0) {
let array = data.filter(v => v.nodeName === value)
if (Array.isArray(array) && array.length) {
form.setValueByPath(targetPath, array[0].nodeValue)
}
}
}
}
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