index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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"
  14. style="flex: 1;width: 100%;padding-top:12px;" />
  15. <span style="align-items: center;display: flex;">—</span>
  16. <input v-model="endTime" type="date" @input="timeSizer" style="padding-top: 12px;" />
  17. </view>
  18. </view>
  19. </view>
  20. <view class="uni-row" style="margin-top: 10rpx;">
  21. <view class="scan-btn " style="min-height: 80rpx;" @click.stop="handleAddOutsourcedInspection">新增外协检查
  22. </view>
  23. <view class="scan-btn " style="background-color: #aaaaff;min-height: 80rpx;margin-left: 24rpx;"
  24. @click="handleScan">扫码</view>
  25. </view>
  26. <view class="daywork-item uni-column" v-for="(item, index) in inspecionList" :key="index"
  27. @click="handleSelection(item)">
  28. <view class="lot-code uni-row">
  29. <text>批次号:{{ item.lotCode }}</text>
  30. <text :style="selectType(item)">{{ selectText(item) }}</text>
  31. <!-- <uni-icons type="right" size="16" /> -->
  32. <!-- item.creatorId === userId && item.status == 0 -->
  33. <text v-if="delable(item)" class="fa fa-trash" style="font-size: 16; color: red;"
  34. @click.stop="deleteItem(item)"></text>
  35. <text v-else class="fa fa-trash" style="font-size: 16; color: white;"></text>
  36. </view>
  37. <view class="info">
  38. <view class="info-row uni-row">
  39. <view class="label">序检箱号:</view>
  40. <view class="value">{{ item.carrierCode }}</view>
  41. <view class="label">检察员:</view>
  42. <view class="value">{{ item.technicianName }}</view>
  43. </view>
  44. <view class="info-row uni-row">
  45. <view class="label">检查数量:</view>
  46. <view class="value">{{ item.examiningNum }}</view>
  47. <view class="label">不良品量:</view>
  48. <view class="value">{{ item.disqualificationNum }}</view>
  49. <view class="label">废品量:</view>
  50. <view class="value">{{ item.rejectNum }}</view>
  51. </view>
  52. <view class="info-row uni-row">
  53. <view class="label">产品描述:</view>
  54. <view class="value">{{ item.productDescription }}</view>
  55. </view>
  56. <view class="info-row uni-row" style="justify-content: space-between;">
  57. <view class="label">检测载具:</view>
  58. <view class="value">{{ item.inspectionCarrierCode }}
  59. {{ item.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  60. </view>
  61. <button class="reporting-tag" size="mini" type="primary"
  62. @click.stop="changeCheckCarrier(item)">检测载具</button>
  63. </view>
  64. </view>
  65. </view>
  66. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  67. </view>
  68. </template>
  69. <script setup>
  70. import {
  71. ref
  72. } from 'vue'
  73. import {
  74. getOutsourcedInspection,
  75. getLotInfo,
  76. delProcessInspection
  77. } from '@/api/business/processInspection.js'
  78. import {
  79. timestampToTime,
  80. toHHmmss
  81. } from '@/utils/common.js'
  82. import QrScanner from '../vueQrCode/index.vue'
  83. import {
  84. onLoad,
  85. onReady,
  86. onUnload,
  87. onShow,
  88. onReachBottom
  89. } from '@dcloudio/uni-app'
  90. import {
  91. store
  92. } from '@/store/index.js'
  93. import {
  94. getToken
  95. } from '@/utils/auth'
  96. import path from '@/api/base/path.js'
  97. const keywords = ref('')
  98. const inspecionList = ref([]); //时间后筛选数组
  99. const original = ref([]); //原始数组
  100. const startTime = ref(new Date().toISOString().split('T')[0])
  101. const endTime = ref(new Date().toISOString().split('T')[0])
  102. const userId = ref(store.userInfo.userId)
  103. const pageSize = ref(10)
  104. const pageNum = ref(1)
  105. const status = ref(true)
  106. const showQrCodeReader = ref(false);
  107. const range = [{
  108. value: 0,
  109. text: "待确认",
  110. type: "color: #fcab53"
  111. }, {
  112. value: 1,
  113. text: "合格",
  114. type: "color: #55ff7f"
  115. }, {
  116. value: 2,
  117. text: "不合格",
  118. type: "color: #ff0c2c"
  119. }]
  120. const quer = ref({}) //用于查询
  121. /***************************** 页面生命周期函数 *****************************/
  122. onShow(() => {
  123. getList();
  124. getP2();
  125. })
  126. onReachBottom(() => {
  127. console.log(status.value)
  128. if (status.value) {
  129. pageNum.value += 1
  130. quer.value.pageNum = pageNum.value
  131. quer.value.pageSize = pageSize.value
  132. getOutsourcedInspection(quer.value).then(res => {
  133. const existingIds = new Set(inspecionList.value.map(item => item.id));
  134. // 过滤出那些不在 existingIds 中的项,即新数据
  135. const newRows = res.rows.filter(row => !existingIds.has(row.id));
  136. // 如果有新数据,将其添加到 listData
  137. if (newRows.length > 0) {
  138. inspecionList.value = inspecionList.value.concat(newRows);
  139. original.value = original.value.concat(newRows);
  140. } else {
  141. // 如果没有新数据,更新状态表示没有更多数据
  142. status.value = false;
  143. }
  144. })
  145. }
  146. })
  147. /***************************** 定义了一些方法 *****************************/
  148. function getList() {
  149. uni.showLoading({
  150. title: '加载中'
  151. });
  152. // quer.value.userId = store.userInfo.userId;
  153. pageNum.value = 1
  154. quer.value.startTime = startTime.value;
  155. quer.value.endTime = endTime.value
  156. quer.value.isAuto = 0
  157. quer.value.type = "outsourcedInspector"
  158. quer.value.pageNum = pageNum.value
  159. quer.value.pageSize = pageSize.value
  160. if (!checkTime(quer.value.startTime, quer.value.endTime)) {
  161. console.log("777")
  162. uni.showToast({
  163. icon: 'none',
  164. title: "开始日期不能大于结束日期",
  165. duration: 2000
  166. })
  167. } else {
  168. getOutsourcedInspection(quer.value).then(res => {
  169. console.log("res", res);
  170. if (res.code == 200) {
  171. original.value = res.rows;
  172. inspecionList.value = res.rows;
  173. // timeSizer();
  174. uni.hideLoading();
  175. // uni.hideLoading();
  176. }
  177. });
  178. }
  179. }
  180. //判断开始时间是否大于结束时间
  181. function checkTime(time1, time2) {
  182. let date1 = new Date(startTime.value);
  183. let date2 = new Date(endTime.value);
  184. if (date1 > date2) {
  185. return false
  186. }
  187. return true
  188. }
  189. function handleSearch() {
  190. pageNum.value = 1
  191. status.value = true
  192. getList()
  193. }
  194. //查询P2中外协完成后需要检查的工序
  195. function getP2() {
  196. let token = 'Bearer ' + getToken();
  197. let header = {
  198. Authorization: token
  199. }
  200. uni.request({
  201. url: path.furnaceNoURL + '/business/sfc10300/getP2ProcessWrbz/' + "Y",
  202. method: 'GET',
  203. header,
  204. sslVerify: false,
  205. success: (res) => {
  206. console.log("P2查询", res);
  207. //将工序编码保存到store中
  208. if (res.data.code == 200) {
  209. store.outsourcedCode = res.data.rows.map(item => item.prcode.trim());
  210. // console.log("store", store.outsourcedCode);
  211. }
  212. },
  213. fail: (err) => {
  214. console.log(err)
  215. }
  216. })
  217. }
  218. //H5扫码器回调
  219. function onDecodeHandler(data) {
  220. showQrCodeReader.value = false;
  221. let vehicleObj = {
  222. carrierCode: data
  223. };
  224. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  225. uni.showToast({
  226. icon: "none",
  227. title: "请扫载具码",
  228. duration: 1000
  229. })
  230. return;
  231. }
  232. quer.value.keyword = vehicleObj.carrierCode
  233. getList()
  234. }
  235. //H5扫码器关闭
  236. function qrReaderClose() {
  237. showQrCodeReader.value = false;
  238. }
  239. //扫码
  240. function handleScan() {
  241. showQrCodeReader.value = true;
  242. // 引入原生插件
  243. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  244. // if (mpaasScanModule) {
  245. // // 调用插件的 mpaasScan 方法
  246. // mpaasScanModule.mpaasScan({
  247. // // 扫码识别类型,参数可多选,qrCode、barCode,
  248. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  249. // scanType: ["qrCode", "barCode"],
  250. // // 是否隐藏相册,默认false不隐藏
  251. // hideAlbum: false,
  252. // },
  253. // (ret) => {
  254. // console.log(ret);
  255. // let vehicleObj = {
  256. // carrierCode: ret.resp_result
  257. // };
  258. // if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  259. // uni.showToast({
  260. // icon: "none",
  261. // title: "请扫载具码",
  262. // duration: 1000
  263. // })
  264. // return;
  265. // }
  266. // quer.value.keyword = vehicleObj.carrierCode
  267. // getList()
  268. // }
  269. // );
  270. // } else {
  271. // // 测试时用
  272. // quer.value.keyword = ""
  273. // getList()
  274. // }
  275. }
  276. //时间筛选
  277. function timeSizer() {
  278. // inspecionList.value = filterSameDayItems(original.value, startTime.value);
  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/outsourcedInspection/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 handleAddOutsourcedInspection = () => {
  342. uni.navigateTo({
  343. url: '/pages/outsourcedInspection/scan'
  344. })
  345. }
  346. // 添加不合格信息
  347. const handleShowUnfit = () => {
  348. uni.navigateTo({
  349. url: '/pages/outsourcedInspection/form'
  350. })
  351. }
  352. const deleteItem = (item) => {
  353. // uni.showToast({
  354. // title: "删除方法未完成"
  355. // })
  356. uni.showModal({
  357. title: '确认',
  358. content: (item.rejectNum > 0 ? "已有外协检测信息,确认删除么?" : '确认删除该序检么?'),
  359. success: function(res) {
  360. if (res.confirm) {
  361. delProcessInspection(item.id).then(res => {
  362. if (res.code === 200) {
  363. console.log(res)
  364. getList()
  365. } else {
  366. uni.showToast({
  367. icon: 'none',
  368. title: res.msg
  369. })
  370. }
  371. })
  372. } else if (res.cancel) {
  373. uni.showToast({
  374. title: '已取消',
  375. icon: 'none'
  376. })
  377. }
  378. }
  379. })
  380. }
  381. const changeCheckCarrier = (item) => {
  382. // uni.showToast({
  383. // title: "检测载具方法未完成"
  384. // })
  385. // uni.$once('refreshProcessInspection', () => {
  386. // })
  387. const openItem = {
  388. dayworkId: item.dayworkId,
  389. processInspectionId: item.id,
  390. daywork: item
  391. }
  392. uni.navigateTo({
  393. url: "/pages/changeInspectionBox/index",
  394. success: function(res) {
  395. // 通过eventChannel向被打开页面传送数据
  396. res.eventChannel.emit('outsourceFromOpenerPage', {
  397. data: openItem
  398. })
  399. }
  400. })
  401. }
  402. function delable(item) {
  403. if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:remove') && item.status == 0) {
  404. return true
  405. }
  406. if (item.creatorId === userId.value && item.status == 0) {
  407. return true
  408. }
  409. return false
  410. }
  411. </script>
  412. <style lang="scss">
  413. .time-controls {
  414. .title {
  415. margin: 20% auto 40% auto;
  416. }
  417. .sta {
  418. justify-content: flex-start;
  419. align-items: center;
  420. input {
  421. border: 1rpx solid gray;
  422. border-radius: 8rpx;
  423. width: 100%;
  424. // width: 400rpx;
  425. flex: 1;
  426. height: 64rpx;
  427. }
  428. }
  429. }
  430. .page-container {
  431. // height: 100%;
  432. background-color: #ececec;
  433. font-size: 28rpx;
  434. padding: 24rpx;
  435. box-sizing: border-box;
  436. }
  437. .search-container {
  438. border-radius: 12rpx;
  439. align-items: center;
  440. input {
  441. flex: 1;
  442. background-color: #ffffff;
  443. height: 64rpx;
  444. box-sizing: border-box;
  445. padding: 0 16rpx;
  446. }
  447. .btn {
  448. width: 120rpx;
  449. height: 64rpx;
  450. background-color: #1684FC;
  451. justify-content: center;
  452. font-size: 24rpx;
  453. color: #ffffff;
  454. justify-content: center;
  455. align-items: center;
  456. }
  457. }
  458. .scan-btn {
  459. height: 64rpx;
  460. color: #ffffff;
  461. background-color: #f47c3c;
  462. align-items: center;
  463. justify-content: center;
  464. border-radius: 8rpx;
  465. flex: 1;
  466. }
  467. .daywork-item {
  468. padding: 24rpx;
  469. background-color: #ffffff;
  470. margin-top: 24rpx;
  471. border-radius: 8rpx;
  472. .lot-code {
  473. align-items: center;
  474. justify-content: space-between;
  475. font-weight: 700;
  476. }
  477. .info {
  478. font-size: 24rpx;
  479. color: #767676;
  480. .info-row {
  481. margin-top: 16rpx;
  482. .label {
  483. width: 120rpx;
  484. }
  485. .value {
  486. flex: 1;
  487. }
  488. }
  489. }
  490. }
  491. </style>