inspectionExecute.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <view class="incidentList">
  3. <view class="head">
  4. <view class="tab" :class="{active: tab.id === dataInfo.tabActiveId}" v-for="tab in dataInfo.tabs" :key="tab.id" @click="clickTab(tab.id)">
  5. {{tab.name}}<text v-if="tab.num !== ''">({{tab.num}})</text>
  6. </view>
  7. <view class="filter" @click="filterClick">
  8. <text class="newicon newicon-shaixuan"></text>
  9. </view>
  10. </view>
  11. <view class="body" v-if="dataInfo.list.length">
  12. <view class="body_item" v-for="data in dataInfo.list" :key="data.id" @click="toInspectionTaskDetail(data)">
  13. <view class="body_item_head ellipsis-multiline">
  14. <text class="sign" v-if="data.status.value == 2" :class="{signRed: data.exception == 1}">{{data.exception == 1 ? '异常' : '正常'}}</text>{{ data.inspectionDTO?.inspectionFormDTO?.name }}-{{ data.inspectionNodeDTO?.name }}-{{ data.batchNo }}
  15. </view>
  16. <view class="body_item_content">
  17. <view class="body_item_content_p" v-if="data.inspectionDTO">
  18. <text class="name ellipsis">计划标题:{{data.inspectionDTO.name}}</text>
  19. </view>
  20. <view class="body_item_content_p" v-if="data.signType">
  21. <text class="name ellipsis">签到方式:{{data.signType.name}}</text>
  22. </view>
  23. <view class="body_item_content_p" v-if="data.userDTO || data.groupDTO">
  24. <text class="name ellipsis">执行人或组:{{ data.userDTO?.name || data.groupDTO?.groupName }}</text>
  25. </view>
  26. <view class="body_item_content_p" v-if="data.status || data.addTime">
  27. <text class="name ellipsis">状态:{{ data.status?.name}}</text>
  28. <text class="date">{{formatDate(data.addTime, 'yyyy-MM-dd HH:mm')}}</text>
  29. </view>
  30. <view class="body_item_content_p" v-if="data.incidentDTO">
  31. <text class="name ellipsis">故障单号:{{ data.incidentDTO.incidentsign}}</text>
  32. <text class="date">{{ data.incidentDTO.state?.name}}</text>
  33. </view>
  34. </view>
  35. <view class="body_item_foot">
  36. <view class="btns pt0">
  37. <button v-if="data.status.value === '1'" @click.stop="toInspectionValue(data)" type="default" class="primaryButton btn">执行</button>
  38. <button v-if="data.status.value === '2' && data.exception == 1 && !data.incidentId && data.inspectionDTO.inspectionFormDTO.showOrder == 1" @click.stop="toBuildIncident(data)" type="default" class="primaryButton btn">生成维修单</button>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="zanwu" v-else>
  44. <text class="newicon newicon-zanwu"></text>
  45. </view>
  46. <view class="toolbar" @click="scanning()">
  47. <text class="toolbar-icon newicon newicon-saoma"></text>
  48. <text class="toolbar-sao">扫一扫</text>
  49. </view>
  50. <InspectionListFilter v-if="dataInfo.isFilter" @cancelEmit="cancelFilter" @confirmEmit="conformFilter" :evt="dataInfo.evtFilter"></InspectionListFilter>
  51. </view>
  52. </template>
  53. <script setup>
  54. import InspectionListFilter from '@/components/InspectionListFilter.vue';
  55. import { startOfDay, endOfDay, format, add } from 'date-fns'
  56. import { ref, reactive, computed } from 'vue'
  57. import { onLoad, onPullDownRefresh, onReachBottom, onTabItemTap } from '@dcloudio/uni-app'
  58. import { SM } from "@/http/http.js"
  59. import { api_getDictionary, api_inspectionTask, api_listCount, api_scanCode, api_scanNodeCode, api_listAttachment } from "@/http/api.js"
  60. import { filterFormatDate } from '@/filters/filterFormatDate.js'
  61. import { computedPriorityStyle } from '@/filters/computedPriorityStyle.js'
  62. import { computedStateStyle } from '@/filters/computedStateStyle.js'
  63. import { computedCurrentLogOverTime } from '@/filters/computedCurrentLogOverTime.js'
  64. import { defaultColor } from '@/static/js/theme.js'
  65. import { useSetTitle } from '@/share/useSetTitle.js'
  66. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  67. import { useLoginUserStore } from '@/stores/loginUser'
  68. import { useIncidentNumStore } from '@/stores/incidentNum'
  69. import { useInspectionListSearchStore } from '@/stores/inspectionListSearch'
  70. import { useInspectionValueStore } from '@/stores/inspectionValue'
  71. import { useSetTabbar } from '@/share/useSetTabbar.js'
  72. import { useIncidentBuildStore } from '@/stores/incidentBuild'
  73. useSetTitle();
  74. const loginUserStore = useLoginUserStore();
  75. const incidentNumStore = useIncidentNumStore();
  76. const inspectionListSearchStore = useInspectionListSearchStore();
  77. const inspectionValueStore = useInspectionValueStore();
  78. const { formatDate } = filterFormatDate();
  79. const { priorityStyle } = computedPriorityStyle();
  80. const { stateStyle } = computedStateStyle();
  81. const { currentLogOverTime } = computedCurrentLogOverTime();
  82. const { makePhoneCall } = useMakePhoneCall();
  83. const { setTabbar } = useSetTabbar();
  84. const incidentBuildStore = useIncidentBuildStore();
  85. // 主题颜色
  86. const primaryColor = ref(defaultColor)
  87. const assignFlag = ref(false);//指派权限
  88. const qiangdan = ref(false);//接单权限
  89. // 转换协同人
  90. const computedSynergetic = computed(() => (synergetic) => {
  91. return (synergetic && synergetic.length) ? synergetic.map(v => v.name).join(',') : ''
  92. })
  93. // 故障来源列表
  94. const defaultSourceValue = ref();
  95. // 数据
  96. const dataInfo = reactive({
  97. tabs: [{id: 0, name: '全部', value: 'all', num: ''}],
  98. tabActiveId: 0,//当前选择的tab
  99. list: [],//工单列表
  100. idx: 0,//页码
  101. hasMore: true,//是否有更多数据
  102. isFilter: false,//筛选框开关
  103. evtFilter: {
  104. area: {id: 0, area: '全部'},
  105. inspectionForm: {id: 0, name: '全部'},
  106. acceptDate: [],
  107. },//筛选框数据
  108. })
  109. // 详情
  110. function toInspectionTaskDetail(data){
  111. uni.navigateTo({
  112. url: `/pages/inspection/inspectionDetail/inspectionDetail?inspectionTaskId=${data.id}`
  113. })
  114. }
  115. // 扫一扫
  116. function scanning(){
  117. uni.showLoading({
  118. title: "加载中",
  119. mask: true,
  120. });
  121. SM().then((ress1) => {
  122. // ----------------------------------
  123. let postData = {
  124. queryTask: 'todo',
  125. code: ress1,
  126. idx: 0,
  127. sum: 1,
  128. assignAccount: loginUserStore.loginUser.user.account,
  129. };
  130. api_scanNodeCode(postData).then((res) => {
  131. if (res.status == 200) {
  132. if(res.totalNum == 1){
  133. let data = res.list[0];
  134. let postData = {
  135. code: ress1,
  136. taskId: data.id,
  137. account: loginUserStore.loginUser.user.account,
  138. };
  139. api_scanCode(postData).then((res) => {
  140. uni.hideLoading();
  141. if (res.status == 200) {
  142. inspectionValueStore.setInspectionValueData(res.data);
  143. uni.navigateTo({
  144. url: `/pages/inspection/inspectionValue/inspectionValue?inspectionExecuteId=${data.id}`
  145. })
  146. } else {
  147. uni.showToast({
  148. icon: 'none',
  149. title: res.msg || '请求数据失败!'
  150. });
  151. }
  152. });
  153. }else{
  154. uni.hideLoading();
  155. uni.navigateTo({
  156. url: `/pages/inspection/inspectionScanning/inspectionScanning?inspectionNodeNewCode=${ress1}&inspectionNodeCode=${res.data.code}&inspectionNodeName=${res.data.name}`
  157. })
  158. }
  159. } else {
  160. uni.hideLoading();
  161. uni.showToast({
  162. icon: 'none',
  163. title: res.msg || '请求数据失败!'
  164. });
  165. }
  166. });
  167. }).catch(err=>{
  168. uni.hideLoading();
  169. });
  170. }
  171. // 获取故障来源列表
  172. function getSources(){
  173. let postData = {
  174. "key": 'incident_source',
  175. "type": "list",
  176. };
  177. api_getDictionary(postData).then(res => {
  178. res = res || [];
  179. let discover = res.find(v => v.value === 'inspection');
  180. if(discover){
  181. defaultSourceValue.value = discover.id;
  182. }
  183. })
  184. }
  185. // 新建事件
  186. async function toBuildIncident(res){
  187. incidentBuildStore.clearIncidentBuildData();
  188. let imgObj = res.inspectionFormValuesList.find(v => v.inspectionFormItemDTO.type.value == 7);
  189. let repairImgList = [];
  190. if(imgObj){
  191. let result = await api_listAttachment('inspection', res.id);
  192. result.data = result.data || [];
  193. result.data = result.data.filter(v => v.recordId == imgObj.itemId);
  194. result.data = result.data.map(v => ({
  195. url: location.origin + "/file" + v.relativeFilePath,
  196. path: location.origin + "/file" + v.relativeFilePath,
  197. size: v.size,
  198. name: v.name,
  199. extname: v.suffix,
  200. }))
  201. repairImgList = result.data;
  202. }
  203. console.log(repairImgList, 'repairImgList')
  204. let incidentData = {
  205. place: res.inspectionNodeDTO.floorDTO,
  206. houseNumber: res.inspectionNodeDTO.address,
  207. source: defaultSourceValue.value,
  208. description: res.inspectionFormValuesList.filter(v => v.exception == 1).map(v => `${v.name}填写值为${v.valuex ? v.valuex : (v.formItemConfigList ? v.formItemConfigList.map(vv => vv.name).join(',') : '')}`).join(';'),
  209. requester: loginUserStore.loginUser.user,
  210. branch: loginUserStore.loginUser.user.currentHospital.parent ? loginUserStore.loginUser.user.currentHospital.parent.id : loginUserStore.loginUser.user.currentHospital.id,
  211. contacts: loginUserStore.loginUser.user.name,
  212. contactsInformation: loginUserStore.loginUser.user.phone,
  213. category: res.inspectionDTO.inspectionFormDTO.categoryDTO,
  214. department: res.inspectionDTO.inspectionFormDTO.repairDeptDTO,
  215. priority: res.inspectionDTO.inspectionFormDTO.priorityDTO,
  216. repairImgList,
  217. inspectionTaskId: res.id,
  218. }
  219. console.log(incidentData, 'incidentData')
  220. incidentBuildStore.setIncidentBuildData(incidentData, 'buildIncident');
  221. uni.navigateTo({
  222. url: `/pages/buildIncident/buildIncident?type=inspection`
  223. })
  224. }
  225. // 巡检项
  226. function toInspectionValue(data){
  227. uni.showLoading({
  228. title: "加载中",
  229. mask: true,
  230. });
  231. // 'inspection|$|1bd0c704-0962-4ed4-b5a6-b5bda3d78231'
  232. // 'inspection|$|bc9f61af-99c8-4c86-88f9-f29dd3fc43c0'
  233. // 'inspection|$|92e7bb9a-5f58-42f6-991a-fcd67247e295'
  234. SM().then((ress1) => {
  235. let postData = {
  236. code: ress1,
  237. taskId: data.id,
  238. account: loginUserStore.loginUser.user.account,
  239. };
  240. api_scanCode(postData).then((res) => {
  241. uni.hideLoading();
  242. if (res.status == 200) {
  243. inspectionValueStore.setInspectionValueData(res.data);
  244. uni.navigateTo({
  245. url: `/pages/inspection/inspectionValue/inspectionValue?inspectionExecuteId=${data.id}`
  246. })
  247. } else {
  248. uni.showToast({
  249. icon: 'none',
  250. title: res.msg || '请求数据失败!'
  251. });
  252. }
  253. });
  254. }).catch(err=>{
  255. uni.hideLoading();
  256. });
  257. }
  258. // 获取tab选项
  259. function getTabs(){
  260. uni.showLoading({
  261. title: "加载中",
  262. mask: true,
  263. });
  264. api_getDictionary({
  265. "type": "list",
  266. "key": "inspection_task_status"
  267. }).then(res => {
  268. uni.hideLoading();
  269. let list = res || [];
  270. let todo = list.find(v => v.value === '1');
  271. let close = list.find(v => v.value === '2');
  272. dataInfo.tabs = [{id: 0, name: '全部', value: 'all', num: ''}];
  273. todo && dataInfo.tabs.push({...todo, ...{num: '', value: 'todo'}});
  274. close && dataInfo.tabs.push({...close, ...{num: '', value: 'close'}});
  275. getList(0);
  276. })
  277. }
  278. // 点击tab
  279. function clickTab(tabId){
  280. dataInfo.tabActiveId = tabId;
  281. getList(0);
  282. }
  283. // 点击筛选
  284. function filterClick(){
  285. dataInfo.isFilter = true;
  286. }
  287. // 确认筛选
  288. function conformFilter(evtFilter){
  289. dataInfo.evtFilter = evtFilter;
  290. dataInfo.isFilter = false;
  291. getList(0);
  292. }
  293. // 关闭筛选
  294. function cancelFilter(){
  295. dataInfo.isFilter = false;
  296. }
  297. // 获取列表信息
  298. function getList(idx){
  299. uni.showLoading({
  300. title: "加载中",
  301. mask: true,
  302. });
  303. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  304. if(dataInfo.idx === 0){
  305. dataInfo.list = [];
  306. }
  307. let tabActiveObj = dataInfo.tabs.find(v => v.id == dataInfo.tabActiveId);
  308. let postData = {
  309. "idx": dataInfo.idx,
  310. "sum": 10,
  311. "account": loginUserStore.loginUser.user.account,
  312. "inspectionTask": {
  313. "queryTask": tabActiveObj ? tabActiveObj.value : undefined,
  314. "assignAccount": loginUserStore.loginUser.user.account,
  315. }
  316. }
  317. if(dataInfo.evtFilter && dataInfo.evtFilter.inspectionForm && dataInfo.evtFilter.inspectionForm.id){
  318. postData.inspectionTask.formId = dataInfo.evtFilter.inspectionForm.id;
  319. }
  320. if(dataInfo.evtFilter && Array.isArray(dataInfo.evtFilter.acceptDate) && dataInfo.evtFilter.acceptDate.length){
  321. postData.inspectionTask.addTimeStart = format(startOfDay(new Date(dataInfo.evtFilter.acceptDate[0])), 'yyyy-MM-dd HH:mm:ss');
  322. postData.inspectionTask.addTimeEnd = format(endOfDay(dataInfo.evtFilter.acceptDate[1]), 'yyyy-MM-dd HH:mm:ss');
  323. }
  324. if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
  325. postData.inspectionTask.buildId = dataInfo.evtFilter.area.id;
  326. }
  327. inspectionListSearchStore.setInspectionListSearchData(dataInfo);
  328. api_inspectionTask(postData).then(res => {
  329. uni.hideLoading();
  330. uni.stopPullDownRefresh();
  331. if(res.status == 200){
  332. let list = res.list || [];
  333. if(list.length){
  334. dataInfo.hasMore = true;
  335. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  336. }else{
  337. dataInfo.hasMore = false;
  338. }
  339. }else{
  340. uni.showToast({
  341. icon: 'none',
  342. title: res.msg || '请求数据失败!'
  343. });
  344. }
  345. })
  346. getCount(postData.inspectionTask);
  347. }
  348. // 获取列表数量
  349. function getCount(inspectionTask = {}){
  350. let postData = {
  351. account: loginUserStore.loginUser.user.account,
  352. taskList: [],
  353. }
  354. dataInfo.tabs.forEach(v => {
  355. postData.taskList.push({...inspectionTask, ...{ queryTask: v.value }});
  356. })
  357. api_listCount(postData).then(res => {
  358. if(res.state == 200){
  359. let myData = res.data || [];
  360. dataInfo.tabs.forEach((v) => {
  361. v.num = myData[v.value];
  362. })
  363. }else{
  364. uni.showToast({
  365. icon: 'none',
  366. title: res.msg || '请求数据失败!'
  367. });
  368. }
  369. })
  370. }
  371. // 初始化
  372. function onLoadFn(){
  373. // 我的-数量跳转
  374. if(inspectionListSearchStore.inspectionListSearch.data){
  375. // 缓存的搜索条件
  376. Object.assign(dataInfo, inspectionListSearchStore.inspectionListSearch.data);
  377. }
  378. getTabs();
  379. }
  380. onLoad((option) => {
  381. getSources();
  382. for(let i = 0; i<7; i++){
  383. setTabbar(i)
  384. }
  385. onLoadFn();
  386. })
  387. onTabItemTap(e => {
  388. onLoadFn();
  389. })
  390. onPullDownRefresh(() => {
  391. getList(0)
  392. })
  393. onReachBottom(() => {
  394. dataInfo.idx += 1;
  395. if (dataInfo.hasMore) {
  396. getList(); // 当触底时加载更多数据
  397. }
  398. })
  399. </script>
  400. <style lang="scss" scoped>
  401. .toolbar {
  402. position: fixed;
  403. left: 0;
  404. bottom: var(--window-bottom);
  405. z-index: 99;
  406. width: 100%;
  407. height: 88rpx;
  408. display: flex;
  409. justify-content: center;
  410. align-items: center;
  411. box-sizing: border-box;
  412. border-radius: 4rpx;
  413. background-color: #E5E8ED;
  414. .toolbar-icon {
  415. font-size: 52rpx;
  416. margin-right: 16rpx;
  417. color: #49B856;
  418. }
  419. .toolbar-sao {
  420. font-size: 36rpx;
  421. color: #333;
  422. }
  423. }
  424. page{
  425. height: calc(100vh - var(--window-bottom));
  426. }
  427. .incidentList{
  428. display: flex;
  429. flex-direction: column;
  430. justify-content: space-between;
  431. .head{
  432. height: 88rpx;
  433. display: flex;
  434. position: fixed;
  435. z-index: 99;
  436. width: 100%;
  437. background-color: #fff;
  438. font-size: 30rpx;
  439. .tab{
  440. flex: 1;
  441. display: flex;
  442. justify-content: center;
  443. align-items: center;
  444. border-bottom: 4rpx solid transparent;
  445. &.active{
  446. color: $uni-primary;
  447. border-color: $uni-primary;
  448. }
  449. }
  450. .filter{
  451. width: 84rpx;
  452. display: flex;
  453. justify-content: center;
  454. align-items: center;
  455. .newicon-shaixuan{
  456. font-size: 36rpx;
  457. color: #2C2C2C;
  458. }
  459. }
  460. }
  461. .body{
  462. margin-bottom: calc(var(--window-bottom) + 88rpx);
  463. margin-top: 88rpx;
  464. border-top: 6rpx solid #EBEBEB;
  465. .body_item{
  466. border-bottom: 8rpx solid #EBEBEB;
  467. .body_item_head{
  468. word-break: break-all;
  469. text-align: justify;
  470. text-align: left;
  471. margin: 24rpx;
  472. font-size: 30rpx;
  473. .sign{
  474. margin-right: 16rpx;
  475. font-weight: bold;
  476. color: #49B856;
  477. &.signRed{
  478. color: #FF0000;
  479. }
  480. }
  481. }
  482. .body_item_content{
  483. border-top: 1rpx solid #D8D8D8;
  484. padding: 24rpx 24rpx 24rpx 48rpx;
  485. .body_item_content_p{
  486. color: #6A6A6A;
  487. font-size: 26rpx;
  488. display: flex;
  489. justify-content: space-between;
  490. align-items: center;
  491. margin-bottom: 24rpx;
  492. &:last-of-type{
  493. margin-bottom: 0;
  494. }
  495. .name{
  496. flex: 1;
  497. }
  498. .status{
  499. padding: 4rpx 10rpx;
  500. border-radius: 20rpx;
  501. background-color: #DBE8FE;
  502. font-size: 22rpx;
  503. color: #006CF9;
  504. }
  505. .icon_all{
  506. .mic-filled,
  507. .image-filled
  508. {
  509. margin-left: 16rpx;
  510. }
  511. }
  512. }
  513. }
  514. .body_item_foot{
  515. border-top: 1rpx solid #D8D8D8;
  516. font-size: 26rpx;
  517. padding: 24rpx;
  518. .foot_info{
  519. display: flex;
  520. justify-content: space-between;
  521. align-items: center;
  522. .phone-filled{
  523. margin-left: 5rpx;
  524. }
  525. }
  526. }
  527. }
  528. }
  529. .zanwu{
  530. box-sizing: border-box;
  531. margin-bottom: calc(var(--window-bottom) + 88rpx);
  532. margin-top: 88rpx;
  533. border-top: 6rpx solid #EBEBEB;
  534. height: calc(100vh - var(--window-bottom) - 176rpx);
  535. display: flex;
  536. justify-content: center;
  537. background-color: #F7F7F7;
  538. .newicon-zanwu{
  539. font-size: 256rpx;
  540. color: #D6D6D6;
  541. margin-top: 140rpx;
  542. }
  543. }
  544. }
  545. </style>