index.vue 9.0 KB

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