diff --git a/aircraft/server/index/index.vue b/aircraft/server/index/index.vue index e7cbbc3..353b475 100644 --- a/aircraft/server/index/index.vue +++ b/aircraft/server/index/index.vue @@ -32,6 +32,7 @@ boxShadow: '0rpx 0rpx 12rpx rgba(202,202,182,0.5)', filter: 'opacity(0.96)'}"> + @@ -42,15 +43,19 @@ import Route from '@/aircraft/server/route/route.vue'; import My from '@/aircraft/server/my/my.vue'; import configService from '@/common/config.service.js'; import Topnav from '@/components/topnav/index.vue'; +import Movable from '../order/components/movable.vue'; export default { components: { - Order, Equipment, Route, My, Topnav + Order, Equipment, Route, My, Topnav, Movable }, data() { return { current: uni.getStorageSync('current')||0,// 当前页码下标 loading: false, fileUrl: configService.fileUrl + 'aerocraft/navigation/',//导航栏图标基础路径 + ordFileUrl: configService.fileUrl + 'aerocraft/order/',//订单页图标基础路径 + // 新增图标 + addIcon: 'add.png', // a端导航栏按钮 aNavicationList:[ { diff --git a/aircraft/server/order/add.vue b/aircraft/server/order/add.vue index 21d7a42..1cf56bf 100644 --- a/aircraft/server/order/add.vue +++ b/aircraft/server/order/add.vue @@ -3,6 +3,9 @@ + + + - + - - + 保存 - 完成订单 @@ -186,6 +191,8 @@ export default { showScenOrCus: false, // 当前景区/客户选择类型 scenOrCusType: '', + // 订单状态 + orderStatus: ['进行中','已完成','已取消'], } }, onReady() { @@ -198,6 +205,18 @@ export default { const arr = isScen ? this.scenics : this.customers; const index = this.form[isScen?'attractionId':'customerId']; return index?[arr.findIndex(item=>item.id === index)]:[0]; + }, + // 判断是否可以删除 + canDelete(){ + const { orderId, orderInitiatorId, confirmStatus, orderTaskDetailList } = this.form; + return orderId&&this.isPilot&&orderInitiatorId==this.userMessage.id + &&(!confirmStatus||confirmStatus===0)&&(!orderTaskDetailList||orderTaskDetailList.some( + item=>!this.orderStatus.includes(item.orderItemStatus))); + }, + // 判断是否禁用保存 + isDisable(){ + const { orderTaskDetailList } = this.form; + return orderTaskDetailList&&orderTaskDetailList.length>0; } }, onLoad(e) { @@ -234,27 +253,65 @@ export default { async getOrderDetail(){ let res = await this.$api.orderDetail(this.form.orderId); if(res){ - const { id, customerName, phone, scenicName, surchargeAmount, cargoWeight, orderNo, orderCreateTime, orderInitiator } = res; + const { id, customerName, phone, scenicName, surchargeAmount, cargoWeight, + orderNo, orderCreateTime, orderInitiator, confirmStatus, orderInitiatorId, + customerId, attractionId, routeIds, operatorIds, orderTaskDetailList } = res; this.form = { orderId: id, orderNo: orderNo, orderType: 1, orderTypeName: '载物订单', customerName: customerName, - customerId: '',// + customerId: customerId,// phone: phone, attractionName: scenicName, - attractionId: '',// + attractionId: attractionId,// surchargeAmount: surchargeAmount, cargoWeight: cargoWeight, operatorIds: [], routeIds: [], orderInitiator: orderInitiator, orderCreateTime: orderCreateTime, + confirmStatus: confirmStatus, + orderInitiatorId: orderInitiatorId, + orderTaskDetailList: orderTaskDetailList, + } + 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)); + } else { + this.$refs.uToast.show({type: 'error',title: "景区路线获取失败!"}); } } else this.$refs.uToast.show({type: 'error',title: "订单详情获取失败!"}); }, + // 删除订单 + handleDelete(){ + let that = this; + uni.showModal({ + title: '提示', + content: '是否确认删除该订单?', + confirmColor: '#FE020E', + success: async(res) => { + if (res.confirm) { + try { + let res = await that.$api.deleteOrder(that.form.orderId); + if(res === undefined){ + that.$refs.uToast.show({type: 'error',title: "订单详删除失败!"}); + return; + } + uni.navigateBack({complete() { + that.$u.toast('订单删除成功!'); + }}) + } catch (error) { + that.$refs.uToast.show({type: 'error',title: "订单详删除失败!"}); + } + } + } + }) + }, // 选择路线 changeRoute(e){ }, @@ -294,14 +351,13 @@ export default { routeIds:that.form.routeIds.map(item=>item.key), orderCreateTime:that.$u.timeFormat(new Date().getTime(),'yyyy-mm-dd hh:MM:ss')} console.log('验证通过',that.form); - let res = await that.$api.addOrder(data); + let res = that.form.orderId ? await that.$api.editOrder(data) : await that.$api.addOrder(data); that.saveLoading = false; uni.navigateBack({complete() { - uni.showToast({ - icon: 'none', - title: '订单新增成功!' - }) + that.$u.toast(`订单${that.form.orderId?'编辑':'新增'}成功!`); }}) + }else{ + that.saveLoading = false; } }); }catch(e){ @@ -312,15 +368,23 @@ export default { // 完成订单 async finishOrder(){ let that = this; + if(!this.form.orderTaskDetailList || this.form.orderTaskDetailList.length === 0){ + this.$refs.uToast.show({type: 'warning',title: "该订单不存在飞行任务,无法完成!"}); + return; + } uni.showModal({ title: '订单完成', content: '是否确认完成该订单?', confirmColor: '#f7c04d', success: async(res) => { if (res.confirm) { - let res = await that.$api.completeOrder(that.form.orderId); - that.$refs.uToast.show({type: res?'success':'error', - title: `订单完成操作${res?'成功':'失败'}!`}); + try { + let res = await that.$api.completeOrder(that.form.orderId); + that.$refs.uToast.show({type: 'success', title: `订单完成操作成功!`}); + that.init(); + } catch (error) { + that.$refs.uToast.show({type: 'error', title: `订单完成操作失败!`}); + } } } }) @@ -334,6 +398,15 @@ export default { display: flex; flex-direction: column; min-height: 100vh; + position: relative; + .order-delete{ + position: absolute; + right: 50rpx; + z-index: 1; + &:active{ + opacity: 0.7; + } + } .order-form{ padding: 30rpx 32rpx 52rpx; display: flex; diff --git a/aircraft/server/order/detail.vue b/aircraft/server/order/detail.vue index d552370..da79a8f 100644 --- a/aircraft/server/order/detail.vue +++ b/aircraft/server/order/detail.vue @@ -109,7 +109,7 @@ 新增任务 - + @@ -120,14 +120,19 @@ 执行设备 + custom-style="font-size:32rpx;" placeholder="请选择设备" type="select" + v-model="form.deviceName" @click="handleClickPick('设备')" :clearable="false"/> + + + 执行路线 + 载货重量 KG @@ -189,13 +194,22 @@ - + + + + + + + + @@ -212,8 +226,14 @@ export default { computed:{ // 获取选择器默认值 getDefaultSelector(){ - const index = this.form.equipmentId; - return index?[this.equipments.findIndex(item=>item.id === index)]:[0]; + const isDevice = this.pickType === '设备'; + const index = isDevice ? this.form.deviceId : this.form.routeId; + const arr = isDevice ? this.equipments : this.routes; + return index?[arr.findIndex(item=>item.key === index)]:[0]; + }, + // 获取状态选择器默认值 + getDefaultStateSelector(){ + return [this.stateList.findIndex(item=>item.key === this.stateForm.taskStatus)]||[0]; } }, data(){ @@ -251,6 +271,12 @@ export default { borderRadius: '10rpx', border: '2rpx solid #999999' }, + // 状态表单 + stateForm: { + orderTaskId: '', + taskStatus: 0, + taskStatusName: '未进行' + }, // 上传文件 fileList: [], //我的页图标基础路径 @@ -281,19 +307,38 @@ export default { showAddAction: false, // 执行设备列表 equipments:[], - // 显示设备选择器 - showEquipment: false, + // 显示选择器 + showPick: false, + // 选择器类型 + pickType: '', + // 显示状态更改弹窗 + showChangeState: false, + showChangeStatePick: false, // 任务form form:{ - equipmentName: '', - equipmentId: '', - weight: '', - photo: '' + orderId: '', + deviceName: '', + deviceId: '', + cargoWeight: '', + attachmentMaterialList: [], + routeId: '', + routeName: '' }, + // 新增任务加载 + dotLoading: false, + // 路线列表 + routes: [], // 订单详情 orderDetail: {}, // 当前页 current: 0, + // 状态列表 + stateList: [ + { key: 0, value: '未进行' }, + { key: 1, value: '进行中' }, + { key: 2, value: '已完成' }, + { key: 3, value: '已取消' }, + ], } }, onPageScroll(e) { @@ -303,6 +348,7 @@ export default { this.scrollTop = e.scrollTop; }, onLoad(e) { + this.form.orderId = e.id; this.init(e.id); }, methods:{ @@ -312,40 +358,167 @@ export default { let res = await this.$api.orderDetail(id); if(res) this.orderDetail = res; else this.$refs.uToast.show({type: 'error',title: "订单详情获取失败!"}); + let resp = await this.$api.allRoutesByScenicId(res.attractionId); + if(resp){ + this.routes = resp || []; + } else { + this.$refs.uToast.show({type: 'error',title: "景区路线获取失败!"}); + } + let respx = await this.$api.obtainDeviceList({attractionId: res.attractionId}); + if(respx){ + this.equipments = respx || []; + } else { + this.$refs.uToast.show({type: 'error',title: "景区设备获取失败!"}); + } + }, + // 关闭弹窗 + closeAddAction(){ + this.clearForm(); + this.showAddAction = false; + }, + // 获取订单详情 + async getOrderDetail(id){ + let res = await this.$api.orderDetail(id); + if(res) this.orderDetail = res; + else this.$refs.uToast.show({type: 'error',title: "订单详情获取失败!"}); }, // 设备选择 - handleClickPick(){ - this.showEquipment = true; + handleClickPick(type){ + this.pickType = type; + this.showPick = true; }, // 上传图片 - uploadFile({fileFullPath}){ - this.form.photo = fileFullPath; + uploadFile(file){ + this.form.attachmentMaterialList = [file]; }, // 删除图片 removeFile(index){ - this.form.photo = ""; + this.form.attachmentMaterialList = []; }, // 选择器值改变 handleChangePick(index){ - const val = this.equipments[index[0]]; - this.form.equipmentId = val?.id || ''; - this.form.equipmentName = val?.name || ''; + const valueForm = this.pickType==='设备' ? + { list: this.equipments, id: 'deviceId', name: 'deviceName' } : + { list: this.routes, id: 'routeId', name: 'routeName' } + const val = valueForm.list[index[0]]; + this.form[valueForm.id] = val?.key || ''; + this.form[valueForm.name] = val?.value || ''; + }, + // 选择飞行任务状态 + handleClickState(index){ + const val = this.stateList[index[0]]; + this.stateForm.taskStatus = val.key; + this.stateForm.taskStatusName = val.value; }, // 保存任务 - handleSave(){ - if(this.current === 2){ - this.showAddAction = false; - this.current = 0; + async handleSave(){ + if(this.current!==0){ + this.showAddAction = this.current !== 2; + this.current = (this.current+1)%3; + return; } - this.current += 1; + const data = this.form; + console.log(data); + let warningMessage = ''; + if(!data.deviceId){ + warningMessage = '请选择执行设备!'; + }else if(!data.routeId){ + warningMessage = '请选择执行路线!'; + }else if(!data.cargoWeight||!/^-?\d*\.?\d+$/.test(data.cargoWeight)){ + warningMessage = '载货重量格式错误!'; + }else if(data.attachmentMaterialList.length===0){ + warningMessage = '请上传货物图片!'; + }else{ + try { + this.dotLoading = true; + let res = await this.$api.addOrderTask(data); + if(res === undefined){ + this.$refs.uToast.show({type: 'error',title: '飞行任务新增失败(新增订单飞行任务: 同一个订单同一个飞行员,只能存在一个任务状态处于[未进行或进行中])!'}); + return; + } + await this.clearForm(); + await this.getOrderDetail(this.form.orderId); + this.dotLoading = false; + this.current += 1; + this.$refs.uToast.show({type: 'success',title: `飞行任务新增成功!`}); + } catch (error) { + this.dotLoading = false; + this.$refs.uToast.show({type: 'error',title: '飞行任务新增失败!'}); + } + return; + } + this.$refs.uToast.show({type: 'warning',title: warningMessage}); + }, + // 修改任务状态 + async handleChangeState(){ + try { + const { orderTaskId, taskStatus } = this.stateForm; + let res = await this.$api.editOrderStatus(orderTaskId, taskStatus); + this.showChangeState = false; + if(res === undefined){ + this.$refs.uToast.show({type: 'error',title: '飞行任务状态更改失败!'}); + return; + } + this.$refs.uToast.show({type: 'success',title: `飞行任务状态更改成功!`}); + await this.getOrderDetail(this.form.orderId); + this.stateForm = { + orderTaskId: '', + taskStatus: 0, + taskStatusName: '未进行' + }; + } catch (error) { + this.showChangeState = false; + this.$refs.uToast.show({type: 'error',title: '飞行任务状态更改失败!'}); + } + }, + // 清空表单 + clearForm(){ + this.current = 0; + this.fileList = []; + this.form = { + orderId: this.form.orderId, + deviceName: '', + deviceId: '', + cargoWeight: '', + attachmentMaterialList: [], + routeId: '', + routeName: '' + }; }, // 删除任务 handleDeleteAction(item){ - + let that = this; + uni.showModal({ + title: '提示', + content: '是否确认删除该飞行任务?', + confirmColor: '#FE020E', + success: async(res) => { + if (res.confirm) { + try { + let res = await that.$api.deleteOrderTask(item.id); + console.log(res); + if(res === undefined){ + 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: "飞行任务删除失败!"}); + } + } + } + }) }, // 更改任务状态 - handleChangeAction(item){ - + handleChangeAction({id, orderItemStatus}){ + this.stateForm = { + orderTaskId: id, + taskStatusName: orderItemStatus, + taskStatus: this.stateList.find(item=>item.value===orderItemStatus).key + }; + this.showChangeState = true; } } } @@ -638,4 +811,23 @@ export default { } } } +::v-deep .u-default-hover{ + border-color: #F8B500 !important; + background-color: #fdf6ec !important; + color: #f29100 !important; + &:active{ + border-color: #F8B500 !important; + background-color: #fdf6ec !important; + color: #f29100 !important; + } + &:focus{ + border-color: #F8B500 !important; + background-color: #fdf6ec !important; + color: #f29100 !important; + } +} +.slot-content{ + padding: 10rpx 50rpx; + border-radius: 6rpx; +} \ No newline at end of file diff --git a/aircraft/server/order/order.vue b/aircraft/server/order/order.vue index 9a72904..9d1b1e6 100644 --- a/aircraft/server/order/order.vue +++ b/aircraft/server/order/order.vue @@ -37,28 +37,23 @@ margin-top="250"> -