index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. inspecionList.value = inspecionList.value.concat(newRows);
  142. original.value = original.value.concat(newRows);
  143. } else {
  144. // 如果没有新数据,更新状态表示没有更多数据
  145. status.value = false;
  146. }
  147. })
  148. }
  149. })
  150. /***************************** 定义了一些方法 *****************************/
  151. function getList() {
  152. uni.showLoading({
  153. title: '加载中'
  154. });
  155. pageNum.value = 1
  156. quer.value.startTime = startTime.value;
  157. quer.value.deptId = store.curDeptDetails.deptId
  158. quer.value.userId = store.userInfo.userId
  159. quer.value.pageNum = pageNum.value
  160. quer.value.pageSize = pageSize.value
  161. getProcessInspecionList(quer.value).then(res => {
  162. console.log("res", res);
  163. if (res.code == 200) {
  164. res.rows.forEach(v => {
  165. if (v.type === "deliveryInspection") {
  166. v.inspectionType = "交检"
  167. } else if (v.type === "firstArticleInspection") {
  168. v.inspectionType = "首件检"
  169. } else if (v.type === "patrolInspection") {
  170. v.inspectionType = "巡检"
  171. } else if (v.type === "outsourcedInspector") {
  172. v.inspectionType = "外协检"
  173. } else if (v.type === "factoryInspection") {
  174. v.inspectionType = "出厂检"
  175. } else {
  176. v.inspectionType = "仪器室"
  177. }
  178. });
  179. inspecionList.value = res.rows;
  180. uni.hideLoading();
  181. }
  182. });
  183. }
  184. function handleSearch() {
  185. pageNum.value = 1
  186. status.value = true
  187. getList()
  188. }
  189. function handleChangeStatus() {
  190. pageNum.value = 1
  191. status.value = true
  192. getList()
  193. }
  194. //时间筛选,暂时注释,使用搜索向
  195. function timeSizer() {
  196. getList()
  197. }
  198. // 筛选函数
  199. const filterSameDayItems = (inspectionList, startTime) => {
  200. // 使用filter方法筛选出与startTime同一天的元素
  201. const filteredList = inspectionList.filter(item => {
  202. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  203. const itemDateString = item.createTime.split(' ')[0];
  204. // 比较两个日期字符串是否相同
  205. return itemDateString === startTime;
  206. });
  207. return filteredList;
  208. };
  209. function isSameDate(date1, date2) {
  210. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  211. const formatDate = (date) => date.toISOString().split('T')[0];
  212. // 比较两个日期的年月日部分是否相同
  213. return formatDate(date1) === formatDate(date2);
  214. }
  215. //查看序捡详情
  216. function handleSelection(item) {
  217. store.processInspection = item;
  218. uni.navigateTo({
  219. url: '/pages/inspectionDetails/form'
  220. })
  221. }
  222. //状态文本
  223. function selectText(item) {
  224. for (var i = 0; i < range.length; i++) {
  225. if (item.status == range[i].value) {
  226. return range[i].text
  227. }
  228. }
  229. }
  230. //状态样式
  231. function selectType(item) {
  232. for (var i = 0; i < range.length; i++) {
  233. if (item.status == range[i].value) {
  234. return range[i].type
  235. }
  236. }
  237. }
  238. /***************************** 定义了一些事件 *****************************/
  239. </script>
  240. <style lang="scss">
  241. .uni-seluni-section-content {
  242. flex: 1;
  243. }
  244. .time-controls {
  245. .title {
  246. margin: 20% auto 40% auto;
  247. .first {
  248. font-size: 48rpx;
  249. margin: 0 auto;
  250. }
  251. .second {
  252. color: red;
  253. font-size: 24rpx;
  254. margin: 10rpx auto 0 auto;
  255. }
  256. }
  257. .sta {
  258. justify-content: flex-start;
  259. align-items: center;
  260. input {
  261. border: 1rpx solid gray;
  262. border-radius: 8rpx;
  263. width: 400rpx;
  264. height: 64rpx;
  265. }
  266. }
  267. button {
  268. width: 78%;
  269. background-color: #1684fc;
  270. color: white;
  271. margin: 0 auto;
  272. }
  273. }
  274. .page-container {
  275. background-color: #ececec;
  276. font-size: 28rpx;
  277. padding: 24rpx;
  278. //box-sizing: border-box;
  279. }
  280. .search-container {
  281. border-radius: 12rpx;
  282. align-items: center;
  283. input {
  284. flex: 1;
  285. background-color: #ffffff;
  286. height: 64rpx;
  287. box-sizing: border-box;
  288. padding: 0 16rpx;
  289. }
  290. .btn {
  291. width: 120rpx;
  292. height: 64rpx;
  293. background-color: #1684FC;
  294. justify-content: center;
  295. font-size: 24rpx;
  296. color: #ffffff;
  297. justify-content: center;
  298. align-items: center;
  299. }
  300. }
  301. .scan-btn {
  302. height: 64rpx;
  303. margin: 32rpx 32rpx 0 32rpx;
  304. color: #ffffff;
  305. background-color: #f47c3c;
  306. align-items: center;
  307. justify-content: center;
  308. border-radius: 8rpx;
  309. }
  310. .daywork-item {
  311. padding: 24rpx;
  312. background-color: #ffffff;
  313. margin-top: 24rpx;
  314. border-radius: 8rpx;
  315. .lot-code {
  316. align-items: center;
  317. justify-content: space-between;
  318. font-weight: 700;
  319. }
  320. .info {
  321. font-size: 24rpx;
  322. color: #767676;
  323. .info-row {
  324. margin-top: 16rpx;
  325. .label {
  326. width: 120rpx;
  327. }
  328. .value {
  329. flex: 1;
  330. }
  331. .start-batch-btn {
  332. flex: 1;
  333. height: 80rpx;
  334. line-height: 80rpx;
  335. border-radius: 8rpx;
  336. color: #FFFFFF;
  337. font-size: 28rpx;
  338. }
  339. }
  340. }
  341. }
  342. uni-app,
  343. uni-page,
  344. uni-page-wrapper,
  345. uni-page-body {
  346. height: 100%;
  347. }
  348. </style>