index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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="handleSearch">搜索</view>
  6. <!-- <uni-icons type="scan" size="24" /> -->
  7. </view>
  8. <view class="time-controls"
  9. style="margin-top: 10rpx;display: flex;margin-right: 0px;background-color: #ffffff;">
  10. <view class="uni-row sta">
  11. <span style="align-items: center;display: flex;font-size: 16px;margin-left: 12rpx;">检查日期:</span>
  12. <view class="uni-row" style="flex: 1;width: 100%;">
  13. <input v-model="startTime" type="date" @input="timeSizer"
  14. style="flex: 1;width: 100%;padding-top: 12px;" />
  15. <span style="align-items: center;display: flex;">—</span>
  16. <input v-model="endTime" type="date" @input="timeSizer" style="padding-top: 12px;" />
  17. </view>
  18. </view>
  19. </view>
  20. <view class="uni-row" style="margin-top: 10rpx;">
  21. <view class="scan-btn " style="min-height: 80rpx;" @click="handleAddFirstInspection">新增首件检</view>
  22. <view class="scan-btn " style="background-color: #aaaaff;min-height: 80rpx;margin-left: 24rpx;"
  23. @click="handleScan">扫码</view>
  24. </view>
  25. <view class="daywork-item uni-column" v-for="(item, index) in inspecionList" :key="index"
  26. @click="handleSelection(item)">
  27. <view class="lot-code uni-row">
  28. <text>批次号:{{ item.lotCode }}</text>
  29. <text :style="selectType(item)">{{ selectText(item) }}</text>
  30. <text v-if="delable(item)" class="fa fa-trash" style="font-size: 16; color: red;"
  31. @click.stop="deleteItem(item)"></text>
  32. <text v-else class="fa fa-trash" style="font-size: 16; color: white;"></text>
  33. </view>
  34. <view class="info">
  35. <view class="info-row uni-row">
  36. <view class="label">巡检箱号:</view>
  37. <view class="value">{{ item.carrierCode }}</view>
  38. <view class="label">检察员:</view>
  39. <view class="value">{{ item.technicianName }}</view>
  40. </view>
  41. <view class="info-row uni-row">
  42. <view class="label">检查数量:</view>
  43. <view class="value">{{ item.examiningNum }}</view>
  44. <view class="label">不良品量:</view>
  45. <view class="value">{{ item.disqualificationNum }}</view>
  46. </view>
  47. <view class="info-row uni-row">
  48. <view class="label">产品描述:</view>
  49. <view class="value">{{ item.productDescription }}</view>
  50. </view>
  51. <view class="info-row uni-row">
  52. <view class="label">检测载具:</view>
  53. <view class="value">{{ item.inspectionCarrierCode }}
  54. {{ item.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  55. </view>
  56. <button class="reporting-tag" size="mini" type="primary"
  57. @click.stop="changeCheckCarrier(item)">检测载具</button>
  58. </view>
  59. </view>
  60. </view>
  61. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  62. </view>
  63. </template>
  64. <script setup>
  65. import {
  66. ref
  67. } from 'vue'
  68. import {
  69. getProcessInspecionList,
  70. getLotInfo,
  71. delProcessInspection
  72. } from '@/api/business/processInspection.js'
  73. import QrScanner from '../vueQrCode/index.vue'
  74. import {
  75. timestampToTime,
  76. toHHmmss
  77. } from '@/utils/common.js'
  78. import {
  79. onLoad,
  80. onReady,
  81. onUnload,
  82. onShow,
  83. onReachBottom
  84. } from '@dcloudio/uni-app'
  85. import {
  86. store
  87. } from '@/store/index.js'
  88. const keyword = ref('')
  89. const inspecionList = ref([]); //时间后筛选数组
  90. const original = ref([]); //原始数组
  91. const startTime = ref(new Date().toISOString().split("T")[0])
  92. const endTime = ref(new Date().toISOString().split("T")[0])
  93. const pageSize = ref(10)
  94. const pageNum = ref(1)
  95. const status = ref(true)
  96. const showQrCodeReader = ref(false);
  97. const range = [{
  98. value: 0,
  99. text: "待确认",
  100. type: "color: #fcab53"
  101. }, {
  102. value: 1,
  103. text: "合格",
  104. type: "color: #55ff7f"
  105. }, {
  106. value: 2,
  107. text: "不合格",
  108. type: "color: #ff0c2c"
  109. }]
  110. const quer = ref({}) //用于查询
  111. /***************************** 页面生命周期函数 *****************************/
  112. onShow(() => {
  113. getList()
  114. // uni.showLoading({
  115. // title: '加载中'
  116. // });
  117. // quer.value.userId = store.userInfo.userId;
  118. // quer.value.startTime = startTime.value;
  119. // getProcessInspecionList(quer.value).then(res => {
  120. // console.log("res", res);
  121. // if (res.code == 200) {
  122. // original.value = res.rows;
  123. // // timeSizer();
  124. // uni.hideLoading();
  125. // // uni.hideLoading();
  126. // }
  127. // });
  128. })
  129. onReachBottom(() => {
  130. console.log(status.value)
  131. if (status.value) {
  132. pageNum.value += 1
  133. quer.value.pageNum = pageNum.value
  134. quer.value.pageSize = pageSize.value
  135. getProcessInspecionList(quer.value).then(res => {
  136. const existingIds = new Set(inspecionList.value.map(item => item.id));
  137. // 过滤出那些不在 existingIds 中的项,即新数据
  138. const newRows = res.rows.filter(row => !existingIds.has(row.id));
  139. // 如果有新数据,将其添加到 listData
  140. if (newRows.length > 0) {
  141. inspecionList.value = inspecionList.value.concat(newRows);
  142. original.value = original.value.concat(newRows);
  143. } else {
  144. // 如果没有新数据,更新状态表示没有更多数据
  145. status.value = false;
  146. }
  147. })
  148. }
  149. })
  150. /***************************** 定义了一些方法 *****************************/
  151. // 新增出厂检
  152. const handleAddFirstInspection = () => {
  153. store.processInspection = null
  154. store.isReviewer = true
  155. uni.navigateTo({
  156. url: '/pages/firstInspection/reviewScan'
  157. })
  158. }
  159. function handleSearch() {
  160. pageNum.value = 1
  161. status.value = true
  162. getList()
  163. }
  164. function getList() {
  165. uni.showLoading({
  166. title: '加载中'
  167. });
  168. //quer.value.creatorId = store.userInfo.userId;
  169. pageNum.value = 1
  170. quer.value.deptId = store.curDeptDetails.deptId
  171. quer.value.startTime = startTime.value;
  172. quer.value.endTime = endTime.value;
  173. quer.value.type = "firstArticleInspection"
  174. quer.value.pageNum = pageNum.value
  175. quer.value.pageSize = pageSize.value
  176. if (!checkTime(quer.value.startTime, quer.value.endTime)) {
  177. console.log("777")
  178. uni.showToast({
  179. icon: 'none',
  180. title: "开始日期不能大于结束日期",
  181. duration: 2000
  182. })
  183. } else {
  184. getProcessInspecionList(quer.value).then(res => {
  185. console.log("res", res);
  186. if (res.code == 200) {
  187. original.value = res.rows;
  188. inspecionList.value = res.rows;
  189. uni.hideLoading();
  190. }
  191. });
  192. }
  193. }
  194. //判断开始时间是否大于结束时间
  195. function checkTime(time1, time2) {
  196. let date1 = new Date(startTime.value);
  197. let date2 = new Date(endTime.value);
  198. if (date1 > date2) {
  199. return false
  200. }
  201. return true
  202. }
  203. function delable(item) {
  204. if (item.creatorId === store.userInfo.userId) {
  205. return true
  206. }
  207. return false
  208. }
  209. const changeCheckCarrier = (item) => {
  210. const openItem = {
  211. dayworkId: item.dayworkId,
  212. processInspectionId: item.id,
  213. daywork: item
  214. }
  215. uni.navigateTo({
  216. url: "/pages/changeInspectionBox/index",
  217. success: function(res) {
  218. // 通过eventChannel向被打开页面传送数据
  219. res.eventChannel.emit('outsourceFromOpenerPage', {
  220. data: openItem
  221. })
  222. }
  223. })
  224. }
  225. const deleteItem = (item) => {
  226. uni.showModal({
  227. title: '确认',
  228. content: '确认删除该首件检么?',
  229. success: function(res) {
  230. if (res.confirm) {
  231. delProcessInspection(item.id).then(res => {
  232. if (res.code === 200) {
  233. console.log(res)
  234. getList()
  235. } else {
  236. uni.showToast({
  237. icon: 'none',
  238. title: res.msg
  239. })
  240. }
  241. })
  242. } else if (res.cancel) {
  243. uni.showToast({
  244. title: '已取消',
  245. icon: 'none'
  246. })
  247. }
  248. }
  249. })
  250. }
  251. //H5扫码器回调
  252. function onDecodeHandler(data) {
  253. showQrCodeReader.value = false;
  254. let vehicleObj = {
  255. carrierCode: data
  256. };
  257. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  258. uni.showToast({
  259. icon: "none",
  260. title: "请扫载具码",
  261. duration: 1000
  262. })
  263. return;
  264. }
  265. quer.value.keyword = vehicleObj.carrierCode
  266. getList()
  267. }
  268. //H5扫码器关闭
  269. function qrReaderClose() {
  270. showQrCodeReader.value = false;
  271. }
  272. //扫码
  273. function handleScan() {
  274. showQrCodeReader.value = true;
  275. // 引入原生插件
  276. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  277. // if (mpaasScanModule) {
  278. // // 调用插件的 mpaasScan 方法
  279. // mpaasScanModule.mpaasScan({
  280. // // 扫码识别类型,参数可多选,qrCode、barCode,
  281. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  282. // scanType: ["qrCode", "barCode"],
  283. // // 是否隐藏相册,默认false不隐藏
  284. // hideAlbum: false,
  285. // },
  286. // (ret) => {
  287. // console.log(ret);
  288. // let vehicleObj = {
  289. // carrierCode: ret.resp_result
  290. // };
  291. // if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  292. // uni.showToast({
  293. // icon: "none",
  294. // title: "请扫载具码",
  295. // duration: 1000
  296. // })
  297. // return;
  298. // }
  299. // quer.value.keyword = vehicleObj.carrierCode
  300. // getList()
  301. // }
  302. // );
  303. // } else {
  304. // // 测试时用
  305. // quer.value.keyword = ""
  306. // getList()
  307. // }
  308. }
  309. //时间筛选,暂时注释,使用搜索向
  310. function timeSizer() {
  311. if (!checkTime(startTime.value, endTime.value)) {
  312. console.log("777")
  313. uni.showToast({
  314. icon: 'none',
  315. title: "开始日期不能大于结束日期",
  316. duration: 2000
  317. })
  318. } else {
  319. getList()
  320. }
  321. }
  322. // 筛选函数
  323. const filterSameDayItems = (inspectionList, startTime) => {
  324. // 使用filter方法筛选出与startTime同一天的元素
  325. const filteredList = inspectionList.filter(item => {
  326. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  327. const itemDateString = item.createTime.split(' ')[0];
  328. // 比较两个日期字符串是否相同
  329. return itemDateString === startTime;
  330. });
  331. return filteredList;
  332. };
  333. function isSameDate(date1, date2) {
  334. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  335. const formatDate = (date) => date.toISOString().split('T')[0];
  336. // 比较两个日期的年月日部分是否相同
  337. return formatDate(date1) === formatDate(date2);
  338. }
  339. //查看序捡详情
  340. function handleSelection(item) {
  341. store.processInspection = item;
  342. uni.navigateTo({
  343. url: '/pages/firstInspection/form'
  344. })
  345. }
  346. //状态文本
  347. function selectText(item) {
  348. for (var i = 0; i < range.length; i++) {
  349. if (item.status == range[i].value) {
  350. return range[i].text
  351. }
  352. }
  353. }
  354. //状态样式
  355. function selectType(item) {
  356. for (var i = 0; i < range.length; i++) {
  357. if (item.status == range[i].value) {
  358. return range[i].type
  359. }
  360. }
  361. }
  362. const addProcessInspection = (data) => {
  363. const info = {
  364. title: data.title,
  365. standard: data.standard,
  366. result: '',
  367. number: 1
  368. }
  369. unfitInfos.value.push(info)
  370. }
  371. </script>
  372. <style lang="scss">
  373. .time-controls {
  374. .title {
  375. margin: 20% auto 40% auto;
  376. }
  377. .sta {
  378. justify-content: flex-start;
  379. align-items: center;
  380. input {
  381. border: 1rpx solid gray;
  382. border-radius: 8rpx;
  383. width: 100%;
  384. // width: 400rpx;
  385. flex: 1;
  386. height: 64rpx;
  387. }
  388. }
  389. }
  390. .page-container {
  391. // height: 100%;
  392. background-color: #ececec;
  393. font-size: 28rpx;
  394. padding: 24rpx;
  395. box-sizing: border-box;
  396. }
  397. .search-container {
  398. border-radius: 12rpx;
  399. align-items: center;
  400. input {
  401. flex: 1;
  402. background-color: #ffffff;
  403. height: 64rpx;
  404. box-sizing: border-box;
  405. padding: 0 16rpx;
  406. }
  407. .btn {
  408. width: 120rpx;
  409. height: 64rpx;
  410. background-color: #1684FC;
  411. justify-content: center;
  412. font-size: 24rpx;
  413. color: #ffffff;
  414. justify-content: center;
  415. align-items: center;
  416. }
  417. }
  418. .scan-btn {
  419. height: 64rpx;
  420. color: #ffffff;
  421. background-color: #f47c3c;
  422. align-items: center;
  423. justify-content: center;
  424. border-radius: 8rpx;
  425. flex: 1;
  426. }
  427. .daywork-item {
  428. padding: 24rpx;
  429. background-color: #ffffff;
  430. margin-top: 24rpx;
  431. border-radius: 8rpx;
  432. .lot-code {
  433. align-items: center;
  434. justify-content: space-between;
  435. font-weight: 700;
  436. }
  437. .info {
  438. font-size: 24rpx;
  439. color: #767676;
  440. .info-row {
  441. margin-top: 16rpx;
  442. .label {
  443. width: 120rpx;
  444. }
  445. .value {
  446. flex: 1;
  447. }
  448. }
  449. }
  450. }
  451. </style>