diff --git a/aircraft/server/index/index.vue b/aircraft/server/index/index.vue index 353b475..1f45369 100644 --- a/aircraft/server/index/index.vue +++ b/aircraft/server/index/index.vue @@ -7,10 +7,10 @@ :refresher-enabled="(isPilot&¤t!==3)||(!isPilot&¤t!==1)" :refresher-triggered="triggered" @refresherpulling="onPulling" lower-threshold="60"> - + - + - + diff --git a/aircraft/server/my/my.vue b/aircraft/server/my/my.vue index e0b438a..0960377 100644 --- a/aircraft/server/my/my.vue +++ b/aircraft/server/my/my.vue @@ -4,7 +4,7 @@ + :src="ordFileUrl+(isPilot||!customer.gender?pilotIcon:(customer.gender === '男' ? boyIcon : girlIcon))" /> {{ userMessage.nickName || userMessage.username || '用户' }} 欢迎来到爱尚云,愿您有个美好体验! @@ -36,9 +36,9 @@ export default { }, // #endif props: { - topLevel:{ - type: Number, - default: 0 + isPilot: { + type: Boolean, + default: true }, isLogin: { type: String, @@ -49,11 +49,20 @@ export default { return{ //我的页图标基础路径 fileUrl: configService.fileUrl + 'aerocraft/my/', + ordFileUrl: configService.fileUrl + 'aerocraft/order/',//订单页图标基础路径 // 轮播图 topBg: 'top-bg-a.png', + // 女生头像 + girlIcon: 'girl.png', + // 男生头像 + boyIcon: 'boy.png', + // 飞行员默认头像 + pilotIcon: 'pilot-avatar.png', // 用户信息 // userMessage:{} userMessage: this.$store.state.vuex_token === ''?{}:JSON.parse(this.$store.state.user_message), + // 客户信息 + customer: {}, // 功能列表 functions: [{ name: '历史订单', @@ -68,18 +77,17 @@ export default { icon: 'password.png', url: '/aircraft/server/my/child_pages/reset-password' }], - isPilot: this.$store.state.user_type == 1, } }, computed:{ }, methods:{ // 初始化 - init(){ - if(this.isLogin !== ''){ - this.userMessage = JSON.parse(this.$store.state.user_message); - }else{ - this.userMessage = {}; + async init(){ + this.userMessage = this.isLogin === '' ? {} : JSON.parse(this.$store.state.user_message); + if(this.userMessage.id){ + let res = await this.$api.bSelfDetail(this.userMessage.id); + this.customer = res === undefined ? {} : res; } }, // 功能栏点击 diff --git a/aircraft/server/order/add.vue b/aircraft/server/order/add.vue index 1cf56bf..d7a606c 100644 --- a/aircraft/server/order/add.vue +++ b/aircraft/server/order/add.vue @@ -56,17 +56,18 @@ - + - + 保存 完成订单 + v-if="canFinish" :custom-style="customStyle" :hair-line="false" @click="finishOrder"> + 完成订单 + @@ -139,8 +140,9 @@ export default { trigger: ['change','blur'], }], surchargeAmount: [{ - required: true, - type: 'float', + validator: (rule, value, callback) => { + return value&&/^-?\d*\.?\d+$/.test(value);; + }, message: '附加费格式不正确', trigger: ['change','blur'] }], @@ -192,7 +194,7 @@ export default { // 当前景区/客户选择类型 scenOrCusType: '', // 订单状态 - orderStatus: ['进行中','已完成','已取消'], + orderStatus: ['进行中','已完成','已取消','待确认'], } }, onReady() { @@ -206,15 +208,32 @@ export default { const index = this.form[isScen?'attractionId':'customerId']; return index?[arr.findIndex(item=>item.id === index)]:[0]; }, + // 判断是否可以完成订单 + canFinish(){ + /* + 1.编辑 + 2.订单状态不处于已完成、已取消、未进行、飞行员-待确认 + 3.飞行员-订单发起人||客户-确认人 + 4.不存在飞行任务为未进行或进行中的状态 + */ + const { orderId, mainOrderStatus, orderTaskDetailList, orderInitiatorId, customerId } = this.form; + return orderId&&(!mainOrderStatus||mainOrderStatus!=='未进行')&& + (this.isPilot&&orderInitiatorId==this.userMessage.id&&mainOrderStatus!=='待确认'|| + !this.isPilot&&customerId==userMessage.id)&&(!orderTaskDetailList|| + orderTaskDetailList.some(item=>item.orderItemStatus!=='未进行'||item.orderItemStatus!=='进行中')); + }, // 判断是否可以删除 canDelete(){ - const { orderId, orderInitiatorId, confirmStatus, orderTaskDetailList } = this.form; + const { orderId, orderInitiatorId, mainOrderStatus, orderTaskDetailList } = this.form; return orderId&&this.isPilot&&orderInitiatorId==this.userMessage.id - &&(!confirmStatus||confirmStatus===0)&&(!orderTaskDetailList||orderTaskDetailList.some( - item=>!this.orderStatus.includes(item.orderItemStatus))); + &&(!mainOrderStatus||mainOrderStatus==='未进行')&&(!orderTaskDetailList||orderTaskDetailList.length===0); }, // 判断是否禁用保存 isDisable(){ + /* + 1.订单状态不处于已完成、已取消 + 2.存在飞行任务为进行中、已完成、已取消、待确认状态 + */ const { orderTaskDetailList } = this.form; return orderTaskDetailList&&orderTaskDetailList.length>0; } @@ -248,13 +267,21 @@ export default { } // 获取订单详情 if(this.form.orderId) this.getOrderDetail(); + else { + const userId = this.userMessage.id; + const op = this.operators.find(item=>item.id===userId); + if(op){ + this.form.operatorIds.push(op); + this.operators = this.operators.filter(item=>item.id!==userId); + } + } }, // 获取订单详情 async getOrderDetail(){ let res = await this.$api.orderDetail(this.form.orderId); if(res){ const { id, customerName, phone, scenicName, surchargeAmount, cargoWeight, - orderNo, orderCreateTime, orderInitiator, confirmStatus, orderInitiatorId, + orderNo, orderCreateTime, orderInitiator, orderInitiatorId, mainOrderStatus, customerId, attractionId, routeIds, operatorIds, orderTaskDetailList } = res; this.form = { orderId: id, @@ -272,15 +299,16 @@ export default { routeIds: [], orderInitiator: orderInitiator, orderCreateTime: orderCreateTime, - confirmStatus: confirmStatus, orderInitiatorId: orderInitiatorId, orderTaskDetailList: orderTaskDetailList, + mainOrderStatus: mainOrderStatus } let resp = await this.$api.allRoutesByScenicId(attractionId); if(resp){ this.routes = resp || []; this.form.routeIds = resp.filter(item=> routeIds.includes(item.key)); this.form.operatorIds = this.operators.filter(item=> operatorIds.includes(item.id)); + this.operators = this.operators.filter(item=>item.id!==orderInitiatorId); } else { this.$refs.uToast.show({type: 'error',title: "景区路线获取失败!"}); } @@ -330,6 +358,7 @@ export default { let res = await this.$api.allRoutesByScenicId(val.id); if(res){ this.routes = res || []; + this.form.routeIds = res.length>0?[res[0]]:[]; }else{ this.$refs.uToast.show({type: 'error',title: "景区路线获取失败!"}); } @@ -380,6 +409,10 @@ export default { if (res.confirm) { try { let res = await that.$api.completeOrder(that.form.orderId); + if(res === undefined){ + that.$refs.uToast.show({type: 'error',title: "订单完成操作失败!"}); + return; + } that.$refs.uToast.show({type: 'success', title: `订单完成操作成功!`}); that.init(); } catch (error) { diff --git a/aircraft/server/order/detail.vue b/aircraft/server/order/detail.vue index da79a8f..8dd2418 100644 --- a/aircraft/server/order/detail.vue +++ b/aircraft/server/order/detail.vue @@ -7,7 +7,8 @@ {{ orderDetail.mainOrderStatus }} - {{ orderDetail.mainOrderStatus === '已完成' ? '已完成飞行任务' : '请尽快执行任务'}} + {{ orderDetail.mainOrderStatus === '已完成' ? '已完成飞行任务' : + orderDetail.mainOrderStatus === '待确认'?'请尽快确认完成订单':'请尽快执行任务'}} @@ -47,17 +48,21 @@ :src="fileUrl+textBg" /> + + 订单号 + {{ orderDetail.orderNo }} + 发起人 {{ orderDetail.orderInitiator }} - + 客户名称 {{ orderDetail.customerName }} 手机号 - {{ orderDetail.phone }} + {{ isPilot?orderDetail.phone:orderDetail.initiatorPhone }} 操作员 @@ -67,6 +72,10 @@ 下单时间 {{ orderDetail.orderCreateTime }} + + 订单确认人 + {{ orderDetail.customerName }} + @@ -88,7 +97,7 @@ {{ item.orderItemStatus }} - + 删除 - - + + 新增任务 + + 完成订单 + @@ -139,7 +152,7 @@ 货物图片 - @@ -339,6 +352,7 @@ export default { { key: 2, value: '已完成' }, { key: 3, value: '已取消' }, ], + isPilot: this.$store.state.user_type == 1, } }, onPageScroll(e) { @@ -376,6 +390,10 @@ export default { this.clearForm(); this.showAddAction = false; }, + // 打开新增任务弹窗 + addAction(){ + this.showAddAction = true; + }, // 获取订单详情 async getOrderDetail(id){ let res = await this.$api.orderDetail(id); @@ -433,7 +451,8 @@ export default { this.dotLoading = true; let res = await this.$api.addOrderTask(data); if(res === undefined){ - this.$refs.uToast.show({type: 'error',title: '飞行任务新增失败(新增订单飞行任务: 同一个订单同一个飞行员,只能存在一个任务状态处于[未进行或进行中])!'}); + this.dotLoading = false; + this.$refs.uToast.show({type: 'error',title: '当前无法新增飞行任务!'}); return; } await this.clearForm(); @@ -443,7 +462,7 @@ export default { this.$refs.uToast.show({type: 'success',title: `飞行任务新增成功!`}); } catch (error) { this.dotLoading = false; - this.$refs.uToast.show({type: 'error',title: '飞行任务新增失败!'}); + this.$refs.uToast.show({type: 'error',title: '当前无法新增飞行任务!'}); } return; } @@ -456,7 +475,7 @@ export default { let res = await this.$api.editOrderStatus(orderTaskId, taskStatus); this.showChangeState = false; if(res === undefined){ - this.$refs.uToast.show({type: 'error',title: '飞行任务状态更改失败!'}); + this.$refs.uToast.show({type: 'error',title: '无法更改该飞行任务状态!'}); return; } this.$refs.uToast.show({type: 'success',title: `飞行任务状态更改成功!`}); @@ -468,13 +487,14 @@ export default { }; } catch (error) { this.showChangeState = false; - this.$refs.uToast.show({type: 'error',title: '飞行任务状态更改失败!'}); + this.$refs.uToast.show({type: 'error',title: '无法更改该飞行任务状态!'}); } }, // 清空表单 clearForm(){ this.current = 0; this.fileList = []; + this.$refs['uploadRef'].lists = []; this.form = { orderId: this.form.orderId, deviceName: '', @@ -498,14 +518,14 @@ export default { let res = await that.$api.deleteOrderTask(item.id); console.log(res); if(res === undefined){ - that.$refs.uToast.show({type: 'error',title: "您没有权限删除此订单任务!"}); + that.$refs.uToast.show({type: 'error',title: "飞行任务无法删除!"}); return; } that.getOrderDetail(this.form.orderId); that.clearForm(); that.$refs.uToast.show({type: 'success',title: "飞行任务删除成功!"}); } catch (error) { - that.$refs.uToast.show({type: 'error',title: "飞行任务删除失败!"}); + that.$refs.uToast.show({type: 'error',title: "飞行任务无法删除!"}); } } } @@ -519,7 +539,31 @@ export default { taskStatus: this.stateList.find(item=>item.value===orderItemStatus).key }; this.showChangeState = true; - } + }, + // 完成订单 + async finishOrder(){ + let that = this; + uni.showModal({ + title: '订单完成', + content: '是否确认完成该订单?', + confirmColor: '#f7c04d', + success: async(res) => { + if (res.confirm) { + try { + let res = await that.$api.completeOrder(that.orderDetail.id); + if(res === undefined){ + that.$refs.uToast.show({type: 'error',title: "订单完成操作失败!"}); + return; + } + that.getOrderDetail(that.form.orderId); + that.$refs.uToast.show({type: 'success', title: `订单完成操作成功!`}); + } catch (error) { + that.$refs.uToast.show({type: 'error', title: `订单完成操作失败!`}); + } + } + } + }) + }, } } diff --git a/aircraft/server/order/order.vue b/aircraft/server/order/order.vue index 9d1b1e6..5fedb6d 100644 --- a/aircraft/server/order/order.vue +++ b/aircraft/server/order/order.vue @@ -18,7 +18,7 @@ + :src="fileUrl+(!isPilot?pilotIcon:(customers[item.customerId].gender === '男' ? boyIcon : girlIcon))" /> {{ customers[item.customerId].name }} {{ item.customerPhone }} @@ -26,7 +26,7 @@ 执行任务 + :hair-line="false" @click.stop="handleDoAction(item)">{{isPilot?'执行任务':'查看详情'}} @@ -49,6 +49,12 @@ export default { styleIsolation: 'shared' }, // #endif + props: { + isPilot:{ + type: Boolean, + default: true + }, + }, data(){ return { fileUrl: configService.fileUrl + 'aerocraft/order/',//订单页图标基础路径 @@ -58,12 +64,15 @@ export default { girlIcon: 'girl.png', // 男生头像 boyIcon: 'boy.png', + // 飞行员默认头像 + pilotIcon: 'pilot-avatar.png', // 订单状态 orderStatus: { 0:'未进行', 1:'进行中', 2:'已完成', - 3:'已取消' + 3:'已取消', + 4:'待确认', }, // 订单类型 orderTypes: { @@ -92,7 +101,7 @@ export default { size: 10, // 是否结束——loadmore加载更多,loading加载中,nomore无更多 isFinish: 'nomore', - mainOrderStatusList: '0,1,3', + mainOrderStatusList: '0,1', }, // 用户列表 customers: {}, @@ -103,11 +112,11 @@ export default { methods:{ // 初始化 async init(){ - this.form = {size: 10,current: 1,isFinish: 'nomore',mainOrderStatusList: '0,1,3'}; + this.form = {size: 10,current: 1,isFinish: 'nomore',mainOrderStatusList: this.isPilot?'0,1':'0,1,4'}; // 查询订单列表 await this.getOrderList(); // 查询全部客户 - let cusRes = await this.$api.allCustomers(); + let cusRes = this.isPilot ? await this.$api.allCustomers() : await this.$api.allEmployees(); if(!cusRes){ this.$refs.uToast.show({type: 'error',title: "客户获取失败!"}); }else this.customers = await cusRes.reduce((obj, item) => ({...obj,[item.id]: item}), {})||{}; @@ -145,6 +154,7 @@ export default { }, // 查看详情 showDetail(item){ + if(this.isPilot) uni.navigateTo({ url: `/aircraft/server/order/add?id=${item.id}` }) diff --git a/common/http.api.js b/common/http.api.js index ebb0ee9..52bc942 100644 --- a/common/http.api.js +++ b/common/http.api.js @@ -11,6 +11,7 @@ const install = (Vue, vm) => { vm.$api.aUpdatePass = async (params = {}) => await vm.$u.post(`/api/emEmployees/updatePass`,params);// 修改飞行员密码 vm.$api.bUpdatePass = async (params = {}) => await vm.$u.post(`/cnCustomer/updatePass`,params);// 修改客户密码 vm.$api.allEmployees = async (params = {}) => await vm.$u.get('/api/emEmployees/all',params);// 条件查询全部飞行员 + vm.$api.bSelfDetail = async (id) => await vm.$u.get(`/cnCustomer/${id}`);// 查询客户信息 // 区域/景区管理 vm.$api.allAreas = async () => await vm.$u.get('/emArea/all');// 获取全部区域