index.vue 7.4 KB

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