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' }) uni.showToast({ title: val, icon: 'none' })
} }
const confirmModal = (title) => { const confirmModal = (title, opt = {}) => {
return new Promise((resolve)=> { return new Promise((resolve)=> {
uni.showModal({ content: title, confirmColor: '#B12D29' }).then((res)=> { uni.showModal({ content: title, confirmColor: '#B12D29', ...opt }).then((res)=> {
if(res.confirm) { 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 { export {
reLaunch, reLaunch,
goto, goto,
@ -270,4 +286,6 @@ export {
getImageInfo, getImageInfo,
uniPromiseApi, uniPromiseApi,
promiseTimeout, promiseTimeout,
setNavigationBarTitle,
reloadCurrentPage,
} }

View File

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

View File

@ -9,7 +9,7 @@
<view style="flex:1;"> <view style="flex:1;">
<tpx-scan-input v-model:value="submitParam.billCode" @change="handleScanChange"></tpx-scan-input> <tpx-scan-input v-model:value="submitParam.billCode" @change="handleScanChange"></tpx-scan-input>
</view> </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()" <u-button @click="handleCreateOrderNo()"
custom-style="font-size: 28rpx;padding:0 10rpx;height: 74rpx;" :plain="true" >系统生成</u-button> custom-style="font-size: 28rpx;padding:0 10rpx;height: 74rpx;" :plain="true" >系统生成</u-button>
</view> </view>
@ -291,6 +291,10 @@
import { debounce } from "@/common/util" import { debounce } from "@/common/util"
import * as apiService from "@/common/api" import * as apiService from "@/common/api"
import { getOrderModels } from "./model" import { getOrderModels } from "./model"
const pageTypeEnum = {
create: 'create',
edit: 'edit'
}
export default { export default {
components: { BpeAddressinfoTmp, BpeGoodstaticTmp, BpeCostTmp, BpeGooditemEditTmp, BpeGoodphotoTmp, BpeGoodKuaidiTmp, BpeGoodsizeTmp }, components: { BpeAddressinfoTmp, BpeGoodstaticTmp, BpeCostTmp, BpeGooditemEditTmp, BpeGoodphotoTmp, BpeGoodKuaidiTmp, BpeGoodsizeTmp },
@ -338,10 +342,16 @@
methods: { methods: {
getDefaultData() { // data的默认数据 getDefaultData() { // data的默认数据
return { return {
pageTypeEnum,
pageTypeMap: {
[pageTypeEnum.create]: { title: '开单', savedConfirmTitle: '是否操作下一单' },
[pageTypeEnum.edit]: { title: '运单修改', savedConfirmTitle: '是否操作下一单' }
},
curPageType: {},
pageLoading: true, pageLoading: true,
isEdit: false, isEdit: false,
queryOption: { queryOption: {
type: '', // edit 修改 type: '', // edit: 运单修改, create: 下单,
defaultSubParams: '', // 提交默认参数 defaultSubParams: '', // 提交默认参数
billCode: '', // 运单id billCode: '', // 运单id
orderSn: '', // 订单id orderSn: '', // 订单id
@ -378,6 +388,8 @@
getSalemanList: apiService.getSalemanList, getSalemanList: apiService.getSalemanList,
async initData() { // 初始化 async initData() { // 初始化
this.queryOption.billCode = this.queryOption.billCode || this.queryOption.copyBillCode 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) this.isEdit = Boolean(this.queryOption.billCode || this.queryOption.orderSn)
if(this.queryOption.defaultSubParams) { if(this.queryOption.defaultSubParams) {
try{ try{
@ -406,7 +418,7 @@
}, },
handleScanChange: debounce(function(val){ handleScanChange: debounce(function(val){
// 创建不做 查询详情 // 创建不做 查询详情
if(this.queryOption.type != 'create') { if(this.queryOption.type != pageTypeEnum.create) {
// 扫码回调 要重新查询新运单信息,并覆盖老的 // 扫码回调 要重新查询新运单信息,并覆盖老的
this.queryOption.billCode = val this.queryOption.billCode = val
this.initData(); this.initData();
@ -464,17 +476,29 @@
}, },
async handleSave(type) { async handleSave(type) {
let saveServerHand = apiService.submitOrder let saveServerHand = apiService.submitOrder
if(this.isEdit) { if(this.isEdit) { }
// 编辑订单 TODO
}
let params = JSON.parse(JSON.stringify(this.submitParam)); let params = JSON.parse(JSON.stringify(this.submitParam));
params.goodsPics = params.goodsPics.join(",") params.goodsPics = params.goodsPics.join(",")
await saveServerHand(params) await saveServerHand(params)
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.showToast('操作成功')
this.goBack() this.goBack()
} }
} }
} }
}
</script> </script>
<style lang="scss"> <style lang="scss">