index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. if (res.code === 200) {
  162. uni.showToast({
  163. icon: 'success',
  164. title: '添加成功',
  165. duration: 2000
  166. });
  167. uni.navigateTo({
  168. url: '/pages/batchReporting/index'
  169. })
  170. let pages = getCurrentPages(); //当前页面栈
  171. if (pages.length > 1) {
  172. let beforePage = pages[pages.length - 2]; //获取上一个页面实例对象
  173. beforePage.$vm.init(curSubPlan.value.id); //触发上一个页面中的方法,并传过去当前的值
  174. }
  175. } else {
  176. uni.showToast({
  177. icon: 'error',
  178. title: '添加失败',
  179. duration: 2000
  180. });
  181. }
  182. })
  183. }
  184. </script>
  185. <style lang="scss">
  186. .container {
  187. height: 100%;
  188. background-color: #f5f5f5;
  189. }
  190. .bottom {
  191. background-color: white;
  192. width: 100%;
  193. height: 10%;
  194. position: fixed;
  195. bottom: 0;
  196. align-items: center;
  197. .add {
  198. margin: 0 auto;
  199. width: 80%;
  200. height: 80rpx;
  201. line-height: 80rpx;
  202. padding-left: 0;
  203. }
  204. }
  205. .content {
  206. width: 90%;
  207. // height: auto;
  208. background-color: rgba(255, 255, 255, 1);
  209. margin: 50rpx auto;
  210. padding-bottom: 50rpx;
  211. padding-top: 20rpx;
  212. border-radius: 12rpx;
  213. .title {
  214. margin: 10rpx 39%;
  215. width: 30%;
  216. font-size: 36rpx;
  217. font-weight: bold;
  218. }
  219. }
  220. .batchNo {
  221. justify-content: flex-start;
  222. flex-wrap: wrap;
  223. width: 100%;
  224. height: 320rpx;
  225. overflow: auto;
  226. padding: 0 80rpx;
  227. margin-bottom: 40rpx;
  228. border-radius: 6rpx;
  229. .batchNo-item {
  230. justify-content: center;
  231. align-items: center;
  232. width: 240rpx;
  233. margin: 10rpx;
  234. height: 60rpx;
  235. border: 1px solid rgba(213, 213, 213, 1);
  236. border-radius: 6rpx;
  237. }
  238. .batchNoCheck {
  239. color: #FFF;
  240. border: 1 solid rgba(22, 132, 252, 1);
  241. background-color: rgba(22, 132, 252, 1);
  242. }
  243. }
  244. .vehicleList {
  245. justify-content: flex-start;
  246. flex-wrap: wrap;
  247. width: 100%;
  248. height: 120rpx;
  249. overflow: auto;
  250. padding: 0 80rpx;
  251. .vehicleNo {
  252. padding: 0 10rpx;
  253. margin: 10rpx;
  254. justify-content: space-between;
  255. align-items: center;
  256. width: 230rpx;
  257. height: 60rpx;
  258. border: 1px solid rgba(213, 213, 213, 1);
  259. border-radius: 6rpx;
  260. }
  261. }
  262. .middle {
  263. display: flex;
  264. flex-direction: row;
  265. align-items: center;
  266. justify-content: center
  267. }
  268. .segment {
  269. width: 280rpx;
  270. background-color: rgba(213, 213, 213, 1);
  271. border: 1rpx solid rgba(213, 213, 213, 1);
  272. }
  273. .info {
  274. width: 100%;
  275. justify-content: space-around;
  276. align-items: center;
  277. label {
  278. flex: 1;
  279. text-combine-upright: all;
  280. margin: 0 30rpx;
  281. }
  282. text {
  283. flex: 3;
  284. width: 80%;
  285. }
  286. .data-select {
  287. flex: 3;
  288. width: 80%;
  289. height: 60rpx;
  290. margin-right: 40rpx;
  291. border-radius: 18rpx;
  292. background-color: #FFF;
  293. .data-select-options {
  294. width: 200rpx;
  295. }
  296. }
  297. }
  298. </style>