index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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" style="padding-top: 12px;" />
  9. </uni-section>
  10. <uni-section title="结束日期:" type="square" class="uni-row end">
  11. <input v-model="endTime" type="date" style="padding-top: 12px;" />
  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: 43px;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. } from "@/api/business/dayWorkItem.js"
  170. import {
  171. store
  172. } from '@/store/index.js'
  173. import {
  174. toHHmmss
  175. } from '@/utils/common.js'
  176. const listDaywork = ref([])
  177. const listData = ref([]) // 回显
  178. const listDataItem = ref([])
  179. const lotInfo = ref(null) // 详情弹窗
  180. const selectDate = ref('')
  181. const dateList = ref([]) // 选择的日期列表
  182. const show = ref(false)
  183. const startTime = ref('')
  184. const endTime = ref('')
  185. const total = ref(0)
  186. const editStatus = ref(false)
  187. onLoad(() => {
  188. })
  189. onShow(() => {
  190. resetPage();
  191. })
  192. function resetPage() {
  193. listData.value = [];
  194. listDataItem.value = [];
  195. selectDate.value = '';
  196. dateList.value = [];
  197. show.value = false;
  198. startTime.value = '';
  199. endTime.value = '';
  200. }
  201. function handleSearch() {
  202. let today = Date.parse(new Date());
  203. let startTimestamp = Date.parse(new Date(startTime.value));
  204. let endTimestamp = Date.parse(new Date(endTime.value));
  205. if (endTimestamp - startTimestamp < 0) {
  206. uni.showToast({
  207. icon: 'none',
  208. title: '开始日期不能超过结束日期',
  209. duration: 2000
  210. })
  211. return;
  212. }
  213. if (today - endTimestamp < 0 || today - startTimestamp < 0) {
  214. uni.showToast({
  215. icon: 'none',
  216. title: '开始或结束日期不能超过今日',
  217. duration: 2000
  218. })
  219. return;
  220. }
  221. if (!startTime.value || !endTime.value) {
  222. uni.showToast({
  223. icon: 'none',
  224. title: '请选择开始或结束日期',
  225. duration: 2000
  226. })
  227. return;
  228. }
  229. if (endTimestamp - startTimestamp > 1000 * 60 * 60 * 24 * 30) {
  230. uni.showToast({
  231. icon: 'none',
  232. title: '日期区间最长不超过31天',
  233. duration: 2000
  234. })
  235. return;
  236. }
  237. show.value = !show.value
  238. if (show.value) {
  239. init();
  240. }
  241. }
  242. function init() {
  243. uni.showLoading({
  244. title: '加载中'
  245. });
  246. console.log(startTime.value);
  247. console.log(endTime.value)
  248. getDayWorkItemHistory(startTime.value, endTime.value).then(res => {
  249. if (res.code == 200) {
  250. listData.value = res.rows || [];
  251. listDataItem.value = res.rows || [];
  252. console.log(listData.value)
  253. total.value = res.rows.length;
  254. // 时间戳转工时
  255. for (var i = 0; i < listDataItem.value.length; i++) {
  256. let timeStamp = listDataItem.value[i].workingHours;
  257. listDataItem.value[i].taskTime = toHHmmss(timeStamp);
  258. }
  259. // 转为二维数组
  260. console.log(listDataItem.value)
  261. const groupedData = listDataItem.value.reduce((accumulator, currentItem) => {
  262. // 获取当前对象的日期字符串
  263. const dateString = currentItem.startTime.split(' ')[0];
  264. // 如果有这个日期,则 push 到对应的数组中,否则创建一个新的数组
  265. if (accumulator[dateString]) {
  266. accumulator[dateString].push(currentItem);
  267. } else {
  268. accumulator[dateString] = [currentItem];
  269. }
  270. return accumulator;
  271. }, {});
  272. var hasEndTime = false
  273. // 0718
  274. for (var i = 0; i < listData.value.length; i++) {
  275. var current = listData.value[i];
  276. var found = false;
  277. var endTimeStatus = "";
  278. for (var j = 0; j < listDaywork.value.length; j++) {
  279. if (listDaywork.value[j].dayworkId === current.dayworkId && listDaywork.value[j]
  280. .processStepNumber === current.processStepNumber) {
  281. listDaywork.value[j].qualifiedNum += current.qualifiedNum;
  282. listDaywork.value[j].rejectSum += current.rejectSum;
  283. if (listDaywork.value[j].equipmentDetailCode != null && listDaywork.value[j]
  284. .equipmentDetailCode != undefined && listDaywork.value[j].equipmentDetailCode !=
  285. listDaywork.value[j].equipmentDetailCode) {
  286. listDaywork.value[j].equipmentDetailCode = listDaywork.value[j]
  287. .equipmentDetailCode + "," + current.equipmentDetailCode
  288. }
  289. found = true;
  290. break;
  291. }
  292. }
  293. if (current.status == 3) {
  294. console.log("999")
  295. hasEndTime = true
  296. endTimeStatus = current.endTime;
  297. console.log(endTimeStatus)
  298. }
  299. if (!hasEndTime && current.status != 3) {
  300. console.log("777")
  301. endTimeStatus = null;
  302. }
  303. if (!found && current.status == 3) {
  304. console.log()
  305. listDaywork.value.push({
  306. processAlias: current.process.processAlias,
  307. equipmentDetailCode: current.equipmentDetailCode,
  308. lotCode: current.lotCode,
  309. productDescription: current.productDescription,
  310. daywork: current.daywork,
  311. dayworkId: current.dayworkId,
  312. processId: current.processId,
  313. qualifiedNum: current.qualifiedNum,
  314. rejectSum: current.rejectSum,
  315. endTime: endTimeStatus,
  316. adoptStatus: current.adoptStatus == null ? null : current.adoptStatus
  317. });
  318. }
  319. }
  320. console.log(listData.value);
  321. console.log(listDaywork.value);
  322. uni.hideLoading();
  323. } else {
  324. uni.showToast({
  325. icon: "none",
  326. title: res.message,
  327. duration: 2000
  328. })
  329. uni.hideLoading();
  330. }
  331. })
  332. }
  333. function handleCheckTab() {
  334. editStatus.value = true
  335. }
  336. function handleCheckTabHis() {
  337. editStatus.value = false
  338. }
  339. function change() {
  340. listDataItem.value = listData.value[selectDate.value]
  341. }
  342. // function handleOpenLonInfo() {
  343. // lotInfo.value.open();
  344. // }
  345. </script>
  346. <style lang="scss">
  347. .time-controls {
  348. align-items: center;
  349. .title {
  350. margin: 20% auto 40% auto;
  351. .first {
  352. font-size: 48rpx;
  353. margin: 0 auto;
  354. }
  355. .second {
  356. color: red;
  357. font-size: 24rpx;
  358. margin: 10rpx auto 0 auto;
  359. }
  360. }
  361. .sta {
  362. justify-content: center;
  363. align-items: center;
  364. margin-bottom: 48rpx;
  365. input {
  366. border: 1rpx solid gray;
  367. border-radius: 8rpx;
  368. width: 400rpx;
  369. height: 64rpx;
  370. }
  371. }
  372. .end {
  373. justify-content: center;
  374. align-items: center;
  375. margin-bottom: 64rpx;
  376. input {
  377. border: 1rpx solid gray;
  378. border-radius: 8rpx;
  379. width: 400rpx;
  380. height: 64rpx;
  381. }
  382. }
  383. button {
  384. width: 78%;
  385. background-color: #1684fc;
  386. color: white;
  387. margin: 0 auto;
  388. }
  389. }
  390. .container {
  391. height: 100%;
  392. background-color: #f5f5f5;
  393. overflow: auto;
  394. position: absolute;
  395. top: 0;
  396. left: 0;
  397. right: 0;
  398. }
  399. .scroll-container {
  400. position: relative;
  401. top: 140rpx;
  402. }
  403. .selected {
  404. border: 1px solid #1684fc;
  405. }
  406. .list-item {
  407. background-color: #fff;
  408. position: relative;
  409. padding: 16rpx;
  410. padding-bottom: 24rpx;
  411. margin: 0 24rpx;
  412. margin-bottom: 24rpx;
  413. border-radius: 8rpx;
  414. .title-container {
  415. margin: 8rpx 0;
  416. width: 100%;
  417. .title {
  418. height: 48rpx;
  419. justify-content: space-between;
  420. align-items: center;
  421. flex: 7;
  422. .label {
  423. font-weight: bold;
  424. }
  425. .code {
  426. margin-left: 8rpx;
  427. }
  428. }
  429. }
  430. .item-info {
  431. margin-bottom: 8rpx;
  432. .label {
  433. font-size: 28rpx;
  434. width: 152rpx;
  435. color: #808080;
  436. &.right {
  437. flex: 1;
  438. color: #000000;
  439. }
  440. }
  441. }
  442. .right-info {
  443. .label {
  444. font-size: 28rpx;
  445. }
  446. .time {
  447. margin-left: 8rpx;
  448. color: #1684fc;
  449. }
  450. .number {
  451. margin-left: 8rpx;
  452. color: #1684fc;
  453. }
  454. }
  455. }
  456. .tab-container {
  457. display: flex;
  458. flex-direction: row;
  459. width: 100%;
  460. height: 32px;
  461. justify-content: space-around;
  462. .table-item {
  463. display: flex;
  464. flex-direction: row;
  465. flex: 1;
  466. font-size: 14px;
  467. color: #666;
  468. align-items: center;
  469. justify-content: center;
  470. }
  471. }
  472. .tab-item.active {
  473. color: rgba(25, 137, 250, 1);
  474. font-weight: 700;
  475. }
  476. </style>