handler.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. <template>
  2. <view class="handler">
  3. <view class="head">
  4. <view class="tab" :class="{active: tab.value === dataInfo.tabActiveValue}" v-for="tab in dataInfo.tabs" :key="tab.id" @click="clickTab(tab.value)">
  5. {{tab.name}}<text v-if="tab.num !== ''">({{tab.num}})</text>
  6. </view>
  7. </view>
  8. <scroll-view scroll-y class="body" :class="{ page_padding: !(dataInfo.tabActiveValue === 'doing' && isInSummaryOrder), bg: (dataInfo.tabActiveValue === 'doing' && isInSummaryOrder) }">
  9. <!-- 汇总单 -->
  10. <template v-if="dataInfo.tabActiveValue === 'doing' && isInSummaryOrder">
  11. <!-- 耗材 -->
  12. <view class="summaryItem">
  13. <view class="summaryItem_head">
  14. 耗材清单
  15. </view>
  16. <view class="summaryItem_body" v-if="dataInfo.summaryObj.consumableList.length">
  17. <view class="summaryItem_bodyItem" v-for="item in dataInfo.summaryObj.consumableList" :key="item.id" @click="numberClick(item, 'editConsumable')">
  18. <view class="summaryItem_bodyItem_top">
  19. <text class="name ellipsis">{{ item.consumableName }}({{ item.consumableBrandModel }})</text>
  20. <text class="value">{{ item.consumableEndPrice }}元</text>
  21. </view>
  22. <view class="summaryItem_bodyItem_bottom">
  23. <text class="name">x{{ item.consumablesNum }}</text>
  24. <text class="value">总价{{item.consumablesNum * item.consumableEndPrice}}元</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="summaryItem_foot">
  29. <view class="summaryItem_foot_total">
  30. 耗材总价:{{dataInfo.summaryObj.consumablePrice}}元
  31. </view>
  32. <view class="summaryItem_foot_add" @click="addConsumable">
  33. <text class="newicon newicon-icon-test"></text>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 工时 -->
  38. <view class="summaryItem">
  39. <view class="summaryItem_head">
  40. 工时清单
  41. </view>
  42. <view class="summaryItem_body" v-if="dataInfo.summaryObj.workHourManagementList.length">
  43. <view class="summaryItem_bodyItem" v-for="item in dataInfo.summaryObj.workHourManagementList" :key="item.id" @click="numberClick(item, 'editWorkHourManagement')">
  44. <view class="summaryItem_bodyItem_top">
  45. <text class="name ellipsis">{{ item.workName }}</text>
  46. <text class="value">{{ item.wage }}元</text>
  47. </view>
  48. <view class="summaryItem_bodyItem_bottom">
  49. <text class="name">x{{ item.workHourNum2 }}{{ item.workUnit }}</text>
  50. <text class="value">总价{{item.workHourNum2 * item.wage}}元</text>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="summaryItem_foot">
  55. <view class="summaryItem_foot_total">
  56. 工时总价:{{dataInfo.summaryObj.workHourPrice}}元
  57. </view>
  58. <view class="summaryItem_foot_add" @click="addWorkHourManagement">
  59. <text class="newicon newicon-icon-test"></text>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 汇总单总价 -->
  64. <view class="summaryItem">
  65. <view class="summaryItem_foot total">
  66. <view class="summary_total">
  67. 汇总单总价:{{dataInfo.summaryObj.totalMaintenancePrice}}元
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <!-- 故障处理 -->
  73. <template v-if="dataInfo.tabActiveValue === 'doing' && !isInSummaryOrder">
  74. <view class="form_item column" v-if="dataInfo.category.hasSimple != 1">
  75. <view class="title"><text class="required newicon newicon-bitian"></text>解决方案:</view>
  76. <uni-easyinput class="value" type="textarea" v-model="dataInfo.handleDescription" placeholder="请输入解决方案" :class="{formRed: isSubmit && !dataInfo.handleDescription.trim()}" />
  77. </view>
  78. <view class="form_item" v-if="dataInfo.category.hasSimple != 1">
  79. <view class="title"><text class="required newicon newicon-bitian"></text>故障现象:</view>
  80. <view class="value category" @click="selectCategory">
  81. <text class="categoryName ellipsis-multiline">{{dataInfo.category.mutiCategory}}</text>
  82. <text class="newicon newicon-weibiaoti2010104"></text>
  83. </view>
  84. </view>
  85. <view class="form_item">
  86. <view class="title select"><text class="required newicon newicon-bitian"></text>处理方式:</view>
  87. <uni-data-select class="value" v-model="dataInfo.handleCategory" :localdata="dataInfo.handleCategoryList" :clear="false" placeholder="请选择处理方式" :class="{formRed: isSubmit && !dataInfo.handleCategory}"></uni-data-select>
  88. </view>
  89. <view class="form_item" v-if="dataInfo.category.hasSimple != 1">
  90. <view class="title select"><text class="required newicon newicon-bitian"></text>处理结果:</view>
  91. <uni-data-select class="value" v-model="dataInfo.closecode" :localdata="dataInfo.closecodeList" :clear="false" placeholder="请选择处理结果" :class="{formRed: isSubmit && !dataInfo.closecode}"></uni-data-select>
  92. </view>
  93. <view class="form_item">
  94. <view class="title"><text class="required newicon newicon-bitian transparent"></text>协同人员:</view>
  95. <text class="synergeticNames ellipsis">{{dataInfo.synergetic.map(v => v.name).join(',')}}</text>
  96. <button type="primary" plain size="mini" class="primaryPlainButton synergeticAdd" @click="synergeticAdd">+立即添加</button>
  97. </view>
  98. <view class="form_item_column">
  99. <view class="form_item">
  100. <view class="title"><text class="required newicon newicon-bitian transparent"></text>处理图片:</view>
  101. <view class="value">
  102. <uni-file-picker ref="handlerImgRef" v-model="dataInfo.handlerImgList" limit="3" @success="handlerImgSuccess" @fail="handlerImgFail" @select="handlerImgSelect" @delete="handlerImgDelete"></uni-file-picker>
  103. </view>
  104. </view>
  105. <view class="form_item">
  106. <view class="title transparent"><text class="required newicon newicon-bitian transparent"></text>处理图片:</view>
  107. <view class="value">
  108. <text class="imgTips ellipsis">(支持JPG/PNG格式图片,单张大小10M以内)</text>
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <!-- 延期处理 -->
  114. <template v-if="dataInfo.tabActiveValue === 'overtime'">
  115. <view class="form_item">
  116. <view class="title select"><text class="required newicon newicon-bitian"></text>延期原因:</view>
  117. <uni-data-select class="value" v-model="dataInfo.repairTypeId" :localdata="dataInfo.repairTypeList" :clear="false" placeholder="请选择延期原因" :class="{formRed: isSubmit && !dataInfo.repairTypeId}"></uni-data-select>
  118. </view>
  119. <view class="form_item column">
  120. <view class="title"><text class="required newicon newicon-bitian"></text>延期说明:</view>
  121. <uni-easyinput class="value" type="textarea" v-model="dataInfo.deferralRemark" placeholder="请输入延期说明" :class="{formRed: isSubmit && !dataInfo.deferralRemark.trim()}" />
  122. </view>
  123. <view class="form_item">
  124. <view class="title select"><text class="required newicon newicon-bitian"></text>延期天数:</view>
  125. <uni-data-select class="value" v-model="dataInfo.deferralDayId" :localdata="dataInfo.deferralDayList" :clear="false" placeholder="请选择延期天数" :class="{formRed: isSubmit && !dataInfo.deferralDayId}"></uni-data-select>
  126. </view>
  127. </template>
  128. </scroll-view>
  129. <view class="foot_common_btns">
  130. <button @click="goBackOrToList" type="default" class="cancelButton btn">{{dataInfo.isSummaryNext ? '上一步' : '返回'}}</button>
  131. <button @click="submit" type="default" class="primaryButton btn">{{dataInfo.tabActiveValue === 'doing' && isInSummaryOrder ? '下一步' : '提交'}}</button>
  132. </view>
  133. <NumberModal v-if="dataInfo.isNumber" @cancelEmit="cancelNumber" @confirmEmit="conformNumber" @removeEmit="removeNumber" :selectData="dataInfo.selectData" :selectType="dataInfo.selectType" :evtNumber="dataInfo.evtNumber" showRemove></NumberModal>
  134. </view>
  135. </template>
  136. <script setup>
  137. import { ref, reactive, computed } from 'vue'
  138. import NumberModal from '@/components/NumberModal.vue';
  139. import { onLoad } from '@dcloudio/uni-app'
  140. import { generateNumberArray } from '@/utils/index.js'
  141. import { api_group, api_incidentDetail, api_user, api_incidentTask, api_branch, api_dutyDepartment, api_getDictionary, api_querySummaryDoc, api_addSummaryDoc } from "@/http/api.js"
  142. import { defaultColor } from '@/static/js/theme.js'
  143. import { useSetTitle } from '@/share/useSetTitle.js'
  144. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  145. import { useUploadFile } from '@/share/useUploadFile.js'
  146. import { useGoBack } from '@/share/useGoBack.js'
  147. import { useLoginUserStore } from '@/stores/loginUser'
  148. import { useHandlerStore } from '@/stores/handler'
  149. useSetTitle();
  150. const loginUserStore = useLoginUserStore();
  151. const handlerStore = useHandlerStore();
  152. const { makePhoneCall } = useMakePhoneCall();
  153. const { uploadFile } = useUploadFile();
  154. const { goBack } = useGoBack();
  155. // 主题颜色
  156. const primaryColor = ref(defaultColor)
  157. // 数据
  158. const dataInfo = reactive({
  159. tabs: [
  160. // {id: 5, name: '故障处理', value: 'doing', num: ''},
  161. // {id: 6, name: '延期处理', value: 'overtime', num: ''},
  162. ],
  163. tabActiveValue: 0,//当前选择的tab
  164. incidentId: undefined,//事件ID
  165. incidentData: {},//事件对象
  166. repairTypeList: [], //延期原因列表
  167. repairTypeId: undefined, //延期原因ID
  168. deferralDayList: [], //延期天数列表
  169. deferralDayId: undefined, //延期天数ID
  170. deferralRemark: '',//延期说明
  171. summaryObj: {
  172. consumableList: [],//耗材列表
  173. workHourManagementList: [],//工时列表
  174. },//汇总单信息
  175. summaryId: undefined,//汇总单Id
  176. isNumber: false,//修改数量弹窗
  177. evtNumber: 1,//弹窗返回的数量
  178. selectData: {},//选择的对象
  179. selectType: {},//选择的对象类型
  180. handleDescription: '',//解决方案
  181. handleCategory: undefined,//处理方式
  182. handleCategoryList: [],//处理方式列表
  183. closecode: undefined,//处理结果
  184. closecodeList: [],//处理结果列表
  185. handlerImgList: [],//处理图片列表
  186. category: {},//故障现象
  187. synergetic: [],//协同人员
  188. isSummaryNext: false,//汇总单-下一步
  189. })
  190. // 是否提交
  191. const isSubmit = ref(false)
  192. // 处理图片
  193. const handlerImgRef = ref(null)
  194. // 是否进入汇总单
  195. const isInSummaryOrder = computed(() => {
  196. return dataInfo.tabActiveValue === 'doing' && dataInfo.incidentData.duty && dataInfo.incidentData.duty.addSummary == 1 && (dataInfo.incidentData.handlingPersonnelUser.id == loginUserStore.loginUser.user.id);
  197. })
  198. // 上一步或者返回列表
  199. function goBackOrToList(){
  200. if(dataInfo.isSummaryNext){
  201. goBack();
  202. }else{
  203. uni.reLaunch({
  204. url: '/pages/incidentList/incidentList'
  205. })
  206. }
  207. }
  208. // 上传处理图片成功
  209. function handlerImgSuccess(e){
  210. dataInfo.handlerImgList.forEach(v => {
  211. v.url = v.path;
  212. })
  213. console.log(dataInfo.handlerImgList);
  214. let handlerOrder$ = handlerOrder();
  215. let requestList = [handlerOrder$];
  216. dataInfo.handlerImgList.forEach(v => {
  217. let handlerOrderImg$ = handlerOrderImg(v);
  218. requestList.push(handlerOrderImg$);
  219. })
  220. Promise.all(requestList).then(resList => {
  221. uni.hideLoading();
  222. console.log(resList);
  223. if(resList[0].state == 200){
  224. uni.showToast({
  225. icon: 'none',
  226. title: '处理成功',
  227. mask: true,
  228. });
  229. setTimeout(() => {
  230. uni.reLaunch({
  231. url: '/pages/incidentList/incidentList',
  232. })
  233. }, 1500)
  234. }else{
  235. uni.showToast({
  236. icon: 'none',
  237. title: resList[0].msg || '请求数据失败!'
  238. });
  239. }
  240. })
  241. }
  242. // 上传处理图片失败
  243. function handlerImgFail(e){
  244. dataInfo.handlerImgList.forEach(v => {
  245. v.url = v.path;
  246. })
  247. console.log(dataInfo.handlerImgList);
  248. }
  249. // 选择上传图片
  250. function handlerImgSelect(e){
  251. dataInfo.handlerImgList = dataInfo.handlerImgList.concat(e.tempFiles);
  252. console.log(dataInfo.handlerImgList);
  253. }
  254. // 删除上传图片
  255. function handlerImgDelete(e){
  256. dataInfo.handlerImgList = dataInfo.handlerImgList.filter(v => e.tempFile.uuid != v.uuid);
  257. console.log(dataInfo.handlerImgList);
  258. }
  259. // 添加协同人员
  260. function synergeticAdd(){
  261. handlerStore.setHandlerData(dataInfo, 'handler');
  262. uni.navigateTo({
  263. url: `/pages/synergeticAdd/synergeticAdd?incidentId=${dataInfo.incidentId}`
  264. })
  265. }
  266. // 选择故障现象
  267. function selectCategory(){
  268. handlerStore.setHandlerData(dataInfo, 'handler');
  269. uni.navigateTo({
  270. url: `/pages/categoryOne/categoryOne?incidentId=${dataInfo.incidentId}`
  271. })
  272. }
  273. // 点击修改数量
  274. function numberClick(data, type){
  275. if(type === 'editConsumable'){
  276. dataInfo.evtNumber = data.consumablesNum;
  277. }else if(type === 'editWorkHourManagement'){
  278. dataInfo.evtNumber = data.workHourNum2;
  279. }
  280. dataInfo.isNumber = true;
  281. dataInfo.selectData = data;
  282. dataInfo.selectType = type;
  283. }
  284. // 确认修改数量
  285. function conformNumber(evtNumber){
  286. dataInfo.evtNumber = evtNumber;
  287. dataInfo.isNumber = false;
  288. addSummaryDoc();
  289. }
  290. // 移除数量
  291. function removeNumber(evtNumber){
  292. dataInfo.evtNumber = evtNumber;
  293. dataInfo.isNumber = false;
  294. removeSummaryDoc();
  295. }
  296. // 关闭修改数量
  297. function cancelNumber(){
  298. dataInfo.isNumber = false;
  299. }
  300. // 修改耗材/工时
  301. function addSummaryDoc(){
  302. uni.showLoading({
  303. title: "加载中",
  304. mask: true,
  305. });
  306. let postData = {
  307. "summaryId": dataInfo.summaryId,
  308. "modifyNum": 'edit',
  309. };
  310. if(dataInfo.selectType === 'editConsumable'){
  311. postData.consumableList = [
  312. {
  313. "consumablesId": dataInfo.selectData.consumableId,
  314. "consumablesNum": dataInfo.evtNumber,
  315. }
  316. ];
  317. }else if(dataInfo.selectType === 'editWorkHourManagement'){
  318. postData.workHourManagementList = [
  319. {
  320. "workHourId": dataInfo.selectData.id,
  321. "workHourNum": dataInfo.evtNumber,
  322. }
  323. ];
  324. }
  325. api_addSummaryDoc(postData).then(res => {
  326. uni.hideLoading();
  327. if(res.status == 200){
  328. uni.showToast({
  329. icon: 'none',
  330. title: '修改数量成功',
  331. mask: true,
  332. });
  333. getSummaryList();
  334. }else{
  335. uni.showToast({
  336. icon: 'none',
  337. title: res.msg || '请求数据失败!'
  338. });
  339. }
  340. })
  341. }
  342. // 移除耗材/工时
  343. function removeSummaryDoc(){
  344. uni.showLoading({
  345. title: "加载中",
  346. mask: true,
  347. });
  348. let postData = {
  349. "summaryId": dataInfo.summaryId,
  350. "remove": 'remove',
  351. };
  352. if(dataInfo.selectType === 'editConsumable'){
  353. postData.consumableList = [
  354. {
  355. "consumablesId": dataInfo.selectData.consumableId,
  356. "consumablesNum": dataInfo.evtNumber,
  357. }
  358. ];
  359. }else if(dataInfo.selectType === 'editWorkHourManagement'){
  360. postData.workHourManagementList = [
  361. {
  362. "workHourId": dataInfo.selectData.id,
  363. "workHourNum": dataInfo.evtNumber,
  364. }
  365. ];
  366. }
  367. api_addSummaryDoc(postData).then(res => {
  368. uni.hideLoading();
  369. if(res.status == 200){
  370. uni.showToast({
  371. icon: 'none',
  372. title: '移除成功',
  373. mask: true,
  374. });
  375. getSummaryList();
  376. }else{
  377. uni.showToast({
  378. icon: 'none',
  379. title: res.msg || '请求数据失败!'
  380. });
  381. }
  382. })
  383. }
  384. // 重置
  385. function reset(){
  386. dataInfo.repairTypeList = []; //延期原因列表
  387. dataInfo.repairTypeId = undefined; //延期原因ID
  388. dataInfo.deferralDayList = []; //延期天数列表
  389. dataInfo.deferralDayId = undefined; //延期天数ID
  390. dataInfo.deferralRemark = '';//延期说明
  391. dataInfo.summaryObj = {
  392. consumableList: [],//耗材列表
  393. workHourManagementList: [],//工时列表
  394. };//汇总单信息
  395. dataInfo.summaryId = undefined;//汇总单Id
  396. dataInfo.isNumber = false;//修改数量弹窗
  397. dataInfo.evtNumber = 1;//弹窗返回的数量
  398. dataInfo.selectData = {};//选择的对象
  399. dataInfo.selectType = {};//选择的对象类型
  400. dataInfo.handleDescription = '';//解决方案
  401. dataInfo.handleCategory = undefined;//处理方式
  402. dataInfo.handleCategoryList = [];//处理方式列表
  403. dataInfo.closecode = undefined;//处理结果
  404. dataInfo.closecodeList = [];//处理结果列表
  405. dataInfo.handlerImgList = [];//处理图片列表
  406. dataInfo.category = {};//故障现象
  407. dataInfo.synergetic = [];//协同人员
  408. }
  409. // 初始化表单
  410. function initForm(){
  411. if(dataInfo.tabActiveValue === 'doing' && isInSummaryOrder.value){
  412. getSummaryList();
  413. }else if(dataInfo.tabActiveValue === 'doing' && !isInSummaryOrder.value){
  414. getHandleCategorys();
  415. getClosecodes();
  416. }else if(dataInfo.tabActiveValue === 'overtime'){
  417. getRepairTypes();
  418. getDeferralDays();
  419. }
  420. }
  421. // 点击tab
  422. function clickTab(tabValue){
  423. if(dataInfo.tabActiveValue == tabValue){
  424. return;
  425. }
  426. dataInfo.tabActiveValue = tabValue;
  427. isSubmit.value = false;
  428. reset();
  429. dataInfo.category = dataInfo.incidentData.category || {};
  430. dataInfo.synergetic = dataInfo.incidentData.synergetic || [];
  431. initForm();
  432. }
  433. // 获取事件详情
  434. function getIncidentDetail(){
  435. uni.showLoading({
  436. title: "加载中",
  437. mask: true,
  438. });
  439. api_incidentDetail(dataInfo.incidentId).then(res => {
  440. uni.hideLoading();
  441. if(res.status == 200){
  442. dataInfo.incidentData = res.data || {};
  443. if(dataInfo.isSummaryNext){
  444. // 汇总单-下一步
  445. dataInfo.incidentData.duty.addSummary = 0;
  446. }
  447. // 跳转页面选择了选项并且工单ID一致
  448. if(handlerStore.handler.data && handlerStore.handler.data.incidentId == dataInfo.incidentId){
  449. Object.assign(dataInfo, handlerStore.handler.data);
  450. console.log(dataInfo)
  451. handlerStore.clearHandlerData();
  452. }else{
  453. handlerStore.clearHandlerData();
  454. // 初始化回显
  455. dataInfo.category = dataInfo.incidentData.category || {};
  456. dataInfo.synergetic = dataInfo.incidentData.synergetic || [];
  457. let chuli = false;//故障处理权限
  458. for (let i = 0; i < loginUserStore.loginUser.menu.length; i++) {
  459. if (loginUserStore.loginUser.menu[i].link == "shijianliebiao_chuli") {
  460. chuli = true
  461. }
  462. }
  463. // 故障处理
  464. if(dataInfo.incidentData.state.value == 'handler' && dataInfo.incidentData.handlingPersonnelUser && dataInfo.incidentData.handlingPersonnelUser.id == loginUserStore.loginUser.user.id && chuli){
  465. let flag = dataInfo.tabs.some(v => v.value === 'doing');
  466. !flag && dataInfo.tabs.splice(0, 0, {id: 5, name: '故障处理', value: 'doing', num: ''});
  467. }
  468. // 延期处理
  469. if(dataInfo.incidentData.state.value == 'handler' && dataInfo.incidentData.handlingPersonnelUser && dataInfo.incidentData.handlingPersonnelUser.id == loginUserStore.loginUser.user.id){
  470. let flag = dataInfo.tabs.some(v => v.value === 'overtime');
  471. !flag && dataInfo.tabs.push({id: 6, name: '延期处理', value: 'overtime', num: ''});
  472. }
  473. dataInfo.tabActiveValue = dataInfo.tabs[0].value;
  474. }
  475. initForm()
  476. }else{
  477. uni.showToast({
  478. icon: 'none',
  479. title: res.msg || '请求数据失败!'
  480. });
  481. }
  482. })
  483. }
  484. // 获取延期原因列表
  485. function getRepairTypes(){
  486. uni.showLoading({
  487. title: "加载中",
  488. mask: true,
  489. });
  490. let postData = {
  491. "key": 'repair_type',
  492. "type": "list",
  493. };
  494. api_getDictionary(postData).then(res => {
  495. uni.hideLoading();
  496. res = res || [];
  497. dataInfo.repairTypeList = res.map(v => ({
  498. text: v.name,
  499. value: v.id,
  500. }));
  501. })
  502. }
  503. // 获取处理方式列表
  504. function getHandleCategorys(){
  505. uni.showLoading({
  506. title: "加载中",
  507. mask: true,
  508. });
  509. let postData = {
  510. "key": 'incident_handleCategory',
  511. "type": "list",
  512. };
  513. api_getDictionary(postData).then(res => {
  514. uni.hideLoading();
  515. res = res || [];
  516. dataInfo.handleCategoryList = res.map(v => ({
  517. text: v.name,
  518. value: v.id,
  519. key: v.value,
  520. }));
  521. if(!dataInfo.handleCategory){
  522. let handleCategory = dataInfo.handleCategoryList.find(v => v.key == 'SUPPORT');
  523. dataInfo.handleCategory = handleCategory ? handleCategory.value : undefined;
  524. }
  525. })
  526. }
  527. // 获取处理结果列表
  528. function getClosecodes(){
  529. uni.showLoading({
  530. title: "加载中",
  531. mask: true,
  532. });
  533. let postData = {
  534. "key": 'incident_closecode',
  535. "type": "list",
  536. };
  537. api_getDictionary(postData).then(res => {
  538. uni.hideLoading();
  539. res = res || [];
  540. dataInfo.closecodeList = res.map(v => ({
  541. text: v.name,
  542. value: v.id,
  543. key: v.value,
  544. }));
  545. if(!dataInfo.closecode){
  546. let closecode = dataInfo.closecodeList.find(v => v.key == '060');
  547. dataInfo.closecode = closecode ? closecode.value : undefined;
  548. }
  549. })
  550. }
  551. // 获取延期天数列表
  552. function getDeferralDays(){
  553. dataInfo.deferralDayList = generateNumberArray(1, 15).map(v => ({
  554. text: v + '天',
  555. value: v,
  556. }));
  557. }
  558. // 获取汇总单信息
  559. function getSummaryList(){
  560. uni.showLoading({
  561. title: "加载中",
  562. mask: true,
  563. });
  564. let postData = {
  565. "incidentId": dataInfo.incidentId,
  566. };
  567. api_querySummaryDoc(postData).then(res => {
  568. uni.hideLoading();
  569. if(res.status == 200){
  570. dataInfo.summaryObj = {...{consumableList:[], workHourManagementList: []}, ...res };
  571. console.log(dataInfo.summaryObj)
  572. dataInfo.summaryId = res.summaryId;
  573. }else if(res.status == 201){
  574. // 事件第一次绑定汇总单
  575. dataInfo.summaryId = res.summaryId;
  576. }else{
  577. uni.showToast({
  578. icon: 'none',
  579. title: res.msg || '请求数据失败!'
  580. });
  581. }
  582. })
  583. }
  584. // 添加耗材
  585. function addConsumable(){
  586. uni.navigateTo({
  587. url: `/pages/consumableList/consumableList?incidentId=${dataInfo.incidentId}&summaryId=${dataInfo.summaryId}`
  588. })
  589. }
  590. // 添加工时
  591. function addWorkHourManagement(){
  592. uni.navigateTo({
  593. url: `/pages/workHourManagementOne/workHourManagementOne?incidentId=${dataInfo.incidentId}&summaryId=${dataInfo.summaryId}`
  594. })
  595. }
  596. // 提交
  597. function submit(){
  598. isSubmit.value = true;
  599. if(dataInfo.tabActiveValue === 'doing' && isInSummaryOrder.value){
  600. uni.navigateTo({
  601. url: `/pages/handler/handler?incidentId=${dataInfo.incidentId}&isSummaryNext=1`,
  602. });
  603. }else if(dataInfo.tabActiveValue === 'doing' && !isInSummaryOrder.value){
  604. submitHandler();
  605. }else if(dataInfo.tabActiveValue === 'overtime'){
  606. submitOvertime();
  607. }
  608. }
  609. // 处理提交事件
  610. function handlerOrder(){
  611. let postData = {
  612. incident: dataInfo.incidentData,
  613. }
  614. postData.incident.handleDescription = dataInfo.handleDescription;
  615. postData.incident.handleCategory = {id: dataInfo.handleCategory};
  616. postData.incident.closecode = {id: dataInfo.closecode};
  617. postData.incident.category = dataInfo.category;
  618. postData.incident.synergetic = dataInfo.synergetic;
  619. return api_incidentTask(dataInfo.tabActiveValue, postData);
  620. }
  621. // 处理图片
  622. function handlerOrderImg(imgObj){
  623. return uploadFile(imgObj, 'incident', dataInfo.incidentId)
  624. }
  625. // 处理提交
  626. function submitHandler(){
  627. console.log(dataInfo);
  628. if(!dataInfo.handleDescription.trim() && dataInfo.category.hasSimple != 1){
  629. uni.showToast({
  630. icon: 'none',
  631. title: '请填写解决方案'
  632. });
  633. return;
  634. }
  635. if(!dataInfo.category.id && dataInfo.category.hasSimple != 1){
  636. uni.showToast({
  637. icon: 'none',
  638. title: '请选择故障现象'
  639. });
  640. return;
  641. }
  642. if(!dataInfo.handleCategory){
  643. uni.showToast({
  644. icon: 'none',
  645. title: '请选择处理方式'
  646. });
  647. return;
  648. }
  649. if(!dataInfo.closecode && dataInfo.category.hasSimple != 1){
  650. uni.showToast({
  651. icon: 'none',
  652. title: '请选择处理结果'
  653. });
  654. return;
  655. }
  656. console.log(dataInfo.handlerImgList)
  657. uni.showLoading({
  658. title: "加载中",
  659. mask: true,
  660. });
  661. if(dataInfo.handlerImgList.length){
  662. // 有图片
  663. handlerImgRef.value.upload();
  664. }else{
  665. // 没有图片
  666. let handlerOrder$ = handlerOrder();
  667. let requestList = [handlerOrder$];
  668. Promise.all(requestList).then(resList => {
  669. uni.hideLoading();
  670. console.log(resList);
  671. if(resList[0].state == 200){
  672. uni.showToast({
  673. icon: 'none',
  674. title: '处理成功',
  675. mask: true,
  676. });
  677. setTimeout(() => {
  678. uni.reLaunch({
  679. url: '/pages/incidentList/incidentList',
  680. })
  681. }, 1500)
  682. }else{
  683. uni.showToast({
  684. icon: 'none',
  685. title: resList[0].msg || '请求数据失败!'
  686. });
  687. }
  688. })
  689. }
  690. }
  691. // 延期处理提交
  692. function submitOvertime(){
  693. if(!dataInfo.repairTypeId){
  694. uni.showToast({
  695. icon: 'none',
  696. title: '请选择延期原因'
  697. });
  698. return;
  699. }
  700. if(!dataInfo.deferralRemark.trim()){
  701. uni.showToast({
  702. icon: 'none',
  703. title: '请填写延期说明'
  704. });
  705. return;
  706. }
  707. if(!dataInfo.deferralDayId){
  708. uni.showToast({
  709. icon: 'none',
  710. title: '请选择延期天数'
  711. });
  712. return;
  713. }
  714. uni.showLoading({
  715. title: "加载中",
  716. mask: true,
  717. });
  718. let postData = {
  719. incident: dataInfo.incidentData,
  720. }
  721. postData.incident.currentLog = {
  722. remark: dataInfo.deferralRemark,
  723. extra1: dataInfo.repairTypeId,
  724. extra2: dataInfo.deferralDayId,
  725. }
  726. api_incidentTask(dataInfo.tabActiveValue, postData).then(res => {
  727. uni.hideLoading();
  728. if(res.state == 200){
  729. uni.showToast({
  730. icon: 'none',
  731. title: '延期处理成功',
  732. mask: true,
  733. });
  734. setTimeout(() => {
  735. uni.reLaunch({
  736. url: '/pages/incidentList/incidentList',
  737. })
  738. }, 1500)
  739. }else{
  740. uni.showToast({
  741. icon: 'none',
  742. title: res.msg || '请求数据失败!'
  743. });
  744. }
  745. })
  746. }
  747. onLoad((option) => {
  748. dataInfo.incidentId = option.incidentId;
  749. dataInfo.isSummaryNext = option.isSummaryNext == 1;
  750. getIncidentDetail();
  751. })
  752. </script>
  753. <style lang="scss" scoped>
  754. .handler{
  755. height: 100%;
  756. display: flex;
  757. flex-direction: column;
  758. justify-content: space-between;
  759. .head{
  760. height: 88rpx;
  761. display: flex;
  762. position: fixed;
  763. z-index: 99;
  764. width: 100%;
  765. background-color: #fff;
  766. font-size: 30rpx;
  767. .tab{
  768. flex: 1;
  769. display: flex;
  770. justify-content: center;
  771. align-items: center;
  772. border-bottom: 4rpx solid transparent;
  773. &.active{
  774. color: $uni-primary;
  775. border-color: $uni-primary;
  776. }
  777. }
  778. }
  779. .body{
  780. margin-top: 88rpx;
  781. box-sizing: border-box;
  782. flex: 1;
  783. min-height: 0;
  784. &.bg{
  785. background-color: #F7F7F7;
  786. }
  787. .summaryItem{
  788. &:first-of-type{
  789. .summaryItem_head{
  790. border-bottom: 1rpx solid #DDDDDD;
  791. }
  792. }
  793. .summary_total{
  794. padding: 20rpx 0;
  795. display: flex;
  796. justify-content: center;
  797. align-items: center;
  798. }
  799. .summaryItem_head{
  800. padding: 24rpx;
  801. font-size: 26rpx;
  802. color: #3A3A3A;
  803. }
  804. .summaryItem_body{
  805. font-size: 30rpx;
  806. background-color: #fff;
  807. .summaryItem_bodyItem{
  808. padding: 24rpx;
  809. border-bottom: 1rpx solid #DDDDDD;
  810. .summaryItem_bodyItem_top{
  811. display: flex;
  812. justify-content: space-between;
  813. align-items: center;
  814. .value{
  815. padding-left: 48rpx;
  816. flex-shrink: 0;
  817. }
  818. }
  819. .summaryItem_bodyItem_bottom{
  820. margin-top: 24rpx;
  821. display: flex;
  822. justify-content: space-between;
  823. align-items: center;
  824. .name{
  825. text-align: right;
  826. flex: 1;
  827. }
  828. .value{
  829. width: 240rpx;
  830. text-align: right;
  831. padding-left: 48rpx;
  832. flex-shrink: 0;
  833. }
  834. }
  835. }
  836. }
  837. .summaryItem_foot{
  838. font-size: 30rpx;
  839. background-color: #fff;
  840. &.total{
  841. margin-top: 24rpx;
  842. }
  843. .summaryItem_foot_total{
  844. padding: 24rpx 0;
  845. display: flex;
  846. justify-content: center;
  847. align-items: center;
  848. }
  849. .summaryItem_foot_add{
  850. border-top: 1rpx solid #DDDDDD;
  851. padding: 24rpx 0;
  852. display: flex;
  853. justify-content: center;
  854. align-items: center;
  855. .newicon-icon-test{
  856. font-size: 30rpx;
  857. font-weight: bold;
  858. }
  859. }
  860. }
  861. }
  862. .form_item_column{
  863. padding-top: 24rpx;
  864. min-height: 86rpx;
  865. .form_item{
  866. padding-top: 0;
  867. min-height: auto;
  868. }
  869. }
  870. .form_item{
  871. display: flex;
  872. align-items: center;
  873. padding-top: 24rpx;
  874. min-height: 86rpx;
  875. &.column{
  876. height: auto;
  877. flex-direction: column;
  878. align-items: flex-start;
  879. .title{
  880. margin-right: 0;
  881. }
  882. .value{
  883. margin-top: 10rpx;
  884. padding-left: 20rpx;
  885. box-sizing: border-box;
  886. }
  887. .tips{
  888. padding: 24rpx;
  889. text-align: center;
  890. font-size: 22rpx;
  891. color: #909399;
  892. width: 100%;
  893. box-sizing: border-box;
  894. }
  895. }
  896. .title{
  897. font-size: 26rpx;
  898. display: flex;
  899. align-items: center;
  900. margin-right: 12rpx;
  901. flex-shrink: 0;
  902. &.select{
  903. width: calc(5em + 20rpx);
  904. }
  905. }
  906. .value{
  907. width: 100%;
  908. &.category{
  909. width: 100%;
  910. display: flex;
  911. justify-content: space-between;
  912. align-items: center;
  913. .categoryName{
  914. font-size: 26rpx;
  915. color: #555;
  916. flex: 1;
  917. }
  918. .newicon-weibiaoti2010104{
  919. color: $uni-primary;
  920. margin-left: 24rpx;
  921. }
  922. }
  923. .imgTips{
  924. color: #909399;
  925. font-size: 22rpx;
  926. }
  927. }
  928. .synergeticNames{
  929. font-size: 26rpx;
  930. margin-right: 24rpx;
  931. }
  932. .synergeticAdd{
  933. flex-shrink: 0;
  934. }
  935. }
  936. }
  937. }
  938. </style>