index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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="quer.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. } from '@dcloudio/uni-app'
  60. import {
  61. store
  62. } from '@/store/index.js'
  63. const keyword = ref('')
  64. const inspecionList = ref([]); //时间后筛选数组
  65. const original = ref([]); //原始数组
  66. const startTime = ref(new Date().toISOString().split('T')[0])
  67. const range = [{
  68. value: 0,
  69. text: "待确认",
  70. type: "color: #fcab53"
  71. }, {
  72. value: 1,
  73. text: "合格",
  74. type: "color: #55ff7f"
  75. }, {
  76. value: 2,
  77. text: "不合格",
  78. type: "color: #ff0c2c"
  79. }]
  80. const quer = ref({}) //用于查询
  81. /***************************** 页面生命周期函数 *****************************/
  82. onShow(() => {
  83. // getList()
  84. uni.showLoading({
  85. title: '加载中'
  86. });
  87. quer.value.userId = store.userInfo.userId;
  88. getProcessInspecionList(quer.value).then(res => {
  89. console.log("res", res);
  90. if (res.code == 200) {
  91. original.value = res.rows;
  92. timeSizer();
  93. uni.hideLoading();
  94. // uni.hideLoading();
  95. }
  96. });
  97. })
  98. /***************************** 定义了一些方法 *****************************/
  99. function getList() {
  100. uni.showLoading({
  101. title: '加载中'
  102. });
  103. quer.value.userId = store.userInfo.userId;
  104. // quer.value.startTime = startTime.value;
  105. getProcessInspecionList(quer.value).then(res => {
  106. console.log("res", res);
  107. if (res.code == 200) {
  108. original.value = res.rows;
  109. timeSizer();
  110. uni.hideLoading();
  111. // uni.hideLoading();
  112. }
  113. });
  114. }
  115. //时间筛选,暂时注释,使用搜索向
  116. function timeSizer() {
  117. // quer.value.startTime = startTime.value;
  118. // 显示加载指示器
  119. // uni.showLoading();
  120. // getProcessInspecionList(quer.value).then(res => {
  121. // console.log("res", res);
  122. // if (res.code == 200) {
  123. // original.value = res.rows;
  124. // timeSizer();
  125. // uni.hideLoading();
  126. // // uni.hideLoading();
  127. // }
  128. // });
  129. inspecionList.value = filterSameDayItems(original.value, startTime.value);
  130. }
  131. // 筛选函数
  132. const filterSameDayItems = (inspectionList, startTime) => {
  133. // 使用filter方法筛选出与startTime同一天的元素
  134. const filteredList = inspectionList.filter(item => {
  135. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  136. const itemDateString = item.createTime.split(' ')[0];
  137. // 比较两个日期字符串是否相同
  138. return itemDateString === startTime;
  139. });
  140. return filteredList;
  141. };
  142. function isSameDate(date1, date2) {
  143. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  144. const formatDate = (date) => date.toISOString().split('T')[0];
  145. // 比较两个日期的年月日部分是否相同
  146. return formatDate(date1) === formatDate(date2);
  147. }
  148. //查看序捡详情
  149. function handleSelection(item) {
  150. store.processInspection = item;
  151. uni.navigateTo({
  152. url: '/pages/processInspection/form'
  153. })
  154. }
  155. //状态文本
  156. function selectText(item) {
  157. for (var i = 0; i < range.length; i++) {
  158. if (item.status == range[i].value) {
  159. return range[i].text
  160. }
  161. }
  162. }
  163. //状态样式
  164. function selectType(item) {
  165. for (var i = 0; i < range.length; i++) {
  166. if (item.status == range[i].value) {
  167. return range[i].type
  168. }
  169. }
  170. }
  171. const addProcessInspection = (data) => {
  172. const info = {
  173. title: data.title,
  174. standard: data.standard,
  175. result: '',
  176. number: 1
  177. }
  178. unfitInfos.value.push(info)
  179. }
  180. /***************************** 定义了一些事件 *****************************/
  181. // 新增序检
  182. const handleAddProcessInspection = () => {
  183. uni.navigateTo({
  184. url: '/pages/processInspection/scan'
  185. })
  186. }
  187. // 添加不合格信息
  188. const handleShowUnfit = () => {
  189. uni.navigateTo({
  190. url: '/pages/processInspection/form'
  191. })
  192. }
  193. </script>
  194. <style lang="scss">
  195. .time-controls {
  196. .title {
  197. margin: 20% auto 40% auto;
  198. .first {
  199. font-size: 48rpx;
  200. margin: 0 auto;
  201. }
  202. .second {
  203. color: red;
  204. font-size: 24rpx;
  205. margin: 10rpx auto 0 auto;
  206. }
  207. }
  208. .sta {
  209. justify-content: center;
  210. align-items: center;
  211. input {
  212. border: 1rpx solid gray;
  213. border-radius: 8rpx;
  214. width: 400rpx;
  215. height: 64rpx;
  216. }
  217. }
  218. button {
  219. width: 78%;
  220. background-color: #1684fc;
  221. color: white;
  222. margin: 0 auto;
  223. }
  224. }
  225. .page-container {
  226. height: 100%;
  227. background-color: #ececec;
  228. font-size: 28rpx;
  229. padding: 24rpx;
  230. box-sizing: border-box;
  231. }
  232. .search-container {
  233. border-radius: 12rpx;
  234. align-items: center;
  235. input {
  236. flex: 1;
  237. background-color: #ffffff;
  238. height: 64rpx;
  239. box-sizing: border-box;
  240. padding: 0 16rpx;
  241. }
  242. .btn {
  243. width: 120rpx;
  244. height: 64rpx;
  245. background-color: #1684FC;
  246. justify-content: center;
  247. font-size: 24rpx;
  248. color: #ffffff;
  249. justify-content: center;
  250. align-items: center;
  251. }
  252. }
  253. .scan-btn {
  254. height: 64rpx;
  255. margin: 32rpx 32rpx 0 32rpx;
  256. color: #ffffff;
  257. background-color: #f47c3c;
  258. align-items: center;
  259. justify-content: center;
  260. border-radius: 8rpx;
  261. }
  262. .daywork-item {
  263. padding: 24rpx;
  264. background-color: #ffffff;
  265. margin-top: 24rpx;
  266. border-radius: 8rpx;
  267. .lot-code {
  268. align-items: center;
  269. justify-content: space-between;
  270. font-weight: 700;
  271. }
  272. .info {
  273. font-size: 24rpx;
  274. color: #767676;
  275. .info-row {
  276. margin-top: 16rpx;
  277. .label {
  278. width: 120rpx;
  279. }
  280. .value {
  281. flex: 1;
  282. }
  283. }
  284. }
  285. }
  286. </style>