index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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. getLotList(obj).then(res => {
  134. batchNoList.value = res.rows;
  135. })
  136. }
  137. function handleCheckBatchNo(item) {
  138. batchNoCheck.value = item;
  139. dayWork.value.lotId = item.id;
  140. }
  141. function handleDelVehicleNo(index) {
  142. vehicleList.value.splice(index, 1);
  143. }
  144. function handleValidate() {
  145. if (batchNoCheck.value && vehicleList.value) {
  146. return true;
  147. } else {
  148. return false;
  149. }
  150. }
  151. function handleScanCode() {
  152. uni.scanCode({
  153. scanType: ['qrCode'],
  154. onlyFromCamera: true, // 只允许相机扫码
  155. success: function(res) {
  156. let vehicleObj = JSON.parse(res.result);
  157. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  158. uni.showToast({
  159. icon: "error",
  160. title: "请扫载具码",
  161. duration: 1000
  162. })
  163. return;
  164. }
  165. for (let i = 0; i < vehicleList.value.length; i++) {
  166. if (vehicleList.value[i].carrierId == vehicleObj.carrierId) {
  167. uni.showToast({
  168. icon: "error",
  169. title: "载具已存在",
  170. duration: 1000
  171. })
  172. return;
  173. }
  174. }
  175. // getCarrierById(vehicleObj.carrierId).then(response => {
  176. // })
  177. vehicleList.value.push(vehicleObj);
  178. }
  179. });
  180. }
  181. function handleAdd() {
  182. dayWork.value.dayworkCarriers = vehicleList.value;
  183. console.log(dayWork.value)
  184. console.log(batchNoCheck.value)
  185. console.log(vehicleList.value)
  186. if (handleValidate()) {
  187. saveDayWork(dayWork.value).then(res => {
  188. console.log(res)
  189. if (res.code === 200) {
  190. uni.showToast({
  191. icon: 'success',
  192. title: '添加成功',
  193. duration: 2000
  194. });
  195. uni.$emit('batchReporting-addBatch');
  196. uni.$emit('dayworkItemUpdate');
  197. uni.navigateBack({
  198. url: '/pages/batchReporting/index'
  199. })
  200. } else {
  201. uni.showToast({
  202. icon: 'error',
  203. title: res.msg,
  204. duration: 2000
  205. });
  206. }
  207. })
  208. } else {
  209. uni.showToast({
  210. icon: 'error',
  211. title: '未选择完整信息',
  212. duration: 2000
  213. });
  214. }
  215. }
  216. </script>
  217. <style lang="scss">
  218. .container {
  219. background-color: #f5f5f5;
  220. padding-bottom: 112rpx;
  221. }
  222. .bottom {
  223. background-color: white;
  224. width: 100%;
  225. position: fixed;
  226. bottom: 0;
  227. align-items: center;
  228. background-color: #ffffff;
  229. padding: 16rpx 0;
  230. .add {
  231. margin: 0 auto;
  232. width: 80%;
  233. height: 80rpx;
  234. }
  235. }
  236. .content {
  237. position: relative;
  238. width: auto;
  239. background-color: rgba(255, 255, 255, 1);
  240. margin: 32rpx;
  241. padding-bottom: 50rpx;
  242. padding-top: 20rpx;
  243. border-radius: 12rpx;
  244. .title {
  245. width: auto;
  246. font-size: 36rpx;
  247. font-weight: bold;
  248. text-align: center;
  249. }
  250. }
  251. .batchNo {
  252. justify-content: flex-start;
  253. flex-wrap: wrap;
  254. width: auto;
  255. height: 320rpx;
  256. overflow: auto;
  257. padding: 0 80rpx;
  258. margin-bottom: 40rpx;
  259. border-radius: 6rpx;
  260. .batchNo-item {
  261. justify-content: center;
  262. align-items: center;
  263. width: 240rpx;
  264. margin: 10rpx;
  265. height: 60rpx;
  266. border: 1px solid rgba(213, 213, 213, 1);
  267. border-radius: 6rpx;
  268. }
  269. .batchNoCheck {
  270. color: #FFF;
  271. border: 1 solid rgba(22, 132, 252, 1);
  272. background-color: rgba(22, 132, 252, 1);
  273. }
  274. }
  275. .vehicleList {
  276. justify-content: flex-start;
  277. flex-wrap: wrap;
  278. width: auto;
  279. height: 120rpx;
  280. overflow: auto;
  281. padding: 0 80rpx;
  282. .vehicleNo {
  283. padding: 0 10rpx;
  284. margin: 10rpx;
  285. justify-content: space-between;
  286. align-items: center;
  287. width: 230rpx;
  288. height: 60rpx;
  289. border: 1px solid rgba(213, 213, 213, 1);
  290. border-radius: 6rpx;
  291. }
  292. }
  293. .middle {
  294. display: flex;
  295. flex-direction: row;
  296. align-items: center;
  297. justify-content: center
  298. }
  299. .segment {
  300. width: 280rpx;
  301. background-color: rgba(213, 213, 213, 1);
  302. border: 1rpx solid rgba(213, 213, 213, 1);
  303. }
  304. .info {
  305. width: 100%;
  306. justify-content: space-around;
  307. align-items: center;
  308. label {
  309. flex: 1;
  310. text-combine-upright: all;
  311. margin: 0 30rpx;
  312. }
  313. text {
  314. flex: 3;
  315. // width: 80%;
  316. }
  317. .data-select {
  318. flex: 3;
  319. width: 80%;
  320. height: 60rpx;
  321. margin-right: 40rpx;
  322. border-radius: 18rpx;
  323. background-color: #FFF;
  324. .data-select-options {
  325. width: 200rpx;
  326. }
  327. }
  328. }
  329. </style>