index.vue 8.1 KB

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