inspectionScanning.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class="incidentList">
  3. <view class="title">{{dataInfo.inspectionNodeName}}</view>
  4. <view class="head">
  5. <view class="tab" :class="{active: tab.id === dataInfo.tabActiveId}" v-for="tab in dataInfo.tabs" :key="tab.id" @click="clickTab(tab.id)">
  6. {{tab.name}}<text v-if="tab.num !== ''">({{tab.num}})</text>
  7. </view>
  8. </view>
  9. <view class="body" v-if="dataInfo.list.length">
  10. <view class="body_item" v-for="data in dataInfo.list" :key="data.id">
  11. <view class="body_item_head ellipsis-multiline">
  12. <text class="sign" v-if="dataInfo.tabActiveId == 1" :class="{signRed: data.exception == 1}">{{data.exception == 1 ? '异常' : '正常'}}</text>{{ data.inspectionDTO?.inspectionFormDTO?.name }}-{{ data.inspectionNodeDTO?.name }}-{{ data.batchNo }}
  13. </view>
  14. <view class="body_item_content">
  15. <view class="body_item_content_p" v-if="data.inspectionDTO">
  16. <text class="name ellipsis">计划标题:{{data.inspectionDTO.name}}</text>
  17. </view>
  18. <view class="body_item_content_p" v-if="data.signType">
  19. <text class="name ellipsis">签到方式:{{data.signType.name}}</text>
  20. </view>
  21. <view class="body_item_content_p" v-if="data.userDTO || data.groupDTO">
  22. <text class="name ellipsis">执行人或组:{{ data.userDTO?.name || data.groupDTO?.groupName }}</text>
  23. </view>
  24. <view class="body_item_content_p" v-if="data.status || data.addTime">
  25. <text class="name ellipsis">状态:{{ data.status?.name}}</text>
  26. <text class="date">{{formatDate(data.addTime, 'yyyy-MM-dd HH:mm')}}</text>
  27. </view>
  28. </view>
  29. <view class="body_item_foot">
  30. <view class="btns pt0">
  31. <button v-if="data.status.value === '1' && dataInfo.tabActiveId === 0" @click.stop="toInspectionValue(data)" type="default" class="primaryButton btn">执行</button>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="zanwu" v-else>
  37. <text class="newicon newicon-zanwu"></text>
  38. </view>
  39. </view>
  40. </template>
  41. <script setup>
  42. import { startOfDay, endOfDay, format, add } from 'date-fns'
  43. import { ref, reactive, computed } from 'vue'
  44. import { onLoad, onPullDownRefresh, onReachBottom, onTabItemTap } from '@dcloudio/uni-app'
  45. import { SM } from "@/http/http.js"
  46. import { api_getDictionary, api_inspectionTask, api_listCount, api_scanCode, api_inspectionNode } from "@/http/api.js"
  47. import { filterFormatDate } from '@/filters/filterFormatDate.js'
  48. import { computedPriorityStyle } from '@/filters/computedPriorityStyle.js'
  49. import { computedStateStyle } from '@/filters/computedStateStyle.js'
  50. import { computedCurrentLogOverTime } from '@/filters/computedCurrentLogOverTime.js'
  51. import { defaultColor } from '@/static/js/theme.js'
  52. import { useSetTitle } from '@/share/useSetTitle.js'
  53. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  54. import { useLoginUserStore } from '@/stores/loginUser'
  55. import { useIncidentNumStore } from '@/stores/incidentNum'
  56. import { useInspectionListSearchStore } from '@/stores/inspectionListSearch'
  57. import { useInspectionValueStore } from '@/stores/inspectionValue'
  58. import { useSetTabbar } from '@/share/useSetTabbar.js'
  59. useSetTitle();
  60. const loginUserStore = useLoginUserStore();
  61. const incidentNumStore = useIncidentNumStore();
  62. const inspectionListSearchStore = useInspectionListSearchStore();
  63. const inspectionValueStore = useInspectionValueStore();
  64. const { formatDate } = filterFormatDate();
  65. const { priorityStyle } = computedPriorityStyle();
  66. const { stateStyle } = computedStateStyle();
  67. const { currentLogOverTime } = computedCurrentLogOverTime();
  68. const { makePhoneCall } = useMakePhoneCall();
  69. const { setTabbar } = useSetTabbar();
  70. // 主题颜色
  71. const primaryColor = ref(defaultColor)
  72. // 数据
  73. const dataInfo = reactive({
  74. tabs: [{id: 0, name: '巡检工单', value: 'todo', num: ''}, {id: 1, name: '历史工单', value: 'close', num: ''}],
  75. tabActiveId: 0,//当前选择的tab
  76. list: [],//工单列表
  77. idx: 0,//页码
  78. hasMore: true,//是否有更多数据
  79. inspectionNodeDTO: {},
  80. inspectionNodeNewCode: '',//巡检点二维码
  81. inspectionNodeCode: '',//巡检点原始二维码
  82. inspectionNodeName: '',
  83. })
  84. // 巡检项
  85. function toInspectionValue(data){
  86. uni.showLoading({
  87. title: "加载中",
  88. mask: true,
  89. });
  90. let postData = {
  91. code: dataInfo.inspectionNodeNewCode,
  92. taskId: data.id,
  93. account: loginUserStore.loginUser.user.account,
  94. };
  95. // 'inspection|$|1bd0c704-0962-4ed4-b5a6-b5bda3d78231'
  96. // 'inspection|$|bc9f61af-99c8-4c86-88f9-f29dd3fc43c0'
  97. // 'inspection|$|92e7bb9a-5f58-42f6-991a-fcd67247e295'
  98. api_scanCode(postData).then((res) => {
  99. uni.hideLoading();
  100. if (res.status == 200) {
  101. inspectionValueStore.setInspectionValueData(res.data);
  102. uni.navigateTo({
  103. url: `/pages/inspection/inspectionValue/inspectionValue?inspectionExecuteId=${data.id}`
  104. })
  105. } else {
  106. uni.showToast({
  107. icon: 'none',
  108. title: res.msg || '请求数据失败!'
  109. });
  110. }
  111. });
  112. }
  113. // 点击tab
  114. function clickTab(tabId){
  115. dataInfo.tabActiveId = tabId;
  116. getList(0);
  117. }
  118. // 获取列表信息
  119. function getList(idx){
  120. uni.showLoading({
  121. title: "加载中",
  122. mask: true,
  123. });
  124. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  125. if(dataInfo.idx === 0){
  126. dataInfo.list = [];
  127. }
  128. let tabActiveObj = dataInfo.tabs.find(v => v.id == dataInfo.tabActiveId);
  129. let tabActiveObjIndex = dataInfo.tabs.findIndex(v => v.id == dataInfo.tabActiveId);
  130. let postData = {
  131. "idx": dataInfo.idx,
  132. "sum": 10,
  133. "inspectionTask": {
  134. "queryTask": tabActiveObj.value || undefined,
  135. "assignAccount": tabActiveObj.id == 0 ? loginUserStore.loginUser.user.account : undefined,
  136. "inspectionNodeDTO":{
  137. code: dataInfo.inspectionNodeCode,
  138. }
  139. }
  140. }
  141. api_inspectionTask(postData).then(res => {
  142. uni.hideLoading();
  143. uni.stopPullDownRefresh();
  144. if(res.status == 200){
  145. let list = res.list || [];
  146. dataInfo.tabs[tabActiveObjIndex].num = res.totalNum;
  147. if(list.length){
  148. dataInfo.hasMore = true;
  149. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  150. dataInfo.inspectionNodeDTO = list[0].inspectionNodeDTO;
  151. }else{
  152. dataInfo.hasMore = false;
  153. dataInfo.inspectionNodeDTO = {};
  154. }
  155. }else{
  156. uni.showToast({
  157. icon: 'none',
  158. title: res.msg || '请求数据失败!'
  159. });
  160. }
  161. })
  162. getCount(tabActiveObj.id);
  163. }
  164. // 获取列表数量
  165. function getCount(id){
  166. dataInfo.tabs.forEach(v => {
  167. if(v.id != id){
  168. let tabActiveObj = v;
  169. let postData = {
  170. "idx": 0,
  171. "sum": 1,
  172. "inspectionTask": {
  173. "queryTask": tabActiveObj.value || undefined,
  174. "assignAccount": tabActiveObj.id == 0 ? loginUserStore.loginUser.user.account : undefined,
  175. "inspectionNodeDTO":{
  176. code: dataInfo.inspectionNodeCode,
  177. }
  178. }
  179. }
  180. api_inspectionTask(postData).then(res => {
  181. if(res.status == 200){
  182. v.num = res.totalNum;
  183. }else{
  184. uni.showToast({
  185. icon: 'none',
  186. title: res.msg || '请求数据失败!'
  187. });
  188. }
  189. })
  190. }
  191. })
  192. }
  193. onLoad((option) => {
  194. dataInfo.inspectionNodeCode = option.inspectionNodeCode;
  195. dataInfo.inspectionNodeNewCode = option.inspectionNodeNewCode;
  196. dataInfo.inspectionNodeName = option.inspectionNodeName;
  197. getList(0);
  198. })
  199. onPullDownRefresh(() => {
  200. getList(0)
  201. })
  202. onReachBottom(() => {
  203. dataInfo.idx += 1;
  204. if (dataInfo.hasMore) {
  205. getList(); // 当触底时加载更多数据
  206. }
  207. })
  208. </script>
  209. <style lang="scss" scoped>
  210. .toolbar {
  211. position: fixed;
  212. left: 0;
  213. bottom: var(--window-bottom);
  214. z-index: 99;
  215. width: 100%;
  216. height: 88rpx;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. box-sizing: border-box;
  221. border-radius: 4rpx;
  222. background-color: #E5E8ED;
  223. .toolbar-icon {
  224. font-size: 52rpx;
  225. margin-right: 16rpx;
  226. color: #49B856;
  227. }
  228. .toolbar-sao {
  229. font-size: 36rpx;
  230. color: #333;
  231. }
  232. }
  233. .incidentList{
  234. display: flex;
  235. flex-direction: column;
  236. justify-content: space-between;
  237. .title{
  238. width: 100%;
  239. height: 88rpx;
  240. position: fixed;
  241. z-index: 99;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. background-color: #EBEBEB;
  246. font-weight: bold;
  247. font-size: 32rpx;
  248. }
  249. .head{
  250. height: 88rpx;
  251. display: flex;
  252. top: 88rpx;
  253. position: fixed;
  254. z-index: 99;
  255. width: 100%;
  256. background-color: #fff;
  257. font-size: 30rpx;
  258. .tab{
  259. flex: 1;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. border-bottom: 4rpx solid transparent;
  264. &.active{
  265. color: $uni-primary;
  266. border-color: $uni-primary;
  267. }
  268. }
  269. .filter{
  270. width: 84rpx;
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. .newicon-shaixuan{
  275. font-size: 36rpx;
  276. color: #2C2C2C;
  277. }
  278. }
  279. }
  280. .body{
  281. margin-top: 176rpx;
  282. border-top: 6rpx solid #EBEBEB;
  283. .body_item{
  284. border-bottom: 8rpx solid #EBEBEB;
  285. .body_item_head{
  286. word-break: break-all;
  287. text-align: justify;
  288. text-align: left;
  289. margin: 24rpx;
  290. font-size: 30rpx;
  291. .sign{
  292. margin-right: 16rpx;
  293. font-weight: bold;
  294. color: #49B856;
  295. &.signRed{
  296. color: #FF0000;
  297. }
  298. }
  299. }
  300. .body_item_content{
  301. border-top: 1rpx solid #D8D8D8;
  302. padding: 24rpx 24rpx 24rpx 48rpx;
  303. .body_item_content_p{
  304. color: #6A6A6A;
  305. font-size: 26rpx;
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: center;
  309. margin-bottom: 24rpx;
  310. &:last-of-type{
  311. margin-bottom: 0;
  312. }
  313. .name{
  314. flex: 1;
  315. }
  316. .status{
  317. padding: 4rpx 10rpx;
  318. border-radius: 20rpx;
  319. background-color: #DBE8FE;
  320. font-size: 22rpx;
  321. color: #006CF9;
  322. }
  323. .icon_all{
  324. .mic-filled,
  325. .image-filled
  326. {
  327. margin-left: 16rpx;
  328. }
  329. }
  330. }
  331. }
  332. .body_item_foot{
  333. border-top: 1rpx solid #D8D8D8;
  334. font-size: 26rpx;
  335. padding: 24rpx;
  336. .foot_info{
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. .phone-filled{
  341. margin-left: 5rpx;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. .zanwu{
  348. box-sizing: border-box;
  349. margin-top: 176rpx;
  350. border-top: 6rpx solid #EBEBEB;
  351. height: calc(100vh - 88rpx);
  352. display: flex;
  353. justify-content: center;
  354. background-color: #F7F7F7;
  355. .newicon-zanwu{
  356. font-size: 256rpx;
  357. color: #D6D6D6;
  358. margin-top: 140rpx;
  359. }
  360. }
  361. }
  362. </style>