index.vue 12 KB

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