feat: 新增需求

This commit is contained in:
caijun
2026-01-19 17:34:15 +08:00
parent 8fa31df250
commit 9f5b2a92c4
67 changed files with 7518 additions and 481 deletions

View File

@@ -37,6 +37,7 @@
this.userInfo = uni.getStorageSync('userInfo') || {}
this.setting = data
this.formConf = data.formConf ? JSON.parse(data.formConf) : {}
console.log(this.formConf,'formConf112')
this.dataForm.id = data.id || null;
this.dataForm.flowId = data.flowId;
this.loading = true;
@@ -74,91 +75,91 @@
},
fillFormData(form, data) {
form.disabled = this.setting.readonly
const loop = (list, parent) => {
for (let i = 0; i < list.length; i++) {
let item = list[i]
let vModel = item.__vModel__
let config = item.__config__
if (vModel) {
let val = data.hasOwnProperty(vModel) ? data[vModel] : config.defaultValue
if (!config.isSubTable) config.defaultValue = val
if (this.isAdd || config.isSubTable) { //新增时候,默认当前
if (config.defaultCurrent) {
if (config.jnpfKey === 'datePicker') {
if (!data.hasOwnProperty(vModel)) {
let format = this.jnpf.handelFormat(item.format)
let dateStr = this.jnpf.toDate(new Date().getTime(), format)
let time = format === 'yyyy' ? '-01-01 00:00:00' : format === 'yyyy-MM' ?
'-01 00:00:00' : format === 'yyyy-MM-dd' ?
' 00:00:00' : ''
val = new Date(dateStr + time).getTime()
config.defaultValue = val
}
}
if (config.jnpfKey === 'timePicker') {
if (!data.hasOwnProperty(vModel)) {
config.defaultValue = this.jnpf.toDate(new Date(), item.format)
}
}
if (config.jnpfKey === 'organizeSelect' && this.userInfo.organizeIds?.length) {
config.defaultValue = item.multiple ? this.userInfo.organizeIds :
this.userInfo.organizeId
}
if (config.jnpfKey === 'posSelect' && this.userInfo.positionIds?.length) {
config.defaultValue = item.multiple ? this.userInfo.positionIds :
this.userInfo.positionId
}
const userId = this.userInfo.userId
if (config.jnpfKey === 'userSelect' && userId) {
config.defaultValue = item.multiple ? [userId] : userId;
}
if (config.jnpfKey === 'usersSelect' && userId) {
config.defaultValue = [userId + '--user'];
}
if (config.jnpfKey === 'sign' && this.userInfo.signImg) {
config.defaultValue = this.userInfo.signImg
}
}
}
let noShow = item.__config__.noShow || false,
isDisabled = item.disabled || false,
required = item.__config__.required || false,
isVisibility = false
if (!item.__config__.visibility || (Array.isArray(item.__config__.visibility) && item
.__config__.visibility.includes('app'))) isVisibility = true
if (this.setting.formOperates && this.setting.formOperates.length) {
let id = item.__config__.isSubTable ? parent?.__vModel__ + '-' + item?.__vModel__ :
item
.__vModel__
let arr = this.setting.formOperates.filter(o => o.id === id) || []
if (arr.length) {
let obj = arr[0]
noShow = !obj.read
isDisabled = !obj.write
required = obj.required ? obj.required : item.__config__.required
}
}
isDisabled = item.readonly ? item.readonly : isDisabled;
if (this.setting.readonly || config.disabled) isDisabled = true
if (this.setting.origin === 'scan') isDisabled = true
this.$set(item, 'disabled', isDisabled)
this.$set(item.__config__, 'noShow', noShow)
this.$set(item.__config__, 'required', required)
this.$set(item.__config__, 'isVisibility', isVisibility)
} else {
let noShow = item.__config__.noShow ? item.__config__.noShow : false,
isVisibility = false
if (!item.__config__.visibility || (Array.isArray(item.__config__.visibility) && item
.__config__.visibility.includes('app'))) isVisibility = true
this.$set(item.__config__, 'isVisibility', isVisibility)
this.$set(item.__config__, 'noShow', noShow)
}
if (item.__config__ && item.__config__.children && Array.isArray(item.__config__.children)) {
loop(item.__config__.children, item)
}
}
}
loop(form.fields)
// const loop = (list, parent) => {
// for (let i = 0; i < list?.length; i++) {
// let item = list[i]
// let vModel = item.__vModel__
// let config = item.__config__
// if (vModel) {
// let val = data.hasOwnProperty(vModel) ? data[vModel] : config.defaultValue
// if (!config.isSubTable) config.defaultValue = val
// if (this.isAdd || config.isSubTable) { //新增时候,默认当前
// if (config.defaultCurrent) {
// if (config.jnpfKey === 'datePicker') {
// if (!data.hasOwnProperty(vModel)) {
// let format = this.jnpf.handelFormat(item.format)
// let dateStr = this.jnpf.toDate(new Date().getTime(), format)
// let time = format === 'yyyy' ? '-01-01 00:00:00' : format === 'yyyy-MM' ?
// '-01 00:00:00' : format === 'yyyy-MM-dd' ?
// ' 00:00:00' : ''
// val = new Date(dateStr + time).getTime()
// config.defaultValue = val
// }
// }
// if (config.jnpfKey === 'timePicker') {
// if (!data.hasOwnProperty(vModel)) {
// config.defaultValue = this.jnpf.toDate(new Date(), item.format)
// }
// }
// if (config.jnpfKey === 'organizeSelect' && this.userInfo.organizeIds?.length) {
// config.defaultValue = item.multiple ? this.userInfo.organizeIds :
// this.userInfo.organizeId
// }
// if (config.jnpfKey === 'posSelect' && this.userInfo.positionIds?.length) {
// config.defaultValue = item.multiple ? this.userInfo.positionIds :
// this.userInfo.positionId
// }
// const userId = this.userInfo.userId
// if (config.jnpfKey === 'userSelect' && userId) {
// config.defaultValue = item.multiple ? [userId] : userId;
// }
// if (config.jnpfKey === 'usersSelect' && userId) {
// config.defaultValue = [userId + '--user'];
// }
// if (config.jnpfKey === 'sign' && this.userInfo.signImg) {
// config.defaultValue = this.userInfo.signImg
// }
// }
// }
// let noShow = item.__config__.noShow || false,
// isDisabled = item.disabled || false,
// required = item.__config__.required || false,
// isVisibility = false
// if (!item.__config__.visibility || (Array.isArray(item.__config__.visibility) && item
// .__config__.visibility.includes('app'))) isVisibility = true
// if (this.setting.formOperates && this.setting.formOperates.length) {
// let id = item.__config__.isSubTable ? parent?.__vModel__ + '-' + item?.__vModel__ :
// item
// .__vModel__
// let arr = this.setting.formOperates.filter(o => o.id === id) || []
// if (arr.length) {
// let obj = arr[0]
// noShow = !obj.read
// isDisabled = !obj.write
// required = obj.required ? obj.required : item.__config__.required
// }
// }
// isDisabled = item.readonly ? item.readonly : isDisabled;
// if (this.setting.readonly || config.disabled) isDisabled = true
// if (this.setting.origin === 'scan') isDisabled = true
// this.$set(item, 'disabled', isDisabled)
// this.$set(item.__config__, 'noShow', noShow)
// this.$set(item.__config__, 'required', required)
// this.$set(item.__config__, 'isVisibility', isVisibility)
// } else {
// let noShow = item.__config__.noShow ? item.__config__.noShow : false,
// isVisibility = false
// if (!item.__config__.visibility || (Array.isArray(item.__config__.visibility) && item
// .__config__.visibility.includes('app'))) isVisibility = true
// this.$set(item.__config__, 'isVisibility', isVisibility)
// this.$set(item.__config__, 'noShow', noShow)
// }
// if (item.__config__ && item.__config__.children && Array.isArray(item.__config__.children)) {
// loop(item.__config__.children, item)
// }
// }
// }
// loop(form.fields)
form.formData = data
},
sumbitForm(data, callback) {