index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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}}
  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>
  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. const batchNoCheck = ref(null) // 批次号是否选中
  90. const batchNoList = ref([]) // 批次号列表
  91. const vehicleList = ref([])
  92. const basicInfo = ref({ // 基础信息对象
  93. heatNo: 'cs222',
  94. manufacturer: 'DMS',
  95. incomingInfo: 'L123456',
  96. materia: 'dx1111'
  97. })
  98. const dayWork = ref({})
  99. const curSubPlan = ref({})
  100. const range = ref([{
  101. value: 0,
  102. text: "篮球"
  103. },
  104. {
  105. value: 1,
  106. text: "足球"
  107. },
  108. {
  109. value: 2,
  110. text: "游泳"
  111. },
  112. ])
  113. onLoad((options) => {
  114. curSubPlan.value = JSON.parse(options.currentSubPlan);
  115. dayWork.value.productionPlanDetailSubDetailId = curSubPlan.value.id;
  116. dayWork.value.productionPlanDetailId = curSubPlan.value.productionPlanDetailId;
  117. dayWork.value.productionPlanId = curSubPlan.value.productionDetailId;
  118. init();
  119. })
  120. function init() {
  121. let obj = {}
  122. obj.productionPlanId = curSubPlan.value.productionPlanId;
  123. getLotList(obj).then(res => {
  124. for (var i = 0; i < res.rows.length; i++) {
  125. batchNoList.value.push(res.rows[i].lotCode)
  126. }
  127. })
  128. }
  129. function handleCheckBatchNo(item) {
  130. batchNoCheck.value = item;
  131. dayWork.value.lotId = item.id;
  132. dayWork.value.lotCode = item.lotCode;
  133. }
  134. function handleDelVehicleNo(index) {
  135. vehicleList.value.splice(index, 1);
  136. }
  137. function handleScanCode() {
  138. uni.scanCode({
  139. scanType: ['qrCode'], // 条形码扫描
  140. onlyFromCamera: true, // 只允许相机扫码
  141. success: function(res) {
  142. let vehicleObj = JSON.parse(res.result);
  143. for (let i = 0; i < vehicleList.value.length; i++) {
  144. if (Object.entries(vehicleList.value[i]).toString() === Object.entries(vehicleObj)
  145. .toString()) {
  146. uni.showToast({
  147. icon: "error",
  148. title: "载具已存在"
  149. })
  150. return;
  151. }
  152. }
  153. vehicleList.value.push(vehicleObj);
  154. }
  155. });
  156. }
  157. function handleAdd() {
  158. dayWork.value.dayworkCarriers = vehicleList.value;
  159. console.log(dayWork.value)
  160. saveDayWork(dayWork.value).then(res => {
  161. console.log(res)
  162. if (res.code === 200) {
  163. uni.showToast({
  164. icon: 'success',
  165. title: '添加成功',
  166. duration: 2000
  167. });
  168. uni.$emit('addBatch')
  169. uni.navigateTo({
  170. url: '/pages/batchReporting/index'
  171. })
  172. } else {
  173. uni.showToast({
  174. icon: 'error',
  175. title: '添加失败',
  176. duration: 2000
  177. });
  178. uni.$emit('addBatch')
  179. uni.navigateBack({
  180. url: '/pages/batchReporting/index'
  181. })
  182. }
  183. })
  184. }
  185. </script>
  186. <style lang="scss">
  187. .container {
  188. height: 100%;
  189. background-color: #f5f5f5;
  190. }
  191. .bottom {
  192. background-color: white;
  193. width: 100%;
  194. height: 10%;
  195. position: fixed;
  196. bottom: 0;
  197. align-items: center;
  198. .add {
  199. margin: 0 auto;
  200. width: 80%;
  201. height: 80rpx;
  202. line-height: 80rpx;
  203. padding-left: 0;
  204. }
  205. }
  206. .content {
  207. width: 90%;
  208. // height: auto;
  209. background-color: rgba(255, 255, 255, 1);
  210. margin: 50rpx auto;
  211. padding-bottom: 50rpx;
  212. padding-top: 20rpx;
  213. border-radius: 12rpx;
  214. .title {
  215. margin: 10rpx 39%;
  216. width: 30%;
  217. font-size: 36rpx;
  218. font-weight: bold;
  219. }
  220. }
  221. .batchNo {
  222. justify-content: flex-start;
  223. flex-wrap: wrap;
  224. width: 100%;
  225. height: 320rpx;
  226. overflow: auto;
  227. padding: 0 80rpx;
  228. margin-bottom: 40rpx;
  229. border-radius: 6rpx;
  230. .batchNo-item {
  231. justify-content: center;
  232. align-items: center;
  233. width: 240rpx;
  234. margin: 10rpx;
  235. height: 60rpx;
  236. border: 1px solid rgba(213, 213, 213, 1);
  237. border-radius: 6rpx;
  238. }
  239. .batchNoCheck {
  240. color: #FFF;
  241. border: 1 solid rgba(22, 132, 252, 1);
  242. background-color: rgba(22, 132, 252, 1);
  243. }
  244. }
  245. .vehicleList {
  246. justify-content: flex-start;
  247. flex-wrap: wrap;
  248. width: 100%;
  249. height: 120rpx;
  250. overflow: auto;
  251. padding: 0 80rpx;
  252. .vehicleNo {
  253. padding: 0 10rpx;
  254. margin: 10rpx;
  255. justify-content: space-between;
  256. align-items: center;
  257. width: 230rpx;
  258. height: 60rpx;
  259. border: 1px solid rgba(213, 213, 213, 1);
  260. border-radius: 6rpx;
  261. }
  262. }
  263. .middle {
  264. display: flex;
  265. flex-direction: row;
  266. align-items: center;
  267. justify-content: center
  268. }
  269. .segment {
  270. width: 280rpx;
  271. background-color: rgba(213, 213, 213, 1);
  272. border: 1rpx solid rgba(213, 213, 213, 1);
  273. }
  274. .info {
  275. width: 100%;
  276. justify-content: space-around;
  277. align-items: center;
  278. label {
  279. flex: 1;
  280. text-combine-upright: all;
  281. margin: 0 30rpx;
  282. }
  283. text {
  284. flex: 3;
  285. width: 80%;
  286. }
  287. .data-select {
  288. flex: 3;
  289. width: 80%;
  290. height: 60rpx;
  291. margin-right: 40rpx;
  292. border-radius: 18rpx;
  293. background-color: #FFF;
  294. .data-select-options {
  295. width: 200rpx;
  296. }
  297. }
  298. }
  299. </style>