index.vue 7.4 KB

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