index.vue 10 KB

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