index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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="getList">搜索</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 delable(item) {
  169. if (item.creatorId === store.userInfo.userId) {
  170. return true
  171. }
  172. return false
  173. }
  174. const deleteItem = (item) => {
  175. uni.showModal({
  176. title: '确认',
  177. content: '确认删除该仪器室检查么?',
  178. success: function(res) {
  179. if (res.confirm) {
  180. delProcessInspection(item.id).then(res => {
  181. if (res.code === 200) {
  182. console.log(res)
  183. getList()
  184. } else {
  185. uni.showToast({
  186. icon: 'none',
  187. title: res.msg
  188. })
  189. }
  190. })
  191. } else if (res.cancel) {
  192. uni.showToast({
  193. title: '已取消',
  194. icon: 'none'
  195. })
  196. }
  197. }
  198. })
  199. }
  200. const changeCheckCarrier = (item) => {
  201. const openItem = {
  202. dayworkId: item.dayworkId,
  203. processInspectionId: item.id,
  204. daywork: item
  205. }
  206. uni.navigateTo({
  207. url: "/pages/changeInspectionBox/index",
  208. success: function(res) {
  209. // 通过eventChannel向被打开页面传送数据
  210. res.eventChannel.emit('outsourceFromOpenerPage', {
  211. data: openItem
  212. })
  213. }
  214. })
  215. }
  216. //扫码
  217. function handleScan() {
  218. // 引入原生插件
  219. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  220. if (mpaasScanModule) {
  221. // 调用插件的 mpaasScan 方法
  222. mpaasScanModule.mpaasScan({
  223. // 扫码识别类型,参数可多选,qrCode、barCode,
  224. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  225. scanType: ["qrCode", "barCode"],
  226. // 是否隐藏相册,默认false不隐藏
  227. hideAlbum: false,
  228. },
  229. (ret) => {
  230. console.log(ret);
  231. let vehicleObj = {
  232. carrierCode: ret.resp_result
  233. };
  234. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  235. uni.showToast({
  236. icon: "none",
  237. title: "请扫载具码",
  238. duration: 1000
  239. })
  240. return;
  241. }
  242. quer.value.keyword = vehicleObj.carrierCode
  243. getList()
  244. }
  245. );
  246. } else {
  247. // 测试时用
  248. quer.value.keyword = ""
  249. getList()
  250. }
  251. }
  252. //时间筛选,暂时注释,使用搜索向
  253. function timeSizer() {
  254. getList()
  255. }
  256. // 筛选函数
  257. const filterSameDayItems = (inspectionList, startTime) => {
  258. // 使用filter方法筛选出与startTime同一天的元素
  259. const filteredList = inspectionList.filter(item => {
  260. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  261. const itemDateString = item.createTime.split(' ')[0];
  262. // 比较两个日期字符串是否相同
  263. return itemDateString === startTime;
  264. });
  265. return filteredList;
  266. };
  267. function isSameDate(date1, date2) {
  268. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  269. const formatDate = (date) => date.toISOString().split('T')[0];
  270. // 比较两个日期的年月日部分是否相同
  271. return formatDate(date1) === formatDate(date2);
  272. }
  273. //查看序捡详情
  274. function handleSelection(item) {
  275. store.processInspection = item;
  276. uni.navigateTo({
  277. url: '/pages/instrumentRoomInspection/form'
  278. })
  279. }
  280. //状态文本
  281. function selectText(item) {
  282. for (var i = 0; i < range.length; i++) {
  283. if (item.status == range[i].value) {
  284. return range[i].text
  285. }
  286. }
  287. }
  288. //状态样式
  289. function selectType(item) {
  290. for (var i = 0; i < range.length; i++) {
  291. if (item.status == range[i].value) {
  292. return range[i].type
  293. }
  294. }
  295. }
  296. const addProcessInspection = (data) => {
  297. const info = {
  298. title: data.title,
  299. standard: data.standard,
  300. result: '',
  301. number: 1
  302. }
  303. unfitInfos.value.push(info)
  304. }
  305. /***************************** 定义了一些事件 *****************************/
  306. </script>
  307. <style lang="scss">
  308. .time-controls {
  309. .title {
  310. margin: 20% auto 40% auto;
  311. .first {
  312. font-size: 48rpx;
  313. margin: 0 auto;
  314. }
  315. .second {
  316. color: red;
  317. font-size: 24rpx;
  318. margin: 10rpx auto 0 auto;
  319. }
  320. }
  321. .sta {
  322. justify-content: center;
  323. align-items: center;
  324. input {
  325. border: 1rpx solid gray;
  326. border-radius: 8rpx;
  327. width: 400rpx;
  328. height: 64rpx;
  329. }
  330. }
  331. button {
  332. width: 78%;
  333. background-color: #1684fc;
  334. color: white;
  335. margin: 0 auto;
  336. }
  337. }
  338. .page-container {
  339. // height: 100%;
  340. background-color: #ececec;
  341. font-size: 28rpx;
  342. padding: 24rpx;
  343. box-sizing: border-box;
  344. }
  345. .search-container {
  346. border-radius: 12rpx;
  347. align-items: center;
  348. input {
  349. flex: 1;
  350. background-color: #ffffff;
  351. height: 64rpx;
  352. box-sizing: border-box;
  353. padding: 0 16rpx;
  354. }
  355. .btn {
  356. width: 120rpx;
  357. height: 64rpx;
  358. background-color: #1684FC;
  359. justify-content: center;
  360. font-size: 24rpx;
  361. color: #ffffff;
  362. justify-content: center;
  363. align-items: center;
  364. }
  365. }
  366. .scan-btn {
  367. height: 64rpx;
  368. color: #ffffff;
  369. background-color: #f47c3c;
  370. align-items: center;
  371. justify-content: center;
  372. border-radius: 8rpx;
  373. flex:1;
  374. }
  375. .daywork-item {
  376. padding: 24rpx;
  377. background-color: #ffffff;
  378. margin-top: 24rpx;
  379. border-radius: 8rpx;
  380. .lot-code {
  381. align-items: center;
  382. justify-content: space-between;
  383. font-weight: 700;
  384. }
  385. .info {
  386. font-size: 24rpx;
  387. color: #767676;
  388. .info-row {
  389. margin-top: 16rpx;
  390. .label {
  391. width: 120rpx;
  392. }
  393. .value {
  394. flex: 1;
  395. }
  396. }
  397. }
  398. }
  399. </style>