index.vue 11 KB

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