index.vue 9.6 KB

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