emis-sapp/pages/post/post.vue
2024-12-21 00:41:15 +08:00

483 lines
18 KiB
Vue

<template>
<tpx-page>
<tpx-layout v-if="!pageLoading">
<template v-slot:body>
<view class="com-jianju pos-rlt pb-30" style="padding-top: 2rpx;">
<!-- <view class="blcok" style="background-color: #0E0708;">
<u-row>
<image class="mr-20" style="height: 28rpx;width: 34rpx;"
:src="getCdnUrl(`post/gangbo.png`)"></image>
<u-text size="24" color="#fff" text="下单后会有业务员及时联系您,请保持电话畅通!"></u-text>
</u-row>
</view> -->
<view class="blcok-white">
<bpe-bindedpost-tmp v-model:value="submitParam"></bpe-bindedpost-tmp>
</view>
<view class="blcok-white">
<!-- 地址选择 -->
<bpe-addressinfo-tmp v-model:value="submitParam" @onChange="handleAddressChange"></bpe-addressinfo-tmp>
</view>
<view class="com-section mt-30">路线信息</view>
<view class="blcok-white">
<view v-if="submitParam.reciever.country && submitParam.sender.country">
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.transLine" v-model:text="submitParam.transLineTypeName" v-model:resObject="wayRes"
:getListFun="getTransLineList" :transKeyVal="{valKey: 'lineCode',titleKey: 'lineName'}"
:searchParam="waySearchParam" @onChange="handleWayChange" placeholder="请选择路线"
>
<tpx-text-item :required="true" label="路线" :value="submitParam.transLineTypeName"></tpx-text-item>
</tpx-select>
</view>
</view>
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.pickupMethod" :list="dicData.emis_qujian_fangshi"
mode="drop"
>
<tpx-text-item :required="true" label="取件方式" :value="submitParam.pickupMethod" :list="dicData.emis_qujian_fangshi"></tpx-text-item>
</tpx-select>
</view>
<view>
<view v-if="submitParam.pickupMethod == 1">
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.salesmen" v-model:text="submitParam.salesmen" v-model:resObject="salemanRes" :getListFun="getSalemanList" :transKeyVal="{valKey: 'empName',titleKey: 'empName'}"
placeholder="请选择销售联系人"
>
<tpx-text-item :required="true" label="销售联系人">
<template v-slot:right>
{{submitParam.salesmen || '请选择'}}
<u-icon size="26" name="arrow-right" color="#333"></u-icon>
</template>
</tpx-text-item>
</tpx-select>
</view>
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.intoWarehouseCode" v-model:text="submitParam.intoWarehouseName" v-model:resObject="wareRes"
:getListFun="getLisWarehouse" :transKeyVal="{valKey: 'code',titleKey: 'name'}"
:searchParam="wareSearchParam" placeholder="请选择仓库" @onChange="handleWareHouseChange"
>
<tpx-text-item label="仓库" :value="submitParam.intoWarehouseName"></tpx-text-item>
</tpx-select>
<view v-if="submitParam.intoWarehouseCode">
<u-row justify="between" custom-style="margin-top:5rpx;">
<view>
<text class="clr-sub pr-10">联系人</text>
<text>{{submitParam.intoWarehouseContact || '-'}}</text>
</view>
<view>
<text class="clr-sub pr-10">电话</text>
<text>{{submitParam.intoWarehousePhone || '-'}}</text>
</view>
</u-row>
<u-row custom-style="margin-top:5rpx;" align="top">
<view class="clr-sub pr-10" style="width: 80rpx;">地址</view>
<view style="flex: 1;" class="text-singe-line">{{submitParam.intoWarehouseAddress || '-'}}</view>
</u-row>
</view>
</view>
</view>
<view v-if="submitParam.pickupMethod == 1" class="yunf-input-item pos-rlt">
<u-row justify="between">
<view class="font-weight">预计入仓时间</view>
<u-row custom-style="flex: 1;" justify="end" align="center">
<view v-if="submitParam.pickStartDate">{{submitParam.pickStartDate}}</view>
<view v-else>请选择</view>
<u-icon size="26" name="arrow-right" color="#333"></u-icon>
</u-row>
</u-row>
<view class="pos-abt-all" style="z-index: 1;">
<tpx-date-input v-model:value="submitParam.pickStartDate" mode="datetime" :minDate="rucangMinDate" :maxDate="rucangMaxDate" customStyle="opacity:0;"></tpx-date-input>
</view>
</view>
<view @click="handleDialogClick(revtimeModal)" v-if="submitParam.pickupMethod == 2" class="yunf-input-item">
<u-row justify="between">
<view class="font-weight">期望上门时间</view>
<u-row custom-style="flex: 1;" justify="end" align="center">
<view v-if="submitParam.pickStartDate">{{submitParam.pickStartDate}}</view>
<view v-else>请选择</view>
<u-icon size="26" name="arrow-right" color="#333"></u-icon>
</u-row>
</u-row>
</view>
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.paymentType" :list="dicData.emis_payment_type"
mode="drop"
>
<tpx-text-item :required="true" label="付款方式" :value="submitParam.paymentType" :list="dicData.emis_payment_type"></tpx-text-item>
</tpx-select>
</view>
<template v-if="isShowYueJie">
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.custNo" v-model:text="submitParam.custName" v-model:resObject="yuejieRes" :getListFun="getMonthpayAccountList" :transKeyVal="{valKey: 'custNo',titleKey: 'custName'}"
@onChange="handleYueJieSelect" placeholder="请选择月结账户" ref="yjSltRef"
>
<tpx-text-item :required="true" label="月结账户" :value="submitParam.custName"></tpx-text-item>
<template #listTop>
<view class="mb-20" @click="handleToMonthCardManage">
<u-row>
<u-icon name="order" color="#B12D29" size="36"></u-icon>
<view class="pl-10 clr-prm font-28">管理月结卡</view>
</u-row>
</view>
</template>
</tpx-select>
</view>
<template v-if="submitParam.custNo">
<view class="yunf-input-item">
<tpx-text-item label="月结编号">
<template v-slot:right>{{submitParam.custNo}}</template>
</tpx-text-item>
</view>
</template>
</template>
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.customsEclaration" :list="dicData.emis_declare_mode"
mode="drop"
>
<tpx-text-item :required="true" label="报关方式" :value="submitParam.customsEclaration" :list="dicData.emis_declare_mode"></tpx-text-item>
</tpx-select>
</view>
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.customsClear" :list="dicData.emis_customs_clear"
mode="drop" @onChange="handleCstClrChange"
>
<tpx-text-item :required="true" label="清关方式" :value="submitParam.customsClear" :list="dicData.emis_customs_clear"></tpx-text-item>
</tpx-select>
</view>
<view v-if="submitParam.customsClear!=2" class="yunf-input-item">
<tpx-select v-model:value="submitParam.dispatchMethod" :list="dicData.emis_tab_dispatch_mode"
mode="drop"
>
<tpx-text-item label="派送方式" :value="submitParam.dispatchMethod" :list="dicData.emis_tab_dispatch_mode"></tpx-text-item>
</tpx-select>
</view>
</view>
</view>
<view class="com-section mt-30 pos-rlt">
<u-row justify="space-between">
<span class="pl-20">
<text class="lbRequiredDot">货物信息</text>
</span>
</u-row>
</view>
<view class="blcok-white" @click="handleDialogClick(goodChooseModal)">
<u-row custom-style="padding-bottom: 10rpx;" >
<u-row>
<u-icon name="edit-pen" size="42"></u-icon>
<span class="font-28 pl-10 clr-prm">编辑</span>
</u-row>
</u-row>
<bpe-goodstatic-tmp v-model:value="submitParam"></bpe-goodstatic-tmp>
</view>
<view class="com-section mt-30">
<span class="pl-20">
<text class="lbRequiredDot">产品类型</text>
</span>
</view>
<view class="blcok-white yunf-list" style="padding-bottom: 2rpx;">
<bpe-choosetypelist-tmp ref="caleRef" v-model:value="submitParam" :calType="2"></bpe-choosetypelist-tmp>
</view>
<view class="com-section mt-30">给快递员捎话</view>
<view class="blcok-white">
<bpe-remark-tmp v-model:value="submitParam"></bpe-remark-tmp>
</view>
</view>
</template>
<template v-slot:footer>
<view class="pos-rlt blcok-white" style="border-radius: 0;margin-top: 0;">
<u-row justify="between">
<view>
<bpe-checkagree-tmp v-model:value="submitParam"></bpe-checkagree-tmp>
</view>
<u-row>
<u-button @click="handleSave" size="large" shape="circle"
custom-style="width: 200rpx;height:80rpx;font-size: 30rpx;" type="primary">{{curPageType.saveBtnTitle || '提交'}}</u-button>
</u-row>
</u-row>
</view>
</template>
</tpx-layout>
<buns-revtime-sheet v-model:show="revtimeModal.show" v-model:value="submitParam"></buns-revtime-sheet>
<buns-edit-sheet percentHeight="70" title="货物信息" v-model:show="goodChooseModal.show" v-model:value="submitParam" v-slot="tempObject" @onSure="handleGoodInfoSure">
<!-- 保证弹框内容重新渲染 -->
<view v-if="goodChooseModal.show">
<view class="">
<bpe-gooditem-edit-tmp :value="tempObject.value"></bpe-gooditem-edit-tmp>
</view>
<view class="mt-30">
<bpe-goodphoto-tmp :value="tempObject.value" filedName="goodsPics">
<template v-slot:title>
<text class="font-weight font-28">货物照片</text>
</template>
</bpe-goodphoto-tmp>
</view>
</view>
</buns-edit-sheet>
</tpx-page>
</template>
<script>
import BpeAddressinfoTmp from "@/components/buns-post-edit-templates/bpe-addressinfo-tmp"
import BpeGoodstaticTmp from "@/components/buns-post-edit-templates/bpe-goodstatic-tmp"
import BpeGooditemEditTmp from "@/components/buns-post-edit-templates/bpe-gooditem-edit-tmp"
import BpeGoodphotoTmp from "@/components/buns-post-edit-templates/bpe-goodphoto-tmp"
import BpeBindedpostTmp from "@/components/buns-post-edit-templates/bpe-bindedpost-tmp"
import BpeChoosetypelistTmp from "@/components/buns-post-edit-templates/bpe-choosetypelist-tmp"
import BpeRemarkTmp from "@/components/buns-post-edit-templates/bpe-remark-tmp"
import BpeCheckagreeTmp from "@/components/buns-post-edit-templates/bpe-checkagree-tmp"
import dayjs from "dayjs"
import { debounce } from "@/common/util"
import { triggerSubscribeMessage } from "@/common/componentEventHandle"
import * as apiService from "@/common/api"
import { getOrderModels, initDefaultModel, setBindTsm, getBindTsm, checkSubmitParams } from "./model"
const pageTypeEnum = {
create: 'create',
edit: 'edit'
}
export default {
components: { BpeAddressinfoTmp, BpeGoodstaticTmp, BpeGooditemEditTmp, BpeGoodphotoTmp, BpeBindedpostTmp, BpeChoosetypelistTmp, BpeRemarkTmp, BpeCheckagreeTmp },
props: {
// hasLeftWin: {
// type: Boolean
// }
},
computed: {
waySearchParam() {
return { country: this.submitParam.reciever.country, fromCountry: this.submitParam.sender.country }
},
wareSearchParam(){
return { params: { transLine: this.submitParam.transLine } }
},
dicData() {
return this.$store.getters.dicData
},
isShowYueJie(){
let { submitParam } = this
return submitParam.paymentType == 2 || submitParam.paymentType == 4 || submitParam.paymentType == 5
},
},
data() {
return this.getDefaultData()
},
onShareAppMessage() {
return {
}
},
onLoad(option = {}) {
this.queryOption = option
this.initData();
},
onUnload() {
},
methods: {
getTransLineList: apiService.getTransLineList,
getLisWarehouse: apiService.getLisWarehouse,
getMonthpayAccountList: apiService.getMonthpayAccountList,
getSalemanList: apiService.getSalemanList,
getDefaultData() { // data的默认数据
return {
rucangMinDate: dayjs().add(0, 'day').format(`YYYY-MM-DD`),
rucangMaxDate: dayjs().add(30, 'day').format(`YYYY-MM-DD`),
pageTypeEnum,
pageTypeMap: {
[pageTypeEnum.create]: { title: '下单寄件', savedConfirmTitle: '是否操作下一单', saveBtnTitle: '下单' },
[pageTypeEnum.edit]: { title: '运单修改', savedConfirmTitle: '是否操作下一单', saveBtnTitle: '保存' }
},
curPageType: {},
pageLoading: true,
isEdit: false,
queryOption: {
type: '', // edit 修改
defaultSubParams: '', // 提交默认参数
billCode: '', // 运单id
orderSn: '', // 订单id
copyBillCode: '', // 复制的运单id
},
wayRes: { list: [] },
yuejieRes: { list: [] },
wareRes: { list: [] },
salemanRes: { list: [] },
revtimeModal: {
show: false,
},
goodChooseModal: {
show: false,
},
submitParam: {
...getOrderModels(),
}
}
},
async initData() { // 初始化
// 初始化默认model
await initDefaultModel(this.submitParam)
this.queryOption.billCode = this.queryOption.billCode || this.queryOption.copyBillCode
this.curPageType = this.pageTypeMap[this.queryOption.type] || this.pageTypeMap[pageTypeEnum.create]
this.setNavigationBarTitle(this.curPageType.title)
this.isEdit = Boolean(this.queryOption.billCode || this.queryOption.orderSn)
if(this.queryOption.defaultSubParams) {
try{
this.queryOption.defaultSubParams = JSON.parse(decodeURIComponent(this.queryOption.defaultSubParams))
Object.assign(this.submitParam, this.queryOption.defaultSubParams)
}catch(e){
console.error("queryOption.defaultSubParams=====转换失败===", this.queryOption.defaultSubParams)
}
}
if(this.isEdit) {
let res = await apiService.getOrderDetail({...this.queryOption, _loading: true})
let data = res.data || {}
data.goodsPics = (data.goodsPics && data.goodsPics.split(",")) || []
data._agreePrivacy = true
// 更新绑定业务员字段
await getBindTsm(data)
this.submitParam = res.data
// 复制场景 清除billCode orderSn
if(this.queryOption.copyBillCode) {
delete this.submitParam.billCode
delete this.submitParam.orderSn
this.submitParam.sendDate = getOrderModels().sendDate
}
}
this.pageLoading = false
setTimeout(async ()=> {
if(this.$refs.caleRef.checkeCalParams()) {
// 重新计算费用
await this.$refs.caleRef.calcTypeFee()
}
}, 1000)
},
handleAddressChange() { // 地址切换
let { wayRes, submitParam } = this.getDefaultData()
if(this.submitParam.reciever.country && this.submitParam.sender.country) {
this.submitParam.transLine = submitParam.transLine
this.submitParam.transLineTypeName = submitParam.transLineTypeName
this.handleWayChange() // 调用线路切换,清空后续数据
}
},
handleWayChange(val) { // 线路切换
let { productRes, submitParam } = this.getDefaultData()
// 清空产品类型数据
this.submitParam.productType = submitParam.productType
this.submitParam.productTypeName = submitParam.productTypeName
const item = this.wayRes.list.filter(t=> t.val == val)[0]
this.updateDltDestSite({ lineCode: val })
this.updateDltSendSite({ lineCode: val })
if(item?.transType == 1) {
this.submitParam.customsEclaration = 1
this.submitParam.customsClear = 1
} else {
this.submitParam.customsEclaration = 2
this.submitParam.customsClear = 3
}
},
async updateDltDestSite({ lineCode }) {
const { country, province, city, county, address } = this.submitParam.reciever
let res = await apiService.getCaculteDestSite({ lineCode, country, province, city, county, address })
// 更新路线推荐的默认目的地
let data = res.data || {}
this.submitParam.destinationCode = data.destCode
this.submitParam.destinationName = data.destName
this.submitParam.dispatchUnderlingSiteCode = data.siteCode;
this.submitParam.dispatchUnderlingSiteName = data.siteName;
},
async updateDltSendSite({ lineCode }) {
const { country, province, city, county, address } = this.submitParam.sender
let sendRes = await apiService.getCaculteSendSite({ lineCode, country, province, city, county, address })
let data = sendRes.data || {}
this.submitParam.sendSiteCode = data.siteCode
this.submitParam.sendSiteName = data.siteName
},
async handleWareHouseChange(val){
const item = this.wareRes.list.filter(t=> t.val == val)[0]
this.submitParam.intoWarehouseAddress = item.address
this.submitParam.intoWarehouseContact = item.contact
this.submitParam.intoWarehousePhone = item.tel
},
handleCstClrChange(val){
if(val == 2){
this.submitParam.dispatchMethod = 2
}
},
handleToMonthCardManage(){
this.$refs.yjSltRef.show = false
this.goto(`user/monthCardList`)
},
handleDialogClick(curModal){
curModal.show = true
},
async handleSave(type) {
triggerSubscribeMessage() // 唤起消息订阅
let saveServerHand = apiService.submitOrder
if(this.isEdit) { }
let params = JSON.parse(JSON.stringify(this.submitParam));
let { bl, errMsg } = checkSubmitParams(params)
if(errMsg[0]) {
return this.showToast(errMsg[0])
}
params.goodsPics = params.goodsPics.join(",")
params.totalVolume = params.totalVolume || 0
setBindTsm(params)
params._loading = true
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({_finalUrl: 'tabBar/search/search'})
}
} else {
this.showToast('操作成功')
this.goBack()
}
}
}
}
</script>
<style lang="scss">
@import '@/common/uni-nvue.scss';
page {
background-color: #F6F6F6;
height: 100% !important;
}
</style>
<style scoped lang="scss">
.yunf-input-item{
padding: 26rpx 0;
border-bottom: 2rpx solid #F6F6F6;
}
</style>