index.vue 7.0 KB

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