assign.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  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. "duty": dataInfo.incidentData.duty || undefined,
  415. "selectType": "nouser"
  416. }
  417. };
  418. api_group(postData).then(res => {
  419. uni.hideLoading();
  420. if(res.status == 200){
  421. res.list = res.list || [];
  422. dataInfo.groupList = res.list.map(v => ({
  423. text: v.groupName,
  424. value: v.id,
  425. }));
  426. }else{
  427. uni.showToast({
  428. icon: 'none',
  429. title: res.msg || '请求数据失败!'
  430. });
  431. }
  432. })
  433. }
  434. // 获取用户列表
  435. function getUsers(){
  436. uni.showLoading({
  437. title: "加载中",
  438. mask: true,
  439. });
  440. let postData = {
  441. "idx": 0,
  442. "sum": 9999,
  443. "user": {
  444. "duty": dataInfo.incidentData.duty || undefined,
  445. "groupdata":{
  446. "id": dataInfo.groupId,
  447. },
  448. "roledata": {
  449. "rolecode": "first-line support"
  450. },
  451. "selectType": "1",
  452. "selectDetails": 1,
  453. "simple": true,
  454. "engineer": 1,
  455. }
  456. };
  457. api_user(postData).then(res => {
  458. uni.hideLoading();
  459. if(res.status == 200){
  460. res.list = res.list || [];
  461. dataInfo.userList = res.list.map(v => ({
  462. text: v.name,
  463. value: v.id,
  464. }));
  465. }else{
  466. uni.showToast({
  467. icon: 'none',
  468. title: res.msg || '请求数据失败!'
  469. });
  470. }
  471. })
  472. }
  473. // 获取处理方式列表
  474. function getHandleCategorys(){
  475. uni.showLoading({
  476. title: "加载中",
  477. mask: true,
  478. });
  479. let postData = {
  480. "key": 'incident_handleCategory',
  481. "type": "list",
  482. };
  483. api_getDictionary(postData).then(res => {
  484. uni.hideLoading();
  485. res = res || [];
  486. dataInfo.handleCategoryList = res.map(v => ({
  487. text: v.name,
  488. value: v.id,
  489. key: v.value,
  490. }));
  491. if(!dataInfo.handleCategory){
  492. let handleCategory = dataInfo.handleCategoryList.find(v => v.key == 'SUPPORT');
  493. dataInfo.handleCategory = handleCategory ? handleCategory.value : undefined;
  494. }
  495. })
  496. }
  497. // 获取关闭代码列表
  498. function getClosecodes(){
  499. uni.showLoading({
  500. title: "加载中",
  501. mask: true,
  502. });
  503. let postData = {
  504. "key": 'incident_closecode',
  505. "type": "list",
  506. };
  507. api_getDictionary(postData).then(res => {
  508. uni.hideLoading();
  509. res = res || [];
  510. dataInfo.closecodeList = res.map(v => ({
  511. text: v.name,
  512. value: v.id,
  513. key: v.value,
  514. }));
  515. if(!dataInfo.closecode){
  516. let closecode = dataInfo.closecodeList.find(v => v.key == '060');
  517. dataInfo.closecode = closecode ? closecode.value : undefined;
  518. }
  519. })
  520. }
  521. // 添加耗材
  522. function addConsumable(){
  523. uni.navigateTo({
  524. url: `/pages/consumableList/consumableList?incidentId=${dataInfo.incidentId}&summaryId=${dataInfo.summaryId}`
  525. })
  526. }
  527. // 添加工时
  528. function addWorkHourManagement(){
  529. uni.navigateTo({
  530. url: `/pages/workHourManagementOne/workHourManagementOne?incidentId=${dataInfo.incidentId}&summaryId=${dataInfo.summaryId}`
  531. })
  532. }
  533. // 提交
  534. function submit(){
  535. isSubmit.value = true;
  536. if(dataInfo.tabActiveValue === 'direct'){
  537. submitHandler();
  538. }else if(dataInfo.tabActiveValue === 'assign'){
  539. submitAssign();
  540. }
  541. }
  542. // 处理提交事件
  543. async function handlerOrder(){
  544. let postData = {
  545. incident: dataInfo.incidentData,
  546. }
  547. let result = await beforeBuild();
  548. if(result[0].status == 200 && result[1].status == 200){
  549. postData.incident.repairType = result[0].list.length ? result[0].list[0].valueconfig : undefined;
  550. postData.incident.incidentsign = result[1].data || undefined;
  551. }else{
  552. uni.showToast({
  553. icon: 'none',
  554. title: '请求数据失败!'
  555. });
  556. return;
  557. }
  558. postData.incident.handleDescription = dataInfo.handleDescription;
  559. postData.incident.handleCategory = {id: dataInfo.handleCategory};
  560. postData.incident.closecode = {id: dataInfo.closecode};
  561. postData.incident.category = dataInfo.category;
  562. postData.incident.synergetic = dataInfo.synergetic;
  563. postData.incident.directProcess = 1;//直接解决
  564. return api_incidentTask('accept', postData);
  565. }
  566. // 建单前的接口
  567. function beforeBuild(){
  568. let repairMain$ = api_systemConfiguration({
  569. "idx": 0,
  570. "sum": 1,
  571. "systemConfiguration": {
  572. "keyconfig": "repairMain"
  573. }
  574. })
  575. let sj$ = api_sj();
  576. return Promise.all([repairMain$, sj$])
  577. }
  578. // 派单提交事件
  579. async function assignOrder(){
  580. let postData = {
  581. incident: dataInfo.incidentData,
  582. }
  583. let result = await beforeBuild();
  584. if(result[0].status == 200 && result[1].status == 200){
  585. postData.incident.repairType = result[0].list.length ? result[0].list[0].valueconfig : undefined;
  586. postData.incident.incidentsign = result[1].data || undefined;
  587. }else{
  588. uni.showToast({
  589. icon: 'none',
  590. title: '请求数据失败!'
  591. });
  592. return;
  593. }
  594. if(dataInfo.userId){
  595. // 派人
  596. postData.incident.assignee = dataInfo.userId;
  597. } else {
  598. // 派组
  599. postData.incident.candidateGroups = dataInfo.groupId;
  600. }
  601. return api_incidentTask('accept', postData);
  602. }
  603. // 处理图片
  604. function handlerOrderImg(imgObj){
  605. return uploadFile(imgObj, 'incident', dataInfo.incidentId)
  606. }
  607. // 报修图片
  608. function repairOrderImg(imgObj){
  609. return uploadFile(imgObj, 'wechatRequesterIncident', dataInfo.incidentId)
  610. }
  611. // 处理提交
  612. function submitHandler(){
  613. console.log(dataInfo);
  614. if(!dataInfo.handleDescription.trim() && dataInfo.category.hasSimple != 1){
  615. uni.showToast({
  616. icon: 'none',
  617. title: '请填写解决方案'
  618. });
  619. return;
  620. }
  621. if(!dataInfo.category.id && dataInfo.category.hasSimple != 1){
  622. uni.showToast({
  623. icon: 'none',
  624. title: '请选择故障现象'
  625. });
  626. return;
  627. }
  628. if(!dataInfo.handleCategory){
  629. uni.showToast({
  630. icon: 'none',
  631. title: '请选择处理方式'
  632. });
  633. return;
  634. }
  635. if(!dataInfo.closecode && dataInfo.category.hasSimple != 1){
  636. uni.showToast({
  637. icon: 'none',
  638. title: '请选择关闭代码'
  639. });
  640. return;
  641. }
  642. if(!dataInfo.incidentData.duty){
  643. uni.showToast({
  644. icon: 'none',
  645. title: '您选择的故障现象没有设置责任科室'
  646. });
  647. return;
  648. }
  649. console.log(dataInfo)
  650. console.log(dataInfo.handlerImgList)
  651. console.log(dataInfo.incidentData.repairImgList)
  652. uni.showLoading({
  653. title: "加载中",
  654. mask: true,
  655. });
  656. if(dataInfo.handlerImgList.length){
  657. // 有处理图片
  658. let handlerOrder$ = handlerOrder();
  659. let requestList = [handlerOrder$];
  660. Promise.all(requestList).then(resList => {
  661. console.log(resList);
  662. if(resList[0].state == 200){
  663. dataInfo.incidentId = resList[0].data.id;
  664. handlerImgRef.value.upload();
  665. }else{
  666. uni.hideLoading();
  667. uni.showToast({
  668. icon: 'none',
  669. title: resList[0].msg || '请求数据失败!'
  670. });
  671. }
  672. })
  673. }else if(dataInfo.incidentData.repairImgList.length){
  674. // 有报修图片,无处理图片
  675. let handlerOrder$ = handlerOrder();
  676. let requestList = [handlerOrder$];
  677. Promise.all(requestList).then(resList => {
  678. console.log(resList);
  679. if(resList[0].state == 200){
  680. dataInfo.incidentId = resList[0].data.id;
  681. handlerImgSuccessNew();
  682. }else{
  683. uni.hideLoading();
  684. uni.showToast({
  685. icon: 'none',
  686. title: resList[0].msg || '请求数据失败!'
  687. });
  688. }
  689. })
  690. }else{
  691. // 没有图片
  692. let handlerOrder$ = handlerOrder();
  693. let requestList = [handlerOrder$];
  694. Promise.all(requestList).then(resList => {
  695. uni.hideLoading();
  696. console.log(resList);
  697. if(resList[0].state == 200){
  698. incidentBuildStore.clearIncidentBuildData();
  699. uni.showToast({
  700. icon: 'none',
  701. title: '建单成功',
  702. mask: true,
  703. });
  704. setTimeout(() => {
  705. uni.reLaunch({
  706. url: '/pages/incidentList/incidentList',
  707. })
  708. }, 1500)
  709. }else{
  710. uni.showToast({
  711. icon: 'none',
  712. title: resList[0].msg || '请求数据失败!'
  713. });
  714. }
  715. })
  716. }
  717. }
  718. // 派单提交
  719. function submitAssign(){
  720. if(!dataInfo.groupId){
  721. uni.showToast({
  722. icon: 'none',
  723. title: '请选择工作组'
  724. });
  725. return;
  726. }
  727. if(dataInfo.isAssignUser == 1 && !dataInfo.userId){
  728. uni.showToast({
  729. icon: 'none',
  730. title: '请选择指派对象'
  731. });
  732. return;
  733. }
  734. if(!dataInfo.incidentData.duty){
  735. uni.showToast({
  736. icon: 'none',
  737. title: '您选择的故障现象没有设置责任科室'
  738. });
  739. return;
  740. }
  741. uni.showLoading({
  742. title: "加载中",
  743. mask: true,
  744. });
  745. if(dataInfo.incidentData.repairImgList.length){
  746. // 有图片
  747. let assignOrder$ = assignOrder();
  748. let requestList = [assignOrder$];
  749. Promise.all(requestList).then(resList => {
  750. console.log(resList);
  751. if(resList[0].state == 200){
  752. dataInfo.incidentId = resList[0].data.id;
  753. // handlerImgRef.value.upload();
  754. handlerImgSuccessNew();
  755. }else{
  756. uni.hideLoading();
  757. uni.showToast({
  758. icon: 'none',
  759. title: resList[0].msg || '请求数据失败!'
  760. });
  761. }
  762. })
  763. }else{
  764. // 没有图片
  765. let assignOrder$ = assignOrder();
  766. let requestList = [assignOrder$];
  767. Promise.all(requestList).then(resList => {
  768. uni.hideLoading();
  769. console.log(resList);
  770. if(resList[0].state == 200){
  771. incidentBuildStore.clearIncidentBuildData();
  772. uni.showToast({
  773. icon: 'none',
  774. title: '建单成功',
  775. mask: true,
  776. });
  777. setTimeout(() => {
  778. uni.reLaunch({
  779. url: '/pages/incidentList/incidentList',
  780. })
  781. }, 1500)
  782. }else{
  783. uni.showToast({
  784. icon: 'none',
  785. title: resList[0].msg || '请求数据失败!'
  786. });
  787. }
  788. })
  789. }
  790. }
  791. onLoad((option) => {
  792. // 跳转页面选择了选项
  793. if(handlerStore.handler.data){
  794. Object.assign(dataInfo, handlerStore.handler.data);
  795. console.log(dataInfo)
  796. handlerStore.clearHandlerData();
  797. if(dataInfo.category){
  798. dataInfo.incidentData.category = dataInfo.category;
  799. // 处理责任科室
  800. if(dataInfo.category.branchType == 1){
  801. // 分院区
  802. if(dataInfo.incidentData.branch){
  803. let dutyConfig = dataInfo.category.branchUserGroups.find(v=>v.branchId == dataInfo.incidentData.branch);
  804. if(dutyConfig && dutyConfig.dutyId && dutyConfig.dutyName){
  805. dataInfo.incidentData.duty = {id:dutyConfig.dutyId,dept:dutyConfig.dutyName};
  806. }else{
  807. dataInfo.incidentData.duty = undefined;
  808. }
  809. }else{
  810. dataInfo.incidentData.duty = undefined;
  811. }
  812. }else{
  813. // 不分院区
  814. dataInfo.incidentData.duty = dataInfo.category.dutyDepartment;
  815. }
  816. }
  817. }else if(incidentBuildStore.incidentBuild.data){
  818. // 初始化
  819. Object.assign(dataInfo.incidentData, incidentBuildStore.incidentBuild.data);
  820. if(dataInfo.incidentData.category){
  821. dataInfo.category = dataInfo.incidentData.category;
  822. // 处理责任科室
  823. if(dataInfo.category.branchType == 1){
  824. // 分院区
  825. if(dataInfo.incidentData.branch){
  826. let dutyConfig = dataInfo.category.branchUserGroups.find(v=>v.branchId == dataInfo.incidentData.branch);
  827. if(dutyConfig && dutyConfig.dutyId && dutyConfig.dutyName){
  828. dataInfo.incidentData.duty = {id:dutyConfig.dutyId,dept:dutyConfig.dutyName};
  829. }else{
  830. dataInfo.incidentData.duty = undefined;
  831. }
  832. }else{
  833. dataInfo.incidentData.duty = undefined;
  834. }
  835. }else{
  836. // 不分院区
  837. dataInfo.incidentData.duty = dataInfo.category.dutyDepartment;
  838. }
  839. }
  840. if(dataInfo.incidentData.priority){
  841. dataInfo.incidentData.priority = { id: dataInfo.incidentData.priority };
  842. }
  843. if(dataInfo.incidentData.source){
  844. dataInfo.incidentData.source = { id: dataInfo.incidentData.source };
  845. }
  846. if(dataInfo.incidentData.requester){
  847. dataInfo.incidentData.requester = dataInfo.incidentData.requester
  848. }
  849. }
  850. dataInfo.tabActiveValue = dataInfo.tabs[0].value;
  851. initForm()
  852. })
  853. </script>
  854. <style lang="scss" scoped>
  855. .handler{
  856. height: 100%;
  857. display: flex;
  858. flex-direction: column;
  859. justify-content: space-between;
  860. .head{
  861. height: 88rpx;
  862. display: flex;
  863. position: fixed;
  864. z-index: 99;
  865. width: 100%;
  866. background-color: #fff;
  867. font-size: 30rpx;
  868. .tab{
  869. flex: 1;
  870. display: flex;
  871. justify-content: center;
  872. align-items: center;
  873. border-bottom: 4rpx solid transparent;
  874. &.active{
  875. color: $uni-primary;
  876. border-color: $uni-primary;
  877. }
  878. }
  879. }
  880. .body{
  881. margin-top: 88rpx;
  882. box-sizing: border-box;
  883. flex: 1;
  884. min-height: 0;
  885. &.bg{
  886. background-color: #F7F7F7;
  887. }
  888. .summaryItem{
  889. &:first-of-type{
  890. .summaryItem_head{
  891. border-bottom: 1rpx solid #DDDDDD;
  892. }
  893. }
  894. .summary_total{
  895. padding: 20rpx 0;
  896. display: flex;
  897. justify-content: center;
  898. align-items: center;
  899. }
  900. .summaryItem_head{
  901. padding: 24rpx;
  902. font-size: 26rpx;
  903. color: #3A3A3A;
  904. }
  905. .summaryItem_body{
  906. font-size: 30rpx;
  907. background-color: #fff;
  908. .summaryItem_bodyItem{
  909. padding: 24rpx;
  910. border-bottom: 1rpx solid #DDDDDD;
  911. .summaryItem_bodyItem_top{
  912. display: flex;
  913. justify-content: space-between;
  914. align-items: center;
  915. .value{
  916. padding-left: 48rpx;
  917. flex-shrink: 0;
  918. }
  919. }
  920. .summaryItem_bodyItem_bottom{
  921. margin-top: 24rpx;
  922. display: flex;
  923. justify-content: space-between;
  924. align-items: center;
  925. .name{
  926. text-align: right;
  927. flex: 1;
  928. }
  929. .value{
  930. width: 240rpx;
  931. text-align: right;
  932. padding-left: 48rpx;
  933. flex-shrink: 0;
  934. }
  935. }
  936. }
  937. }
  938. .summaryItem_foot{
  939. font-size: 30rpx;
  940. background-color: #fff;
  941. &.total{
  942. margin-top: 24rpx;
  943. }
  944. .summaryItem_foot_total{
  945. padding: 24rpx 0;
  946. display: flex;
  947. justify-content: center;
  948. align-items: center;
  949. }
  950. .summaryItem_foot_add{
  951. border-top: 1rpx solid #DDDDDD;
  952. padding: 24rpx 0;
  953. display: flex;
  954. justify-content: center;
  955. align-items: center;
  956. .newicon-icon-test{
  957. font-size: 30rpx;
  958. font-weight: bold;
  959. }
  960. }
  961. }
  962. }
  963. .form_item_column{
  964. padding-top: 24rpx;
  965. min-height: 86rpx;
  966. .form_item{
  967. padding-top: 0;
  968. min-height: auto;
  969. }
  970. }
  971. .form_item{
  972. display: flex;
  973. align-items: center;
  974. padding-top: 24rpx;
  975. min-height: 86rpx;
  976. &.column{
  977. height: auto;
  978. flex-direction: column;
  979. align-items: flex-start;
  980. .title{
  981. margin-right: 0;
  982. }
  983. .value{
  984. margin-top: 10rpx;
  985. padding-left: 20rpx;
  986. box-sizing: border-box;
  987. }
  988. .tips{
  989. padding: 24rpx;
  990. text-align: center;
  991. font-size: 22rpx;
  992. color: #909399;
  993. width: 100%;
  994. box-sizing: border-box;
  995. }
  996. }
  997. .title{
  998. font-size: 26rpx;
  999. display: flex;
  1000. align-items: center;
  1001. margin-right: 12rpx;
  1002. flex-shrink: 0;
  1003. &.select{
  1004. width: calc(5em + 20rpx);
  1005. }
  1006. }
  1007. .value{
  1008. width: 100%;
  1009. &.category{
  1010. width: 100%;
  1011. display: flex;
  1012. justify-content: space-between;
  1013. align-items: center;
  1014. .categoryName{
  1015. font-size: 26rpx;
  1016. color: #555;
  1017. flex: 1;
  1018. }
  1019. .newicon-weibiaoti2010104{
  1020. color: $uni-primary;
  1021. margin-left: 24rpx;
  1022. }
  1023. }
  1024. .imgTips{
  1025. color: #909399;
  1026. font-size: 22rpx;
  1027. }
  1028. }
  1029. .synergeticNames{
  1030. font-size: 26rpx;
  1031. margin-right: 24rpx;
  1032. }
  1033. .synergeticAdd{
  1034. flex-shrink: 0;
  1035. }
  1036. }
  1037. }
  1038. }
  1039. </style>