index.vue 7.1 KB

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