index.vue 11 KB

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