index.vue 6.3 KB

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