index.vue 13 KB

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