inspectionExecute.vue 15 KB

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