index.vue 15 KB

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