Commit bb128a73 by 李伟康

fix(dailyNewspaper): 修复日报编辑页面返回逻辑及数据处理问题

- 修改返回按钮事件处理,添加物理返回键拦截逻辑
- 新增reportStatus字段用于控制页面状态判断
- 优化模板数据解析逻辑,修复子表单数据处理问题
- 添加空值判断和格式化功能,避免显示异常
- 修复表格组件中的数据展示格式问题
- 完善日报记录ID和状态的数据绑定逻辑
1 parent 904dbc39
......@@ -14,7 +14,8 @@
:columns="item.columns"
:data="item.dataList"
tableStyle="padding-right:32rpx"
/>
>
</Table>
</view>
</template>
......@@ -62,6 +63,9 @@ export default {
},
methods: {
formatValue (value) {
return value != null && value != '' ? value : '-'
},
formatData (list) {
console.log(list)
list.map(item => {
......
......@@ -121,7 +121,7 @@ export default {
this.$set(this.list[index].children, c_index, utils.deepClone(data))
},
formatValue (value) {
return value != null ? value : '-'
return value != null && value != '' ? value : '-'
}
}
}
......
<template>
<view class="report-content ">
<view :class="['report-component',{'opacity':showNegotiationList}]">
<template v-if="!isToday">
{{ }}
<template v-if="!isToday || reportStatus() == 1">
<Detail :templateData="templateData" />
</template>
<template v-else>
......@@ -40,6 +41,7 @@ export default {
},
computed: {
},
watch: {
currentDate: {
......
......@@ -50,6 +50,7 @@
import Nothing from '../components/Nothing'
import Footer from '../components/Footer'
import Table from '../components/Table'
import utils from '@/utils/utils'
export default {
name: 'negotiationList',
......@@ -114,7 +115,28 @@ export default {
})
if (data) {
let list = JSON.parse(data.jsonContent || '[]')
list.map(item => {
list.forEach(e => {
if (e.childrenValue && e.childrenValue.length > 0) {
const children = e.childrenValue.map(c => {
// 每次循环创建新的深拷贝,避免引用共享问题
const originChildren = utils.deepClone(e.origin_children)
originChildren.forEach(item => {
const key = item.key
const val = c[e.key]?.[key]
if (typeof val === 'string') {
item.value = val
} else if (val) {
item.value = val.text
item[key] = val.value
}
})
return originChildren
})
e.children = children
}
})
list.forEach(item => {
let columns = [],
dataList = [],
values = {}
......
......@@ -65,7 +65,7 @@
:rowIndex="rowIndex"
></slot>
</template>
<template v-else><text class="cell-text">{{ row.data[colIndex] }}</text></template>
<template v-else><text class="cell-text">{{ formatValue(row.data[colIndex]) }}</text></template>
</view>
</view>
</view>
......@@ -164,6 +164,9 @@ export default {
mounted () {
},
methods: {
formatValue (value) {
return value !== null && value !== '' ? value : '-'
},
handleRowClick (row, rowIndex) {
this.$emit('rowClick', row, rowIndex, this.tableIndex)
},
......
......@@ -3,7 +3,7 @@
<view class="nav-bar">
<view
class="back"
@click="backPage"
@click="back"
>
<uni-icons
type="left"
......@@ -83,6 +83,7 @@ export default {
userInfo: this.userInfo,
templateType: () => this.templateType,
dailyReportRecordId: () => this.dailyReportRecordId,
reportStatus: () => this.reportStatus,
}
},
data () {
......@@ -98,9 +99,20 @@ export default {
templateData: [],
assignTitle: '',
assignIcon: '',
dailyReportRecordId: ''
dailyReportRecordId: '',
reportStatus: '',
}
},
onBackPress (options) {
if (options.from === 'backbutton') {
// 物理返回按钮触发
// 阻止默认行为,即不执行页面返回
this.back()
return true
}
// 其他情况允许正常返回
return false
},
computed: {
userInfo () {
return uni.$storage.get("userInfo")
......@@ -171,6 +183,33 @@ export default {
onUnload () {
},
methods: {
back () {
this.$refs.notice.buttonsList = [
{
text: '确认退出',
type: 'default',
callback: () => {
this.backPage()
}
},
{
text: '继续编辑',
type: 'primary',
callback: () => {
this.$refs.notice.close()
}
}
]
let now = dayjs().format('YYYY-MM-DD')
if (this.currentDate == now) {
if (this.templateType != 2) {
this.$refs.notice.open()
} else {
if (this.reportStatus != 1) this.$refs.notice.open()
else this.backPage()
}
} else this.backPage()
},
async getReportList () {
const { uuid, shopMerchantId } = this.userInfo,
{ templateType, dayList } = this
......@@ -270,6 +309,7 @@ export default {
})
if (data) {
this.dailyReportRecordId = data.id
this.reportStatus = data.reportStatus
let templateData = JSON.parse(data.jsonContent || '[]')
templateData.forEach(e => {
if (e.childrenValue && e.childrenValue.length > 0) {
......@@ -279,7 +319,7 @@ export default {
originChildren.forEach(item => {
const key = item.key
const val = c[e.key]?.[key]
if (typeof val === 'string') {
item.value = val
} else if (val) {
......
......@@ -4,7 +4,7 @@ import utils from '@/utils/utils'
export default {
inject: ['sceneType', 'userInfo', 'templateType', 'dailyReportRecordId'],
inject: ['sceneType', 'userInfo', 'templateType', 'dailyReportRecordId','reportStatus'],
data () {
return {
dayjs,
......@@ -54,7 +54,7 @@ export default {
[e.key]: {}
})
c.map(i => {
let value = i.value || ''
let value = i.value
if (i[i.key]) childrenValue[cIndex][e.key][i.key] = {
text: value,
value: i[i.key]
......@@ -65,7 +65,7 @@ export default {
}
})
e.childrenValue = childrenValue
delete e.children
if (e.type == 'subform') delete e.children
})
let jsonContent = JSON.stringify(list)
reportParams.jsonContent = jsonContent
......@@ -95,8 +95,8 @@ export default {
[e.key]: {}
})
c.map(i => {
if (i.required && i.show && (i.value == null || i.value == undefined)) throw `${e.label}第${cIndex + 1}项${i.label}不能为空`
let value = i.value || ''
if (i.required && i.show && (i.value === null || i.value === undefined)) throw `${e.label}第${cIndex + 1}项${i.label}不能为空`
let value = i.value
if (i[i.key]) childrenValue[cIndex][e.key][i.key] = {
text: value,
value: i[i.key]
......@@ -109,7 +109,7 @@ export default {
}
})
e.childrenValue = childrenValue
delete e.children
if (e.type == 'subform') delete e.children
})
console.log('提交日报', list)
reportParams.jsonContent = JSON.stringify(list)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!