index.vue 8.5 KB

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