storageAdd.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <!-- 新增入库 -->
  2. <template>
  3. <view id="register">
  4. <view class="register_li">
  5. <view class="register_li_min" @click="seleteGasFun()">
  6. <view>*</view>
  7. <view style="color: #999999;">气瓶:</view>
  8. <input v-model="form.gasName" disabled placeholder="请选择气瓶" placeholder-style="color:#333;" type="text" >
  9. </view>
  10. <view class="register_li_min" style="border-bottom:0;">
  11. <view></view>
  12. <view style="color: #999999;">气体规格:</view>
  13. <input v-model="form.levelSizeName" disabled type="text" >
  14. </view>
  15. </view>
  16. <view class="register_li">
  17. <view class="register_li_min" style="border:0;" v-if="isSelect">
  18. <view></view>
  19. <view>瓶身颜色:</view>
  20. <picker @change="bottleColorChange" :range="bottleColorArr">
  21. <input class="picker-text" v-model="form.bottleColour" disabled type="text" placeholder-style="color:#999; text-align: right;font-size:24rpx;" placeholder="请选择瓶身颜色">
  22. </picker>
  23. </view>
  24. <view class="register_li_min" style="border:0;" v-if="!isSelect">
  25. <view></view>
  26. <view>瓶身颜色:</view>
  27. <input class="picker-text" v-model="form.bottleColour" type="text" placeholder-style="color:#999; text-align: right;font-size:24rpx;" placeholder="请输入瓶身颜色">
  28. </view>
  29. <view class="custom_li_min" style="justify-content: flex-end;">
  30. <view class="custom" @click="selectFun">{{isSelect?'自定义输入':'选择颜色'}}</view>
  31. </view>
  32. <view class="register_li_min" v-for="(item,index) in list">
  33. <view></view>
  34. <view>{{item.name}}</view>
  35. <view class="radio_group">
  36. <view class="radio" v-for="(item2,index2) in item.radioList" @click="radioClick(item,item2)">
  37. <img v-if="!item2.checked" src="@/pages_manage/images/icon_5.png">
  38. <img v-if="item2.checked" src="@/pages_manage/images/icon_6.png">
  39. <text>{{item2.name}}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="register_li_min">
  44. <view> </view>
  45. <view>气表压力:</view>
  46. <input v-model="form.gasPressure" maxlength="6" @input="onKeyVinInput($event)" placeholder-style="color:#999;" placeholder="请输入气表压力">
  47. </view>
  48. <!-- 检验有效期 -->
  49. <view class="register_li_min2">
  50. <view><text style="color: #f00;margin-right: 10rpx;"> </text>检验有效期:</view>
  51. <picker mode="date" @change="startChange($event)">
  52. <input class="picker-text" v-model="form.validPeriod" disabled type="text" placeholder-style="color:#999;" placeholder="时间">
  53. </picker>
  54. </view>
  55. <view class="register_li_min" >
  56. <view>*</view>
  57. <view>信标标签:</view>
  58. <input v-model="form.beaconTag" type="text" placeholder-style="color:#999;" placeholder="请输入信标标签ID">
  59. <img @click.stop="saoCode" class="code_img" src="@/pages_manage/images/Version2.2/icon_aqjc_sm.png">
  60. </view>
  61. <view class="register_li_min">
  62. <view>*</view>
  63. <view>实验室:</view>
  64. <picker @change="bindPickerChange" :value="laboratoryIndex" :range="laboratory">
  65. <input class="picker-text" v-model="form.subjectName" disabled type="text" placeholder-style="color:#999; text-align: right;font-size:24rpx;" placeholder="请选择入库实验室">
  66. </picker>
  67. </view>
  68. <view class="register_li_min" style="border: none;">
  69. <view>*</view>
  70. <view>备注:</view>
  71. <input v-model="form.remark" type="text" placeholder-style="color:#999;" placeholder="请输入验收备注">
  72. </view>
  73. </view>
  74. <view class="sub_btn" @click="submitForm()">确认信息并入库</view>
  75. </view>
  76. </template>
  77. <script>
  78. import {getSubjectDict,airbottleStockEnter,subjectList,laboratorySubjectListSubJoinbeacon} from '@/api/index.js'
  79. import { config } from '@/api/request/config.js'
  80. export default {
  81. data() {
  82. return {
  83. form:{
  84. },
  85. laboratory:['请选择实验室'],
  86. laboratoryList:[],
  87. laboratoryIndex:0,
  88. infoForm:{},
  89. item:{},
  90. id:{},
  91. bottleColorArr:[],
  92. bottleColorArrList:uni.getStorageSync('bottleColor'),
  93. isSelect:true,
  94. list:[
  95. {
  96. id:'0',
  97. name:'有无手轮:',
  98. lab:'isHandwheel',
  99. radioList:[
  100. {
  101. id:1,
  102. name:'有',
  103. checked:true,
  104. },
  105. {
  106. id:0,
  107. name:'无',
  108. checked:false,
  109. },
  110. ]
  111. },
  112. {
  113. id:'0',
  114. name:'是否固定:',
  115. lab:'isFixed',
  116. radioList:[
  117. {
  118. id:1,
  119. name:'是',
  120. checked:true,
  121. },
  122. {
  123. id:0,
  124. name:'否',
  125. checked:false,
  126. },
  127. ]
  128. },
  129. {
  130. id:'0',
  131. name:'电子标签:',
  132. lab:'isElectronicTag',
  133. radioList:[
  134. {
  135. id:1,
  136. name:'有',
  137. checked:true,
  138. },
  139. {
  140. id:0,
  141. name:'无',
  142. checked:false,
  143. },
  144. ]
  145. },
  146. {
  147. id:'0',
  148. name:'气瓶状态标牌:',
  149. lab:'isStatusSign',
  150. radioList:[
  151. {
  152. id:1,
  153. name:'有',
  154. checked:true,
  155. },
  156. {
  157. id:0,
  158. name:'无',
  159. checked:false,
  160. },
  161. ]
  162. }
  163. ],
  164. }
  165. },
  166. onLoad(option) {
  167. let self=this;
  168. //获取气瓶颜色
  169. if(this.bottleColorArrList){
  170. let list = [];
  171. for(let i=0;i<this.bottleColorArrList.length;i++){
  172. list.push(this.bottleColorArrList[i].dictValue);
  173. }
  174. this.bottleColorArr = Array.from(new Set(list));
  175. }
  176. if(option.form){
  177. this.form=JSON.parse(decodeURIComponent(option.form));
  178. if(this.form.gasName){
  179. self.$set(self.form,'bottleColour','');
  180. console.log(this.bottleColorArrList)
  181. this.bottleColorArrList.forEach(function(item){
  182. if(self.form.gasName==item.dictLabel){
  183. self.$set(self.form,'bottleColour',item.dictValue);
  184. }
  185. })
  186. }
  187. }
  188. },
  189. onShow(){
  190. },
  191. mounted(){
  192. this.getSubjectDict();
  193. },
  194. methods: {
  195. //限制只能输入数字
  196. onKeyVinInput(e) {
  197. const o = e.detail.value
  198. const inputRule = /[^\-?\d.]/g
  199. this.$nextTick(() => {
  200. this.form.gasPressure = o.replace(inputRule, '');
  201. if (this.form.gasPressure == '') {
  202. return
  203. } else {
  204. //执行对应代码
  205. }
  206. })
  207. },
  208. //颜色选择
  209. selectFun(){
  210. if(this.isSelect){
  211. this.isSelect=false;
  212. }else{
  213. this.isSelect=true;
  214. }
  215. this.form.bottleColour='';
  216. },
  217. //开始时间选中事件
  218. startChange(e){
  219. this.$set(this.form,'validPeriod',e.target.value);
  220. },
  221. //实验室选择器
  222. bindPickerChange(e){
  223. let self=this;
  224. self.laboratoryIndex = e.target.value;
  225. let subjectName = self.laboratory[self.laboratoryIndex];
  226. self.$set(self.form,'subjectName',subjectName);
  227. self.laboratoryList.forEach(function(item){
  228. if(item.name==subjectName){
  229. self.$set(self.form,'subjectId',item.id);
  230. }
  231. })
  232. },
  233. //气瓶颜色选择
  234. bottleColorChange(e){
  235. let self=this;
  236. let bottleColour = self.bottleColorArr[e.target.value];
  237. self.$set(self.form,'bottleColour',bottleColour);
  238. },
  239. //单选按钮
  240. radioClick(p,d){
  241. d.checked=!d.checked
  242. if(d.checked){
  243. //如果有选中的,循环把其他选中的取消
  244. p.radioList.forEach(function(item){
  245. if(item.id==d.id){
  246. }else{
  247. item.checked=false;
  248. }
  249. })
  250. }else{
  251. }
  252. },
  253. //调用摄像头
  254. saoCode(){
  255. let _this = this;
  256. uni.scanCode({
  257. onlyFromCamera: true,
  258. success: function (res) {
  259. _this.$set(_this.form,'beaconTag',res.result);
  260. }
  261. });
  262. },
  263. //实验室列表
  264. async getSubjectDict(){
  265. let self = this;
  266. let {data} = await laboratorySubjectListSubJoinbeacon()
  267. if(data.code == 200){
  268. if(data.data[0]){
  269. let list = [];
  270. for(let i=0;i<data.data.length;i++){
  271. list.push(data.data[i].name);
  272. }
  273. this.laboratory = list;
  274. this.laboratoryList = data.data;
  275. }
  276. }
  277. },
  278. //选择气瓶
  279. seleteGasFun(){
  280. uni.redirectTo({
  281. url:'/pages/gasBottle/stockList/seleteGas?form='+encodeURIComponent(JSON.stringify(this.form))
  282. });
  283. },
  284. //提交
  285. async submitForm(){
  286. let _this = this;
  287. if(!this.form.gasName){
  288. uni.showToast({
  289. title: '请选择气体名称',
  290. icon:"none",
  291. mask:true,
  292. duration: 2000
  293. });
  294. return
  295. }
  296. // if(!this.form.gasPressure){
  297. // uni.showToast({
  298. // title: '请输入气表压力',
  299. // icon:"none",
  300. // mask:true,
  301. // duration: 2000
  302. // });
  303. // return
  304. // }
  305. // if(!this.form.validPeriod){
  306. // uni.showToast({
  307. // title: '请选择检验有效期',
  308. // icon:"none",
  309. // mask:true,
  310. // duration: 2000
  311. // });
  312. // return
  313. // }
  314. if(!this.form.beaconTag){
  315. uni.showToast({
  316. title: '请输入信标标签',
  317. icon:"none",
  318. mask:true,
  319. duration: 2000
  320. });
  321. return
  322. }
  323. if(!this.form.subjectId){
  324. uni.showToast({
  325. title: '请选择实验室',
  326. icon:"none",
  327. mask:true,
  328. duration: 2000
  329. });
  330. return
  331. }
  332. _this.list.forEach(function(item){
  333. item.radioList.forEach(function(item2){
  334. if(item.lab=='isHandwheel' && item2.checked){
  335. _this.form.handwheel=item2.id;
  336. }else if(item.lab=='isFixed' && item2.checked){
  337. _this.form.fixed=item2.id;
  338. }else if(item.lab=='isElectronicTag' && item2.checked){
  339. _this.form.electronicTag=item2.id;
  340. }else if(item.lab=='isStatusSign' && item2.checked){
  341. _this.form.statusLabel=item2.id;
  342. }
  343. })
  344. })
  345. const {data} = await airbottleStockEnter(_this.form);
  346. if(data.code == 200){
  347. uni.showToast({
  348. title: '提交成功',
  349. icon:"none",
  350. mask:true,
  351. duration: 2000
  352. });
  353. setTimeout(function(){
  354. uni.redirectTo({
  355. url: '/pages/gasBottle/stockList/stockList'
  356. });
  357. },2000);
  358. }
  359. },
  360. }
  361. }
  362. </script>
  363. <style lang="stylus" scoped>
  364. #register{
  365. height:auto;
  366. width:100%;
  367. display flex
  368. flex-direction column;
  369. padding-bottom: 220rpx;
  370. .register_li{
  371. background #fff;
  372. border-radius:20rpx;
  373. margin:20rpx 20rpx 0;
  374. padding:20rpx 0;
  375. box-sizing: border-box;
  376. .register_li_min{
  377. margin:0 26rpx;
  378. display flex;
  379. align-items center;
  380. border-bottom: 1px solid #F5F5F5;
  381. view{
  382. line-height:100rpx;
  383. font-size:28rpx;
  384. }
  385. view:nth-child(1){
  386. color:red;
  387. line-height:28rpx;
  388. margin-right: 12rpx;
  389. }
  390. view:nth-child(2){
  391. //width:140rpx;
  392. flex: 1;
  393. font-size: 28rpx;
  394. font-family: PingFang SC;
  395. font-weight: 500;
  396. color: #333333;
  397. }
  398. .picker-text{
  399. text-align: right;
  400. font-size: 28rpx;
  401. }
  402. >input{
  403. width 400rpx;
  404. text-align: right;
  405. font-size: 24rpx;
  406. font-family: PingFang SC;
  407. font-weight: 500;
  408. color: #333333;
  409. }
  410. .code_img{
  411. width: 30rpx;
  412. height: 28rpx;
  413. margin-left: 26rpx;
  414. }
  415. /* 单选按钮 */
  416. .radio_group{
  417. display: flex;
  418. .radio{
  419. display: flex;
  420. margin-left: 74rpx;
  421. margin-right: 0;
  422. >img{
  423. width: 30rpx;
  424. height: 30rpx;
  425. }
  426. >text{
  427. margin-left: 34rpx;
  428. font-size: 28rpx;
  429. font-family: PingFang SC;
  430. font-weight: 500;
  431. color: #333333;
  432. line-height: 28rpx;
  433. }
  434. }
  435. }
  436. }
  437. /* 时间 */
  438. .register_li_min2{
  439. margin:0 26rpx;
  440. border-bottom: 1px solid #f5f5f5;
  441. height: 100rpx;
  442. display: flex;
  443. justify-content: flex-start;
  444. align-items: center;
  445. >view:nth-child(1){
  446. font-size: 28rpx;
  447. font-family: PingFang SC;
  448. font-weight: 500;
  449. color: #333333;
  450. line-height: 100rpx;
  451. margin-right: 96rpx;
  452. }
  453. .picker-text{
  454. font-size: 24rpx;
  455. font-family: PingFang SC;
  456. font-weight: 500;
  457. color: #999999;
  458. line-height: 100rpx;
  459. width: 390rpx;
  460. text-align: right;
  461. }
  462. >view:nth-child(2){
  463. font-size: 24rpx;
  464. font-family: PingFang SC;
  465. font-weight: 500;
  466. color: #999999;
  467. line-height: 100rpx;
  468. }
  469. .picker-text2{
  470. font-size: 24rpx;
  471. font-family: PingFang SC;
  472. font-weight: 500;
  473. color: #999999;
  474. line-height: 100rpx;
  475. width: 188rpx;
  476. text-align: right;
  477. }
  478. }
  479. }
  480. /* 按钮 */
  481. .custom_li_min{
  482. margin:0 26rpx;
  483. display flex;
  484. align-items center;
  485. border-bottom: 1px solid #F5F5F5;
  486. .custom{
  487. width: 150rpx;
  488. height: 60rpx;
  489. border-radius: 10rpx 10rpx 10rpx 10rpx;
  490. opacity: 1;
  491. border: 1rpx solid #0183FA;
  492. font-size: 26rpx;
  493. font-family: PingFang SC-Medium, PingFang SC;
  494. font-weight: 400;
  495. color: #0183FA;
  496. line-height: 60rpx;
  497. text-align: center;
  498. float: right;
  499. margin-bottom: 12rpx;
  500. }
  501. }
  502. /* 按钮 */
  503. .sub_btn{
  504. width: 650rpx;
  505. height: 100rpx;
  506. background: #0183FA;
  507. border-radius: 50rpx;
  508. font-size: 28rpx;
  509. font-family: PingFang SC;
  510. font-weight: 500;
  511. color: #FFFFFF;
  512. line-height: 100rpx;
  513. text-align: center;
  514. margin-left: 50rpx;
  515. position: fixed;
  516. bottom:30rpx;
  517. z-index: 1000;
  518. }
  519. }
  520. /deep/.input-value-border{
  521. display :none !important;
  522. }
  523. </style>