diff --git a/components/orderCard.vue b/components/orderCard.vue index fe0fd42..d489bdb 100644 --- a/components/orderCard.vue +++ b/components/orderCard.vue @@ -162,25 +162,7 @@ export default { * 开始施工 */ doOrder(id){ - request({ - url: '/admin-api/repair/tickets/take', - method: 'get', - params:{id:id} - }).then((res) => { - console.log(res) - if (res.code == 200) { - uni.showToast({ - icon: 'none', - title: '接单成功,请尽快处理!' - }) - this.$emit('childEvent'); - }else{ - uni.showToast({ - icon: 'none', - title: res.message - }) - } - }) + this.$emit('startWork',id); }, gotoDetail() { uni.navigateTo({ diff --git a/pages-home/home/home.vue b/pages-home/home/home.vue index 7f037ab..9dfb1ab 100644 --- a/pages-home/home/home.vue +++ b/pages-home/home/home.vue @@ -34,7 +34,7 @@ - + @@ -52,7 +52,7 @@ import VNavigationBar from '@/components/VNavigationBar.vue' import OrderCard from "@/components/orderCard.vue"; import config from '@/config' import request from '@/utils/request'; -import {formatTimestamp,getOrderStatusText,builderOrder} from "@/utils/utils"; +import {formatTimestamp,getOrderStatusText,builderOrder,saveTicketsRecords} from "@/utils/utils"; import { getToken, getUserInfo, @@ -148,6 +148,52 @@ export default { this.orderList = [] this.getOrderList() }, + /** + * 开始施工 + */ + startWork(id){ + let paramsObj = {ticketId:id} + //先查当前用户在本工单下有几个维修项目 + request({ + url: '/admin-api/repair/titem/listProject', + method: 'get', + params:paramsObj + }).then((res) => { + console.log(res) + if (res.code == 200 && res.data.length>0) { + if(res.data.length==1){ + //只有1个,直接开始施工 + this.startWorkRequest(id,"02",res.data[0].id,"02","kssg","开始施工") + }else{ + uni.showActionSheet({ + itemList: res.data.map(m => m.itemName), + success: ({ + tapIndex + }) => { + this.startWorkRequest(id,"02",res.data[tapIndex].id,"02","kssg","开始施工") + } + }) + } + }else{ + uni.showToast({ + title: '操作失败,请联系管理员', + icon: 'none' + }) + } + }) + }, + /** + * 开始施工请求后台 + */ + async startWorkRequest(id,ticketsWorkStatus,itemId,itemStatus,recordType,remark){ + try { + const result = await saveTicketsRecords(id,ticketsWorkStatus,itemId,itemStatus,recordType,remark,null); + console.error("result",result); + this.onRefresherrefresh() + } catch (error) { + console.error(error); + } + }, /** * 查本人待处理工单 */ diff --git a/pages-order/orderList/orderList.vue b/pages-order/orderList/orderList.vue index 5498377..7a51df2 100644 --- a/pages-order/orderList/orderList.vue +++ b/pages-order/orderList/orderList.vue @@ -18,7 +18,7 @@ - + @@ -34,7 +34,7 @@ import VNavigationBar from '@/components/VNavigationBar.vue' import tabBarVue from '@/components/tabBar/tabBar.vue' import OrderCard from "@/components/orderCard.vue"; import request from '@/utils/request'; -import {formatTimestamp,getOrderStatusText,builderOrder} from "@/utils/utils"; +import {formatTimestamp,getOrderStatusText,builderOrder,saveTicketsRecords} from "@/utils/utils"; import { getToken, getUserInfo, @@ -116,6 +116,52 @@ export default { this.searchText = "" this.onRefresherrefresh() }, + /** + * 开始施工 + */ + startWork(id){ + let paramsObj = {ticketId:id} + //先查当前用户在本工单下有几个维修项目 + request({ + url: '/admin-api/repair/titem/listProject', + method: 'get', + params:paramsObj + }).then((res) => { + console.log(res) + if (res.code == 200 && res.data.length>0) { + if(res.data.length==1){ + //只有1个,直接开始施工 + this.startWorkRequest(id,"02",res.data[0].id,"02","kssg","开始施工") + }else{ + uni.showActionSheet({ + itemList: res.data.map(m => m.itemName), + success: ({ + tapIndex + }) => { + this.startWorkRequest(id,"02",res.data[tapIndex].id,"02","kssg","开始施工") + } + }) + } + }else{ + uni.showToast({ + title: '操作失败,请联系管理员', + icon: 'none' + }) + } + }) + }, + /** + * 开始施工请求后台 + */ + async startWorkRequest(id,ticketsWorkStatus,itemId,itemStatus,recordType,remark){ + try { + const result = await saveTicketsRecords(id,ticketsWorkStatus,itemId,itemStatus,recordType,remark,null); + console.error("result",result); + this.onRefresherrefresh() + } catch (error) { + console.error(error); + } + }, getOrderList(){ let paramsObj = {pageNo: this.pageNo, pageSize: this.pageSize, isFinish: "0"} console.log("this.searchText",this.searchText) diff --git a/utils/utils.js b/utils/utils.js index 5c8511c..dacf424 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -79,6 +79,48 @@ export function getDictByCode(dictCode){ return dictArray } } +/** + * 工单记录操作日志 + * @param id 工单主表id + * @param ticketsWorkStatus 工单主表状态 + * @param itemId 工单子表id + * @param itemStatus 工单子表状态 + * @param recordType 操作类型 对应后端枚举:RecordTypeEnum + * @param remark 备注 + * @param image 图片相对路径,多个英文逗号隔开 + */ +export function saveTicketsRecords(id,ticketsWorkStatus,itemId,itemStatus,recordType,remark,image){ + return new Promise((resolve, reject) => { + let dataObj = { + id: id, + ticketsWorkStatus:ticketsWorkStatus, + item: {id: itemId, itemStatus: itemStatus}, + recordType: recordType, + remark: remark, + image: image + } + request({ + url: '/admin-api/repair/tickets/updateStatus', + method: 'POST', + data:dataObj + }).then((res) => { + console.log(res) + if (res.code == 200) { + uni.showToast({ + title: '操作成功', + icon: 'none' + }) + resolve(1); + }else{ + uni.showToast({ + title: '操作失败,请联系管理员', + icon: 'none' + }) + reject(0); + } + }) + }); +} /** * 翻译字典