inspectionExecute.vue 15 KB

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