index.vue 9.5 KB

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