handler.vue 34 KB

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