Commit 4771a714 by 李伟康

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

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