This commit is contained in:
aihe 2024-06-13 01:55:24 +08:00
parent a0ca273332
commit 116f8590d0
3 changed files with 54 additions and 12 deletions

View File

@ -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,
}

View File

@ -78,7 +78,7 @@
{
"path": "pages/post/openorder",
"style": {
"navigationBarTitleText": "开单"
"navigationBarTitleText": ""
}
},
{

View File

@ -9,7 +9,7 @@
<view style="flex:1;">
<tpx-scan-input v-model:value="submitParam.billCode" @change="handleScanChange"></tpx-scan-input>
</view>
<view class="pl-10" v-if="queryOption.type == 'create' || queryOption.copyBillCode">
<view class="pl-10" v-if="queryOption.type == pageTypeEnum.create || queryOption.copyBillCode">
<u-button @click="handleCreateOrderNo()"
custom-style="font-size: 28rpx;padding:0 10rpx;height: 74rpx;" :plain="true" >系统生成</u-button>
</view>
@ -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()
}
}
}
}