assign.vue 32 KB

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