Commit bb128a73 by 李伟康

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

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