handler.vue 36 KB

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