index.vue 11 KB

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