index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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="getList">搜索</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. 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 handleChangeStatus() {
  182. getList()
  183. }
  184. //时间筛选,暂时注释,使用搜索向
  185. function timeSizer() {
  186. getList()
  187. }
  188. // 筛选函数
  189. const filterSameDayItems = (inspectionList, startTime) => {
  190. // 使用filter方法筛选出与startTime同一天的元素
  191. const filteredList = inspectionList.filter(item => {
  192. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  193. const itemDateString = item.createTime.split(' ')[0];
  194. // 比较两个日期字符串是否相同
  195. return itemDateString === startTime;
  196. });
  197. return filteredList;
  198. };
  199. function isSameDate(date1, date2) {
  200. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  201. const formatDate = (date) => date.toISOString().split('T')[0];
  202. // 比较两个日期的年月日部分是否相同
  203. return formatDate(date1) === formatDate(date2);
  204. }
  205. //查看序捡详情
  206. function handleSelection(item) {
  207. store.processInspection = item;
  208. uni.navigateTo({
  209. url: '/pages/inspectionDetails/form'
  210. })
  211. }
  212. //状态文本
  213. function selectText(item) {
  214. for (var i = 0; i < range.length; i++) {
  215. if (item.status == range[i].value) {
  216. return range[i].text
  217. }
  218. }
  219. }
  220. //状态样式
  221. function selectType(item) {
  222. for (var i = 0; i < range.length; i++) {
  223. if (item.status == range[i].value) {
  224. return range[i].type
  225. }
  226. }
  227. }
  228. /***************************** 定义了一些事件 *****************************/
  229. </script>
  230. <style lang="scss">
  231. .uni-section-content {
  232. width: 70%;
  233. }
  234. .time-controls {
  235. .title {
  236. margin: 20% auto 40% auto;
  237. .first {
  238. font-size: 48rpx;
  239. margin: 0 auto;
  240. }
  241. .second {
  242. color: red;
  243. font-size: 24rpx;
  244. margin: 10rpx auto 0 auto;
  245. }
  246. }
  247. .sta {
  248. justify-content: flex-start;
  249. align-items: center;
  250. input {
  251. border: 1rpx solid gray;
  252. border-radius: 8rpx;
  253. width: 400rpx;
  254. height: 64rpx;
  255. }
  256. }
  257. button {
  258. width: 78%;
  259. background-color: #1684fc;
  260. color: white;
  261. margin: 0 auto;
  262. }
  263. }
  264. .page-container {
  265. background-color: #ececec;
  266. font-size: 28rpx;
  267. padding: 24rpx;
  268. //box-sizing: border-box;
  269. }
  270. .search-container {
  271. border-radius: 12rpx;
  272. align-items: center;
  273. input {
  274. flex: 1;
  275. background-color: #ffffff;
  276. height: 64rpx;
  277. box-sizing: border-box;
  278. padding: 0 16rpx;
  279. }
  280. .btn {
  281. width: 120rpx;
  282. height: 64rpx;
  283. background-color: #1684FC;
  284. justify-content: center;
  285. font-size: 24rpx;
  286. color: #ffffff;
  287. justify-content: center;
  288. align-items: center;
  289. }
  290. }
  291. .scan-btn {
  292. height: 64rpx;
  293. margin: 32rpx 32rpx 0 32rpx;
  294. color: #ffffff;
  295. background-color: #f47c3c;
  296. align-items: center;
  297. justify-content: center;
  298. border-radius: 8rpx;
  299. }
  300. .daywork-item {
  301. padding: 24rpx;
  302. background-color: #ffffff;
  303. margin-top: 24rpx;
  304. border-radius: 8rpx;
  305. .lot-code {
  306. align-items: center;
  307. justify-content: space-between;
  308. font-weight: 700;
  309. }
  310. .info {
  311. font-size: 24rpx;
  312. color: #767676;
  313. .info-row {
  314. margin-top: 16rpx;
  315. .label {
  316. width: 120rpx;
  317. }
  318. .value {
  319. flex: 1;
  320. }
  321. .start-batch-btn {
  322. flex: 1;
  323. height: 80rpx;
  324. line-height: 80rpx;
  325. border-radius: 8rpx;
  326. color: #FFFFFF;
  327. font-size: 28rpx;
  328. }
  329. }
  330. }
  331. }
  332. uni-app, uni-page, uni-page-wrapper, uni-page-body {
  333. height: 100%;
  334. }
  335. </style>