index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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. }
  243. }
  244. selectedProcess.value = filteredData[0].id;
  245. dayWork.value.processId = selectedProcess.value;
  246. }
  247. })
  248. }
  249. // function handleCheckBatchNo(item) {
  250. // batchNoCheck.value = item;
  251. // dayWork.value.lotId = item.id;
  252. // }
  253. // function handleDelVehicleNo(index) {
  254. // vehicleList.value.splice(index, 1);
  255. // }
  256. // function handleValidate() {
  257. // if (batchNoCheck.value && vehicleList.value) {
  258. // return true;
  259. // } else {
  260. // return false;
  261. // }
  262. // }
  263. function iconClick() {
  264. checkLotCode(inpValue.value);
  265. }
  266. function checkLotCode(lotCode) {
  267. if (lotList.value.some(item => item.lotCode == lotCode)) {
  268. for (let i = 0; i < lotList.value.length; i++) {
  269. if (lotList.value[i].lotCode == lotCode) {
  270. batchNoList.value = [lotList.value[i]];
  271. dayWork.value.lotId = lotList.value[i].id;
  272. dayWork.value.lotCode = lotList.value[i].lotCode;
  273. uni.showToast({
  274. icon: "none",
  275. title: "该批次号可用",
  276. duration: 2000
  277. })
  278. return true;
  279. }
  280. }
  281. } else {
  282. uni.showToast({
  283. icon: "none",
  284. title: "该批次号已被使用或不属于该产品",
  285. duration: 2000
  286. })
  287. return false;
  288. }
  289. }
  290. function handleDoLastLot() {
  291. uni.showModal({
  292. title: '提示',
  293. content: '确认是否加工尾批?',
  294. success: function(res) {
  295. if (res.confirm) {
  296. if(lotList.value.some(item => item.isLast == 1)){
  297. for (let i = 0; i < lotList.value.length; i++) {
  298. if (lotList.value[i].isLast == 1) {
  299. batchNoList.value = [lotList.value[i]];
  300. dayWork.value.lotId = lotList.value[i].id;
  301. dayWork.value.lotCode = lotList.value[i].lotCode;
  302. dayWork.value.isLast = '1';
  303. return;
  304. }
  305. }
  306. }else{
  307. uni.showToast({
  308. icon: 'none',
  309. title: '当前计划尾批已被加工',
  310. duration: 2500
  311. })
  312. }
  313. } else if (res.cancel) {}
  314. }
  315. });
  316. }
  317. function handleConfirmLotCode() {
  318. // 引入原生插件
  319. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  320. // 调用插件的 mpaasScan 方法
  321. mpaasScanModule.mpaasScan({
  322. // 扫码识别类型,参数可多选,qrCode、barCode,
  323. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  324. scanType: ["qrCode", "barCode"],
  325. // 是否隐藏相册,默认false不隐藏
  326. hideAlbum: false,
  327. },
  328. (ret) => {
  329. console.log(ret);
  330. // uni.showModal({
  331. // title: "扫码结果",
  332. // // 返回值中,有三个参数 resp_code、resp_message、resp_result
  333. // // resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
  334. // // resp_message 表示返回结果信息
  335. // // resp_result 表示扫码结果,只有成功才会有返回
  336. // content: JSON.stringify(ret),
  337. // showCancel: false,
  338. // confirmText: "确定",
  339. // });
  340. if (ret.resp_result) {
  341. checkLotCode(ret.resp_result);
  342. }
  343. }
  344. );
  345. }
  346. function handleFurnaceNumberChange() {
  347. dayWork.value.furnaceNoInfo = basicInfo.value;
  348. }
  349. function handleProcessChange() {
  350. dayWork.value.processId = selectedProcess.value;
  351. }
  352. // function handleScanCode() {
  353. // uni.scanCode({
  354. // scanType: ['qrCode'],
  355. // onlyFromCamera: true, // 只允许相机扫码
  356. // autoZoom: false,
  357. // success: function(res) {
  358. // let vehicleObj = JSON.parse(res.result);
  359. // if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  360. // uni.showToast({
  361. // icon: "error",
  362. // title: "请扫载具码",
  363. // duration: 1000
  364. // })
  365. // return;
  366. // }
  367. // for (let i = 0; i < vehicleList.value.length; i++) {
  368. // if (vehicleList.value[i].carrierId == vehicleObj.carrierId) {
  369. // uni.showToast({
  370. // icon: "error",
  371. // title: "载具已存在",
  372. // duration: 1000
  373. // })
  374. // return;
  375. // }
  376. // }
  377. // checkCarrier(vehicleObj.carrierId).then(response => {
  378. // if (response.code == 200) {
  379. // vehicleList.value.push(vehicleObj);
  380. // } else {
  381. // uni.showToast({
  382. // icon: 'none',
  383. // title: response.msg
  384. // })
  385. // return;
  386. // }
  387. // })
  388. // }
  389. // });
  390. // }
  391. function handleAdd() {
  392. if (selectedProcess.value == null) {
  393. uni.showToast({
  394. icon: 'none',
  395. title: '请选择工序后再开始批次'
  396. })
  397. return;
  398. }
  399. console.log(dayWork.value)
  400. console.log(basicInfo.value)
  401. store.furnaceNumberInfo = basicInfo.value;
  402. if (checkLotCode(dayWork.value.lotCode)) {
  403. saveDayWork(dayWork.value).then(res => {
  404. console.log(res)
  405. if (res.code === 200) {
  406. uni.showToast({
  407. icon: 'success',
  408. title: '添加成功',
  409. duration: 2000
  410. });
  411. // uni.$emit('batchReporting-addBatch');
  412. // uni.$emit('dayworkItemUpdate');
  413. uni.navigateBack({
  414. url: '/pages/batchReporting/index'
  415. })
  416. } else {
  417. uni.showToast({
  418. icon: 'none',
  419. title: res.msg,
  420. duration: 2000
  421. });
  422. }
  423. })
  424. } else {
  425. uni.showToast({
  426. icon: "none",
  427. title: "该批次号已被使用或不属于该产品",
  428. duration: 2000
  429. })
  430. }
  431. }
  432. </script>
  433. <style lang="scss">
  434. .container {
  435. height: 90%;
  436. background-color: #f5f5f5;
  437. padding-bottom: 112rpx;
  438. }
  439. .bottom {
  440. background-color: white;
  441. width: 100%;
  442. position: fixed;
  443. bottom: 0;
  444. align-items: center;
  445. background-color: #ffffff;
  446. padding: 16rpx 0;
  447. .add {
  448. margin: 0 auto;
  449. width: 80%;
  450. height: 80rpx;
  451. }
  452. }
  453. .content {
  454. position: relative;
  455. width: auto;
  456. background-color: rgba(255, 255, 255, 1);
  457. margin: 32rpx;
  458. padding-bottom: 50rpx;
  459. padding-top: 20rpx;
  460. border-radius: 12rpx;
  461. height: 100%;
  462. overflow: auto;
  463. .title {
  464. width: auto;
  465. font-size: 36rpx;
  466. font-weight: bold;
  467. text-align: center;
  468. }
  469. }
  470. .inpAndScan {
  471. justify-content: space-between;
  472. width: calc(88% + 20rpx);
  473. margin: 0 auto;
  474. .inp {
  475. width: calc(100% - 16rpx);
  476. margin: 10rpx auto;
  477. height: 74rpx;
  478. }
  479. .scanLotCode {
  480. border-radius: 6rpx;
  481. border: 1rpx solid rgba(22, 132, 252, 1);
  482. height: 60rpx;
  483. margin: 10rpx;
  484. height: 72rpx;
  485. width: 46%;
  486. text-align: center;
  487. line-height: 72rpx;
  488. background-color: rgba(22, 132, 252, 1);
  489. color: white;
  490. }
  491. }
  492. .batchNo {
  493. // justify-content: flex-start;
  494. // flex-wrap: wrap;
  495. // width: auto;
  496. // height: 320rpx;
  497. // overflow: auto;
  498. // padding-left: calc(100% - 88% - 4rpx - 40rpx);
  499. // margin-bottom: 40rpx;
  500. // border-radius: 6rpx;
  501. justify-content: center;
  502. .batchNo-item {
  503. justify-content: center;
  504. align-items: center;
  505. width: 88%;
  506. margin: 10rpx;
  507. height: 72rpx;
  508. border: 1px solid rgba(213, 213, 213, 1);
  509. border-radius: 6rpx;
  510. }
  511. .batchNoCheck {
  512. color: #FFF;
  513. border: 1rpx solid rgba(22, 132, 252, 1);
  514. background-color: rgba(22, 132, 252, 1);
  515. }
  516. }
  517. .vehicleList {
  518. justify-content: flex-start;
  519. flex-wrap: wrap;
  520. width: auto;
  521. height: 120rpx;
  522. overflow: auto;
  523. padding: 0 80rpx;
  524. .vehicleNo {
  525. padding: 0 10rpx;
  526. margin: 10rpx;
  527. justify-content: space-between;
  528. align-items: center;
  529. width: 230rpx;
  530. height: 60rpx;
  531. border: 1px solid rgba(213, 213, 213, 1);
  532. border-radius: 6rpx;
  533. }
  534. }
  535. .middle {
  536. display: flex;
  537. flex-direction: row;
  538. align-items: center;
  539. justify-content: center
  540. }
  541. .segment {
  542. width: 280rpx;
  543. background-color: rgba(213, 213, 213, 1);
  544. border: 1rpx solid rgba(213, 213, 213, 1);
  545. }
  546. .info {
  547. width: 94%;
  548. justify-content: space-around;
  549. padding: 10rpx;
  550. margin: 0 auto;
  551. label {
  552. flex: 1;
  553. text-combine-upright: all;
  554. margin: 0 30rpx 0 20rpx;
  555. }
  556. text {
  557. flex: 3;
  558. // width: 80%;
  559. }
  560. .data-select {
  561. flex: 3;
  562. width: 80%;
  563. height: 60rpx;
  564. margin-right: 40rpx;
  565. border-radius: 18rpx;
  566. background-color: #FFF;
  567. .data-select-options {
  568. width: 200rpx;
  569. }
  570. }
  571. }
  572. .material {
  573. height: auto;
  574. width: 60%;
  575. }
  576. .selectedProcess {
  577. width: 88%;
  578. margin: 20rpx auto 40rpx;
  579. }
  580. </style>