index.vue 7.7 KB

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