assign.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  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.handlerImgList)
  648. uni.showLoading({
  649. title: "加载中",
  650. mask: true,
  651. });
  652. if(dataInfo.handlerImgList.length || dataInfo.incidentData.repairImgList.length){
  653. // 有图片
  654. let handlerOrder$ = handlerOrder();
  655. let requestList = [handlerOrder$];
  656. Promise.all(requestList).then(resList => {
  657. uni.hideLoading();
  658. console.log(resList);
  659. if(resList[0].state == 200){
  660. dataInfo.incidentId = resList[0].data.id;
  661. handlerImgRef.value.upload();
  662. }else{
  663. uni.showToast({
  664. icon: 'none',
  665. title: resList[0].msg || '请求数据失败!'
  666. });
  667. }
  668. })
  669. }else{
  670. // 没有图片
  671. let handlerOrder$ = handlerOrder();
  672. let requestList = [handlerOrder$];
  673. Promise.all(requestList).then(resList => {
  674. uni.hideLoading();
  675. console.log(resList);
  676. if(resList[0].state == 200){
  677. incidentBuildStore.clearIncidentBuildData();
  678. uni.showToast({
  679. icon: 'none',
  680. title: '建单成功',
  681. mask: true,
  682. });
  683. setTimeout(() => {
  684. uni.reLaunch({
  685. url: '/pages/incidentList/incidentList',
  686. })
  687. }, 1500)
  688. }else{
  689. uni.showToast({
  690. icon: 'none',
  691. title: resList[0].msg || '请求数据失败!'
  692. });
  693. }
  694. })
  695. }
  696. }
  697. // 派单提交
  698. function submitAssign(){
  699. if(!dataInfo.groupId){
  700. uni.showToast({
  701. icon: 'none',
  702. title: '请选择工作组'
  703. });
  704. return;
  705. }
  706. if(dataInfo.isAssignUser == 1 && !dataInfo.userId){
  707. uni.showToast({
  708. icon: 'none',
  709. title: '请选择指派对象'
  710. });
  711. return;
  712. }
  713. if(!dataInfo.incidentData.duty){
  714. uni.showToast({
  715. icon: 'none',
  716. title: '您选择的故障现象没有设置责任科室'
  717. });
  718. return;
  719. }
  720. uni.showLoading({
  721. title: "加载中",
  722. mask: true,
  723. });
  724. if(dataInfo.incidentData.repairImgList.length){
  725. // 有图片
  726. let assignOrder$ = assignOrder();
  727. let requestList = [assignOrder$];
  728. Promise.all(requestList).then(resList => {
  729. uni.hideLoading();
  730. console.log(resList);
  731. if(resList[0].state == 200){
  732. dataInfo.incidentId = resList[0].data.id;
  733. // handlerImgRef.value.upload();
  734. handlerImgSuccessNew();
  735. }else{
  736. uni.showToast({
  737. icon: 'none',
  738. title: resList[0].msg || '请求数据失败!'
  739. });
  740. }
  741. })
  742. }else{
  743. // 没有图片
  744. let assignOrder$ = assignOrder();
  745. let requestList = [assignOrder$];
  746. Promise.all(requestList).then(resList => {
  747. uni.hideLoading();
  748. console.log(resList);
  749. if(resList[0].state == 200){
  750. incidentBuildStore.clearIncidentBuildData();
  751. uni.showToast({
  752. icon: 'none',
  753. title: '建单成功',
  754. mask: true,
  755. });
  756. setTimeout(() => {
  757. uni.reLaunch({
  758. url: '/pages/incidentList/incidentList',
  759. })
  760. }, 1500)
  761. }else{
  762. uni.showToast({
  763. icon: 'none',
  764. title: resList[0].msg || '请求数据失败!'
  765. });
  766. }
  767. })
  768. }
  769. }
  770. onLoad((option) => {
  771. // 跳转页面选择了选项
  772. if(handlerStore.handler.data){
  773. Object.assign(dataInfo, handlerStore.handler.data);
  774. console.log(dataInfo)
  775. handlerStore.clearHandlerData();
  776. if(dataInfo.category){
  777. dataInfo.incidentData.category = dataInfo.category;
  778. // 处理责任科室
  779. if(dataInfo.category.branchType == 1){
  780. // 分院区
  781. if(dataInfo.incidentData.branch){
  782. let dutyConfig = dataInfo.category.branchUserGroups.find(v=>v.branchId == dataInfo.incidentData.branch);
  783. if(dutyConfig && dutyConfig.dutyId && dutyConfig.dutyName){
  784. dataInfo.incidentData.duty = {id:dutyConfig.dutyId,dept:dutyConfig.dutyName};
  785. }else{
  786. dataInfo.incidentData.duty = undefined;
  787. }
  788. }else{
  789. dataInfo.incidentData.duty = undefined;
  790. }
  791. }else{
  792. // 不分院区
  793. dataInfo.incidentData.duty = dataInfo.category.dutyDepartment;
  794. }
  795. }
  796. }else if(incidentBuildStore.incidentBuild.data){
  797. // 初始化
  798. Object.assign(dataInfo.incidentData, incidentBuildStore.incidentBuild.data);
  799. if(dataInfo.incidentData.category){
  800. dataInfo.category = dataInfo.incidentData.category;
  801. // 处理责任科室
  802. if(dataInfo.category.branchType == 1){
  803. // 分院区
  804. if(dataInfo.incidentData.branch){
  805. let dutyConfig = dataInfo.category.branchUserGroups.find(v=>v.branchId == dataInfo.incidentData.branch);
  806. if(dutyConfig && dutyConfig.dutyId && dutyConfig.dutyName){
  807. dataInfo.incidentData.duty = {id:dutyConfig.dutyId,dept:dutyConfig.dutyName};
  808. }else{
  809. dataInfo.incidentData.duty = undefined;
  810. }
  811. }else{
  812. dataInfo.incidentData.duty = undefined;
  813. }
  814. }else{
  815. // 不分院区
  816. dataInfo.incidentData.duty = dataInfo.category.dutyDepartment;
  817. }
  818. }
  819. if(dataInfo.incidentData.priority){
  820. dataInfo.incidentData.priority = { id: dataInfo.incidentData.priority };
  821. }
  822. if(dataInfo.incidentData.source){
  823. dataInfo.incidentData.source = { id: dataInfo.incidentData.source };
  824. }
  825. if(dataInfo.incidentData.requester){
  826. dataInfo.incidentData.requester = { id: dataInfo.incidentData.requester }
  827. }
  828. }
  829. dataInfo.tabActiveValue = dataInfo.tabs[0].value;
  830. initForm()
  831. })
  832. </script>
  833. <style lang="scss" scoped>
  834. .handler{
  835. height: 100%;
  836. display: flex;
  837. flex-direction: column;
  838. justify-content: space-between;
  839. .head{
  840. height: 88rpx;
  841. display: flex;
  842. position: fixed;
  843. z-index: 99;
  844. width: 100%;
  845. background-color: #fff;
  846. font-size: 30rpx;
  847. .tab{
  848. flex: 1;
  849. display: flex;
  850. justify-content: center;
  851. align-items: center;
  852. border-bottom: 4rpx solid transparent;
  853. &.active{
  854. color: $uni-primary;
  855. border-color: $uni-primary;
  856. }
  857. }
  858. }
  859. .body{
  860. margin-top: 88rpx;
  861. box-sizing: border-box;
  862. flex: 1;
  863. min-height: 0;
  864. &.bg{
  865. background-color: #F7F7F7;
  866. }
  867. .summaryItem{
  868. &:first-of-type{
  869. .summaryItem_head{
  870. border-bottom: 1rpx solid #DDDDDD;
  871. }
  872. }
  873. .summary_total{
  874. padding: 20rpx 0;
  875. display: flex;
  876. justify-content: center;
  877. align-items: center;
  878. }
  879. .summaryItem_head{
  880. padding: 24rpx;
  881. font-size: 26rpx;
  882. color: #3A3A3A;
  883. }
  884. .summaryItem_body{
  885. font-size: 30rpx;
  886. background-color: #fff;
  887. .summaryItem_bodyItem{
  888. padding: 24rpx;
  889. border-bottom: 1rpx solid #DDDDDD;
  890. .summaryItem_bodyItem_top{
  891. display: flex;
  892. justify-content: space-between;
  893. align-items: center;
  894. .value{
  895. padding-left: 48rpx;
  896. flex-shrink: 0;
  897. }
  898. }
  899. .summaryItem_bodyItem_bottom{
  900. margin-top: 24rpx;
  901. display: flex;
  902. justify-content: space-between;
  903. align-items: center;
  904. .name{
  905. text-align: right;
  906. flex: 1;
  907. }
  908. .value{
  909. width: 240rpx;
  910. text-align: right;
  911. padding-left: 48rpx;
  912. flex-shrink: 0;
  913. }
  914. }
  915. }
  916. }
  917. .summaryItem_foot{
  918. font-size: 30rpx;
  919. background-color: #fff;
  920. &.total{
  921. margin-top: 24rpx;
  922. }
  923. .summaryItem_foot_total{
  924. padding: 24rpx 0;
  925. display: flex;
  926. justify-content: center;
  927. align-items: center;
  928. }
  929. .summaryItem_foot_add{
  930. border-top: 1rpx solid #DDDDDD;
  931. padding: 24rpx 0;
  932. display: flex;
  933. justify-content: center;
  934. align-items: center;
  935. .newicon-icon-test{
  936. font-size: 30rpx;
  937. font-weight: bold;
  938. }
  939. }
  940. }
  941. }
  942. .form_item_column{
  943. padding-top: 24rpx;
  944. min-height: 86rpx;
  945. .form_item{
  946. padding-top: 0;
  947. min-height: auto;
  948. }
  949. }
  950. .form_item{
  951. display: flex;
  952. align-items: center;
  953. padding-top: 24rpx;
  954. min-height: 86rpx;
  955. &.column{
  956. height: auto;
  957. flex-direction: column;
  958. align-items: flex-start;
  959. .title{
  960. margin-right: 0;
  961. }
  962. .value{
  963. margin-top: 10rpx;
  964. padding-left: 20rpx;
  965. box-sizing: border-box;
  966. }
  967. .tips{
  968. padding: 24rpx;
  969. text-align: center;
  970. font-size: 22rpx;
  971. color: #909399;
  972. width: 100%;
  973. box-sizing: border-box;
  974. }
  975. }
  976. .title{
  977. font-size: 26rpx;
  978. display: flex;
  979. align-items: center;
  980. margin-right: 12rpx;
  981. flex-shrink: 0;
  982. &.select{
  983. width: calc(5em + 20rpx);
  984. }
  985. }
  986. .value{
  987. width: 100%;
  988. &.category{
  989. width: 100%;
  990. display: flex;
  991. justify-content: space-between;
  992. align-items: center;
  993. .categoryName{
  994. font-size: 26rpx;
  995. color: #555;
  996. flex: 1;
  997. }
  998. .newicon-weibiaoti2010104{
  999. color: $uni-primary;
  1000. margin-left: 24rpx;
  1001. }
  1002. }
  1003. .imgTips{
  1004. color: #909399;
  1005. font-size: 22rpx;
  1006. }
  1007. }
  1008. .synergeticNames{
  1009. font-size: 26rpx;
  1010. margin-right: 24rpx;
  1011. }
  1012. .synergeticAdd{
  1013. flex-shrink: 0;
  1014. }
  1015. }
  1016. }
  1017. }
  1018. </style>