index.vue 11 KB

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