|
|
|
@ -245,3 +245,93 @@ export function formatParams(params = {}, equal: any = [], otherQuery: any = [])
|
|
|
|
|
postData.queryCondition = JSON.stringify(conditions)
|
|
|
|
|
return postData
|
|
|
|
|
}
|
|
|
|
|
// 获取列表设置详情接口
|
|
|
|
|
import { GetCustomColumnSetInfo } from '/@/components/HColSet/api'
|
|
|
|
|
import type { FormSchema } from '/@/types/form'
|
|
|
|
|
import { deepMerge } from '/@/utils'
|
|
|
|
|
// 重组列配置
|
|
|
|
|
export function updateColumns(code, data) {
|
|
|
|
|
// 获取数据列
|
|
|
|
|
GetCustomColumnSetInfo({
|
|
|
|
|
code
|
|
|
|
|
}).then(res => {
|
|
|
|
|
const oldSchema = data
|
|
|
|
|
let updateData = []
|
|
|
|
|
if (res.data) {
|
|
|
|
|
updateData = JSON.parse(res.data.content)
|
|
|
|
|
}
|
|
|
|
|
// 重组的表单
|
|
|
|
|
const schema: FormSchema[] = []
|
|
|
|
|
if (updateData.length == oldSchema.length) {
|
|
|
|
|
// 如果原始表单和赋值表单长度相同,则用赋值表单排序
|
|
|
|
|
updateData.forEach((item) => {
|
|
|
|
|
let _val
|
|
|
|
|
oldSchema.forEach((val) => {
|
|
|
|
|
if (item.data === val.data) {
|
|
|
|
|
_val = val
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (_val !== undefined && item.data === _val.data) {
|
|
|
|
|
const newSchema = deepMerge(_val, item)
|
|
|
|
|
schema.push(newSchema as FormSchema)
|
|
|
|
|
} else {
|
|
|
|
|
schema.push(_val)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 如果原始表单和赋值表单长度不同,则不考虑排序,用原始表单进行赋值
|
|
|
|
|
oldSchema.forEach((val) => {
|
|
|
|
|
let _val
|
|
|
|
|
updateData.forEach((item) => {
|
|
|
|
|
if (val.data === item.data) {
|
|
|
|
|
_val = item
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (_val !== undefined && val.field === _val.field) {
|
|
|
|
|
const newSchema = deepMerge(val, _val)
|
|
|
|
|
schema.push(newSchema as FormSchema)
|
|
|
|
|
} else {
|
|
|
|
|
schema.push(val)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return schema
|
|
|
|
|
})
|
|
|
|
|
// // 重组的表单
|
|
|
|
|
// const schema: FormSchema[] = []
|
|
|
|
|
// // 原始的表单
|
|
|
|
|
// const oldSchema = unref(getSchema)
|
|
|
|
|
// if (updateData.length == oldSchema.length) {
|
|
|
|
|
// // 如果原始表单和赋值表单长度相同,则用赋值表单排序
|
|
|
|
|
// updateData.forEach((item) => {
|
|
|
|
|
// let _val
|
|
|
|
|
// oldSchema.forEach((val) => {
|
|
|
|
|
// if (item.field === val.field) {
|
|
|
|
|
// _val = val
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// if (_val !== undefined && item.field === _val.field) {
|
|
|
|
|
// const newSchema = deepMerge(_val, item)
|
|
|
|
|
// schema.push(newSchema as FormSchema)
|
|
|
|
|
// } else {
|
|
|
|
|
// schema.push(_val)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// } else {
|
|
|
|
|
// // 如果原始表单和赋值表单长度不同,则不考虑排序,用原始表单进行赋值
|
|
|
|
|
// oldSchema.forEach((val) => {
|
|
|
|
|
// let _val
|
|
|
|
|
// updateData.forEach((item) => {
|
|
|
|
|
// if (val.field === item.field) {
|
|
|
|
|
// _val = item
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// if (_val !== undefined && val.field === _val.field) {
|
|
|
|
|
// const newSchema = deepMerge(val, _val)
|
|
|
|
|
// schema.push(newSchema as FormSchema)
|
|
|
|
|
// } else {
|
|
|
|
|
// schema.push(val)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
}
|