index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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="getList">搜索</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. quer.value.startTime = startTime.value;
  142. quer.value.isAuto = 0
  143. quer.value.type = "outsourcedInspector"
  144. quer.value.pageNum = pageNum.value
  145. quer.value.pageSize = pageSize.value
  146. getOutsourcedInspection(quer.value).then(res => {
  147. console.log("res", res);
  148. if (res.code == 200) {
  149. original.value = res.rows;
  150. inspecionList.value = res.rows;
  151. // timeSizer();
  152. uni.hideLoading();
  153. // uni.hideLoading();
  154. }
  155. });
  156. }
  157. //查询P2中外协完成后需要检查的工序
  158. function getP2() {
  159. let token = 'Bearer ' + getToken();
  160. let header = {
  161. Authorization: token
  162. }
  163. uni.request({
  164. url: path.furnaceNoURL + '/business/sfc10300/getP2ProcessWrbz/' + "Y",
  165. method: 'GET',
  166. header,
  167. sslVerify: false,
  168. success: (res) => {
  169. console.log("P2查询", res);
  170. //将工序编码保存到store中
  171. if (res.data.code == 200) {
  172. store.outsourcedCode = res.data.rows.map(item => item.prcode.trim());
  173. // console.log("store", store.outsourcedCode);
  174. }
  175. },
  176. fail: (err) => {
  177. console.log(err)
  178. }
  179. })
  180. }
  181. //扫码
  182. function handleScan() {
  183. // 引入原生插件
  184. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  185. if (mpaasScanModule) {
  186. // 调用插件的 mpaasScan 方法
  187. mpaasScanModule.mpaasScan({
  188. // 扫码识别类型,参数可多选,qrCode、barCode,
  189. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  190. scanType: ["qrCode", "barCode"],
  191. // 是否隐藏相册,默认false不隐藏
  192. hideAlbum: false,
  193. },
  194. (ret) => {
  195. console.log(ret);
  196. let vehicleObj = {
  197. carrierCode: ret.resp_result
  198. };
  199. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  200. uni.showToast({
  201. icon: "none",
  202. title: "请扫载具码",
  203. duration: 1000
  204. })
  205. return;
  206. }
  207. quer.value.keyword = vehicleObj.carrierCode
  208. getList()
  209. }
  210. );
  211. } else {
  212. // 测试时用
  213. quer.value.keyword = ""
  214. getList()
  215. }
  216. }
  217. //时间筛选
  218. function timeSizer() {
  219. // inspecionList.value = filterSameDayItems(original.value, startTime.value);
  220. getList()
  221. }
  222. // 筛选函数
  223. const filterSameDayItems = (inspectionList, startTime) => {
  224. // 使用filter方法筛选出与startTime同一天的元素
  225. const filteredList = inspectionList.filter(item => {
  226. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  227. const itemDateString = item.createTime.split(' ')[0];
  228. // 比较两个日期字符串是否相同
  229. return itemDateString === startTime;
  230. });
  231. return filteredList;
  232. };
  233. function isSameDate(date1, date2) {
  234. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  235. const formatDate = (date) => date.toISOString().split('T')[0];
  236. // 比较两个日期的年月日部分是否相同
  237. return formatDate(date1) === formatDate(date2);
  238. }
  239. //查看序捡详情
  240. function handleSelection(item) {
  241. store.processInspection = item;
  242. uni.navigateTo({
  243. url: '/pages/outsourcedInspection/form'
  244. })
  245. }
  246. //状态文本
  247. function selectText(item) {
  248. for (var i = 0; i < range.length; i++) {
  249. if (item.status == range[i].value) {
  250. return range[i].text
  251. }
  252. }
  253. }
  254. //状态样式
  255. function selectType(item) {
  256. for (var i = 0; i < range.length; i++) {
  257. if (item.status == range[i].value) {
  258. return range[i].type
  259. }
  260. }
  261. }
  262. const addProcessInspection = (data) => {
  263. const info = {
  264. title: data.title,
  265. standard: data.standard,
  266. result: '',
  267. number: 1
  268. }
  269. unfitInfos.value.push(info)
  270. }
  271. /***************************** 定义了一些事件 *****************************/
  272. // 新增序检
  273. const handleAddOutsourcedInspection = () => {
  274. uni.navigateTo({
  275. url: '/pages/outsourcedInspection/scan'
  276. })
  277. }
  278. // 添加不合格信息
  279. const handleShowUnfit = () => {
  280. uni.navigateTo({
  281. url: '/pages/outsourcedInspection/form'
  282. })
  283. }
  284. const deleteItem = (item) => {
  285. // uni.showToast({
  286. // title: "删除方法未完成"
  287. // })
  288. uni.showModal({
  289. title: '确认',
  290. content: (item.rejectNum > 0 ? "已有外协检测信息,确认删除么?" : '确认删除该序检么?'),
  291. success: function(res) {
  292. if (res.confirm) {
  293. delProcessInspection(item.id).then(res => {
  294. if (res.code === 200) {
  295. console.log(res)
  296. getList()
  297. } else {
  298. uni.showToast({
  299. icon: 'none',
  300. title: res.msg
  301. })
  302. }
  303. })
  304. } else if (res.cancel) {
  305. uni.showToast({
  306. title: '已取消',
  307. icon: 'none'
  308. })
  309. }
  310. }
  311. })
  312. }
  313. const changeCheckCarrier = (item) => {
  314. // uni.showToast({
  315. // title: "检测载具方法未完成"
  316. // })
  317. // uni.$once('refreshProcessInspection', () => {
  318. // })
  319. const openItem = {
  320. dayworkId: item.dayworkId,
  321. processInspectionId: item.id,
  322. daywork: item
  323. }
  324. uni.navigateTo({
  325. url: "/pages/changeInspectionBox/index",
  326. success: function(res) {
  327. // 通过eventChannel向被打开页面传送数据
  328. res.eventChannel.emit('outsourceFromOpenerPage', {
  329. data: openItem
  330. })
  331. }
  332. })
  333. }
  334. function delable(item) {
  335. if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:remove') && item.status == 0) {
  336. return true
  337. }
  338. if (item.creatorId === userId.value && item.status == 0) {
  339. return true
  340. }
  341. return false
  342. }
  343. </script>
  344. <style lang="scss">
  345. .time-controls {
  346. .title {
  347. margin: 20% auto 40% auto;
  348. .first {
  349. font-size: 48rpx;
  350. margin: 0 auto;
  351. }
  352. .second {
  353. color: red;
  354. font-size: 24rpx;
  355. margin: 10rpx auto 0 auto;
  356. }
  357. }
  358. .sta {
  359. justify-content: center;
  360. align-items: center;
  361. input {
  362. border: 1rpx solid gray;
  363. border-radius: 8rpx;
  364. width: 400rpx;
  365. height: 64rpx;
  366. }
  367. }
  368. button {
  369. width: 78%;
  370. background-color: #1684fc;
  371. color: white;
  372. margin: 0 auto;
  373. }
  374. }
  375. .page-container {
  376. // height: 100%;
  377. background-color: #ececec;
  378. font-size: 28rpx;
  379. padding: 24rpx;
  380. box-sizing: border-box;
  381. }
  382. .search-container {
  383. border-radius: 12rpx;
  384. align-items: center;
  385. input {
  386. flex: 1;
  387. background-color: #ffffff;
  388. height: 64rpx;
  389. box-sizing: border-box;
  390. padding: 0 16rpx;
  391. }
  392. .btn {
  393. width: 120rpx;
  394. height: 64rpx;
  395. background-color: #1684FC;
  396. justify-content: center;
  397. font-size: 24rpx;
  398. color: #ffffff;
  399. justify-content: center;
  400. align-items: center;
  401. }
  402. }
  403. .scan-btn {
  404. height: 64rpx;
  405. color: #ffffff;
  406. background-color: #f47c3c;
  407. align-items: center;
  408. justify-content: center;
  409. border-radius: 8rpx;
  410. flex:1;
  411. }
  412. .daywork-item {
  413. padding: 24rpx;
  414. background-color: #ffffff;
  415. margin-top: 24rpx;
  416. border-radius: 8rpx;
  417. .lot-code {
  418. align-items: center;
  419. justify-content: space-between;
  420. font-weight: 700;
  421. }
  422. .info {
  423. font-size: 24rpx;
  424. color: #767676;
  425. .info-row {
  426. margin-top: 16rpx;
  427. .label {
  428. width: 120rpx;
  429. }
  430. .value {
  431. flex: 1;
  432. }
  433. }
  434. }
  435. }
  436. </style>