index.vue 8.6 KB

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