handler.vue 34 KB

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