index.vue 12 KB

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