index.vue 10 KB

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