Commit 4771a714 by 李伟康

feat(dailyNewspaper): 添加日报详情表格组件功能

- 在Table组件中新增isDetail属性用于区分详情展示样式
- 为各日报详情页面的表格添加isDetail标识
- 在StoreDailyReport中移除多余模板表达式
- 优化表格标题行和角落单元格的样式类绑定逻辑
- 为详情模式下的表格内容设置灰色文字样式以增强可读性
1 parent bb128a73
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
:columns="item.columns" :columns="item.columns"
:data="item.dataList" :data="item.dataList"
tableStyle="padding-right:32rpx" tableStyle="padding-right:32rpx"
isDetail
> >
</Table> </Table>
......
...@@ -51,7 +51,10 @@ ...@@ -51,7 +51,10 @@
</view> </view>
<view class="footer"> <view class="footer">
<Footer> <Footer>
<view class="btn" @click="$emit('submitReport',list)">保存</view> <view
class="btn"
@click="$emit('submitReport',list)"
>保存</view>
</Footer> </Footer>
</view> </view>
</template> </template>
...@@ -116,10 +119,15 @@ export default { ...@@ -116,10 +119,15 @@ export default {
let item = list.find(i => i.key == key) let item = list.find(i => i.key == key)
if (item) value.push(item.value || null) if (item) value.push(item.value || null)
}) })
return func(...value) let show = func(...value)
} else return true i.show = show
return show
} else {
i.show = true
return true
}
} else { } else {
i.show = true
return true return true
} }
}, },
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
:data="item.dataList" :data="item.dataList"
tableStyle="padding-right:32rpx" tableStyle="padding-right:32rpx"
cornerText="门店日报内容项" cornerText="门店日报内容项"
isDetail
/> />
</view> </view>
......
...@@ -68,9 +68,18 @@ ...@@ -68,9 +68,18 @@
</view> </view>
<view class="footer"> <view class="footer">
<Footer> <Footer>
<view class="btn default-btn" @click="$emit('showNegotiationList')">查看洽谈明细表汇总</view> <view
<view class="btn default-btn" @click="$emit('saveReport',list)">保存</view> class="btn default-btn"
<view class="btn" @click="$emit('submitReport',list)">提交</view> @click="$emit('showNegotiationList')"
>查看洽谈明细表汇总</view>
<view
class="btn default-btn"
@click="$emit('saveReport',list)"
>保存</view>
<view
class="btn"
@click="$emit('submitReport',list)"
>提交</view>
</Footer> </Footer>
</view> </view>
</template> </template>
...@@ -142,10 +151,15 @@ export default { ...@@ -142,10 +151,15 @@ export default {
let item = list.find(i => i.key == key) let item = list.find(i => i.key == key)
if (item) value.push(item.value || null) if (item) value.push(item.value || null)
}) })
return func(...value) let show = func(...value)
} else return true i.show = show
return show
} else {
i.show = true
return true
}
} else { } else {
i.show = true
return true return true
} }
}, },
......
<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 || reportStatus() == 1"> <template v-if="!isToday || reportStatus() == 1">
<Detail :templateData="templateData" /> <Detail :templateData="templateData" />
</template> </template>
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
:columns="i.columns" :columns="i.columns"
:data="i.dataList" :data="i.dataList"
tableStyle="padding-right:32rpx" tableStyle="padding-right:32rpx"
isDetail
/> />
</view> </view>
</template> </template>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<view class="table-row header-row"> <view class="table-row header-row">
<!-- 左上角固定单元格 --> <!-- 左上角固定单元格 -->
<view <view
class="table-cell corner-cell fixed-corner" :class="['table-cell corner-cell fixed-corner',{'is-detail': isDetail}]"
:style="{width:LeftWidth, minWidth:LeftWidth}" :style="{width:LeftWidth, minWidth:LeftWidth}"
> >
<text class="cell-text">{{ cornerText }}</text> <text class="cell-text">{{ cornerText }}</text>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<view <view
v-for="(col, colIndex) in columns" v-for="(col, colIndex) in columns"
:key="'header-' + colIndex" :key="'header-' + colIndex"
class="table-cell header-cell fixed-header" :class="['table-cell header-cell fixed-header',{'is-detail': isDetail}]"
:style="{ width: col.width + 'rpx', minWidth: col.width + 'rpx' }" :style="{ width: col.width + 'rpx', minWidth: col.width + 'rpx' }"
> >
<text class="cell-text"> <text class="cell-text">
...@@ -138,6 +138,10 @@ export default { ...@@ -138,6 +138,10 @@ export default {
type: Number, type: Number,
default: 20 default: 20
}, },
isDetail: {
type: Boolean,
default: false
},
}, },
data () { data () {
return { return {
...@@ -340,4 +344,7 @@ export default { ...@@ -340,4 +344,7 @@ export default {
} }
} }
} }
.is-detail{
color: #999 !important;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -48,14 +48,16 @@ ...@@ -48,14 +48,16 @@
:templateData="templateData" :templateData="templateData"
:currentDate="currentDate" :currentDate="currentDate"
@changeComponent="changeComponent" @changeComponent="changeComponent"
@submitReport="submitReport"
/> />
</view> </view>
</view> </view>
<NoticePopup <NoticePopup
ref="notice" ref="notice"
title="重要提示" :title="noticeObj.title"
text="当前页面暂未保存,是否确认退出" :text="noticeObj.text"
type="warning" :type="noticeObj.type || 'success'"
:buttons="noticeObj.buttons"
></NoticePopup> ></NoticePopup>
</view> </view>
</template> </template>
...@@ -88,6 +90,7 @@ export default { ...@@ -88,6 +90,7 @@ export default {
}, },
data () { data () {
return { return {
noticeObj: {},
options: {}, options: {},
transmissionOfData: null, transmissionOfData: null,
endDate: dayjs().format('YYYY-MM-DD'), // 日历结束日期 endDate: dayjs().format('YYYY-MM-DD'), // 日历结束日期
...@@ -178,28 +181,32 @@ export default { ...@@ -178,28 +181,32 @@ export default {
if (options.currentDate) this.setCurrentDate(options.currentDate) if (options.currentDate) this.setCurrentDate(options.currentDate)
this.getReportList() this.getReportList()
this.getReportDetail() this.getReportDetail()
// this.getDailyTemplate()
}, },
onUnload () { onUnload () {
}, },
methods: { methods: {
back () { back () {
this.$refs.notice.buttonsList = [ this.noticeObj = {
{ title: '重要提示',
text: '确认退出', text: '内容尚未保存,是否退出编辑?',
type: 'default', type: 'warning',
callback: () => { buttons: [
this.backPage() {
} text: '继续编辑',
}, type: 'default',
{ callback: _ => {
text: '继续编辑', this.$refs.notice.close()
type: 'primary', }
callback: () => { },
this.$refs.notice.close() {
text: '确定退出',
type: 'primary',
callback: _ => {
this.backPage()
}
} }
} ]
] }
let now = dayjs().format('YYYY-MM-DD') let now = dayjs().format('YYYY-MM-DD')
if (this.currentDate == now) { if (this.currentDate == now) {
if (this.templateType != 2) { if (this.templateType != 2) {
...@@ -284,6 +291,7 @@ export default { ...@@ -284,6 +291,7 @@ export default {
templateData.map(e => { templateData.map(e => {
if (e.children && e.type == 'subform') e.origin_children = e.children[0] if (e.children && e.type == 'subform') e.origin_children = e.children[0]
}) })
uni.hideLoading()
console.log(templateData) console.log(templateData)
this.templateData = templateData this.templateData = templateData
}, },
...@@ -298,45 +306,54 @@ export default { ...@@ -298,45 +306,54 @@ export default {
this.getReportDetail() this.getReportDetail()
}, },
async getReportDetail () { async getReportDetail () {
const { uuid, shopMerchantId } = this.userInfo, uni.showLoading({ title: '加载中...', mask: true })
nowDate = dayjs().format('YYYY-MM-DD'), try {
{ templateType, currentDate } = this, const { uuid, shopMerchantId } = this.userInfo,
data = await uni.$api.dailyTemplateApi.getReportDetail({ nowDate = dayjs().format('YYYY-MM-DD'),
merchantId: shopMerchantId, { templateType, currentDate } = this,
staffUuid: uuid, data = await uni.$api.dailyTemplateApi.getReportDetail({
templateType, merchantId: shopMerchantId,
reportDate: currentDate staffUuid: uuid,
}) templateType,
if (data) { reportDate: currentDate
this.dailyReportRecordId = data.id })
this.reportStatus = data.reportStatus
let templateData = JSON.parse(data.jsonContent || '[]') if (data) {
templateData.forEach(e => { uni.hideLoading()
if (e.childrenValue && e.childrenValue.length > 0) { this.dailyReportRecordId = data.id
const children = e.childrenValue.map(c => { this.reportStatus = data.reportStatus
// 每次循环创建新的深拷贝,避免引用共享问题 let templateData = JSON.parse(data.jsonContent || '[]')
const originChildren = utils.deepClone(e.origin_children) templateData.forEach(e => {
originChildren.forEach(item => { if (e.childrenValue && e.childrenValue.length > 0) {
const key = item.key const children = e.childrenValue.map(c => {
const val = c[e.key]?.[key] // 每次循环创建新的深拷贝,避免引用共享问题
const originChildren = utils.deepClone(e.origin_children)
originChildren.forEach(item => {
const key = item.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) {
item.value = val.text item.value = val.text
item[key] = val.value item[key] = val.value
} }
})
return originChildren
}) })
return originChildren e.children = children
}) }
e.children = children })
} console.log(templateData)
}) this.templateData = templateData
console.log(templateData) }
this.templateData = templateData else {
} if (nowDate == currentDate) this.getDailyTemplate()
else { else uni.hideLoading()
if (nowDate == currentDate) this.getDailyTemplate() }
} catch (error) {
uni.showToast({ title: error, icon: 'none' })
} }
}, },
changeMonth (e) { changeMonth (e) {
...@@ -356,7 +373,42 @@ export default { ...@@ -356,7 +373,42 @@ export default {
changeComponent (val) { changeComponent (val) {
this.assignTitle = val.title this.assignTitle = val.title
this.assignIcon = val.icon this.assignIcon = val.icon
} },
async submitReport (reportParams, skip) {
if (this.templateType == 2 && !skip) {
uni.hideLoading()
this.noticeObj = {
title: '重要提示',
text: '确认提交后将不可再编辑,确认继续?',
type: 'warning',
buttons: [
{
text: '取消',
type: 'default',
callback: _ => {
this.$refs.notice.close()
}
},
{
text: '确定提交',
type: 'primary',
callback: _ => {
this.submitReport(reportParams, true)
}
}
]
}
this.$refs.notice.open()
return
}
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)
},
} }
} }
......
...@@ -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','reportStatus'], inject: ['sceneType', 'userInfo', 'templateType', 'dailyReportRecordId', 'reportStatus'],
data () { data () {
return { return {
dayjs, dayjs,
...@@ -43,6 +43,7 @@ export default { ...@@ -43,6 +43,7 @@ export default {
methods: { methods: {
async saveReport (res) { async saveReport (res) {
try { try {
uni.showLoading({ title: '提交中...', mask: true })
let { reportParams } = this, let { reportParams } = this,
list = utils.deepClone(res) list = utils.deepClone(res)
list.map(e => { list.map(e => {
...@@ -71,15 +72,19 @@ export default { ...@@ -71,15 +72,19 @@ export default {
reportParams.jsonContent = jsonContent reportParams.jsonContent = jsonContent
console.log(reportParams) console.log(reportParams)
const data = await uni.$api.dailyTemplateApi.saveDraft(reportParams) const data = await uni.$api.dailyTemplateApi.saveDraft(reportParams)
uni.hideLoading()
uni.showToast({ title: '操作成功', icon: 'success' })
console.log(data) console.log(data)
} catch (error) { } catch (error) {
uni.hideLoading()
uni.showToast({ title: error, icon: 'none' }) uni.showToast({ title: error, icon: 'none' })
} }
}, },
async submitReport (res) { submitReport (res) {
try { try {
uni.showLoading({ title: '提交中...', mask: true })
let { reportParams } = this, let { reportParams } = this,
list = utils.deepClone(res) list = utils.deepClone(res)
console.log('提交日报', list) console.log('提交日报', list)
...@@ -94,8 +99,10 @@ export default { ...@@ -94,8 +99,10 @@ export default {
childrenValue.push({ childrenValue.push({
[e.key]: {} [e.key]: {}
}) })
c.map(i => { c.forEach(i => {
if (i.required && i.show && (i.value === null || i.value === undefined)) throw `${e.label}第${cIndex + 1}项${i.label}不能为空` let hasShow = Object.prototype.hasOwnProperty.call(i, 'show'),
show = hasShow ? i.show : true
if (i.required && show && (i.value === null || i.value === '' || 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,
...@@ -105,10 +112,13 @@ export default { ...@@ -105,10 +112,13 @@ export default {
}) })
} else { } else {
if (c.required && (c.value == null || c.value == undefined)) throw `${e.label}${c.label}不能为空` if (e.show && c.required) {
if (c.value == null || c.value === '' || c.value == undefined) throw `${e.label}:${c.label}不能为空`
}
} }
}) })
e.childrenValue = childrenValue e.childrenValue = childrenValue
if (e.required && e.show && (e.value == null || e.value == undefined)) throw `${e.label}不能为空`
if (e.type == 'subform') delete e.children if (e.type == 'subform') delete e.children
}) })
console.log('提交日报', list) console.log('提交日报', list)
...@@ -116,9 +126,10 @@ export default { ...@@ -116,9 +126,10 @@ export default {
reportParams.fieldDataList = fieldDataList reportParams.fieldDataList = fieldDataList
reportParams.subformDataList = subformDataList reportParams.subformDataList = subformDataList
console.log(reportParams) console.log(reportParams)
const data = await uni.$api.dailyTemplateApi.submitReport(reportParams) uni.hideLoading()
console.log(data) this.$emit('submitReport', reportParams)
} catch (error) { } catch (error) {
uni.hideLoading()
uni.showToast({ title: error, icon: 'none' }) uni.showToast({ title: error, icon: 'none' })
} }
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!