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. console.log(basicInfo.value);
  181. console.log(furnaceNumberInfoList.value)
  182. }
  183. }
  184. })
  185. getProcessList({
  186. deptId: store.curDeptDetails.deptId,
  187. }).then(res => {
  188. if (res.code == 200) {
  189. //过滤出工序交集
  190. let filteredData = res.data.filter((item1) =>
  191. store.dayworkInfo.processSequence.some((item2) => item2.processCode === item1.processCode)
  192. );
  193. for (let i = 0; i < filteredData.length; i++) {
  194. processList.value[i] = {
  195. text: filteredData[i].processAlias,
  196. value: filteredData[i].processId
  197. }
  198. }
  199. selectedProcess.value = filteredData[0].processId;
  200. }
  201. })
  202. }
  203. // function handleCheckBatchNo(item) {
  204. // batchNoCheck.value = item;
  205. // dayWork.value.lotId = item.id;
  206. // }
  207. // function handleDelVehicleNo(index) {
  208. // vehicleList.value.splice(index, 1);
  209. // }
  210. // function handleValidate() {
  211. // if (batchNoCheck.value && vehicleList.value) {
  212. // return true;
  213. // } else {
  214. // return false;
  215. // }
  216. // }
  217. function iconClick() {
  218. checkLotCode(inpValue.value);
  219. }
  220. function checkLotCode(lotCode) {
  221. if (lotList.value.some(item => item.lotCode == lotCode)) {
  222. for (let i = 0; i < lotList.value.length; i++) {
  223. if (lotList.value[i].lotCode == lotCode) {
  224. batchNoList.value = [lotList.value[i]];
  225. dayWork.value.lotId = lotList.value[i].id;
  226. dayWork.value.lotCode = lotList.value[i].lotCode;
  227. uni.showToast({
  228. icon: "none",
  229. title: "该批次号可用",
  230. duration: 2000
  231. })
  232. return true;
  233. }
  234. }
  235. } else {
  236. uni.showToast({
  237. icon: "none",
  238. title: "该批次号已被使用或不属于该产品",
  239. duration: 2000
  240. })
  241. return false;
  242. }
  243. }
  244. function handleConfirmLotCode() {
  245. // 引入原生插件
  246. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  247. // 调用插件的 mpaasScan 方法
  248. mpaasScanModule.mpaasScan({
  249. // 扫码识别类型,参数可多选,qrCode、barCode,
  250. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  251. scanType: ["qrCode", "barCode"],
  252. // 是否隐藏相册,默认false不隐藏
  253. hideAlbum: false,
  254. },
  255. (ret) => {
  256. console.log(ret);
  257. // uni.showModal({
  258. // title: "扫码结果",
  259. // // 返回值中,有三个参数 resp_code、resp_message、resp_result
  260. // // resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
  261. // // resp_message 表示返回结果信息
  262. // // resp_result 表示扫码结果,只有成功才会有返回
  263. // content: JSON.stringify(ret),
  264. // showCancel: false,
  265. // confirmText: "确定",
  266. // });
  267. if (ret.resp_result) {
  268. checkLotCode(ret.resp_result);
  269. } else {
  270. uni.showToast({
  271. icon: "none",
  272. title: "条形码可能损坏,请重新扫码或手动修正批次号",
  273. duration: 2000
  274. })
  275. }
  276. }
  277. );
  278. }
  279. function handleFurnaceNumberChange() {
  280. }
  281. function handleProcessChange() {
  282. }
  283. // function handleScanCode() {
  284. // uni.scanCode({
  285. // scanType: ['qrCode'],
  286. // onlyFromCamera: true, // 只允许相机扫码
  287. // autoZoom: false,
  288. // success: function(res) {
  289. // let vehicleObj = JSON.parse(res.result);
  290. // if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  291. // uni.showToast({
  292. // icon: "error",
  293. // title: "请扫载具码",
  294. // duration: 1000
  295. // })
  296. // return;
  297. // }
  298. // for (let i = 0; i < vehicleList.value.length; i++) {
  299. // if (vehicleList.value[i].carrierId == vehicleObj.carrierId) {
  300. // uni.showToast({
  301. // icon: "error",
  302. // title: "载具已存在",
  303. // duration: 1000
  304. // })
  305. // return;
  306. // }
  307. // }
  308. // checkCarrier(vehicleObj.carrierId).then(response => {
  309. // if (response.code == 200) {
  310. // vehicleList.value.push(vehicleObj);
  311. // } else {
  312. // uni.showToast({
  313. // icon: 'none',
  314. // title: response.msg
  315. // })
  316. // return;
  317. // }
  318. // })
  319. // }
  320. // });
  321. // }
  322. function handleAdd() {
  323. // dayWork.value.dayworkCarriers = vehicleList.value;
  324. console.log(dayWork.value)
  325. // console.log(batchNoCheck.value)
  326. // console.log(vehicleList.value)
  327. if (checkLotCode(dayWork.value.lotCode)) {
  328. saveDayWork(dayWork.value).then(res => {
  329. console.log(res)
  330. if (res.code === 200) {
  331. uni.showToast({
  332. icon: 'success',
  333. title: '添加成功',
  334. duration: 2000
  335. });
  336. uni.$emit('batchReporting-addBatch');
  337. uni.$emit('dayworkItemUpdate');
  338. uni.navigateBack({
  339. url: '/pages/batchReporting/index'
  340. })
  341. } else {
  342. uni.showToast({
  343. icon: 'error',
  344. title: res.msg,
  345. duration: 2000
  346. });
  347. }
  348. })
  349. } else {
  350. uni.showToast({
  351. icon: "none",
  352. title: "该批次号已被使用或不属于该产品",
  353. duration: 2000
  354. })
  355. }
  356. }
  357. </script>
  358. <style lang="scss">
  359. .container {
  360. height: 90%;
  361. background-color: #f5f5f5;
  362. padding-bottom: 112rpx;
  363. }
  364. .bottom {
  365. background-color: white;
  366. width: 100%;
  367. position: fixed;
  368. bottom: 0;
  369. align-items: center;
  370. background-color: #ffffff;
  371. padding: 16rpx 0;
  372. .add {
  373. margin: 0 auto;
  374. width: 80%;
  375. height: 80rpx;
  376. }
  377. }
  378. .content {
  379. position: relative;
  380. width: auto;
  381. background-color: rgba(255, 255, 255, 1);
  382. margin: 32rpx;
  383. padding-bottom: 50rpx;
  384. padding-top: 20rpx;
  385. border-radius: 12rpx;
  386. .title {
  387. width: auto;
  388. font-size: 36rpx;
  389. font-weight: bold;
  390. text-align: center;
  391. }
  392. }
  393. .inpAndScan {
  394. justify-content: space-between;
  395. width: calc(88% + 20rpx);
  396. margin: 0 auto;
  397. .inp {
  398. width: 52%;
  399. margin: 10rpx;
  400. height: 74rpx;
  401. }
  402. .scanLotCode {
  403. border-radius: 6rpx;
  404. border: 1rpx solid rgba(22, 132, 252, 1);
  405. height: 60rpx;
  406. margin: 10rpx;
  407. height: 72rpx;
  408. width: 36%;
  409. text-align: center;
  410. line-height: 72rpx;
  411. background-color: rgba(22, 132, 252, 1);
  412. color: white;
  413. }
  414. }
  415. .batchNo {
  416. // justify-content: flex-start;
  417. // flex-wrap: wrap;
  418. // width: auto;
  419. // height: 320rpx;
  420. // overflow: auto;
  421. // padding-left: calc(100% - 88% - 4rpx - 40rpx);
  422. // margin-bottom: 40rpx;
  423. // border-radius: 6rpx;
  424. justify-content: center;
  425. .batchNo-item {
  426. justify-content: center;
  427. align-items: center;
  428. width: 88%;
  429. margin: 10rpx;
  430. height: 72rpx;
  431. border: 1px solid rgba(213, 213, 213, 1);
  432. border-radius: 6rpx;
  433. }
  434. .batchNoCheck {
  435. color: #FFF;
  436. border: 1rpx solid rgba(22, 132, 252, 1);
  437. background-color: rgba(22, 132, 252, 1);
  438. }
  439. }
  440. .vehicleList {
  441. justify-content: flex-start;
  442. flex-wrap: wrap;
  443. width: auto;
  444. height: 120rpx;
  445. overflow: auto;
  446. padding: 0 80rpx;
  447. .vehicleNo {
  448. padding: 0 10rpx;
  449. margin: 10rpx;
  450. justify-content: space-between;
  451. align-items: center;
  452. width: 230rpx;
  453. height: 60rpx;
  454. border: 1px solid rgba(213, 213, 213, 1);
  455. border-radius: 6rpx;
  456. }
  457. }
  458. .middle {
  459. display: flex;
  460. flex-direction: row;
  461. align-items: center;
  462. justify-content: center
  463. }
  464. .segment {
  465. width: 280rpx;
  466. background-color: rgba(213, 213, 213, 1);
  467. border: 1rpx solid rgba(213, 213, 213, 1);
  468. }
  469. .info {
  470. width: 96%;
  471. justify-content: space-around;
  472. align-items: center;
  473. label {
  474. flex: 1;
  475. text-combine-upright: all;
  476. margin: 0 20rpx 0 30rpx;
  477. }
  478. text {
  479. flex: 3;
  480. // width: 80%;
  481. }
  482. .data-select {
  483. flex: 3;
  484. width: 80%;
  485. height: 60rpx;
  486. margin-right: 40rpx;
  487. border-radius: 18rpx;
  488. background-color: #FFF;
  489. .data-select-options {
  490. width: 200rpx;
  491. }
  492. }
  493. }
  494. .material {
  495. height: auto;
  496. width: 60%;
  497. }
  498. .selectedProcess {
  499. width: 88%;
  500. margin: 20rpx auto 40rpx;
  501. }
  502. </style>