Commit 89aa9f62 by 李伟康

refactor(dailyNewspaper): 重构日报保存和提交逻辑,统一处理流程

1. 调整Edit组件的保存按钮事件,传递表单数据并新增check参数
2. 优化mixins的saveReport方法,新增check参数用于直接跳转详情校验
3. 移除父页面对checkReportDetail的事件转发,将保存逻辑抽离为独立方法
4. 统一保存接口的loading提示和成功失败反馈逻辑
1 parent becf191e
......@@ -54,7 +54,7 @@
<view class="btn" @click="$emit('submitReport')" v-if="showPushBtn">上报数据</view>
</template>
<template v-else>
<view class="btn w100" @click="save">保存</view>
<view class="btn w100" @click="$emit('saveReport', list)">保存</view>
</template>
</Footer>
</view>
......
......@@ -5,9 +5,9 @@
<Detail :templateData="templateData" />
</template>
<template v-else>
<Edit :templateData="templateData" @showNegotiationList="changeComponent(true)" @saveReport="saveReport"
<Edit :templateData="templateData" @showNegotiationList="changeComponent(true)" @saveReport="saveReport($event, true)"
@submitReport="submitReport" :reportDate="currentDate" :ReportStatus="ReportStatus"
@getSaveBtnStatus="saveBtnStatus = $event" :SubmissionStatus="SubmissionStatus" :isToday="isToday" @checkReportDetail="$emit('checkReportDetail', $event)" />
@getSaveBtnStatus="saveBtnStatus = $event" :SubmissionStatus="SubmissionStatus" :isToday="isToday" />
</template>
</view>
......
......@@ -328,12 +328,10 @@ export default {
this.noticeObj = noticeObj
this.$refs.notice.open()
},
async checkReportDetail(list) {
async checkReportDetail(data) {
let flag = this.dailyReportRecordId
if (!flag) flag = await this.getReportDetail(true)
let componentRef = this.$refs[`ref-${this.componentName}`]
if (flag) {
this.openNotice(
{
title: '数据已被他人更新',
......@@ -345,10 +343,19 @@ export default {
},
false,
_ => {
componentRef.saveReport(list)
this.saveReport(data)
}
)
} else componentRef.saveReport(list)
} else this.saveReport(data)
},
async saveReport(params) {
uni.showLoading({ title: '保存中...', mask: true })
const data = await uni.$api.dailyTemplateApi.saveDraft(params)
uni.hideLoading()
if (data) {
uni.showToast({ title: '操作成功', icon: 'success', mask: true })
this.saveReportStatus(data)
} else uni.showToast({ title: '操作失败', icon: 'none', mask: true })
},
async getReportDetail(getDailyReportRecordId = false) {
console.log(getDailyReportRecordId)
......
......@@ -83,7 +83,7 @@ export default {
console.log(error)
}
},
async saveReport(res) {
async saveReport(res, check) {
try {
const phoneRegex = /^1[3456789]\d{9}$/
uni.showLoading({ title: '提交中...', mask: true })
......@@ -178,6 +178,7 @@ export default {
reportParams.requestJson = JSON.stringify(requestJson)
console.log('提交日报', reportParams)
uni.hideLoading()
if(check) return this.$emit('checkReportDetail', reportParams)
const data = await uni.$api.dailyTemplateApi.saveDraft(reportParams)
uni.hideLoading()
if (data) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!