index.vue 11 KB

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