index.vue 12 KB

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