inspectionExecute.vue 12 KB

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