inspectionExecute.vue 12 KB

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