inspectionScanning.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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: 'all', num: ''}, {id: 1, name: '历史工单', value: '', num: ''}],
  75. tabActiveId: 0,//当前选择的tab
  76. list: [],//工单列表
  77. idx: 0,//页码
  78. hasMore: true,//是否有更多数据
  79. inspectionNodeDTO: {},
  80. inspectionNodeCode: '',
  81. inspectionNodeName: '',
  82. })
  83. // 巡检项
  84. function toInspectionValue(data){
  85. uni.showLoading({
  86. title: "加载中",
  87. mask: true,
  88. });
  89. // 'inspection|$|1bd0c704-0962-4ed4-b5a6-b5bda3d78231'
  90. // 'inspection|$|bc9f61af-99c8-4c86-88f9-f29dd3fc43c0'
  91. // 'inspection|$|92e7bb9a-5f58-42f6-991a-fcd67247e295'
  92. SM().then((ress1) => {
  93. let postData = {
  94. code: ress1,
  95. taskId: data.id,
  96. account: loginUserStore.loginUser.user.account,
  97. };
  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. }).catch(err=>{
  113. uni.hideLoading();
  114. });
  115. }
  116. // 点击tab
  117. function clickTab(tabId){
  118. dataInfo.tabActiveId = tabId;
  119. getList(0);
  120. }
  121. // 获取列表信息
  122. function getList(idx){
  123. uni.showLoading({
  124. title: "加载中",
  125. mask: true,
  126. });
  127. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  128. if(dataInfo.idx === 0){
  129. dataInfo.list = [];
  130. }
  131. let tabActiveObj = dataInfo.tabs.find(v => v.id == dataInfo.tabActiveId);
  132. let tabActiveObjIndex = dataInfo.tabs.findIndex(v => v.id == dataInfo.tabActiveId);
  133. let postData = {
  134. "idx": dataInfo.idx,
  135. "sum": 10,
  136. "inspectionTask": {
  137. "queryTask": tabActiveObj.value || undefined,
  138. "assignAccount": tabActiveObj.id == 0 ? loginUserStore.loginUser.user.account : undefined,
  139. "inspectionNodeDTO":{
  140. code: dataInfo.inspectionNodeCode,
  141. }
  142. }
  143. }
  144. api_inspectionTask(postData).then(res => {
  145. uni.hideLoading();
  146. uni.stopPullDownRefresh();
  147. if(res.status == 200){
  148. let list = res.list || [];
  149. dataInfo.tabs[tabActiveObjIndex].num = res.totalNum;
  150. if(list.length){
  151. dataInfo.hasMore = true;
  152. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  153. dataInfo.inspectionNodeDTO = list[0].inspectionNodeDTO;
  154. }else{
  155. dataInfo.hasMore = false;
  156. dataInfo.inspectionNodeDTO = {};
  157. }
  158. }else{
  159. uni.showToast({
  160. icon: 'none',
  161. title: res.msg || '请求数据失败!'
  162. });
  163. }
  164. })
  165. getCount(tabActiveObj.id);
  166. }
  167. // 获取列表数量
  168. function getCount(id){
  169. dataInfo.tabs.forEach(v => {
  170. if(v.id != id){
  171. let tabActiveObj = v;
  172. let postData = {
  173. "idx": 0,
  174. "sum": 1,
  175. "inspectionTask": {
  176. "queryTask": tabActiveObj.value || undefined,
  177. "assignAccount": tabActiveObj.id == 0 ? loginUserStore.loginUser.user.account : undefined,
  178. "inspectionNodeDTO":{
  179. code: dataInfo.inspectionNodeCode,
  180. }
  181. }
  182. }
  183. api_inspectionTask(postData).then(res => {
  184. if(res.status == 200){
  185. v.num = res.totalNum;
  186. }else{
  187. uni.showToast({
  188. icon: 'none',
  189. title: res.msg || '请求数据失败!'
  190. });
  191. }
  192. })
  193. }
  194. })
  195. }
  196. onLoad((option) => {
  197. dataInfo.inspectionNodeCode = option.inspectionNodeCode;
  198. dataInfo.inspectionNodeName = option.inspectionNodeName;
  199. getList(0);
  200. })
  201. onPullDownRefresh(() => {
  202. getList(0)
  203. })
  204. onReachBottom(() => {
  205. dataInfo.idx += 1;
  206. if (dataInfo.hasMore) {
  207. getList(); // 当触底时加载更多数据
  208. }
  209. })
  210. </script>
  211. <style lang="scss" scoped>
  212. .toolbar {
  213. position: fixed;
  214. left: 0;
  215. bottom: var(--window-bottom);
  216. z-index: 99;
  217. width: 100%;
  218. height: 88rpx;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. box-sizing: border-box;
  223. border-radius: 4rpx;
  224. background-color: #E5E8ED;
  225. .toolbar-icon {
  226. font-size: 52rpx;
  227. margin-right: 16rpx;
  228. color: #49B856;
  229. }
  230. .toolbar-sao {
  231. font-size: 36rpx;
  232. color: #333;
  233. }
  234. }
  235. .incidentList{
  236. display: flex;
  237. flex-direction: column;
  238. justify-content: space-between;
  239. .title{
  240. width: 100%;
  241. height: 88rpx;
  242. position: fixed;
  243. z-index: 99;
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. background-color: #EBEBEB;
  248. font-weight: bold;
  249. font-size: 32rpx;
  250. }
  251. .head{
  252. height: 88rpx;
  253. display: flex;
  254. top: 88rpx;
  255. position: fixed;
  256. z-index: 99;
  257. width: 100%;
  258. background-color: #fff;
  259. font-size: 30rpx;
  260. .tab{
  261. flex: 1;
  262. display: flex;
  263. justify-content: center;
  264. align-items: center;
  265. border-bottom: 4rpx solid transparent;
  266. &.active{
  267. color: $uni-primary;
  268. border-color: $uni-primary;
  269. }
  270. }
  271. .filter{
  272. width: 84rpx;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. .newicon-shaixuan{
  277. font-size: 36rpx;
  278. color: #2C2C2C;
  279. }
  280. }
  281. }
  282. .body{
  283. margin-top: 176rpx;
  284. border-top: 6rpx solid #EBEBEB;
  285. .body_item{
  286. border-bottom: 8rpx solid #EBEBEB;
  287. .body_item_head{
  288. word-break: break-all;
  289. text-align: justify;
  290. text-align: left;
  291. margin: 24rpx;
  292. font-size: 30rpx;
  293. .sign{
  294. margin-right: 16rpx;
  295. font-weight: bold;
  296. color: #49B856;
  297. &.signRed{
  298. color: #FF0000;
  299. }
  300. }
  301. }
  302. .body_item_content{
  303. border-top: 1rpx solid #D8D8D8;
  304. padding: 24rpx 24rpx 24rpx 48rpx;
  305. .body_item_content_p{
  306. color: #6A6A6A;
  307. font-size: 26rpx;
  308. display: flex;
  309. justify-content: space-between;
  310. align-items: center;
  311. margin-bottom: 24rpx;
  312. &:last-of-type{
  313. margin-bottom: 0;
  314. }
  315. .name{
  316. flex: 1;
  317. }
  318. .status{
  319. padding: 4rpx 10rpx;
  320. border-radius: 20rpx;
  321. background-color: #DBE8FE;
  322. font-size: 22rpx;
  323. color: #006CF9;
  324. }
  325. .icon_all{
  326. .mic-filled,
  327. .image-filled
  328. {
  329. margin-left: 16rpx;
  330. }
  331. }
  332. }
  333. }
  334. .body_item_foot{
  335. border-top: 1rpx solid #D8D8D8;
  336. font-size: 26rpx;
  337. padding: 24rpx;
  338. .foot_info{
  339. display: flex;
  340. justify-content: space-between;
  341. align-items: center;
  342. .phone-filled{
  343. margin-left: 5rpx;
  344. }
  345. }
  346. }
  347. }
  348. }
  349. .zanwu{
  350. box-sizing: border-box;
  351. margin-top: 176rpx;
  352. border-top: 6rpx solid #EBEBEB;
  353. height: calc(100vh - 88rpx);
  354. display: flex;
  355. justify-content: center;
  356. background-color: #F7F7F7;
  357. .newicon-zanwu{
  358. font-size: 256rpx;
  359. color: #D6D6D6;
  360. margin-top: 140rpx;
  361. }
  362. }
  363. }
  364. </style>