index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="search-container uni-row">
  4. <input type="text" v-model="quer.keyword" placeholder="请输入关键字" />
  5. <view class="btn uni-row" @click="handleSearch">搜索</view>
  6. <!-- <uni-icons type="scan" size="24" /> -->
  7. </view>
  8. <view class="time-controls" style="margin-top: 10rpx;">
  9. <uni-section title="检查日期:" type="square" class="uni-row sta" style="flex: 1;">
  10. <input v-model="startTime" type="date" @input="timeSizer" style="padding-top: 12px;" />
  11. </uni-section>
  12. </view>
  13. <view
  14. style="display: flex; flex-direction: row; align-items: center; margin-top: 10rpx;background-color: #fff;">
  15. <uni-section title="检查状态:" type="square" class="uni-row sta" style="flex: 1 1 100%;">
  16. <uni-data-select v-model="quer.status" :localdata="statusData" :clear="true" placeholder="请选择检查状态"
  17. @change="handleChangeStatus"
  18. style="background-color: #ffffff; flex: 1;margin-right: 62px;"></uni-data-select>
  19. </uni-section>
  20. <view style="width: 18%;"></view>
  21. </view>
  22. <view class="daywork-item uni-column" v-for="(item, index) in inspecionList" :key="index"
  23. @click="handleSelection(item)">
  24. <view class="lot-code uni-row">
  25. <text>批次号:{{ item.lotCode }}</text>
  26. <text style="margin-left: 16rpx;color: #55ff7f;">{{ item.inspectionType }}</text>
  27. <text :style="selectType(item)">{{ selectText(item) }}</text>
  28. <text class="fa fa-trash" style="font-size: 16; color: white;"></text>
  29. </view>
  30. <view class="info">
  31. <view class="info-row uni-row">
  32. <view class="label">检查箱号:</view>
  33. <view class="value">{{ item.carrierCode }}</view>
  34. <view class="label">检察员:</view>
  35. <view class="value">{{ item.technicianName }}</view>
  36. </view>
  37. <view class="info-row uni-row">
  38. <view class="label">检查数量:</view>
  39. <view class="value">{{ item.examiningNum }}</view>
  40. <view class="label">不良品量:</view>
  41. <view class="value">{{ item.disqualificationNum }}</view>
  42. </view>
  43. <view class="info-row uni-row">
  44. <view class="label">产品描述:</view>
  45. <view class="value">{{ item.productDescription }}</view>
  46. </view>
  47. <view class="info-row uni-row">
  48. <view class="label">检测载具:</view>
  49. <view class="value">{{ item.inspectionCarrierCode }}</view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script setup>
  56. import {
  57. ref
  58. } from 'vue'
  59. import {
  60. getProcessInspecionList,
  61. updateAdoptStatus
  62. } from '@/api/business/processInspection.js'
  63. import {
  64. timestampToTime,
  65. toHHmmss
  66. } from '@/utils/common.js'
  67. import {
  68. onLoad,
  69. onReady,
  70. onUnload,
  71. onShow,
  72. onReachBottom
  73. } from '@dcloudio/uni-app'
  74. import {
  75. store
  76. } from '@/store/index.js'
  77. const keyword = ref('')
  78. const inspecionList = ref([]); //时间后筛选数组
  79. const original = ref([]); //原始数组
  80. const startTime = ref(new Date().toISOString().split("T")[0])
  81. const pageSize = ref(10)
  82. const pageNum = ref(1)
  83. const status = ref(true)
  84. const range = [{
  85. value: 0,
  86. text: "待确认",
  87. type: "color: #fcab53"
  88. }, {
  89. value: 1,
  90. text: "合格",
  91. type: "color: #55ff7f"
  92. }, {
  93. value: 2,
  94. text: "不合格",
  95. type: "color: #ff0c2c"
  96. }]
  97. const statusData = ref([{
  98. value: 0,
  99. text: "待确认"
  100. },
  101. {
  102. value: 1,
  103. text: "合格"
  104. },
  105. {
  106. value: 2,
  107. text: "不合格"
  108. },
  109. ])
  110. const quer = ref({}) //用于查询
  111. /***************************** 页面生命周期函数 *****************************/
  112. onShow(() => {
  113. getList()
  114. // uni.showLoading({
  115. // title: '加载中'
  116. // });
  117. // quer.value.userId = store.userInfo.userId;
  118. // quer.value.startTime = startTime.value;
  119. // getProcessInspecionList(quer.value).then(res => {
  120. // console.log("res", res);
  121. // if (res.code == 200) {
  122. // original.value = res.rows;
  123. // // timeSizer();
  124. // uni.hideLoading();
  125. // // uni.hideLoading();
  126. // }
  127. // });
  128. })
  129. onReachBottom(() => {
  130. console.log(status.value)
  131. if (status.value) {
  132. pageNum.value += 1
  133. quer.value.pageNum = pageNum.value
  134. quer.value.pageSize = pageSize.value
  135. getProcessInspecionList(quer.value).then(res => {
  136. const existingIds = new Set(inspecionList.value.map(item => item.id));
  137. // 过滤出那些不在 existingIds 中的项,即新数据
  138. const newRows = res.rows.filter(row => !existingIds.has(row.id));
  139. // 如果有新数据,将其添加到 listData
  140. if (newRows.length > 0) {
  141. newRows.forEach(v => {
  142. if (v.type === "deliveryInspection") {
  143. v.inspectionType = "交检"
  144. } else if (v.type === "firstArticleInspection") {
  145. v.inspectionType = "首件检"
  146. } else if (v.type === "patrolInspection") {
  147. v.inspectionType = "巡检"
  148. } else if (v.type === "outsourcedInspector") {
  149. v.inspectionType = "外协检"
  150. } else if (v.type === "factoryInspection") {
  151. v.inspectionType = "出厂检"
  152. } else {
  153. v.inspectionType = "仪器室"
  154. }
  155. });
  156. inspecionList.value = inspecionList.value.concat(newRows);
  157. original.value = original.value.concat(newRows);
  158. } else {
  159. // 如果没有新数据,更新状态表示没有更多数据
  160. status.value = false;
  161. }
  162. })
  163. }
  164. })
  165. /***************************** 定义了一些方法 *****************************/
  166. function getList() {
  167. uni.showLoading({
  168. title: '加载中'
  169. });
  170. pageNum.value = 1
  171. quer.value.startTime = startTime.value;
  172. quer.value.deptId = store.curDeptDetails.deptId
  173. quer.value.userId = store.userInfo.userId
  174. quer.value.pageNum = pageNum.value
  175. quer.value.pageSize = pageSize.value
  176. getProcessInspecionList(quer.value).then(res => {
  177. console.log("res", res);
  178. if (res.code == 200) {
  179. res.rows.forEach(v => {
  180. if (v.type === "deliveryInspection") {
  181. v.inspectionType = "交检"
  182. } else if (v.type === "firstArticleInspection") {
  183. v.inspectionType = "首件检"
  184. } else if (v.type === "patrolInspection") {
  185. v.inspectionType = "巡检"
  186. } else if (v.type === "outsourcedInspector") {
  187. v.inspectionType = "外协检"
  188. } else if (v.type === "factoryInspection") {
  189. v.inspectionType = "出厂检"
  190. } else {
  191. v.inspectionType = "仪器室"
  192. }
  193. });
  194. inspecionList.value = res.rows;
  195. uni.hideLoading();
  196. }
  197. });
  198. }
  199. function handleSearch() {
  200. pageNum.value = 1
  201. status.value = true
  202. getList()
  203. }
  204. function handleChangeStatus() {
  205. pageNum.value = 1
  206. status.value = true
  207. getList()
  208. }
  209. //时间筛选,暂时注释,使用搜索向
  210. function timeSizer() {
  211. getList()
  212. }
  213. // 筛选函数
  214. const filterSameDayItems = (inspectionList, startTime) => {
  215. // 使用filter方法筛选出与startTime同一天的元素
  216. const filteredList = inspectionList.filter(item => {
  217. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  218. const itemDateString = item.createTime.split(' ')[0];
  219. // 比较两个日期字符串是否相同
  220. return itemDateString === startTime;
  221. });
  222. return filteredList;
  223. };
  224. function isSameDate(date1, date2) {
  225. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  226. const formatDate = (date) => date.toISOString().split('T')[0];
  227. // 比较两个日期的年月日部分是否相同
  228. return formatDate(date1) === formatDate(date2);
  229. }
  230. //查看序捡详情
  231. function handleSelection(item) {
  232. store.processInspection = item;
  233. uni.navigateTo({
  234. url: '/pages/inspectionDetails/form'
  235. })
  236. }
  237. //状态文本
  238. function selectText(item) {
  239. for (var i = 0; i < range.length; i++) {
  240. if (item.status == range[i].value) {
  241. return range[i].text
  242. }
  243. }
  244. }
  245. //状态样式
  246. function selectType(item) {
  247. for (var i = 0; i < range.length; i++) {
  248. if (item.status == range[i].value) {
  249. return range[i].type
  250. }
  251. }
  252. }
  253. /***************************** 定义了一些事件 *****************************/
  254. </script>
  255. <style lang="scss">
  256. .uni-seluni-section-content {
  257. flex: 1;
  258. }
  259. .time-controls {
  260. .title {
  261. margin: 20% auto 40% auto;
  262. .first {
  263. font-size: 48rpx;
  264. margin: 0 auto;
  265. }
  266. .second {
  267. color: red;
  268. font-size: 24rpx;
  269. margin: 10rpx auto 0 auto;
  270. }
  271. }
  272. .sta {
  273. justify-content: flex-start;
  274. align-items: center;
  275. input {
  276. border: 1rpx solid gray;
  277. border-radius: 8rpx;
  278. width: 400rpx;
  279. height: 64rpx;
  280. }
  281. }
  282. button {
  283. width: 78%;
  284. background-color: #1684fc;
  285. color: white;
  286. margin: 0 auto;
  287. }
  288. }
  289. .page-container {
  290. background-color: #ececec;
  291. font-size: 28rpx;
  292. padding: 24rpx;
  293. //box-sizing: border-box;
  294. }
  295. .search-container {
  296. border-radius: 12rpx;
  297. align-items: center;
  298. input {
  299. flex: 1;
  300. background-color: #ffffff;
  301. height: 64rpx;
  302. box-sizing: border-box;
  303. padding: 0 16rpx;
  304. }
  305. .btn {
  306. width: 120rpx;
  307. height: 64rpx;
  308. background-color: #1684FC;
  309. justify-content: center;
  310. font-size: 24rpx;
  311. color: #ffffff;
  312. justify-content: center;
  313. align-items: center;
  314. }
  315. }
  316. .scan-btn {
  317. height: 64rpx;
  318. margin: 32rpx 32rpx 0 32rpx;
  319. color: #ffffff;
  320. background-color: #f47c3c;
  321. align-items: center;
  322. justify-content: center;
  323. border-radius: 8rpx;
  324. }
  325. .daywork-item {
  326. padding: 24rpx;
  327. background-color: #ffffff;
  328. margin-top: 24rpx;
  329. border-radius: 8rpx;
  330. .lot-code {
  331. align-items: center;
  332. justify-content: space-between;
  333. font-weight: 700;
  334. }
  335. .info {
  336. font-size: 24rpx;
  337. color: #767676;
  338. .info-row {
  339. margin-top: 16rpx;
  340. .label {
  341. width: 120rpx;
  342. }
  343. .value {
  344. flex: 1;
  345. }
  346. .start-batch-btn {
  347. flex: 1;
  348. height: 80rpx;
  349. line-height: 80rpx;
  350. border-radius: 8rpx;
  351. color: #FFFFFF;
  352. font-size: 28rpx;
  353. }
  354. }
  355. }
  356. }
  357. uni-app,
  358. uni-page,
  359. uni-page-wrapper,
  360. uni-page-body {
  361. height: 100%;
  362. }
  363. </style>