Commit d289a0ae authored by 田翔's avatar 田翔

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

parent c4907700
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.0.25", "version": "6.0.26",
"description": "6.0.25 下拉框搜索优化", "description": "6.0.26 关联选择一个选项自动赋值",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -415,6 +415,20 @@ export function ExportAccountData({ accountName, ids, exportAll }) { ...@@ -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 }) { export function ExportAccountModel({ accountName, exportAll }) {
return request({ return request({
......
...@@ -194,10 +194,27 @@ const formFieldHide = async (params) => { ...@@ -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 Automatic = debounce(formAutomatic)
const fieldHide = debounce(formFieldHide) const fieldHide = debounce(formFieldHide)
const getSelect = debounce(getSelectItemList)
const getFieldValue = (formValue, fieldName) => { const getFieldValue = (formValue, fieldName) => {
let value = '' let value = ''
Object.keys(formValue).map(k => { Object.keys(formValue).map(k => {
...@@ -274,25 +291,19 @@ export const getWatch = ({ schema, form, startTime, initField }) => { ...@@ -274,25 +291,19 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
RelevanceSelect.forEach(v => { RelevanceSelect.forEach(v => {
let path = getPath(schema, v.fieldParent) let path = getPath(schema, v.fieldParent)
if (path) { if (path) {
watch[path] = (value) => { let someType = paths.find(s => s.path === path)?.type
if (value) { paths.push({
let params = { type: someType?.length ? [...someType, 'RelevanceSelect'] : ['RelevanceSelect'],
startTime,
sourcePath: path,
targetPath: v.targetPath,
form: form,
dictionary: v.dictionary, dictionary: v.dictionary,
value path,
} targetPath: v.targetPath,
debounce(getSelectItemList)(params) })
}
}
} }
}) })
} }
if (Array.isArray(paths)) { if (Array.isArray(paths)) {
paths.forEach(v => { paths.forEach(v => {
watch[v.path] = () => { watch[v.path] = (currentValue) => {
let params = { let params = {
...v, ...v,
tableName: schema.tableName, tableName: schema.tableName,
...@@ -303,6 +314,7 @@ export const getWatch = ({ schema, form, startTime, initField }) => { ...@@ -303,6 +314,7 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
schema: schema, schema: schema,
startTime, startTime,
initField, initField,
currentValue,
} }
if (v.type.includes('AutoCalculate')) { if (v.type.includes('AutoCalculate')) {
Automatic(params) Automatic(params)
...@@ -310,24 +322,11 @@ export const getWatch = ({ schema, form, startTime, initField }) => { ...@@ -310,24 +322,11 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
if (v.type.includes('HiddenWidget')) { if (v.type.includes('HiddenWidget')) {
fieldHide(params) fieldHide(params)
} }
if (v.type.includes('RelevanceSelect')) {
getSelect(params)
}
} }
}) })
} }
return watch 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