assign.vue 34 KB

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