index.vue 12 KB

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