handler.vue 33 KB

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