index.vue 9.0 KB

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