scan-set.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view>
  3. <u-toast ref="uToast"></u-toast>
  4. <view class="set-menu">
  5. <view class="big_font">参数配置</view>
  6. <view class="form">
  7. <view class="box-form-area">
  8. <view class="box-area-text"> 生产组织:*</view>
  9. <view class="input-item flex align-center">
  10. <uni-data-select v-model="boxForm.PrdOrgId" :localdata="orgs" :clear="false"
  11. @change="changeOrg"></uni-data-select>
  12. </view>
  13. </view>
  14. <view class="box-form-area">
  15. <view class="box-area-text"> 生产车间:*</view>
  16. <view class="input-item flex align-center">
  17. <uni-data-select v-model="boxForm.WorkShopId" :localdata="filteredWorkshops" :style=""
  18. :clear="false"></uni-data-select>
  19. </view>
  20. </view>
  21. <view class="box-form-area">
  22. <view class="box-area-text"> 装箱方式:*</view>
  23. <view class="input-item flex align-center">
  24. <uni-data-select v-model="boxForm.EnchaseType" :localdata="packTypes"
  25. :clear="false"></uni-data-select>
  26. </view>
  27. </view>
  28. <view class="box-form-area">
  29. <view class="box-area-text"> 装箱单单据类型:*</view>
  30. <view class="input-item"> 装箱_手工检查(不可修改)</view>
  31. <!-- <view class="input-item flex align-center">
  32. <uni-data-select disabled value="ZXRGJC" :localdata="invTypes" :clear="false"
  33. :style="'background-color: #b9c4de;'"></uni-data-select>
  34. </view> -->
  35. </view>
  36. </view>
  37. <view class="set-btn">
  38. <button type="primary" plain="true" @click="goScanBox" :disabled="isDisabled">下一步</button>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. getOrg,
  46. getDept,
  47. getenchasetype
  48. } from "../../api/enchase.js";
  49. export default {
  50. data() {
  51. return {
  52. isDisabled: true,
  53. boxForm: {
  54. PrdOrgId: '',
  55. PrdOrg: '',
  56. WorkShopId: '',
  57. WorkShop: '',
  58. EnchaseTypeId: '',
  59. EnchaseType: '',
  60. BillType: 'ZXRGJC',
  61. },
  62. invTypes: [{
  63. value: 'ZXRGJC',
  64. text: "装箱_手工检查"
  65. }, ],
  66. filteredOrgs: [],
  67. filterOrg: '',
  68. PrdOrgId: '',
  69. PrdOrg: '',
  70. orgs: [],
  71. WorkShopId: '',
  72. WorkShopCode: '',
  73. WorkShop: '',
  74. workshops: [],
  75. filteredWorkshops: [],
  76. packTypes: [],
  77. EnchaseTypes: []
  78. }
  79. },
  80. mounted() {},
  81. onLoad() {
  82. uni.showLoading({
  83. title: '正在加载参数...',
  84. mask: true,
  85. });
  86. this.fetchData()
  87. },
  88. onReady() {
  89. // this.$nextTick(() => {
  90. // // uni.hideLoading();
  91. // })
  92. },
  93. methods: {
  94. async fetchData() {
  95. try {
  96. //从缓存中获取上次数据
  97. this.boxForm.PrdOrgId = uni.getStorageSync('box_org');
  98. this.boxForm.WorkShopId = uni.getStorageSync('box_workshop');
  99. this.WorkShopCode = uni.getStorageSync('box_workshopCode');
  100. this.WorkShop = uni.getStorageSync('box_workshopName');
  101. this.boxForm.EnchaseType = uni.getStorageSync('box_packType');
  102. this.boxForm.EnchaseTypeId = uni.getStorageSync('box_packTypeId');
  103. //获取三个下拉菜单
  104. await getOrg().then(res => {
  105. this.orgs = res.map(item => ({
  106. value: item.Id,
  107. text: item.Name
  108. }));
  109. }).catch(err => {
  110. console.error('获取组织失败:', err);
  111. this.showToastError('获取组织失败!');
  112. })
  113. await getDept().then(res => {
  114. this.workshops = res
  115. this.filteredWorkshops = res
  116. .filter(item => item.fuseorgid === uni.getStorageSync('box_org'))
  117. .map(item => ({
  118. value: item.Id,
  119. text: item.Name,
  120. Number: item.Number
  121. }));
  122. }).catch(err => {
  123. console.error('获取车间失败:', err);
  124. this.showToastError('获取车间失败!');
  125. })
  126. await getenchasetype().then(res => {
  127. this.EnchaseTypes = res
  128. this.packTypes = res.map(item => ({
  129. value: item.Name,
  130. text: item.Name
  131. }));
  132. }).catch(err => {
  133. console.error('获取装箱失败:', err);
  134. this.showToastError('获取装箱失败!');
  135. })
  136. } catch (error) {
  137. console.error('Failed to fetch data:', error);
  138. } finally {
  139. let vm = this
  140. setTimeout(function() {uni.hideLoading()
  141. vm.showToastSuccess('加载完成');
  142. vm.isDisabled = false;
  143. }, 2000);
  144. }
  145. },
  146. changeOrg() {
  147. this.boxForm.WorkShopId = ''
  148. this.filteredWorkshops = this.workshops
  149. .filter(item => item.fuseorgid === this.boxForm.PrdOrgId)
  150. .map(item => ({
  151. value: item.Id,
  152. text: item.Name,
  153. Number: item.Number
  154. }));
  155. },
  156. showToastSuccess(message) {
  157. // this.$refs.uToast.show({
  158. // message: message,
  159. // type: 'success',
  160. // icon: true,
  161. // position: 'top'
  162. // });
  163. uni.showToast({
  164. title: message,
  165. icon: 'success'
  166. })
  167. },
  168. showToastError(message) {
  169. // this.$refs.uToast.show({
  170. // message: message,
  171. // type: 'error',
  172. // icon: true,
  173. // position: 'top'
  174. // });
  175. uni.showToast({
  176. title: message,
  177. icon: 'error'
  178. })
  179. },
  180. goScanBox() {
  181. let wk = this.filteredWorkshops.find(obj => obj.value == this.boxForm.WorkShopId)
  182. let type = this.EnchaseTypes.find(obj => obj.Name == this.boxForm.EnchaseType)
  183. if(this.boxForm.PrdOrgId && wk && type){
  184. uni.setStorageSync('box_invType', 'ZXRGJC')
  185. uni.setStorageSync('box_org', this.boxForm.PrdOrgId)
  186. uni.setStorageSync('box_workshop', this.boxForm.WorkShopId);
  187. uni.setStorageSync('box_workshopCode', wk.Number);
  188. uni.setStorageSync('box_workshopName', wk.text);
  189. uni.setStorageSync('box_packType', this.boxForm.EnchaseType);
  190. uni.setStorageSync('box_packTypeId', type.Id);
  191. uni.navigateTo({
  192. url: "/pages/index/scan-box"
  193. })
  194. }else{
  195. this.showToastError('请选择必选项!')
  196. }
  197. },
  198. }
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. page {
  203. // background-image: linear-gradient(to bottom, #b9c4de, #ffffff);
  204. }
  205. .set-menu {
  206. display: flex;
  207. flex-wrap: wrap;
  208. flex-direction: column;
  209. align-items: center;
  210. .big_font {
  211. font-size: 100rpx;
  212. margin: 5%
  213. }
  214. .form {
  215. align-items: center;
  216. justify-content: space-between;
  217. .box-form-area {
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. background-color: #cdd9f5;
  222. width: 100%;
  223. .box-area-text {
  224. width: 200rpx;
  225. font-size: 15px;
  226. height: 100rpx;
  227. border: 1px solid white;
  228. }
  229. .input-item {
  230. // margin: 10px auto;
  231. height: 100rpx;
  232. border: 1px solid white;
  233. font-size: 15px;
  234. ::v-deep.uni-select__input-text {
  235. width: 270rpx !important;
  236. }
  237. ::v-deep .uni-select__selector-item text {
  238. white-space: nowrap !important;
  239. text-overflow: ellipsis !important;
  240. overflow: hidden !important;
  241. -o-text-overflow: ellipsis !important;
  242. width: 350rpx !important;
  243. }
  244. width: 350rpx;
  245. }
  246. }
  247. }
  248. .set-btn {
  249. margin: 5%;
  250. width: 50%;
  251. }
  252. }
  253. </style>