index.vue 11 KB

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