index.vue 8.5 KB

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