index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <view v-if="!show" class="time-controls">
  3. <view class="title">
  4. <view class="first">请选择日期区间</view>
  5. <view class="second">注意日期区间最长不超过31天</view>
  6. </view>
  7. <uni-section title="开始日期:" type="square" class="uni-row sta">
  8. <input v-model="startTime" type="date" />
  9. </uni-section>
  10. <uni-section title="结束日期:" type="square" class="uni-row end">
  11. <input v-model="endTime" type="date" />
  12. </uni-section>
  13. <button @click="handleSearch">查询</button>
  14. </view>
  15. <view v-if="show" class="uni-column container">
  16. <view class="uni-row" style="position: fixed;
  17. top: 0;width: 100%;
  18. height: 120rpx;
  19. z-index: 2;
  20. margin:0 auto;
  21. background-color: white;
  22. flex-direction: column;
  23. justify-content: flex-start;
  24. align-items: center;
  25. border-top: 1rpx solid lightgray;
  26. border-bottom: 1rpx solid lightgray;">
  27. <!-- <uni-section title="选择日期:" type="square" class="uni-row" style="margin-left: 16rpx;">
  28. <uni-data-select v-model="selectDate" :localdata="dateList" @change="change" :clear="false"
  29. placeholder="无报工记录"
  30. style="width: 200rpx;"></uni-data-select>
  31. </uni-section> -->
  32. <view class="tab-container">
  33. <view :class="['tab-item', editStatus === false ? 'active': '']" @click="handleCheckTabHis()">历史报工
  34. </view>
  35. <view :class="['tab-item', editStatus === true ? 'active': '']" @click="handleCheckTab()">已完成报工</view>
  36. </view>
  37. <view style="width: 100%;">
  38. <uni-section title="时间范围:" type="square" class="uni-row"
  39. style="justify-content: start;align-items: center;margin-left: 20rpx;">
  40. {{ startTime }}&nbsp; ~ &nbsp;{{endTime}}
  41. </uni-section>
  42. <!-- <view style="width: 100%;font-size: 28rpx; text-align: left; margin-left: 16rpx;">时间范围:{{ startTime }}&nbsp; ~ &nbsp;{{endTime}}</view> -->
  43. <!-- <uni-section title="条数:" type="square" class="uni-row" style="justify-content: center;align-items: center;">
  44. {{ listDataItem.length }}
  45. </uni-section> -->
  46. </view>
  47. </view>
  48. <view class="scroll-container" v-if="!editStatus">
  49. <view v-for="(item, index) in listDataItem" :key="index" class="list-item">
  50. <view class="title-container">
  51. <view class="title uni-row">
  52. <view class="uni-row">
  53. <text class="label">批次号:</text>
  54. <text class="label code"> {{ item['lotCode'] }}</text>
  55. </view>
  56. <!-- <view style="color: #1684fc; margin-right: 0;" @click="handleOpenLonInfo">
  57. <text>批次详情</text>
  58. </view> -->
  59. </view>
  60. <view class="uni-row" style="margin: 10rpx 0 0;">
  61. <view class="right-info uni-row"> <text class="label">工时</text>
  62. <text class="label time">{{ item['taskTime'] }}</text>
  63. </view>
  64. <view class="right-info uni-row" style="margin-left: 50rpx;"> <text class="label">合格数</text>
  65. <text class="label number ">{{ item['qualifiedNum'] }}</text>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="item-info uni-row">
  70. <text class="label">产品描述</text>
  71. <text class="label right">{{ item['productDescription'] }}</text>
  72. </view>
  73. <!-- <view class="item-info uni-row">
  74. <text class="label">操作者</text>
  75. <text class="label right">{{ item['nickName'] }}</text>
  76. </view> -->
  77. <view class="item-info uni-row">
  78. <text class="label">开始时间</text>
  79. <text class="label right">{{ item['startTime'] ? item['startTime'] : '-' }}</text>
  80. </view>
  81. <view class="item-info uni-row">
  82. <text class="label">结束时间</text>
  83. <text class="label right">{{ item['endTime'] ? item['endTime'] : '-'}}</text>
  84. </view>
  85. <view class="item-info uni-row">
  86. <text class="label">废品数</text>
  87. <text class="label right">{{ item['rejectSum'] ? item['rejectSum'] : 0 }}</text>
  88. </view>
  89. <!-- <view class="item-info uni-row">
  90. <text class="label">投入数</text>
  91. <text
  92. class="label right">{{}}</text>
  93. </view> -->
  94. <view class="item-info uni-row">
  95. <text class="label">设备</text>
  96. <text class="label right">{{ item['equipmentDetailCode'] }}</text>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="scroll-container" v-if="editStatus">
  101. <view v-for="(item, index) in listDaywork" :key="index" class="list-item">
  102. <view class="title-container">
  103. <view class="title uni-row">
  104. <view class="uni-row">
  105. <text class="label">批次号:</text>
  106. <text class="label code"> {{ item['lotCode'] }}</text>
  107. </view>
  108. <!-- <view style="color: #1684fc; margin-right: 0;" @click="handleOpenLonInfo">
  109. <text>批次详情</text>
  110. </view> -->
  111. </view>
  112. <view class="uni-row" style="margin: 10rpx 0 0;">
  113. <!-- <view class="right-info uni-row"> <text class="label">工时</text>
  114. <text class="label time">{{ item['taskTime'] }}</text>
  115. </view> -->
  116. <view class="right-info uni-row"> <text class="label">工序</text>
  117. <text class="label time">{{ item['processAlias'] }}</text>
  118. </view>
  119. <view class="right-info uni-row" style="margin-left: 50rpx;"> <text class="label">合格数</text>
  120. <text class="label number ">{{ item['qualifiedNum'] }}</text>
  121. </view>
  122. </view>
  123. </view>
  124. <view class="item-info uni-row">
  125. <text class="label">产品描述</text>
  126. <text class="label right">{{ item['productDescription'] }}</text>
  127. </view>
  128. <!-- <view class="item-info uni-row">
  129. <text class="label">操作者</text>
  130. <text class="label right">{{ item['nickName'] }}</text>
  131. </view> -->
  132. <!-- <view class="item-info uni-row">
  133. <text class="label">开始时间</text>
  134. <text class="label right">{{ item['startTime'] ? item['startTime'] : '-' }}</text>
  135. </view> -->
  136. <view class="item-info uni-row">
  137. <text class="label">结束时间</text>
  138. <text class="label right">{{ item['endTime'] ? item['endTime'] : '-'}}</text>
  139. </view>
  140. <view class="item-info uni-row">
  141. <text class="label">废品数</text>
  142. <text class="label right">{{ item['rejectSum'] ? item['rejectSum'] : 0 }}</text>
  143. </view>
  144. <view class="item-info uni-row">
  145. <text class="label">设备</text>
  146. <text class="label right">{{ item['equipmentDetailCode'] }}</text>
  147. <view class="uni-row" style="justify-content: flex-end;margin-left: 20px;"
  148. v-if="item['adoptStatus'] && item['adoptStatus'] != null">
  149. <text>交检状态:</text>
  150. <text v-if="item['adoptStatus'] == 1" style="color: #67c337;">正常</text>
  151. <text v-if="item['adoptStatus'] == 2" style="color: red;">反选</text>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. </view>
  157. <!-- <dialog-lotInfo ref="lotInfo"></dialog-lotInfo> -->
  158. </template>
  159. <script setup>
  160. import {
  161. ref
  162. } from 'vue'
  163. import {
  164. onLoad,
  165. onShow
  166. } from '@dcloudio/uni-app'
  167. import {
  168. getDayWorkItemHistory,
  169. getDayWorkItemFinishHistory
  170. } from "@/api/business/dayWorkItem.js"
  171. import {
  172. store
  173. } from '@/store/index.js'
  174. import {
  175. toHHmmss
  176. } from '@/utils/common.js'
  177. const listDaywork = ref([])
  178. const listData = ref([]) // 回显
  179. const listDataItem = ref([])
  180. const lotInfo = ref(null) // 详情弹窗
  181. const selectDate = ref('')
  182. const dateList = ref([]) // 选择的日期列表
  183. const show = ref(false)
  184. const startTime = ref('')
  185. const endTime = ref('')
  186. const total = ref(0)
  187. const editStatus = ref(false)
  188. onLoad(() => {
  189. })
  190. onShow(() => {
  191. resetPage();
  192. })
  193. function resetPage() {
  194. listData.value = [];
  195. listDataItem.value = [];
  196. selectDate.value = '';
  197. dateList.value = [];
  198. show.value = false;
  199. startTime.value = '';
  200. endTime.value = '';
  201. }
  202. function handleSearch() {
  203. let today = Date.parse(new Date());
  204. let startTimestamp = Date.parse(new Date(startTime.value));
  205. let endTimestamp = Date.parse(new Date(endTime.value));
  206. if (endTimestamp - startTimestamp < 0) {
  207. uni.showToast({
  208. icon: 'none',
  209. title: '开始日期不能超过结束日期',
  210. duration: 2000
  211. })
  212. return;
  213. }
  214. if (today - endTimestamp < 0 || today - startTimestamp < 0) {
  215. uni.showToast({
  216. icon: 'none',
  217. title: '开始或结束日期不能超过今日',
  218. duration: 2000
  219. })
  220. return;
  221. }
  222. if (!startTime.value || !endTime.value) {
  223. uni.showToast({
  224. icon: 'none',
  225. title: '请选择开始或结束日期',
  226. duration: 2000
  227. })
  228. return;
  229. }
  230. if (endTimestamp - startTimestamp > 1000 * 60 * 60 * 24 * 30) {
  231. uni.showToast({
  232. icon: 'none',
  233. title: '日期区间最长不超过31天',
  234. duration: 2000
  235. })
  236. return;
  237. }
  238. show.value = !show.value
  239. if (show.value) {
  240. init();
  241. }
  242. }
  243. function init() {
  244. uni.showLoading({
  245. title: '加载中'
  246. });
  247. console.log(startTime.value);
  248. console.log(endTime.value)
  249. getDayWorkItemHistory(startTime.value, endTime.value).then(res => {
  250. if (res.code == 200) {
  251. listData.value = res.rows || [];
  252. listDataItem.value = res.rows || [];
  253. console.log(listData.value)
  254. total.value = res.rows.length;
  255. // 时间戳转工时
  256. for (var i = 0; i < listDataItem.value.length; i++) {
  257. let timeStamp = listDataItem.value[i].workingHours;
  258. listDataItem.value[i].taskTime = toHHmmss(timeStamp);
  259. }
  260. // 转为二维数组
  261. // console.log(listDataItem.value)
  262. // const groupedData = listDataItem.value.reduce((accumulator, currentItem) => {
  263. // // 获取当前对象的日期字符串
  264. // const dateString = currentItem.startTime.split(' ')[0];
  265. // // 如果有这个日期,则 push 到对应的数组中,否则创建一个新的数组
  266. // if (accumulator[dateString]) {
  267. // accumulator[dateString].push(currentItem);
  268. // } else {
  269. // accumulator[dateString] = [currentItem];
  270. // }
  271. // return accumulator;
  272. // }, {});
  273. // var hasEndTime = false
  274. // // 0718
  275. // for (var i = 0; i < listData.value.length; i++) {
  276. // var current = listData.value[i];
  277. // var found = false;
  278. // var endTimeStatus = "";
  279. // console.log(current, i)
  280. // console.log(listDaywork.value, i)
  281. // console.log(listDaywork.value.length > 0)
  282. // for (var j = 0; j < listDaywork.value.length; j++) {
  283. // console.log(listDaywork.value[j])
  284. // if (listDaywork.value[j].dayworkId === current.dayworkId && listDaywork.value[j]
  285. // .processStepNumber === current.processStepNumber) {
  286. // listDaywork.value[j].qualifiedNum = listData.value.filter(v => v.dayworkId == current
  287. // .dayworkId && v.processStepNumber == current.processStepNumber).reduce((acc,
  288. // item) => acc + item.qualifiedNum, 0);
  289. // console.log("666", listData.value.filter(v => v.dayworkId == current
  290. // .dayworkId && v.processStepNumber == current.processStepNumber))
  291. // listDaywork.value[j].rejectNum = listData.value.filter(v => v.dayworkId == current
  292. // .dayworkId && v.processStepNumber == current.processStepNumber).reduce((acc,
  293. // item) => acc + item.rejectNum, 0);
  294. // // listDaywork.value[j].qualifiedNum += current.qualifiedNum;
  295. // // listDaywork.value[j].rejectSum += current.rejectSum;
  296. // if (listDaywork.value[j].equipmentDetailCode != null && listDaywork.value[j]
  297. // .equipmentDetailCode != undefined && listDaywork.value[j].equipmentDetailCode !=
  298. // listDaywork.value[j].equipmentDetailCode) {
  299. // listDaywork.value[j].equipmentDetailCode = listDaywork.value[j]
  300. // .equipmentDetailCode + "," + current.equipmentDetailCode
  301. // }
  302. // found = true;
  303. // break;
  304. // }
  305. // }
  306. // if (current.status == 3) {
  307. // console.log("999")
  308. // hasEndTime = true
  309. // endTimeStatus = current.endTime;
  310. // console.log(endTimeStatus)
  311. // }
  312. // if (!hasEndTime && current.status != 3) {
  313. // console.log("777")
  314. // endTimeStatus = null;
  315. // }
  316. // if (!found && current.status == 3) {
  317. // console.log()
  318. // listDaywork.value.push({
  319. // processAlias: current.process.processAlias,
  320. // equipmentDetailCode: current.equipmentDetailCode,
  321. // lotCode: current.lotCode,
  322. // productDescription: current.productDescription,
  323. // daywork: current.daywork,
  324. // dayworkId: current.dayworkId,
  325. // processId: current.processId,
  326. // qualifiedNum: current.qualifiedNum,
  327. // rejectSum: current.rejectSum,
  328. // endTime: endTimeStatus,
  329. // adoptStatus: current.adoptStatus == null ? null : current.adoptStatus,
  330. // processStepNumber: current.processStepNumber
  331. // });
  332. // }
  333. // }
  334. // console.log(listData.value);
  335. // console.log(listDaywork.value);
  336. // 时间下拉
  337. // for (let i = 0; i < Object.keys(groupedData).length; i++) {
  338. // dateList.value[i] = {
  339. // text: Object.keys(groupedData)[i],
  340. // value: Object.keys(groupedData)[i]
  341. // }
  342. // }
  343. // listData.value = groupedData;
  344. // if(dateList.value.length > 0){
  345. // listDataItem.value = listData.value[dateList.value[0].value]
  346. // selectDate.value = dateList.value[0].value;
  347. // }
  348. // console.log(groupedData)
  349. uni.hideLoading();
  350. } else {
  351. uni.showToast({
  352. icon: "none",
  353. title: res.message,
  354. duration: 2000
  355. })
  356. uni.hideLoading();
  357. }
  358. })
  359. }
  360. function handleCheckTab() {
  361. uni.showLoading({
  362. title: '加载中'
  363. });
  364. getDayWorkItemFinishHistory(startTime.value, endTime.value).then(res => {
  365. listDaywork.value = res.data
  366. editStatus.value = true
  367. uni.hideLoading()
  368. })
  369. }
  370. function handleCheckTabHis() {
  371. editStatus.value = false
  372. }
  373. // function change() {
  374. // listDataItem.value = listData.value[selectDate.value]
  375. // }
  376. // function handleOpenLonInfo() {
  377. // lotInfo.value.open();
  378. // }
  379. </script>
  380. <style lang="scss">
  381. .time-controls {
  382. .title {
  383. margin: 20% auto 40% auto;
  384. .first {
  385. font-size: 48rpx;
  386. margin: 0 auto;
  387. }
  388. .second {
  389. color: red;
  390. font-size: 24rpx;
  391. margin: 10rpx auto 0 auto;
  392. }
  393. }
  394. .sta {
  395. justify-content: center;
  396. align-items: center;
  397. margin-bottom: 48rpx;
  398. input {
  399. border: 1rpx solid gray;
  400. border-radius: 8rpx;
  401. width: 400rpx;
  402. height: 64rpx;
  403. }
  404. }
  405. .end {
  406. justify-content: center;
  407. align-items: center;
  408. margin-bottom: 64rpx;
  409. input {
  410. border: 1rpx solid gray;
  411. border-radius: 8rpx;
  412. width: 400rpx;
  413. height: 64rpx;
  414. }
  415. }
  416. button {
  417. width: 78%;
  418. background-color: #1684fc;
  419. color: white;
  420. margin: 0 auto;
  421. }
  422. }
  423. .container {
  424. height: 100%;
  425. background-color: #f5f5f5;
  426. overflow: auto;
  427. }
  428. .scroll-container {
  429. position: relative;
  430. top: 140rpx;
  431. }
  432. .selected {
  433. border: 1px solid #1684fc;
  434. }
  435. .list-item {
  436. background-color: #fff;
  437. position: relative;
  438. padding: 16rpx;
  439. padding-bottom: 24rpx;
  440. margin: 0 24rpx;
  441. margin-bottom: 24rpx;
  442. border-radius: 8rpx;
  443. .title-container {
  444. margin: 8rpx 0;
  445. width: 100%;
  446. .title {
  447. height: 48rpx;
  448. justify-content: space-between;
  449. align-items: center;
  450. flex: 7;
  451. .label {
  452. font-weight: bold;
  453. }
  454. .code {
  455. margin-left: 8rpx;
  456. }
  457. }
  458. }
  459. .item-info {
  460. margin-bottom: 8rpx;
  461. .label {
  462. font-size: 28rpx;
  463. width: 152rpx;
  464. color: #808080;
  465. &.right {
  466. flex: 1;
  467. color: #000000;
  468. }
  469. }
  470. }
  471. .right-info {
  472. .label {
  473. font-size: 28rpx;
  474. }
  475. .time {
  476. margin-left: 8rpx;
  477. color: #1684fc;
  478. }
  479. .number {
  480. margin-left: 8rpx;
  481. color: #1684fc;
  482. }
  483. }
  484. }
  485. .tab-container {
  486. display: flex;
  487. flex-direction: row;
  488. width: 100%;
  489. height: 32px;
  490. justify-content: space-around;
  491. .table-item {
  492. display: flex;
  493. flex-direction: row;
  494. flex: 1;
  495. font-size: 14px;
  496. color: #666;
  497. align-items: center;
  498. justify-content: center;
  499. }
  500. }
  501. .tab-item.active {
  502. color: rgba(25, 137, 250, 1);
  503. font-weight: 700;
  504. }
  505. </style>