index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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,'batchNoCheck':batchNoCheck === item}"
  8. v-for="(item,index) in batchNoList" :key='index' @click="handleCheckBatchNo(item)">
  9. {{item.lotCode}}
  10. </view>
  11. </view>
  12. </view>
  13. <view class='middle'>
  14. <view class='segment'></view>
  15. <uni-icons type="link" size="30" style="margin: 10rpx; transform: rotate(135deg);"></uni-icons>
  16. <view class='segment'></view>
  17. </view>
  18. <view>
  19. <text class='title'>扫码绑定载具</text>
  20. <view class="vehicleList uni-row">
  21. <view class="vehicleNo uni-row" v-for="(item,index) in vehicleList">
  22. <text>{{item.carrierCode}}</text>
  23. <text @click="handleDelVehicleNo(index)">×</text>
  24. </view>
  25. </view>
  26. <view>
  27. <button style='background-color: rgba(0, 226, 166,1);
  28. color: white;margin: 20rpx auto;
  29. width: 80%;' @click='handleScanCode'>扫码</button>
  30. </view>
  31. </view>
  32. <view class='middle'>
  33. <view class='segment'></view>
  34. <uni-icons type="paperclip" size="30" style="margin: 10rpx;"></uni-icons>
  35. <view class='segment'></view>
  36. </view>
  37. <view>
  38. <text class='title' style="margin-bottom: 50rpx;">基础信息</text>
  39. <view class="uni-row info">
  40. <label for="HeatNo">炉号:</label>
  41. <select id="incomingInfo" class="uni-input data-select" v-model="basicInfo.heatNo">
  42. <option class="data-select-options" v-for="(item,index) in range">{{item.text}}</option>
  43. </select>
  44. <!-- <input id="HeatNo" class="uni-input" v-model="basicInfo.heatNo" placeholder="请填写" /> -->
  45. <!-- <text id="HeatNo" class="uni-input">{{basicInfo.heatNo}}</text> -->
  46. </view>
  47. <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
  48. <view class="uni-row info">
  49. <label for="manufacturer">厂家:</label>
  50. <!-- <input id="manufacturer" class="uni-input" v-model="basicInfo.manufacturer" placeholder="请填写" /> -->
  51. <text id="manufacturer" class="uni-input">{{basicInfo.manufacturer}}</text>
  52. </view>
  53. <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
  54. <view class="uni-row info">
  55. <label for="incomingInfo">来料日期:</label>
  56. <!-- <input id="incomingInfo" class="uni-input" v-model="basicInfo.incomingInfo" placeholder="请填写" /> -->
  57. <text id="incomingInfo" class="uni-input">{{basicInfo.incomingInfo}}</text>
  58. </view>
  59. <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
  60. <view class="uni-row info">
  61. <label for="incomingInfo">材质:</label>
  62. <!-- <input id="incomingInfo" class="uni-input" v-model="basicInfo.incomingInfo" placeholder="请填写" /> -->
  63. <text id="incomingInfo" class="uni-input">{{basicInfo.materia}}</text>
  64. </view>
  65. <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
  66. </view>
  67. </view>
  68. <view class='bottom uni-row'>
  69. <button class='add' type=primary @click='handleAdd'>添加</button>
  70. </view>
  71. </view>
  72. </template>
  73. <script setup>
  74. import {
  75. ref
  76. } from 'vue'
  77. import {
  78. onLoad,
  79. onReady
  80. } from '@dcloudio/uni-app'
  81. import {
  82. getLotList
  83. } from "@/api/business/lot.js"
  84. import {
  85. saveDayWork
  86. } from '@/api/business/dayWork.js'
  87. import {
  88. store
  89. } from '@/store/index.js'
  90. import {
  91. getCarrierById
  92. } from '@/api/business/carrier.js'
  93. const batchNoCheck = ref(null) // 批次号是否选中
  94. const batchNoList = ref([]) // 批次号列表
  95. const vehicleList = ref([])
  96. const basicInfo = ref({ // 基础信息对象
  97. heatNo: 'cs222',
  98. manufacturer: 'DMS',
  99. incomingInfo: 'L123456',
  100. materia: 'dx1111'
  101. })
  102. const dayWork = ref({})
  103. const curSubPlan = ref({})
  104. const range = ref([{
  105. value: 0,
  106. text: "LNO001"
  107. },
  108. {
  109. value: 1,
  110. text: "LNO002"
  111. },
  112. {
  113. value: 2,
  114. text: "LNO003"
  115. },
  116. ])
  117. const emit = defineEmits(['batchReporting-addBatch']);
  118. onLoad(() => {
  119. // 处理特殊字符JSON解析失败报错
  120. curSubPlan.value = store.planSubDetails;
  121. console.log(curSubPlan.value)
  122. dayWork.value = {
  123. productionPlanDetailSubDetailId: curSubPlan.value.id,
  124. productionPlanDetailId: curSubPlan.value.productionPlanDetailId,
  125. productionPlanId: curSubPlan.value.productionDetailId,
  126. technologicalProcessId: curSubPlan.value.technologicalProcessId
  127. }
  128. init();
  129. })
  130. function init() {
  131. let obj = {}
  132. obj.productionPlanId = curSubPlan.value.productionPlanId;
  133. obj.productionPlanDetailId = curSubPlan.value.productionPlanDetailId;
  134. getLotList(obj).then(res => {
  135. console.log(res)
  136. batchNoList.value = res.rows;
  137. })
  138. }
  139. function handleCheckBatchNo(item) {
  140. batchNoCheck.value = item;
  141. dayWork.value.lotId = item.id;
  142. }
  143. function handleDelVehicleNo(index) {
  144. vehicleList.value.splice(index, 1);
  145. }
  146. function handleValidate() {
  147. if (batchNoCheck.value && vehicleList.value) {
  148. return true;
  149. } else {
  150. return false;
  151. }
  152. }
  153. function handleScanCode() {
  154. uni.scanCode({
  155. scanType: ['qrCode'],
  156. onlyFromCamera: true, // 只允许相机扫码
  157. autoZoom: false,
  158. success: function(res) {
  159. let vehicleObj = JSON.parse(res.result);
  160. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  161. uni.showToast({
  162. icon: "error",
  163. title: "请扫载具码",
  164. duration: 1000
  165. })
  166. return;
  167. }
  168. for (let i = 0; i < vehicleList.value.length; i++) {
  169. if (vehicleList.value[i].carrierId == vehicleObj.carrierId) {
  170. uni.showToast({
  171. icon: "error",
  172. title: "载具已存在",
  173. duration: 1000
  174. })
  175. return;
  176. }
  177. }
  178. // getCarrierById(vehicleObj.carrierId).then(response => {
  179. // })
  180. vehicleList.value.push(vehicleObj);
  181. }
  182. });
  183. }
  184. function handleAdd() {
  185. dayWork.value.dayworkCarriers = vehicleList.value;
  186. console.log(dayWork.value)
  187. console.log(batchNoCheck.value)
  188. console.log(vehicleList.value)
  189. if (handleValidate()) {
  190. saveDayWork(dayWork.value).then(res => {
  191. console.log(res)
  192. if (res.code === 200) {
  193. uni.showToast({
  194. icon: 'success',
  195. title: '添加成功',
  196. duration: 2000
  197. });
  198. uni.$emit('batchReporting-addBatch');
  199. uni.$emit('dayworkItemUpdate');
  200. uni.navigateBack({
  201. url: '/pages/batchReporting/index'
  202. })
  203. } else {
  204. uni.showToast({
  205. icon: 'error',
  206. title: res.msg,
  207. duration: 2000
  208. });
  209. }
  210. })
  211. } else {
  212. uni.showToast({
  213. icon: 'error',
  214. title: '未选择完整信息',
  215. duration: 2000
  216. });
  217. }
  218. }
  219. </script>
  220. <style lang="scss">
  221. .container {
  222. background-color: #f5f5f5;
  223. padding-bottom: 112rpx;
  224. }
  225. .bottom {
  226. background-color: white;
  227. width: 100%;
  228. position: fixed;
  229. bottom: 0;
  230. align-items: center;
  231. background-color: #ffffff;
  232. padding: 16rpx 0;
  233. .add {
  234. margin: 0 auto;
  235. width: 80%;
  236. height: 80rpx;
  237. }
  238. }
  239. .content {
  240. position: relative;
  241. width: auto;
  242. background-color: rgba(255, 255, 255, 1);
  243. margin: 32rpx;
  244. padding-bottom: 50rpx;
  245. padding-top: 20rpx;
  246. border-radius: 12rpx;
  247. .title {
  248. width: auto;
  249. font-size: 36rpx;
  250. font-weight: bold;
  251. text-align: center;
  252. }
  253. }
  254. .batchNo {
  255. justify-content: flex-start;
  256. flex-wrap: wrap;
  257. width: auto;
  258. height: 320rpx;
  259. overflow: auto;
  260. padding-left: calc(100% - 88% - 4rpx - 40rpx);
  261. margin-bottom: 40rpx;
  262. border-radius: 6rpx;
  263. .batchNo-item {
  264. justify-content: center;
  265. align-items: center;
  266. width: 44%;
  267. margin: 10rpx;
  268. height: 60rpx;
  269. border: 1px solid rgba(213, 213, 213, 1);
  270. border-radius: 6rpx;
  271. }
  272. .batchNoCheck {
  273. color: #FFF;
  274. border: 1 solid rgba(22, 132, 252, 1);
  275. background-color: rgba(22, 132, 252, 1);
  276. }
  277. }
  278. .vehicleList {
  279. justify-content: flex-start;
  280. flex-wrap: wrap;
  281. width: auto;
  282. height: 120rpx;
  283. overflow: auto;
  284. padding: 0 80rpx;
  285. .vehicleNo {
  286. padding: 0 10rpx;
  287. margin: 10rpx;
  288. justify-content: space-between;
  289. align-items: center;
  290. width: 230rpx;
  291. height: 60rpx;
  292. border: 1px solid rgba(213, 213, 213, 1);
  293. border-radius: 6rpx;
  294. }
  295. }
  296. .middle {
  297. display: flex;
  298. flex-direction: row;
  299. align-items: center;
  300. justify-content: center
  301. }
  302. .segment {
  303. width: 280rpx;
  304. background-color: rgba(213, 213, 213, 1);
  305. border: 1rpx solid rgba(213, 213, 213, 1);
  306. }
  307. .info {
  308. width: 100%;
  309. justify-content: space-around;
  310. align-items: center;
  311. label {
  312. flex: 1;
  313. text-combine-upright: all;
  314. margin: 0 30rpx;
  315. }
  316. text {
  317. flex: 3;
  318. // width: 80%;
  319. }
  320. .data-select {
  321. flex: 3;
  322. width: 80%;
  323. height: 60rpx;
  324. margin-right: 40rpx;
  325. border-radius: 18rpx;
  326. background-color: #FFF;
  327. .data-select-options {
  328. width: 200rpx;
  329. }
  330. }
  331. }
  332. </style>