handler.vue 31 KB

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