inspectionExecute.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. // 'inspection|$|1bd0c704-0962-4ed4-b5a6-b5bda3d78231'
  103. SM().then((ress1) => {
  104. let postData = {
  105. code: ress1,
  106. taskId: data.id,
  107. account: loginUserStore.loginUser.user.account,
  108. };
  109. api_scanCode(postData).then((res) => {
  110. uni.hideLoading();
  111. if (res.status == 200) {
  112. inspectionValueStore.setInspectionValueData(res.data);
  113. uni.navigateTo({
  114. url: `/pages/inspection/inspectionValue/inspectionValue?inspectionExecuteId=${data.id}`
  115. })
  116. } else {
  117. uni.showToast({
  118. icon: 'none',
  119. title: res.msg || '请求数据失败!'
  120. });
  121. }
  122. });
  123. }).catch(err=>{
  124. uni.hideLoading();
  125. });
  126. }
  127. // 获取tab选项
  128. function getTabs(){
  129. uni.showLoading({
  130. title: "加载中",
  131. mask: true,
  132. });
  133. api_hsms_getDictionary({
  134. "type": "list",
  135. "key": "inspection_task_status"
  136. }).then(res => {
  137. uni.hideLoading();
  138. let list = res.data || [];
  139. let todo = list.find(v => v.value === '1');
  140. let close = list.find(v => v.value === '2');
  141. dataInfo.tabs = [{id: 0, name: '全部', value: 'all', num: ''}];
  142. todo && dataInfo.tabs.push({...todo, ...{num: '', value: 'todo'}});
  143. close && dataInfo.tabs.push({...close, ...{num: '', value: 'close'}});
  144. getList(0);
  145. })
  146. }
  147. // 点击tab
  148. function clickTab(tabId){
  149. dataInfo.tabActiveId = tabId;
  150. getList(0);
  151. }
  152. // 点击筛选
  153. function filterClick(){
  154. dataInfo.isFilter = true;
  155. }
  156. // 确认筛选
  157. function conformFilter(evtFilter){
  158. dataInfo.evtFilter = evtFilter;
  159. dataInfo.isFilter = false;
  160. getList(0);
  161. }
  162. // 关闭筛选
  163. function cancelFilter(){
  164. dataInfo.isFilter = false;
  165. }
  166. // 获取列表信息
  167. function getList(idx){
  168. uni.showLoading({
  169. title: "加载中",
  170. mask: true,
  171. });
  172. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  173. if(dataInfo.idx === 0){
  174. dataInfo.list = [];
  175. }
  176. let tabActiveObj = dataInfo.tabs.find(v => v.id == dataInfo.tabActiveId);
  177. let postData = {
  178. "idx": dataInfo.idx,
  179. "sum": 10,
  180. "account": loginUserStore.loginUser.user.account,
  181. "inspectionTask": {
  182. "queryTask": tabActiveObj ? tabActiveObj.value : undefined,
  183. "assignAccount": loginUserStore.loginUser.user.account,
  184. }
  185. }
  186. if(dataInfo.evtFilter && dataInfo.evtFilter.inspectionForm && dataInfo.evtFilter.inspectionForm.id){
  187. postData.inspectionTask.formId = dataInfo.evtFilter.inspectionForm.id;
  188. }
  189. if(dataInfo.evtFilter && Array.isArray(dataInfo.evtFilter.acceptDate) && dataInfo.evtFilter.acceptDate.length){
  190. postData.inspectionTask.addTimeStart = format(startOfDay(new Date(dataInfo.evtFilter.acceptDate[0])), 'yyyy-MM-dd HH:mm:ss');
  191. postData.inspectionTask.addTimeEnd = format(endOfDay(dataInfo.evtFilter.acceptDate[1]), 'yyyy-MM-dd HH:mm:ss');
  192. }
  193. if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
  194. postData.inspectionTask.buildId = dataInfo.evtFilter.area.id;
  195. }
  196. inspectionListSearchStore.setInspectionListSearchData(dataInfo);
  197. api_inspectionTask(postData).then(res => {
  198. uni.hideLoading();
  199. uni.stopPullDownRefresh();
  200. if(res.status == 200){
  201. let list = res.list || [];
  202. if(list.length){
  203. dataInfo.hasMore = true;
  204. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  205. }else{
  206. dataInfo.hasMore = false;
  207. }
  208. }else{
  209. uni.showToast({
  210. icon: 'none',
  211. title: res.msg || '请求数据失败!'
  212. });
  213. }
  214. })
  215. getCount(postData.inspectionTask);
  216. }
  217. // 获取列表数量
  218. function getCount(inspectionTask = {}){
  219. let postData = {
  220. account: loginUserStore.loginUser.user.account,
  221. taskList: [],
  222. }
  223. dataInfo.tabs.forEach(v => {
  224. postData.taskList.push({...inspectionTask, ...{ queryTask: v.value }});
  225. })
  226. api_listCount(postData).then(res => {
  227. if(res.state == 200){
  228. let myData = res.data || [];
  229. dataInfo.tabs.forEach((v) => {
  230. v.num = myData[v.value];
  231. })
  232. }else{
  233. uni.showToast({
  234. icon: 'none',
  235. title: res.msg || '请求数据失败!'
  236. });
  237. }
  238. })
  239. }
  240. // 初始化
  241. function onLoadFn(){
  242. // 我的-数量跳转
  243. if(inspectionListSearchStore.inspectionListSearch.data){
  244. // 缓存的搜索条件
  245. Object.assign(dataInfo, inspectionListSearchStore.inspectionListSearch.data);
  246. }
  247. getTabs();
  248. }
  249. onLoad((option) => {
  250. // 巡检tabbar
  251. setTabbar(1);
  252. onLoadFn();
  253. })
  254. onTabItemTap(e => {
  255. onLoadFn();
  256. })
  257. onPullDownRefresh(() => {
  258. getList(0)
  259. })
  260. onReachBottom(() => {
  261. dataInfo.idx += 1;
  262. if (dataInfo.hasMore) {
  263. getList(); // 当触底时加载更多数据
  264. }
  265. })
  266. </script>
  267. <style lang="scss" scoped>
  268. page{
  269. height: calc(100vh - var(--window-bottom));
  270. }
  271. .incidentList{
  272. display: flex;
  273. flex-direction: column;
  274. justify-content: space-between;
  275. .head{
  276. height: 88rpx;
  277. display: flex;
  278. position: fixed;
  279. z-index: 99;
  280. width: 100%;
  281. background-color: #fff;
  282. font-size: 30rpx;
  283. .tab{
  284. flex: 1;
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. border-bottom: 4rpx solid transparent;
  289. &.active{
  290. color: $uni-primary;
  291. border-color: $uni-primary;
  292. }
  293. }
  294. .filter{
  295. width: 84rpx;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. .newicon-shaixuan{
  300. font-size: 36rpx;
  301. color: #2C2C2C;
  302. }
  303. }
  304. }
  305. .body{
  306. margin-bottom: var(--window-bottom);
  307. margin-top: 88rpx;
  308. border-top: 6rpx solid #EBEBEB;
  309. .body_item{
  310. border-bottom: 8rpx solid #EBEBEB;
  311. .body_item_head{
  312. word-break: break-all;
  313. text-align: justify;
  314. text-align: left;
  315. margin: 24rpx;
  316. font-size: 30rpx;
  317. }
  318. .body_item_content{
  319. border-top: 1rpx solid #D8D8D8;
  320. padding: 24rpx 24rpx 24rpx 48rpx;
  321. .body_item_content_p{
  322. color: #6A6A6A;
  323. font-size: 26rpx;
  324. display: flex;
  325. justify-content: space-between;
  326. align-items: center;
  327. margin-bottom: 24rpx;
  328. &:last-of-type{
  329. margin-bottom: 0;
  330. }
  331. .name{
  332. flex: 1;
  333. }
  334. .status{
  335. padding: 4rpx 10rpx;
  336. border-radius: 20rpx;
  337. background-color: #DBE8FE;
  338. font-size: 22rpx;
  339. color: #006CF9;
  340. }
  341. .icon_all{
  342. .mic-filled,
  343. .image-filled
  344. {
  345. margin-left: 16rpx;
  346. }
  347. }
  348. }
  349. }
  350. .body_item_foot{
  351. border-top: 1rpx solid #D8D8D8;
  352. font-size: 26rpx;
  353. padding: 24rpx;
  354. .foot_info{
  355. display: flex;
  356. justify-content: space-between;
  357. align-items: center;
  358. .phone-filled{
  359. margin-left: 5rpx;
  360. }
  361. }
  362. }
  363. }
  364. }
  365. .zanwu{
  366. box-sizing: border-box;
  367. margin-bottom: var(--window-bottom);
  368. margin-top: 88rpx;
  369. border-top: 6rpx solid #EBEBEB;
  370. height: calc(100vh - var(--window-bottom) - 88rpx);
  371. display: flex;
  372. justify-content: center;
  373. background-color: #F7F7F7;
  374. .newicon-zanwu{
  375. font-size: 256rpx;
  376. color: #D6D6D6;
  377. margin-top: 140rpx;
  378. }
  379. }
  380. }
  381. </style>