handler.vue 36 KB

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