index.vue 6.7 KB

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