index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 {
  90. store
  91. } from '@/store/index.js'
  92. import {
  93. getCarrierById
  94. } from '@/api/business/carrier.js'
  95. const batchNoCheck = ref(null) // 批次号是否选中
  96. const batchNoList = ref([]) // 批次号列表
  97. const vehicleList = ref([])
  98. const basicInfo = ref({ // 基础信息对象
  99. heatNo: 'cs222',
  100. manufacturer: 'DMS',
  101. incomingInfo: 'L123456',
  102. materia: 'dx1111'
  103. })
  104. const dayWork = ref({})
  105. const curSubPlan = ref({})
  106. const range = ref([{
  107. value: 0,
  108. text: "LNO001"
  109. },
  110. {
  111. value: 1,
  112. text: "LNO002"
  113. },
  114. {
  115. value: 2,
  116. text: "LNO003"
  117. },
  118. ])
  119. const emit = defineEmits(['batchReporting-addBatch']);
  120. onLoad(() => {
  121. // 处理特殊字符JSON解析失败报错
  122. curSubPlan.value = store.planSubDetails;
  123. console.log(curSubPlan.value)
  124. dayWork.value = {
  125. productionPlanDetailSubDetailId: curSubPlan.value.id,
  126. productionPlanDetailId: curSubPlan.value.productionPlanDetailId,
  127. productionPlanId: curSubPlan.value.productionDetailId,
  128. technologicalProcessId: curSubPlan.value.technologicalProcessId
  129. }
  130. init();
  131. })
  132. function init() {
  133. let obj = {}
  134. obj.productionPlanId = curSubPlan.value.productionPlanId;
  135. getLotList(obj).then(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. success: function(res) {
  158. let vehicleObj = JSON.parse(res.result);
  159. for (let i = 0; i < vehicleList.value.length; i++) {
  160. if (vehicleList.value[i].carrierId == vehicleObj.carrierId) {
  161. uni.showToast({
  162. icon: "error",
  163. title: "载具已存在"
  164. })
  165. return;
  166. }
  167. }
  168. // getCarrierById(vehicleObj.carrierId).then(response => {
  169. // })
  170. vehicleList.value.push(vehicleObj);
  171. }
  172. });
  173. }
  174. function handleAdd() {
  175. dayWork.value.dayworkCarriers = vehicleList.value;
  176. console.log(dayWork.value)
  177. console.log(batchNoCheck.value)
  178. console.log(vehicleList.value)
  179. if (handleValidate()) {
  180. saveDayWork(dayWork.value).then(res => {
  181. console.log(res)
  182. if (res.code === 200) {
  183. uni.showToast({
  184. icon: 'success',
  185. title: '添加成功',
  186. duration: 2000
  187. });
  188. uni.$emit('batchReporting-addBatch');
  189. uni.$emit('dayworkItemUpdate');
  190. uni.navigateBack({
  191. url: '/pages/batchReporting/index'
  192. })
  193. } else {
  194. uni.showToast({
  195. icon: 'error',
  196. title: res.msg,
  197. duration: 2000
  198. });
  199. }
  200. })
  201. } else {
  202. uni.showToast({
  203. icon: 'error',
  204. title: '未选择完整信息',
  205. duration: 2000
  206. });
  207. }
  208. }
  209. </script>
  210. <style lang="scss">
  211. .container {
  212. height: calc(100% - 10%);
  213. background-color: #f5f5f5;
  214. }
  215. .incomingInfo {
  216. overflow: auto;
  217. height: 30%;
  218. }
  219. .bottom {
  220. background-color: white;
  221. width: 100%;
  222. height: 10%;
  223. position: fixed;
  224. bottom: 0;
  225. align-items: center;
  226. .add {
  227. margin: 0 auto;
  228. width: 80%;
  229. height: 80rpx;
  230. line-height: 80rpx;
  231. padding-left: 0;
  232. }
  233. }
  234. .content {
  235. width: 90%;
  236. // height: auto;
  237. background-color: rgba(255, 255, 255, 1);
  238. margin: 50rpx auto;
  239. padding-bottom: 50rpx;
  240. padding-top: 20rpx;
  241. border-radius: 12rpx;
  242. .title {
  243. margin: 10rpx 39%;
  244. width: 30%;
  245. font-size: 36rpx;
  246. font-weight: bold;
  247. }
  248. }
  249. .batchNo {
  250. justify-content: flex-start;
  251. flex-wrap: wrap;
  252. width: 100%;
  253. height: 320rpx;
  254. overflow: auto;
  255. padding: 0 80rpx;
  256. margin-bottom: 40rpx;
  257. border-radius: 6rpx;
  258. .batchNo-item {
  259. justify-content: center;
  260. align-items: center;
  261. width: 240rpx;
  262. margin: 10rpx;
  263. height: 60rpx;
  264. border: 1px solid rgba(213, 213, 213, 1);
  265. border-radius: 6rpx;
  266. }
  267. .batchNoCheck {
  268. color: #FFF;
  269. border: 1 solid rgba(22, 132, 252, 1);
  270. background-color: rgba(22, 132, 252, 1);
  271. }
  272. }
  273. .vehicleList {
  274. justify-content: flex-start;
  275. flex-wrap: wrap;
  276. width: 100%;
  277. height: 120rpx;
  278. overflow: auto;
  279. padding: 0 80rpx;
  280. .vehicleNo {
  281. padding: 0 10rpx;
  282. margin: 10rpx;
  283. justify-content: space-between;
  284. align-items: center;
  285. width: 230rpx;
  286. height: 60rpx;
  287. border: 1px solid rgba(213, 213, 213, 1);
  288. border-radius: 6rpx;
  289. }
  290. }
  291. .middle {
  292. display: flex;
  293. flex-direction: row;
  294. align-items: center;
  295. justify-content: center
  296. }
  297. .segment {
  298. width: 280rpx;
  299. background-color: rgba(213, 213, 213, 1);
  300. border: 1rpx solid rgba(213, 213, 213, 1);
  301. }
  302. .info {
  303. width: 100%;
  304. justify-content: space-around;
  305. align-items: center;
  306. label {
  307. flex: 1;
  308. text-combine-upright: all;
  309. margin: 0 30rpx;
  310. }
  311. text {
  312. flex: 3;
  313. // width: 80%;
  314. }
  315. .data-select {
  316. flex: 3;
  317. width: 80%;
  318. height: 60rpx;
  319. margin-right: 40rpx;
  320. border-radius: 18rpx;
  321. background-color: #FFF;
  322. .data-select-options {
  323. width: 200rpx;
  324. }
  325. }
  326. }
  327. </style>