index.vue 12 KB

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