gasManageAdd.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!-- 回收申请 -->
  2. <template>
  3. <view id="register">
  4. <view class="register_li">
  5. <picker @change="bindPickerChange" :value="pickerIndex" :range="pickerArray">
  6. <view class="register_li_min">
  7. <view>*</view>
  8. <view style="color: #333333;">气体名称:</view>
  9. <input v-model="form.airName" disabled type="text" placeholder="请选择气体名称">
  10. </view>
  11. </picker>
  12. <view class="register_li_min" style="border: none;">
  13. <view style="margin-left: 12rpx;"></view>
  14. <view style="color: #333333;">气体组分:</view>
  15. <input v-model="form.airConstituents" maxlength="20" type="text" placeholder="请输入气体组分">
  16. </view>
  17. </view>
  18. <view class="small_title" v-if="specsList.length>0">气瓶规格</view>
  19. <view class="register_li2" v-if="specsList.length>0">
  20. <view v-for="(item,index) in specsList" :class="item.checked==false?'register_li2_btn':'colorB'" @tap="tabClickSpecs(item)" >{{item.configName}}</view>
  21. </view>
  22. <view class="sub_btn" @click="submitForm()">提交</view>
  23. </view>
  24. </template>
  25. <script>
  26. import {googsList,googsInfoList,bottleAdd,bottleAmend,bottleDetail} from '@/api/apiDemo/index.js'
  27. import { config } from '@/api/request/config.js'
  28. export default {
  29. data() {
  30. return {
  31. form:{
  32. id:'',
  33. airName:'',
  34. airConstituents:'',
  35. configId:'',
  36. configDtos:[],
  37. },
  38. pickerArray:[],
  39. googsArray:[],
  40. listType:0,//0回收申请 1配送申请 2货品问题
  41. specsList:[],
  42. status:null,//0添加1编辑
  43. id:null,
  44. }
  45. },
  46. onLoad(option) {
  47. this.status=option.status;
  48. this.id=option.id;
  49. },
  50. onShow(){
  51. },
  52. methods: {
  53. //气瓶规格选中事件
  54. tabClickSpecs(data){
  55. this.specsList.forEach(function(item){
  56. if(data.configId==item.configId){
  57. item.checked=item.checked==true?false:true;
  58. }
  59. })
  60. },
  61. //气体选中事件
  62. bindPickerChange(e){
  63. let _this=this;
  64. let index=e.target.value
  65. _this.form.airName=this.pickerArray[index]
  66. _this.googsArray.forEach(function(item){
  67. if(_this.pickerArray[index]==item.goodsName){
  68. _this.getGoogsInfoList(item.id)
  69. _this.form.configId=item.id
  70. }
  71. })
  72. },
  73. //获取气体列表数据
  74. async getGoogsList(){
  75. let _this = this;
  76. const {data} = await googsList()
  77. if(data.code==200){
  78. let res=data.rows;
  79. _this.googsArray=res;
  80. if(res){
  81. res.forEach(function(item){
  82. _this.pickerArray.push(item.goodsName)
  83. })
  84. }
  85. }
  86. },
  87. //获取气体列表数据
  88. async getGoogsInfoList(id){
  89. let _this = this;
  90. const {data} = await googsInfoList(id)
  91. if(data.code==200){
  92. let res=data.data;
  93. if(res){
  94. if(_this.status==0){//添加
  95. res.forEach(function(item){
  96. _this.specsList.push({'configName':item.name,'configId':item.id,'checked':false,})
  97. })
  98. }else if(_this.status==1){//编辑
  99. let arr=[];
  100. //重新组装
  101. res.forEach(function(item){
  102. arr.push({'configName':item.name,'configId':item.id,'checked':false,})
  103. })
  104. //循环对比
  105. arr.forEach(function(item){
  106. _this.specsList.forEach(function(item2){
  107. if(item.configId==item2.configId){
  108. item.checked=true;
  109. item.id=item2.id;
  110. }
  111. })
  112. })
  113. _this.specsList=arr;
  114. }
  115. }
  116. }
  117. },
  118. //获取详情
  119. async getInfo(){
  120. let _this = this;
  121. const {data} = await bottleDetail(this.id)
  122. if(data.code==200){
  123. let res=data.data
  124. this.form.id=res.id;
  125. this.form.airName=res.airName;
  126. this.form.airConstituents=res.airConstituents;
  127. this.form.configId=res.configId;
  128. if(res.configVos){
  129. this.specsList=res.configVos;
  130. }
  131. _this.getGoogsInfoList(res.configId)
  132. }
  133. },
  134. //注册提交
  135. async submitForm(){
  136. let _this = this;
  137. if(!this.form.airName){
  138. uni.showToast({
  139. title: '请选择气体名称!',
  140. icon:"none",
  141. mask:true,
  142. duration: 2000
  143. });
  144. return
  145. }
  146. //提交的时候过滤空数据
  147. let arr=[];
  148. _this.specsList.forEach(function(item){
  149. if(item.checked==true){
  150. arr.push(item)
  151. }
  152. })
  153. _this.form.configDtos=arr;
  154. if(this.status==0){//新增
  155. const {data} = await bottleAdd(_this.form);
  156. if(data.code == 200){
  157. uni.showToast({
  158. title: '提交成功',
  159. icon:"none",
  160. mask:true,
  161. duration: 2000
  162. });
  163. setTimeout(function(){
  164. uni.redirectTo({
  165. url: '/pages/supplierWorkbench',
  166. });
  167. },2000);
  168. }
  169. }else if(this.status==1){//编辑
  170. const {data} = await bottleAmend(_this.form);
  171. if(data.code == 200){
  172. uni.showToast({
  173. title: '提交成功',
  174. icon:"none",
  175. mask:true,
  176. duration: 2000
  177. });
  178. setTimeout(function(){
  179. uni.redirectTo({
  180. url: '/pages/supplierWorkbench',
  181. });
  182. },2000);
  183. }
  184. }
  185. },
  186. },
  187. mounted() {
  188. this.getGoogsList()
  189. if(this.status==1 || this.status==2){
  190. this.getInfo();
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="stylus" scoped>
  196. #register{
  197. height:100%;
  198. width:100%;
  199. display flex
  200. flex-direction column;
  201. padding-bottom: 220rpx;
  202. .register_li{
  203. background #fff;
  204. border-radius:20rpx;
  205. margin:20rpx 20rpx 0;
  206. padding:20rpx 0;
  207. box-sizing: border-box;
  208. .register_li_min{
  209. margin:0 26rpx;
  210. display flex;
  211. align-items center;
  212. border-bottom: 1px solid #F5F5F5;
  213. view{
  214. line-height:100rpx;
  215. font-size:28rpx;
  216. }
  217. view:nth-child(1){
  218. color:red;
  219. line-height:28rpx;
  220. margin-right: 12rpx;
  221. }
  222. view:nth-child(2){
  223. //width:140rpx;
  224. font-size: 28rpx;
  225. font-family: PingFang SC;
  226. font-weight: 500;
  227. color: #999999;
  228. }
  229. >input{
  230. flex:1;
  231. text-align: right;
  232. font-size: 24rpx;
  233. font-family: PingFang SC;
  234. font-weight: 500;
  235. color: #333333;
  236. }
  237. }
  238. }
  239. .small_title{
  240. font-size: 30rpx;
  241. font-family: PingFang SC;
  242. font-weight: 500;
  243. color: #999999;
  244. line-height: 100rpx;
  245. margin: 0 40rpx;
  246. }
  247. .register_li2{
  248. background #fff;
  249. border-radius:20rpx;
  250. margin:0 20rpx 0;
  251. padding:44rpx 0 20rpx 20rpx;
  252. box-sizing: border-box;
  253. display: flex;
  254. flex-wrap: wrap;
  255. .register_li2_btn{
  256. width: 200rpx;
  257. height: 60rpx;
  258. background: #F5F5F5;
  259. border-radius: 10rpx;
  260. font-size: 28rpx;
  261. font-family: PingFang SC;
  262. font-weight: 500;
  263. color: #999999;
  264. line-height: 60rpx;
  265. text-align: center;
  266. margin-right: 22rpx;
  267. margin-bottom: 24rpx;
  268. }
  269. .colorB{
  270. width: 200rpx;
  271. height: 60rpx;
  272. background: #0183FA;
  273. border-radius: 10rpx;
  274. font-size: 28rpx;
  275. font-family: PingFang SC;
  276. font-weight: 500;
  277. color: #FFFFFF;
  278. line-height: 60rpx;
  279. text-align: center;
  280. margin-right: 22rpx;
  281. margin-bottom: 24rpx;
  282. }
  283. }
  284. /* 按钮 */
  285. .sub_btn{
  286. width: 650rpx;
  287. height: 100rpx;
  288. background: #0183FA;
  289. border-radius: 20rpx;
  290. font-size: 28rpx;
  291. font-family: PingFang SC;
  292. font-weight: 500;
  293. color: #FFFFFF;
  294. line-height: 100rpx;
  295. text-align: center;
  296. margin-left: 50rpx;
  297. position: fixed;
  298. bottom:30rpx;
  299. z-index: 1000;
  300. }
  301. }
  302. /deep/.input-value-border{
  303. display :none !important;
  304. }
  305. </style>