index.vue 7.1 KB

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