index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <view class='container'>
  3. <view class="content">
  4. <view>
  5. <text class='title'>批次号</text>
  6. <view class="batchNo uni-row">
  7. <view :class="{'batchNo-item':true, 'uni-row': true}" v-for="(item,index) in batchNoList"
  8. :key='index'>
  9. <!-- ,'batchNoCheck':batchNoCheck === item -->
  10. <!-- @click="handleCheckBatchNo(item)" -->
  11. {{ item.lotCode }}{{ item.isLast == 1 ? ' (尾批)': '' }}
  12. </view>
  13. </view>
  14. <view class="inpAndScan ">
  15. <uni-easyinput v-if="batchNoList.length > 0" class="inp" suffixIcon="checkmarkempty"
  16. v-model="inpValue" placeholder="可手动修正批次" @iconClick="iconClick"></uni-easyinput>
  17. <view class="uni-row" style="justify-content: space-between;">
  18. <view v-if="batchNoList.length > 0" class="scanLotCode" @click="handleDoLastLot">
  19. <text>是否加工尾批</text>
  20. </view>
  21. <view v-if="batchNoList.length > 0" class="scanLotCode" @click="handleConfirmLotCode">
  22. <text>扫码修正批次</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class='middle'>
  28. <view class='segment'></view>
  29. <uni-icons type="link" size="30" style="margin: 10rpx; transform: rotate(135deg);"></uni-icons>
  30. <view class='segment'></view>
  31. </view>
  32. <!-- <view>
  33. <text class='title'>扫码绑定载具</text>
  34. <view class="vehicleList uni-row">
  35. <view class="vehicleNo uni-row" v-for="(item,index) in vehicleList">
  36. <text>{{item.carrierCode}}</text>
  37. <text @click="handleDelVehicleNo(index)">×</text>
  38. </view>
  39. </view>
  40. <view>
  41. <button style='background-color: rgba(0, 226, 166,1);
  42. color: white;margin: 20rpx auto;
  43. width: 80%;' @click='handleScanCode'>扫码</button>
  44. </view>
  45. </view> -->
  46. <view class="selectedProcess">
  47. <uni-section title="请选择工序" type="square">
  48. <uni-data-select v-model="selectedProcess" :localdata="processList" :clear="false"
  49. @change="handleProcessChange"></uni-data-select>
  50. </uni-section>
  51. </view>
  52. <view class='middle'>
  53. <view class='segment'></view>
  54. <uni-icons type="paperclip" size="30" style="margin: 10rpx;"></uni-icons>
  55. <view class='segment'></view>
  56. </view>
  57. <view>
  58. <text class='title' style="margin-bottom: 40rpx;">基础信息</text>
  59. <view class="uni-row info" style="align-items: center;">
  60. <label for="HeatNo">炉号:</label>
  61. <uni-data-select id="incomingInfo" class="uni-input data-select" v-model="basicInfo"
  62. :localdata="furnaceNumberInfoList" :clear="false"
  63. @change="handleFurnaceNumberChange"></uni-data-select>
  64. </view>
  65. <!-- <view class='segment' style="width: 90%;margin: 20rpx auto;"></view> -->
  66. <view class="uni-row info">
  67. <label for="productionPlanNo">计划单号:</label>
  68. <text id="productionPlanNo"
  69. class="uni-input">{{ basicInfo.productionPlanNo ? basicInfo.productionPlanNo : '-'}}</text>
  70. </view>
  71. <!-- <view class='segment' style="width: 90%;margin: 20rpx auto;"></view> -->
  72. <view class="uni-row info">
  73. <label for="lineNumber">序号:</label>
  74. <text id="lineNumber"
  75. class="uni-input">{{ basicInfo.lineNumber ? basicInfo.lineNumber : '-'}}</text>
  76. </view>
  77. <!-- <view class='segment' style="width: 90%;margin: 20rpx auto;"></view> -->
  78. <view class="uni-row info">
  79. <label for="factory">厂家:</label>
  80. <text id="factory"
  81. class="material uni-input">{{ basicInfo.factory ? basicInfo.factory : '-'}}</text>
  82. </view>
  83. <view class="uni-row info">
  84. <label for="brandNumber">牌号:</label>
  85. <text id="brandNumber"
  86. class="material uni-input">{{ basicInfo.brandNumber ? basicInfo.brandNumber : '-' }}</text>
  87. </view>
  88. <view class="uni-row info">
  89. <label for="spec">规格:</label>
  90. <text id="spec" class="material uni-input">{{ basicInfo.spec ? basicInfo.spec : '-' }}</text>
  91. </view>
  92. <view class="uni-row info">
  93. <label for="shape">形状:</label>
  94. <text id="shape" class="material uni-input">{{ basicInfo.shape ? basicInfo.shape : '-'}}</text>
  95. </view>
  96. <view class="uni-row info">
  97. <label for="diameter">材料直径:</label>
  98. <text id="diameter"
  99. class="material uni-input">{{ basicInfo.diameter ? basicInfo.diameter : '-' }}</text>
  100. </view>
  101. <view class="uni-row info">
  102. <label for="rawMaterialCode">原料编码:</label>
  103. <text id="rawMaterialCode"
  104. class="material uni-input">{{ basicInfo.rawMaterialCode ? basicInfo.rawMaterialCode : '-' }}</text>
  105. </view>
  106. <view class="uni-row info">
  107. <label for="incomingDate">来料日期:</label>
  108. <text id="incomingDate"
  109. class="material uni-input">{{ basicInfo.incomingDate ? basicInfo.incomingDate : '-' }}</text>
  110. </view>
  111. <view class="uni-row info">
  112. <label for="firstTechnicalRequirement">材质1:</label>
  113. <text id="firstTechnicalRequirement"
  114. class="material uni-input">{{ basicInfo.firstTechnicalRequirement ? basicInfo.firstTechnicalRequirement : '-' }}</text>
  115. </view>
  116. <view class="uni-row info">
  117. <label for="SecondTechnicalRequirement">材质2:</label>
  118. <text id="SecondTechnicalRequirement"
  119. class="material uni-input">{{ basicInfo.SecondTechnicalRequirement ? basicInfo.SecondTechnicalRequirement : '-' }}</text>
  120. </view>
  121. </view>
  122. </view>
  123. <view class='bottom uni-row'>
  124. <button class='add' type=primary @click='handleAdd'>添加</button>
  125. </view>
  126. </view>
  127. </template>
  128. <script setup>
  129. import {
  130. ref
  131. } from 'vue'
  132. import {
  133. onLoad,
  134. onReady
  135. } from '@dcloudio/uni-app'
  136. import {
  137. getLotList
  138. } from "@/api/business/lot.js"
  139. import {
  140. saveDayWork
  141. } from '@/api/business/dayWork.js'
  142. import {
  143. store
  144. } from '@/store/index.js'
  145. import {
  146. getCarrierById,
  147. checkCarrier
  148. } from '@/api/business/carrier.js'
  149. import {
  150. getFurnaceNoInfo
  151. } from '@/api/p2/furnaceNoInfo.js'
  152. import {
  153. getToken
  154. } from '@/utils/auth'
  155. import {
  156. getProcessList
  157. } from '@/api/business/deptProcess.js'
  158. import path from '@/api/base/path.js'
  159. const batchNoCheck = ref(null) // 批次号是否选中
  160. const batchNoList = ref([]) // 批次号列表
  161. const vehicleList = ref([])
  162. const basicInfo = ref({}) // 基础信息对象
  163. const dayWork = ref({})
  164. const curPlan = ref({})
  165. const furnaceNumberInfoList = ref([])
  166. const emit = defineEmits(['batchReporting-addBatch']);
  167. const inpValue = ref('')
  168. const lotList = ref([])
  169. const selectedProcess = ref(null)
  170. const processList = ref([])
  171. onLoad(() => {
  172. // 处理特殊字符JSON解析失败报错
  173. curPlan.value = store.planDetails;
  174. dayWork.value = {
  175. productionPlanDetailId: curPlan.value.id,
  176. productionPlanId: curPlan.value.productionDetailId,
  177. technologicalProcessId: curPlan.value.technologicalProcessId,
  178. deptId: store.curDeptDetails.deptId
  179. }
  180. init();
  181. })
  182. function init() {
  183. let obj = {}
  184. obj.productionPlanDetailId = store.planDetails.id;
  185. getLotList(obj).then(res => {
  186. console.log(res)
  187. lotList.value = res.rows;
  188. if (res.rows.length > 0) {
  189. batchNoList.value = [res.rows[0]];
  190. dayWork.value.lotId = batchNoList.value[0].id;
  191. dayWork.value.lotCode = batchNoList.value[0].lotCode;
  192. if(dayWork.value.technologicalProcessId != batchNoList.value[0].technologicalProcessId){
  193. dayWork.value.technologicalProcessId = batchNoList.value[0].technologicalProcessId;
  194. store.planDetails.technologicalProcessId = batchNoList.value[0].technologicalProcessId;
  195. }
  196. } else {
  197. batchNoList.value = res.rows;
  198. }
  199. })
  200. // 拉取炉号信息from p2
  201. let token = 'Bearer ' + getToken();
  202. let header = {
  203. Authorization: token
  204. }
  205. uni.request({
  206. url: path.furnaceNoURL + '/business/furnaceNoInfo/getFurnaceNoInfo',
  207. data: {
  208. productionPlanNo: store.planDetails.productionPlanNo,
  209. lineNumber: store.planDetails.lineNumber
  210. },
  211. method: 'GET',
  212. header,
  213. sslVerify: false,
  214. success: (res) => {
  215. console.log(res.data);
  216. if (res.data.code == 200 && res.data.data.length > 0) {
  217. for (let i = 0; i < res.data.data.length; i++) {
  218. furnaceNumberInfoList.value[i] = {
  219. text: res.data.data[i].furnaceNumber,
  220. value: res.data.data[i]
  221. }
  222. }
  223. basicInfo.value = res.data.data[0];
  224. dayWork.value.furnaceNoInfo = basicInfo.value;
  225. console.log(basicInfo.value);
  226. console.log(furnaceNumberInfoList.value)
  227. }
  228. }
  229. })
  230. getProcessList({
  231. deptId: store.curDeptDetails.deptId,
  232. }).then(res => {
  233. if (res.code == 200) {
  234. //过滤出工序交集
  235. let filteredData = store.planDetails.processSequence.filter((item1) =>
  236. res.data.some((item2) => item2.processCode === item1.processCode)
  237. );
  238. // for (let i = 0; i < filteredData.length; i++) {
  239. // processList.value[i] = {
  240. // text: filteredData[i].processAlias,
  241. // // value: filteredData[i].id,
  242. // value: filteredData[i].technologicalProcessDetailId,
  243. // processId: filterData[i].id
  244. // }
  245. // }
  246. processList.value = filteredData.map(v => ({
  247. text: v.processAlias,
  248. value: v.technologicalProcessDetailId,
  249. processId: v.id
  250. }))
  251. console.log(processList.value)
  252. selectedProcess.value = filteredData[0].technologicalProcessDetailId;
  253. dayWork.value.processId = filteredData[0].id;
  254. dayWork.value.technologicalProcessDetailId = selectedProcess.value
  255. }
  256. })
  257. }
  258. // function handleCheckBatchNo(item) {
  259. // batchNoCheck.value = item;
  260. // dayWork.value.lotId = item.id;
  261. // }
  262. // function handleDelVehicleNo(index) {
  263. // vehicleList.value.splice(index, 1);
  264. // }
  265. // function handleValidate() {
  266. // if (batchNoCheck.value && vehicleList.value) {
  267. // return true;
  268. // } else {
  269. // return false;
  270. // }
  271. // }
  272. function iconClick() {
  273. checkLotCode(inpValue.value);
  274. }
  275. function checkLotCode(lotCode) {
  276. if (lotList.value.some(item => item.lotCode == lotCode)) {
  277. for (let i = 0; i < lotList.value.length; i++) {
  278. if (lotList.value[i].lotCode == lotCode) {
  279. batchNoList.value = [lotList.value[i]];
  280. dayWork.value.lotId = lotList.value[i].id;
  281. dayWork.value.lotCode = lotList.value[i].lotCode;
  282. uni.showToast({
  283. icon: "none",
  284. title: "该批次号可用",
  285. duration: 2000
  286. })
  287. return true;
  288. }
  289. }
  290. } else {
  291. uni.showToast({
  292. icon: "none",
  293. title: "该批次号已被使用或不属于该产品",
  294. duration: 2000
  295. })
  296. return false;
  297. }
  298. }
  299. function handleDoLastLot() {
  300. uni.showModal({
  301. title: '提示',
  302. content: '确认是否加工尾批?',
  303. success: function(res) {
  304. if (res.confirm) {
  305. if(lotList.value.some(item => item.isLast == 1)){
  306. for (let i = 0; i < lotList.value.length; i++) {
  307. if (lotList.value[i].isLast == 1) {
  308. batchNoList.value = [lotList.value[i]];
  309. dayWork.value.lotId = lotList.value[i].id;
  310. dayWork.value.lotCode = lotList.value[i].lotCode;
  311. dayWork.value.isLast = '1';
  312. return;
  313. }
  314. }
  315. }else{
  316. uni.showToast({
  317. icon: 'none',
  318. title: '当前计划尾批已被加工',
  319. duration: 2500
  320. })
  321. }
  322. } else if (res.cancel) {}
  323. }
  324. });
  325. }
  326. function handleConfirmLotCode() {
  327. // 引入原生插件
  328. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  329. // 调用插件的 mpaasScan 方法
  330. mpaasScanModule.mpaasScan({
  331. // 扫码识别类型,参数可多选,qrCode、barCode,
  332. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  333. scanType: ["qrCode", "barCode"],
  334. // 是否隐藏相册,默认false不隐藏
  335. hideAlbum: false,
  336. },
  337. (ret) => {
  338. console.log(ret);
  339. // uni.showModal({
  340. // title: "扫码结果",
  341. // // 返回值中,有三个参数 resp_code、resp_message、resp_result
  342. // // resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
  343. // // resp_message 表示返回结果信息
  344. // // resp_result 表示扫码结果,只有成功才会有返回
  345. // content: JSON.stringify(ret),
  346. // showCancel: false,
  347. // confirmText: "确定",
  348. // });
  349. if (ret.resp_result) {
  350. checkLotCode(ret.resp_result);
  351. }
  352. }
  353. );
  354. }
  355. function handleFurnaceNumberChange() {
  356. dayWork.value.furnaceNoInfo = basicInfo.value;
  357. }
  358. function handleProcessChange() {
  359. dayWork.value.technologicalProcessDetailId = selectedProcess.value;
  360. dayWork.value.processId = processList.value.findIndex(v => v.value === selectedProcess.value) >= 0 ? processList.value.find(v => v.value === selectedProcess.value).processId : null
  361. }
  362. // function handleScanCode() {
  363. // uni.scanCode({
  364. // scanType: ['qrCode'],
  365. // onlyFromCamera: true, // 只允许相机扫码
  366. // autoZoom: false,
  367. // success: function(res) {
  368. // let vehicleObj = JSON.parse(res.result);
  369. // if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  370. // uni.showToast({
  371. // icon: "error",
  372. // title: "请扫载具码",
  373. // duration: 1000
  374. // })
  375. // return;
  376. // }
  377. // for (let i = 0; i < vehicleList.value.length; i++) {
  378. // if (vehicleList.value[i].carrierId == vehicleObj.carrierId) {
  379. // uni.showToast({
  380. // icon: "error",
  381. // title: "载具已存在",
  382. // duration: 1000
  383. // })
  384. // return;
  385. // }
  386. // }
  387. // checkCarrier(vehicleObj.carrierId).then(response => {
  388. // if (response.code == 200) {
  389. // vehicleList.value.push(vehicleObj);
  390. // } else {
  391. // uni.showToast({
  392. // icon: 'none',
  393. // title: response.msg
  394. // })
  395. // return;
  396. // }
  397. // })
  398. // }
  399. // });
  400. // }
  401. function handleAdd() {
  402. if (selectedProcess.value == null) {
  403. uni.showToast({
  404. icon: 'none',
  405. title: '请选择工序后再开始批次'
  406. })
  407. return;
  408. }
  409. console.log(dayWork.value)
  410. console.log(basicInfo.value)
  411. store.furnaceNumberInfo = basicInfo.value;
  412. if (checkLotCode(dayWork.value.lotCode)) {
  413. saveDayWork(dayWork.value).then(res => {
  414. console.log(res)
  415. if (res.code === 200) {
  416. uni.showToast({
  417. icon: 'success',
  418. title: '添加成功',
  419. duration: 2000
  420. });
  421. // uni.$emit('batchReporting-addBatch');
  422. // uni.$emit('dayworkItemUpdate');
  423. uni.navigateBack({
  424. url: '/pages/batchReporting/index'
  425. })
  426. } else {
  427. uni.showToast({
  428. icon: 'none',
  429. title: res.msg,
  430. duration: 2000
  431. });
  432. }
  433. })
  434. } else {
  435. uni.showToast({
  436. icon: "none",
  437. title: "该批次号已被使用或不属于该产品",
  438. duration: 2000
  439. })
  440. }
  441. }
  442. </script>
  443. <style lang="scss">
  444. .container {
  445. height: 90%;
  446. background-color: #f5f5f5;
  447. padding-bottom: 112rpx;
  448. }
  449. .bottom {
  450. background-color: white;
  451. width: 100%;
  452. position: fixed;
  453. bottom: 0;
  454. align-items: center;
  455. background-color: #ffffff;
  456. padding: 16rpx 0;
  457. .add {
  458. margin: 0 auto;
  459. width: 80%;
  460. height: 80rpx;
  461. }
  462. }
  463. .content {
  464. position: relative;
  465. width: auto;
  466. background-color: rgba(255, 255, 255, 1);
  467. margin: 32rpx;
  468. padding-bottom: 50rpx;
  469. padding-top: 20rpx;
  470. border-radius: 12rpx;
  471. height: 100%;
  472. overflow: auto;
  473. .title {
  474. width: auto;
  475. font-size: 36rpx;
  476. font-weight: bold;
  477. text-align: center;
  478. }
  479. }
  480. .inpAndScan {
  481. justify-content: space-between;
  482. width: calc(88% + 20rpx);
  483. margin: 0 auto;
  484. .inp {
  485. width: calc(100% - 16rpx);
  486. margin: 10rpx auto;
  487. height: 74rpx;
  488. }
  489. .scanLotCode {
  490. border-radius: 6rpx;
  491. border: 1rpx solid rgba(22, 132, 252, 1);
  492. height: 60rpx;
  493. margin: 10rpx;
  494. height: 72rpx;
  495. width: 46%;
  496. text-align: center;
  497. line-height: 72rpx;
  498. background-color: rgba(22, 132, 252, 1);
  499. color: white;
  500. }
  501. }
  502. .batchNo {
  503. // justify-content: flex-start;
  504. // flex-wrap: wrap;
  505. // width: auto;
  506. // height: 320rpx;
  507. // overflow: auto;
  508. // padding-left: calc(100% - 88% - 4rpx - 40rpx);
  509. // margin-bottom: 40rpx;
  510. // border-radius: 6rpx;
  511. justify-content: center;
  512. .batchNo-item {
  513. justify-content: center;
  514. align-items: center;
  515. width: 88%;
  516. margin: 10rpx;
  517. height: 72rpx;
  518. border: 1px solid rgba(213, 213, 213, 1);
  519. border-radius: 6rpx;
  520. }
  521. .batchNoCheck {
  522. color: #FFF;
  523. border: 1rpx solid rgba(22, 132, 252, 1);
  524. background-color: rgba(22, 132, 252, 1);
  525. }
  526. }
  527. .vehicleList {
  528. justify-content: flex-start;
  529. flex-wrap: wrap;
  530. width: auto;
  531. height: 120rpx;
  532. overflow: auto;
  533. padding: 0 80rpx;
  534. .vehicleNo {
  535. padding: 0 10rpx;
  536. margin: 10rpx;
  537. justify-content: space-between;
  538. align-items: center;
  539. width: 230rpx;
  540. height: 60rpx;
  541. border: 1px solid rgba(213, 213, 213, 1);
  542. border-radius: 6rpx;
  543. }
  544. }
  545. .middle {
  546. display: flex;
  547. flex-direction: row;
  548. align-items: center;
  549. justify-content: center
  550. }
  551. .segment {
  552. width: 280rpx;
  553. background-color: rgba(213, 213, 213, 1);
  554. border: 1rpx solid rgba(213, 213, 213, 1);
  555. }
  556. .info {
  557. width: 94%;
  558. justify-content: space-around;
  559. padding: 10rpx;
  560. margin: 0 auto;
  561. label {
  562. flex: 1;
  563. text-combine-upright: all;
  564. margin: 0 30rpx 0 20rpx;
  565. }
  566. text {
  567. flex: 3;
  568. // width: 80%;
  569. }
  570. .data-select {
  571. flex: 3;
  572. width: 80%;
  573. height: 60rpx;
  574. margin-right: 40rpx;
  575. border-radius: 18rpx;
  576. background-color: #FFF;
  577. .data-select-options {
  578. width: 200rpx;
  579. }
  580. }
  581. }
  582. .material {
  583. height: auto;
  584. width: 60%;
  585. }
  586. .selectedProcess {
  587. width: 88%;
  588. margin: 20rpx auto 40rpx;
  589. }
  590. </style>