Commit 2d0434c3 by 李伟康

fix(dailyNewspaper): 解决日报模板数据处理和显示问题

- 修复字符串和数字类型判断逻辑中的空格问题
- 添加缺失的 children 数组初始化检查
- 在提交报告后增加数据验证并处理失败情况
- 实现保存报告状态功能并在成功后更新列表
- 添加表单项显示规则控制方法
- 防止详情模式下表格行点击事件触发
- 优化代码格式和条件判断语法
1 parent 1170dd56
......@@ -9,6 +9,7 @@
<template v-for="(item, index) in list">
<template v-if="item.type == 'group'">
<view
v-if="itemShow(item)"
class="group-box"
:key="`group-${index}`"
>
......@@ -26,6 +27,7 @@
</template>
<template v-else>
<view
v-if="itemShow(item)"
:class="['item',{ 'before-divider': isFollowedByGroup(index)},{'frist': index === 0}]"
:key="`item-${index}`"
>
......@@ -80,6 +82,31 @@ export default {
},
methods: {
itemShow (i) {
if (i.rules) {
let { keys, result } = i.rules,
{ list } = this
if (keys && result) {
let params = keys.map((c, index) => `val${index + 1}`),
// 将 new Function 改为 eval 方式
func = eval(`(function(${params.join(',')}) { return ${result}; })`),
value = []
keys.map(key => {
let item = list.find(i => i.key == key)
if (item) value.push(item.value || null)
})
let show = func(...value)
i.show = show
return show
} else {
i.show = true
return true
}
} else {
i.show = true
return true
}
},
isFollowedByGroup(index) {
const prevItem = this.list[index + 1];
return prevItem && prevItem.type === 'group';
......
......@@ -174,6 +174,7 @@ export default {
return value !== null && value !== '' && value !== undefined ? value : '-'
},
handleRowClick (row, rowIndex) {
if (this.isDetail) return
// 清除之前的定时器
if (this.clickTimer) {
clearTimeout(this.clickTimer)
......
......@@ -50,6 +50,7 @@
:currentDate="currentDate"
@changeComponent="changeComponent"
@submitReport="submitReport"
@saveReportStatus="saveReportStatus"
/>
</view>
</view>
......@@ -377,7 +378,7 @@ export default {
const key = item.key
const val = c[e.key]?.[key]
if (['string','number'].includes(typeof val)) {
if (['string', 'number'].includes(typeof val)) {
item.value = val
} else if (val) {
item.value = val.text
......@@ -388,7 +389,7 @@ export default {
})
e.children = children
} else {
if(!e.children) e.children = []
if (!e.children) e.children = []
}
})
this.templateData = templateData
......@@ -451,12 +452,19 @@ export default {
uni.showLoading({ title: '提交中...', mask: true })
const data = await uni.$api.dailyTemplateApi.submitReport(reportParams)
uni.hideLoading()
uni.showToast({ title: '操作成功', icon: 'success' })
setTimeout(() => {
if (this.templateType == 2) this.getReportDetail()
}, 1500)
},
if (data) {
uni.showToast({ title: '操作成功', icon: 'success' })
this.saveReportStatus(data)
}
else uni.showToast({ title: '操作失败', icon: 'none' })
},
saveReportStatus (data) {
if (data) setTimeout(() => {
this.getReportList()
this.getReportDetail()
}, 1.5e3)
}
}
}
</script>
......
......@@ -73,7 +73,11 @@ export default {
console.log(reportParams)
const data = await uni.$api.dailyTemplateApi.saveDraft(reportParams)
uni.hideLoading()
uni.showToast({ title: '操作成功', icon: 'success' })
if (data) {
uni.showToast({ title: '操作成功', icon: 'success' })
this.$emit('saveReportStatus', data)
}
else uni.showToast({ title: '操作失败', icon: 'none' })
console.log(data)
} catch (error) {
uni.hideLoading()
......@@ -87,7 +91,7 @@ export default {
if (childrenShowRules) {
if (Object.keys(childrenShowRules).includes(item.key)) {
let { keys, result } = childrenShowRules[item.key],
params = keys.map((i, index) => `val${index + 1}`),
params = keys.map((i, index) => `val${index + 1}`),
// 将 new Function 改为 eval 方式
func = eval(`(function(${params.join(',')}) { return ${result}; })`),
value = []
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!