handler.vue 31 KB

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