handler.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  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="HandleData.simpleness != 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="HandleData.simpleness != 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="HandleData.simpleness != 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, getFetchDataList, 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 SummaryData = ref(false)
  244. // 是否简单处理
  245. const HandleData = reactive({
  246. simpleness:null
  247. })
  248. // 处理图片
  249. const handlerImgRef = ref(null)
  250. // 是否进入汇总单
  251. const isInSummaryOrder = computed(() => {
  252. return dataInfo.tabActiveValue === 'doing' && SummaryData.value.value == 1 && (dataInfo.incidentData.handlingPersonnelUser.id == loginUserStore.loginUser.user.id);
  253. })
  254. // 上一步或者返回列表
  255. function goBackOrToList(){
  256. if(dataInfo.isSummaryNext){
  257. handlerStore.setHandlerData(dataInfo, 'assign', 'assign');
  258. goBack();
  259. }else{
  260. uni.reLaunch({
  261. url: '/pages/incidentList/incidentList'
  262. })
  263. }
  264. }
  265. // 上传处理图片成功
  266. function handlerImgSuccess(e){
  267. dataInfo.handlerImgList.forEach(v => {
  268. v.url = v.path;
  269. })
  270. console.log(dataInfo.handlerImgList);
  271. let handlerOrder$ = handlerOrder();
  272. let requestList = [handlerOrder$];
  273. dataInfo.handlerImgList.forEach(v => {
  274. let handlerOrderImg$ = handlerOrderImg(v);
  275. requestList.push(handlerOrderImg$);
  276. })
  277. Promise.all(requestList).then(resList => {
  278. uni.hideLoading();
  279. console.log(resList);
  280. if(resList[0].state == 200){
  281. uni.showToast({
  282. icon: 'none',
  283. title: '处理成功',
  284. mask: true,
  285. });
  286. setTimeout(() => {
  287. uni.reLaunch({
  288. url: '/pages/incidentList/incidentList',
  289. })
  290. }, 1500)
  291. }else{
  292. uni.showToast({
  293. icon: 'none',
  294. title: resList[0].msg || '请求数据失败!'
  295. });
  296. }
  297. })
  298. }
  299. // 上传处理图片失败
  300. function handlerImgFail(e){
  301. dataInfo.handlerImgList.forEach(v => {
  302. v.url = v.path;
  303. })
  304. console.log(dataInfo.handlerImgList);
  305. }
  306. // 选择上传图片
  307. function handlerImgSelect(e){
  308. dataInfo.handlerImgList = dataInfo.handlerImgList.concat(e.tempFiles);
  309. console.log(dataInfo.handlerImgList);
  310. }
  311. // 删除上传图片
  312. function handlerImgDelete(e){
  313. dataInfo.handlerImgList = dataInfo.handlerImgList.filter(v => e.tempFile.uuid != v.uuid);
  314. console.log(dataInfo.handlerImgList);
  315. }
  316. // 添加协同人员
  317. function synergeticAdd(){
  318. handlerStore.setHandlerData(dataInfo, 'handler');
  319. uni.navigateTo({
  320. url: `/pages/synergeticAdd/synergeticAdd?incidentId=${dataInfo.incidentId}`
  321. })
  322. }
  323. // 引入知识库
  324. function importRep(type){
  325. dataInfo.operateType = type
  326. handlerStore.setHandlerData(dataInfo, 'assign', 'assign');
  327. uni.navigateTo({
  328. url: `/pages/repository/repository`
  329. })
  330. }
  331. // 选择故障现象
  332. function selectCategory(){
  333. handlerStore.setHandlerData(dataInfo, 'handler');
  334. uni.navigateTo({
  335. url: `/pages/categoryOne/categoryOne?incidentId=${dataInfo.incidentId}`
  336. })
  337. }
  338. // 点击修改数量
  339. function numberClick(data, type){
  340. if(type === 'editConsumable'){
  341. dataInfo.evtNumber = data.consumablesNum;
  342. }else if(type === 'editWorkHourManagement'){
  343. dataInfo.evtNumber = data.workHourNum2;
  344. }
  345. dataInfo.isNumber = true;
  346. dataInfo.selectData = data;
  347. dataInfo.selectType = type;
  348. }
  349. // 确认修改数量
  350. function conformNumber(evtNumber){
  351. dataInfo.evtNumber = evtNumber;
  352. dataInfo.isNumber = false;
  353. addSummaryDoc();
  354. }
  355. // 移除数量
  356. function removeNumber(evtNumber){
  357. dataInfo.evtNumber = evtNumber;
  358. dataInfo.isNumber = false;
  359. removeSummaryDoc();
  360. }
  361. // 关闭修改数量
  362. function cancelNumber(){
  363. dataInfo.isNumber = false;
  364. }
  365. // 修改耗材/工时
  366. function addSummaryDoc(){
  367. uni.showLoading({
  368. title: "加载中",
  369. mask: true,
  370. });
  371. let postData = {
  372. "summaryId": dataInfo.summaryId,
  373. "modifyNum": 'edit',
  374. };
  375. if(dataInfo.selectType === 'editConsumable'){
  376. postData.consumableList = [
  377. {
  378. "consumablesId": dataInfo.selectData.consumableId,
  379. "consumablesNum": dataInfo.evtNumber,
  380. }
  381. ];
  382. }else if(dataInfo.selectType === 'editWorkHourManagement'){
  383. postData.workHourManagementList = [
  384. {
  385. "workHourId": dataInfo.selectData.id,
  386. "workHourNum": dataInfo.evtNumber,
  387. }
  388. ];
  389. }
  390. api_addSummaryDoc(postData).then(res => {
  391. uni.hideLoading();
  392. if(res.status == 200){
  393. uni.showToast({
  394. icon: 'none',
  395. title: '修改数量成功',
  396. mask: true,
  397. });
  398. getSummaryList();
  399. }else{
  400. uni.showToast({
  401. icon: 'none',
  402. title: res.msg || '请求数据失败!'
  403. });
  404. }
  405. })
  406. }
  407. // 移除耗材/工时
  408. function removeSummaryDoc(){
  409. uni.showLoading({
  410. title: "加载中",
  411. mask: true,
  412. });
  413. let postData = {
  414. "summaryId": dataInfo.summaryId,
  415. "remove": 'remove',
  416. };
  417. if(dataInfo.selectType === 'editConsumable'){
  418. postData.consumableList = [
  419. {
  420. "consumablesId": dataInfo.selectData.consumableId,
  421. "consumablesNum": dataInfo.evtNumber,
  422. }
  423. ];
  424. }else if(dataInfo.selectType === 'editWorkHourManagement'){
  425. postData.workHourManagementList = [
  426. {
  427. "workHourId": dataInfo.selectData.id,
  428. "workHourNum": dataInfo.evtNumber,
  429. }
  430. ];
  431. }
  432. api_addSummaryDoc(postData).then(res => {
  433. uni.hideLoading();
  434. if(res.status == 200){
  435. uni.showToast({
  436. icon: 'none',
  437. title: '移除成功',
  438. mask: true,
  439. });
  440. getSummaryList();
  441. }else{
  442. uni.showToast({
  443. icon: 'none',
  444. title: res.msg || '请求数据失败!'
  445. });
  446. }
  447. })
  448. }
  449. // 重置
  450. function reset(){
  451. dataInfo.repairTypeList = []; //延期原因列表
  452. dataInfo.repairTypeId = undefined; //延期原因ID
  453. dataInfo.deferralDayList = []; //延期天数列表
  454. dataInfo.deferralDayId = undefined; //延期天数ID
  455. dataInfo.deferralRemark = '';//延期说明
  456. dataInfo.summaryObj = {
  457. consumableList: [],//耗材列表
  458. workHourManagementList: [],//工时列表
  459. };//汇总单信息
  460. dataInfo.summaryId = undefined;//汇总单Id
  461. dataInfo.isNumber = false;//修改数量弹窗
  462. dataInfo.evtNumber = 1;//弹窗返回的数量
  463. dataInfo.selectData = {};//选择的对象
  464. dataInfo.selectType = {};//选择的对象类型
  465. dataInfo.handleDescription = '';//解决方案
  466. solutionId.value = null;//引用知识库id
  467. dataInfo.handleCategory = undefined;//处理方式
  468. dataInfo.handleCategoryList = [];//处理方式列表
  469. dataInfo.closecode = undefined;//处理结果
  470. dataInfo.closecodeList = [];//处理结果列表
  471. dataInfo.handlerImgList = [];//处理图片列表
  472. dataInfo.category = {};//故障现象
  473. dataInfo.synergetic = [];//协同人员
  474. dataInfo.provideBackupMachine = 0
  475. dataInfo.returnBackupMachine = null
  476. }
  477. // 初始化表单
  478. function initForm(){
  479. if(dataInfo.tabActiveValue === 'doing' && isInSummaryOrder.value){
  480. getSummaryList();
  481. }else if(dataInfo.tabActiveValue === 'doing' && !isInSummaryOrder.value){
  482. getHandleCategorys();
  483. getClosecodes();
  484. }else if(dataInfo.tabActiveValue === 'overtime'){
  485. getRepairTypes();
  486. getDeferralDays();
  487. }
  488. }
  489. // 点击tab
  490. function clickTab(tabValue){
  491. if(dataInfo.tabActiveValue == tabValue){
  492. return;
  493. }
  494. dataInfo.tabActiveValue = tabValue;
  495. isSubmit.value = false;
  496. reset();
  497. dataInfo.category = dataInfo.incidentData.category || {};
  498. dataInfo.synergetic = dataInfo.incidentData.synergetic || [];
  499. newProvideBackupMachine.value = dataInfo.incidentData.provideBackupMachine
  500. initForm();
  501. }
  502. // 获取事件详情
  503. function getIncidentDetail(){
  504. uni.showLoading({
  505. title: "加载中",
  506. mask: true,
  507. });
  508. let title = null;
  509. api_incidentDetail(dataInfo.incidentId).then(res => {
  510. uni.hideLoading();
  511. if(res.status == 200){
  512. dataInfo.incidentData = res.data || {};
  513. if(res.data.state.value!='handler'){
  514. uni.showToast({
  515. icon: 'none',
  516. title: '工单状态异常!请刷新页面再重试',
  517. });
  518. setTimeout(_=>{
  519. goBackOrToList()
  520. },1000)
  521. return
  522. }
  523. dataInfo.summaryId = res.data.summaryId;
  524. newProvideBackupMachine.value = dataInfo.incidentData.provideBackupMachine
  525. let storeData = handlerStore.handler.data
  526. if(storeData && storeData.type!='rep'){
  527. if(dataInfo.isSummaryNext){
  528. // 汇总单-下一步
  529. dataInfo.incidentData.duty.addSummary = 0;
  530. }
  531. }
  532. // 跳转页面选择了选项并且工单ID一致
  533. if(handlerStore.handler.data && handlerStore.handler.data.incidentId == dataInfo.incidentId){
  534. if(dataInfo.handleDescription){
  535. dataInfo.handleDescription = null;
  536. }
  537. Object.assign(dataInfo, handlerStore.handler.data);
  538. getIntroduceCount(dataInfo.category.id)
  539. handlerStore.clearHandlerData();
  540. }else{
  541. handlerStore.clearHandlerData();
  542. // 初始化回显
  543. dataInfo.category = dataInfo.incidentData.category || {};
  544. dataInfo.synergetic = dataInfo.incidentData.synergetic || [];
  545. getIntroduceCount(dataInfo.category.id)
  546. let chuli = false;//故障处理权限
  547. for (let i = 0; i < loginUserStore.loginUser.menu.length; i++) {
  548. if (loginUserStore.loginUser.menu[i].link == "handle") {
  549. chuli = true
  550. }
  551. }
  552. // 故障处理
  553. if(dataInfo.incidentData.state.value == 'handler' && dataInfo.incidentData.handlingPersonnelUser && dataInfo.incidentData.handlingPersonnelUser.id == loginUserStore.loginUser.user.id && chuli){
  554. let flag = dataInfo.tabs.some(v => v.value === 'doing');
  555. !flag && dataInfo.tabs.splice(0, 0, {id: 5, name: '故障处理', value: 'doing', num: ''});
  556. }
  557. // 延期处理
  558. if(dataInfo.incidentData.state.value == 'handler' && dataInfo.incidentData.handlingPersonnelUser && dataInfo.incidentData.handlingPersonnelUser.id == loginUserStore.loginUser.user.id){
  559. let flag = dataInfo.tabs.some(v => v.value === 'overtime');
  560. !flag && dataInfo.tabs.push({id: 6, name: '延期处理', value: 'overtime', num: ''});
  561. }
  562. dataInfo.tabActiveValue = dataInfo.tabs[0].value;
  563. }
  564. initForm()
  565. }else{
  566. uni.showToast({
  567. icon: 'none',
  568. title: res.msg || '请求数据失败!'
  569. });
  570. }
  571. })
  572. }
  573. // 获取延期原因列表
  574. function getRepairTypes(){
  575. uni.showLoading({
  576. title: "加载中",
  577. mask: true,
  578. });
  579. let postData = {
  580. "key": 'repair_type',
  581. "type": "list",
  582. };
  583. api_getDictionary(postData).then(res => {
  584. uni.hideLoading();
  585. res = res || [];
  586. dataInfo.repairTypeList = res.map(v => ({
  587. text: v.name,
  588. value: v.id,
  589. }));
  590. })
  591. }
  592. // 获取处理方式列表
  593. function getHandleCategorys(){
  594. uni.showLoading({
  595. title: "加载中",
  596. mask: true,
  597. });
  598. let postData = {
  599. "key": 'incident_handle_type',
  600. "type": "list",
  601. };
  602. api_getDictionary(postData).then(res => {
  603. uni.hideLoading();
  604. res = res || [];
  605. dataInfo.handleCategoryList = res.map(v => ({
  606. text: v.name,
  607. value: v.id,
  608. key: v.value,
  609. }));
  610. if(!dataInfo.handleCategory){
  611. let handleCategory = dataInfo.handleCategoryList.find(v => v.key == 'SUPPORT');
  612. dataInfo.handleCategory = handleCategory ? handleCategory.value : undefined;
  613. }
  614. })
  615. }
  616. // 获取处理结果列表
  617. function getClosecodes(){
  618. uni.showLoading({
  619. title: "加载中",
  620. mask: true,
  621. });
  622. let postData = {
  623. "key": 'incident_closecode',
  624. "type": "list",
  625. };
  626. api_getDictionary(postData).then(res => {
  627. uni.hideLoading();
  628. res = res || [];
  629. dataInfo.closecodeList = res.map(v => ({
  630. text: v.name,
  631. value: v.id,
  632. key: v.value,
  633. }));
  634. if(!dataInfo.closecode){
  635. let closecode = dataInfo.closecodeList.find(v => v.key == '1');
  636. dataInfo.closecode = closecode ? closecode.value : undefined;
  637. }
  638. })
  639. }
  640. // 获取延期天数列表
  641. function getDeferralDays(){
  642. dataInfo.deferralDayList = generateNumberArray(1, 15).map(v => ({
  643. text: v + '天',
  644. value: v,
  645. }));
  646. dataInfo.deferralDayList.unshift({
  647. text: '0.5天',
  648. value: 0.5,
  649. })
  650. }
  651. // 获取汇总单信息
  652. function getSummaryList(){
  653. uni.showLoading({
  654. title: "加载中",
  655. mask: true,
  656. });
  657. let postData = {
  658. "incidentId": dataInfo.incidentId,
  659. };
  660. api_querySummaryDoc(postData).then(res => {
  661. uni.hideLoading();
  662. if(res.status == 200){
  663. dataInfo.summaryObj = {...{consumableList:[], workHourManagementList: []}, ...res };
  664. dataInfo.summaryId = res.summaryId;
  665. }else if(res.status == 201){
  666. // 事件第一次绑定汇总单
  667. dataInfo.summaryId = res.summaryId;
  668. }else{
  669. uni.showToast({
  670. icon: 'none',
  671. title: res.msg || '请求数据失败!'
  672. });
  673. }
  674. })
  675. }
  676. // 添加耗材
  677. function addConsumable(){
  678. uni.navigateTo({
  679. url: `/pages/consumableList/consumableList?incidentId=${dataInfo.incidentId}&summaryId=${dataInfo.summaryId}`
  680. })
  681. }
  682. // 添加工时
  683. function addWorkHourManagement(){
  684. let hosId = dataInfo.incidentData.duty.id
  685. uni.navigateTo({
  686. url: `/pages/workHourManagementOne/workHourManagementOne?incidentId=${dataInfo.incidentId}&summaryId=${dataInfo.summaryId}&hosId=${hosId}`
  687. })
  688. }
  689. // 提交
  690. function submit(){
  691. isSubmit.value = true;
  692. if(dataInfo.tabActiveValue === 'doing' && isInSummaryOrder.value){
  693. uni.navigateTo({
  694. url: `/pages/handler/handler?incidentId=${dataInfo.incidentId}&isSummaryNext=1&type=0`,
  695. });
  696. }else if(dataInfo.tabActiveValue === 'doing' && !isInSummaryOrder.value){
  697. submitHandler();
  698. }else if(dataInfo.tabActiveValue === 'overtime'){
  699. submitOvertime();
  700. }
  701. }
  702. // 处理提交事件
  703. function handlerOrder(){
  704. dataInfo.incidentData.returnBackupMachine = dataInfo.returnBackupMachine
  705. let postData = {
  706. incident: dataInfo.incidentData,
  707. solutionId:solutionId.value
  708. }
  709. postData.incident.handleDescription = dataInfo.handleDescription;
  710. postData.incident.handleCategory = {id: dataInfo.handleCategory};
  711. postData.incident.closecode = {id: dataInfo.closecode};
  712. postData.incident.category = dataInfo.category;
  713. postData.incident.synergetic = dataInfo.synergetic;
  714. return api_incidentTask(dataInfo.tabActiveValue, postData);
  715. }
  716. // 处理图片
  717. function handlerOrderImg(imgObj){
  718. return uploadFile(imgObj, 'incident', dataInfo.incidentId)
  719. }
  720. // 处理提交
  721. function submitHandler(){
  722. console.log(dataInfo);
  723. if(!dataInfo.handleDescription.trim() && HandleData.simpleness != 1){
  724. uni.showToast({
  725. icon: 'none',
  726. title: '请填写解决方案'
  727. });
  728. return;
  729. }
  730. if(newProvideBackupMachine.value==1 && dataInfo.returnBackupMachine==null){
  731. uni.showToast({
  732. icon: 'none',
  733. title: '请选择是否归还备用机'
  734. });
  735. return;
  736. }
  737. if(!dataInfo.category.id && HandleData.simpleness != 1){
  738. uni.showToast({
  739. icon: 'none',
  740. title: '请选择故障现象'
  741. });
  742. return;
  743. }
  744. if(!dataInfo.handleCategory){
  745. uni.showToast({
  746. icon: 'none',
  747. title: '请选择处理方式'
  748. });
  749. return;
  750. }
  751. if(!dataInfo.closecode && HandleData.simpleness != 1){
  752. uni.showToast({
  753. icon: 'none',
  754. title: '请选择处理结果'
  755. });
  756. return;
  757. }
  758. console.log(dataInfo.handlerImgList)
  759. // if(HandleData.simpleness==1){
  760. // dataInfo.closecode = '1'
  761. // }
  762. uni.showLoading({
  763. title: "加载中",
  764. mask: true,
  765. });
  766. if(dataInfo.handlerImgList.length){
  767. // 有图片
  768. handlerImgRef.value.upload();
  769. }else{
  770. // 没有图片
  771. let handlerOrder$ = handlerOrder();
  772. let requestList = [handlerOrder$];
  773. Promise.all(requestList).then(resList => {
  774. uni.hideLoading();
  775. console.log(resList);
  776. if(resList[0].state == 200){
  777. uni.showToast({
  778. icon: 'none',
  779. title: '处理成功',
  780. mask: true,
  781. });
  782. setTimeout(() => {
  783. uni.reLaunch({
  784. url: '/pages/incidentList/incidentList',
  785. })
  786. }, 1500)
  787. }else{
  788. uni.showToast({
  789. icon: 'none',
  790. title: resList[0].msg || '请求数据失败!'
  791. });
  792. }
  793. })
  794. }
  795. }
  796. // 延期处理提交
  797. function submitOvertime(){
  798. if(!dataInfo.repairTypeId){
  799. uni.showToast({
  800. icon: 'none',
  801. title: '请选择延期原因'
  802. });
  803. return;
  804. }
  805. if(!dataInfo.deferralRemark.trim()){
  806. uni.showToast({
  807. icon: 'none',
  808. title: '请填写延期说明'
  809. });
  810. return;
  811. }
  812. if(!dataInfo.deferralDayId){
  813. uni.showToast({
  814. icon: 'none',
  815. title: '请选择延期天数'
  816. });
  817. return;
  818. }
  819. uni.showLoading({
  820. title: "加载中",
  821. mask: true,
  822. });
  823. dataInfo.incidentData.provideBackupMachine = dataInfo.provideBackupMachine
  824. let postData = {
  825. incident: dataInfo.incidentData,
  826. }
  827. postData.incident.currentLog = {
  828. remark: dataInfo.deferralRemark,
  829. extra1: dataInfo.repairTypeId,
  830. extra2: dataInfo.deferralDayId,
  831. }
  832. api_incidentTask(dataInfo.tabActiveValue, postData).then(res => {
  833. uni.hideLoading();
  834. if(res.state == 200){
  835. uni.showToast({
  836. icon: 'none',
  837. title: '延期处理成功',
  838. mask: true,
  839. });
  840. setTimeout(() => {
  841. uni.reLaunch({
  842. url: '/pages/incidentList/incidentList',
  843. })
  844. }, 1500)
  845. }else{
  846. uni.showToast({
  847. icon: 'none',
  848. title: res.msg || '请求数据失败!'
  849. });
  850. }
  851. })
  852. }
  853. // 获取知识库数量
  854. function getIntroduceCount(categoryId){
  855. uni.showLoading({
  856. title: "加载中",
  857. mask: true,
  858. });
  859. let query = {
  860. "key": 'solution_status',
  861. "type": "list",
  862. };
  863. api_getDictionary(query).then(res=>{
  864. let typeId = res.find(v => v.value == '3');
  865. let postData = {
  866. idx: 0,
  867. sum: 9999,
  868. solution: {
  869. deleteFlag:0,
  870. hosId: loginUserStore.loginUser.user.currentHospital.id,
  871. categoryId:categoryId,
  872. status:{id:typeId.id},
  873. }
  874. }
  875. api_getSolution(postData).then(res => {
  876. uni.hideLoading();
  877. if(res.status == 200){
  878. dataInfo.introduceCount = res.totalNum
  879. }else{
  880. uni.showToast({
  881. icon: 'none',
  882. title: res.msg || '请求数据失败!'
  883. });
  884. }
  885. })
  886. })
  887. }
  888. // 获取文本内容
  889. function getHtml(html) {
  890. const tempDiv = document.createElement('div');
  891. tempDiv.innerHTML = html;
  892. return tempDiv.textContent || tempDiv.innerText || '';
  893. }
  894. // 获取是否开启汇总单、简易处理
  895. function getHosConfig(){
  896. let postData = {
  897. idx: 0,
  898. sum: 9999,
  899. hospitalConfig:{
  900. hosId: loginUserStore.loginUser.user.currentHospital.id,
  901. model: "itsm"
  902. }
  903. };
  904. getFetchDataList("simple/data", "hospitalConfig", postData)
  905. .then((res) => {
  906. if(dataInfo.isSummaryNext!=1){
  907. SummaryData.value = res.list.find(i=>i.key=='itsmSummarySheet')
  908. }
  909. HandleData.simpleness = res.list.find(i=>i.key=='itsmSimpleHandle').value
  910. });
  911. }
  912. onLoad((option) => {
  913. let storeData = handlerStore.handler.data
  914. if(storeData && storeData.type=='rep'){
  915. solutionId.value = storeData.solutionId
  916. dataInfo.isSummaryNext = storeData.isSummaryNext
  917. dataInfo.incidentId = storeData.incidentId;
  918. }else{
  919. dataInfo.incidentId = option.incidentId;
  920. dataInfo.isSummaryNext = option.isSummaryNext == 1;
  921. }
  922. getHosConfig()
  923. getIncidentDetail();
  924. })
  925. </script>
  926. <style lang="scss" scoped>
  927. .handler{
  928. height: 100%;
  929. display: flex;
  930. flex-direction: column;
  931. justify-content: space-between;
  932. .head{
  933. height: 88rpx;
  934. display: flex;
  935. position: fixed;
  936. z-index: 99;
  937. width: 100%;
  938. background-color: #fff;
  939. font-size: 30rpx;
  940. .tab{
  941. flex: 1;
  942. display: flex;
  943. justify-content: center;
  944. align-items: center;
  945. border-bottom: 4rpx solid transparent;
  946. &.active{
  947. color: $uni-primary;
  948. border-color: $uni-primary;
  949. }
  950. }
  951. }
  952. .body{
  953. margin-top: 88rpx;
  954. box-sizing: border-box;
  955. flex: 1;
  956. min-height: 0;
  957. &.bg{
  958. background-color: #F7F7F7;
  959. }
  960. .summaryItem{
  961. &:first-of-type{
  962. .summaryItem_head{
  963. border-bottom: 1rpx solid #DDDDDD;
  964. }
  965. }
  966. .summary_total{
  967. padding: 20rpx 0;
  968. display: flex;
  969. justify-content: center;
  970. align-items: center;
  971. }
  972. .summaryItem_head{
  973. padding: 24rpx;
  974. font-size: 26rpx;
  975. color: #3A3A3A;
  976. }
  977. .summaryItem_body{
  978. font-size: 30rpx;
  979. background-color: #fff;
  980. .summaryItem_bodyItem{
  981. padding: 24rpx;
  982. border-bottom: 1rpx solid #DDDDDD;
  983. .summaryItem_bodyItem_top{
  984. display: flex;
  985. justify-content: space-between;
  986. align-items: center;
  987. .value{
  988. padding-left: 48rpx;
  989. flex-shrink: 0;
  990. }
  991. }
  992. .summaryItem_bodyItem_bottom{
  993. margin-top: 24rpx;
  994. display: flex;
  995. justify-content: space-between;
  996. align-items: center;
  997. .name{
  998. text-align: right;
  999. flex: 1;
  1000. }
  1001. .value{
  1002. width: 240rpx;
  1003. text-align: right;
  1004. padding-left: 48rpx;
  1005. flex-shrink: 0;
  1006. }
  1007. }
  1008. }
  1009. }
  1010. .summaryItem_foot{
  1011. font-size: 30rpx;
  1012. background-color: #fff;
  1013. &.total{
  1014. margin-top: 24rpx;
  1015. }
  1016. .summaryItem_foot_total{
  1017. padding: 24rpx 0;
  1018. display: flex;
  1019. justify-content: center;
  1020. align-items: center;
  1021. }
  1022. .summaryItem_foot_add{
  1023. border-top: 1rpx solid #DDDDDD;
  1024. padding: 24rpx 0;
  1025. display: flex;
  1026. justify-content: center;
  1027. align-items: center;
  1028. .newicon-icon-test{
  1029. font-size: 30rpx;
  1030. font-weight: bold;
  1031. }
  1032. }
  1033. }
  1034. }
  1035. .form_item_column{
  1036. padding-top: 24rpx;
  1037. min-height: 86rpx;
  1038. .form_item{
  1039. padding-top: 0;
  1040. min-height: auto;
  1041. }
  1042. }
  1043. .form_item{
  1044. display: flex;
  1045. align-items: center;
  1046. padding-top: 24rpx;
  1047. min-height: 86rpx;
  1048. &.column{
  1049. height: auto;
  1050. flex-direction: column;
  1051. align-items: flex-start;
  1052. .import-rep{
  1053. padding: 5rpx 10rpx;
  1054. border-radius: 50rpx;
  1055. background: #d1fcd5;
  1056. color: #49b856;
  1057. font-size: 24rpx;
  1058. }
  1059. .title{
  1060. margin-right: 0;
  1061. }
  1062. .title-width{
  1063. width: 100%;
  1064. }
  1065. .title-fl-sb{
  1066. display: flex;
  1067. justify-content: space-between;
  1068. width: 100%;
  1069. }
  1070. .value{
  1071. margin-top: 10rpx;
  1072. padding-left: 20rpx;
  1073. box-sizing: border-box;
  1074. }
  1075. .tips{
  1076. padding: 24rpx;
  1077. text-align: center;
  1078. font-size: 22rpx;
  1079. color: #909399;
  1080. width: 100%;
  1081. box-sizing: border-box;
  1082. }
  1083. }
  1084. .title{
  1085. font-size: 26rpx;
  1086. display: flex;
  1087. align-items: center;
  1088. margin-right: 12rpx;
  1089. flex-shrink: 0;
  1090. &.select{
  1091. width: calc(5em + 20rpx);
  1092. }
  1093. }
  1094. .value{
  1095. width: 100%;
  1096. &.category{
  1097. width: 100%;
  1098. display: flex;
  1099. justify-content: space-between;
  1100. align-items: center;
  1101. .categoryName{
  1102. font-size: 26rpx;
  1103. color: #555;
  1104. flex: 1;
  1105. }
  1106. .newicon-weibiaoti2010104{
  1107. color: $uni-primary;
  1108. margin-left: 24rpx;
  1109. }
  1110. }
  1111. .imgTips{
  1112. color: #909399;
  1113. font-size: 22rpx;
  1114. }
  1115. }
  1116. .synergeticNames{
  1117. font-size: 26rpx;
  1118. margin-right: 24rpx;
  1119. }
  1120. .synergeticAdd{
  1121. flex-shrink: 0;
  1122. }
  1123. }
  1124. }
  1125. }
  1126. </style>