diff --git a/common/untool.js b/common/untool.js index 13f20e2..4c78adc 100644 --- a/common/untool.js +++ b/common/untool.js @@ -55,11 +55,13 @@ const showToast = (val)=> { uni.showToast({ title: val, icon: 'none' }) } -const confirmModal = (title) => { +const confirmModal = (title, opt = {}) => { return new Promise((resolve)=> { - uni.showModal({ content: title, confirmColor: '#B12D29' }).then((res)=> { + uni.showModal({ content: title, confirmColor: '#B12D29', ...opt }).then((res)=> { if(res.confirm) { - resolve() + resolve(true) + } else { + resolve(false) } }) }) @@ -251,6 +253,20 @@ const promiseTimeout = (time) => { }) } +const setNavigationBarTitle = (title)=> { + uni.setNavigationBarTitle({ + title + }) +} + +const reloadCurrentPage = (_thisPage)=> { + let { fullPath } = _thisPage.$page + uni.redirectTo({ + url: fullPath + }); +} + + export { reLaunch, goto, @@ -270,4 +286,6 @@ export { getImageInfo, uniPromiseApi, promiseTimeout, + setNavigationBarTitle, + reloadCurrentPage, } diff --git a/pages.json b/pages.json index baf06d5..ad9329a 100644 --- a/pages.json +++ b/pages.json @@ -78,7 +78,7 @@ { "path": "pages/post/openorder", "style": { - "navigationBarTitleText": "开单" + "navigationBarTitleText": "" } }, { diff --git a/pages/post/openorder.vue b/pages/post/openorder.vue index 5ddf71f..7e4057b 100644 --- a/pages/post/openorder.vue +++ b/pages/post/openorder.vue @@ -9,7 +9,7 @@ - + 系统生成 @@ -291,6 +291,10 @@ import { debounce } from "@/common/util" import * as apiService from "@/common/api" import { getOrderModels } from "./model" + const pageTypeEnum = { + create: 'create', + edit: 'edit' + } export default { components: { BpeAddressinfoTmp, BpeGoodstaticTmp, BpeCostTmp, BpeGooditemEditTmp, BpeGoodphotoTmp, BpeGoodKuaidiTmp, BpeGoodsizeTmp }, @@ -338,10 +342,16 @@ methods: { getDefaultData() { // data的默认数据 return { + pageTypeEnum, + pageTypeMap: { + [pageTypeEnum.create]: { title: '开单', savedConfirmTitle: '是否操作下一单' }, + [pageTypeEnum.edit]: { title: '运单修改', savedConfirmTitle: '是否操作下一单' } + }, + curPageType: {}, pageLoading: true, isEdit: false, queryOption: { - type: '', // edit 修改 + type: '', // edit: 运单修改, create: 下单, defaultSubParams: '', // 提交默认参数 billCode: '', // 运单id orderSn: '', // 订单id @@ -378,6 +388,8 @@ getSalemanList: apiService.getSalemanList, async initData() { // 初始化 this.queryOption.billCode = this.queryOption.billCode || this.queryOption.copyBillCode + this.curPageType = this.pageTypeMap[this.queryOption.type] || {} + this.setNavigationBarTitle(this.curPageType.title || this.pageTypeMap[pageTypeEnum.create].title) this.isEdit = Boolean(this.queryOption.billCode || this.queryOption.orderSn) if(this.queryOption.defaultSubParams) { try{ @@ -406,7 +418,7 @@ }, handleScanChange: debounce(function(val){ // 创建不做 查询详情 - if(this.queryOption.type != 'create') { + if(this.queryOption.type != pageTypeEnum.create) { // 扫码回调 要重新查询新运单信息,并覆盖老的 this.queryOption.billCode = val this.initData(); @@ -464,14 +476,26 @@ }, async handleSave(type) { let saveServerHand = apiService.submitOrder - if(this.isEdit) { - // 编辑订单 TODO - } + if(this.isEdit) { } let params = JSON.parse(JSON.stringify(this.submitParam)); params.goodsPics = params.goodsPics.join(",") await saveServerHand(params) - this.showToast('操作成功') - this.goBack() + await this.saveSuccessBack() + }, + async saveSuccessBack(){ + let { savedConfirmTitle } = this.curPageType + if(savedConfirmTitle) { + let cBl = await this.confirmModal(`操作成功,${savedConfirmTitle}`) + if(cBl) { + // 刷新当前页面状态 + this.reloadCurrentPage(this) + } else { + this.goBack() + } + } else { + this.showToast('操作成功') + this.goBack() + } } } }