index.vue 14 KB

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