gasUse.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <!--气瓶使用-->
  2. <template>
  3. <view id="gasRecycle">
  4. <view class="title">{{form.gasName}}-{{form.levelName}}({{form.sizeName}})</view>
  5. <view class="register_li">
  6. <view class="register_li_min">
  7. <view>余量:</view>
  8. <input v-model="form.gasPressure" disabled type="text" style="color: #D60000;">
  9. </view>
  10. <view class="register_li_min">
  11. <view>学院:</view>
  12. <input v-model="form.collegeName" disabled type="text" >
  13. </view>
  14. <view class="register_li_min" style="border: none;">
  15. <view>实验地点:</view>
  16. <input v-model="form.subjectName" disabled type="text" >
  17. </view>
  18. </view>
  19. <view class="register_li2">
  20. <view class="period" v-if="pageType==0">
  21. <view class="period_l"><i>*</i>开始时间</view>
  22. <view class="period_r">
  23. <input class="picker-text" @click="changeDateTime()" disabled type="text" v-model="form.usageStartTime" placeholder="开始时间">
  24. </view>
  25. </view>
  26. <view class="period" v-if="pageType==0">
  27. <view class="period_l"><i>*</i>结束时间</view>
  28. <view class="period_r">
  29. <input class="picker-text" @click="changeDateTime2()" disabled type="text" v-model="form.usageEndTime" disabled placeholder="结束时间">
  30. </view>
  31. </view>
  32. <view class="register_li_min" v-if="pageType==0">
  33. <view>*</view>
  34. <view>使用时长:</view>
  35. <input v-model="form.usageTime+usageTimeUnit" placeholder="--" disabled type="text" >
  36. </view>
  37. <view class="register_li_min" v-if="pageType==0">
  38. <view>*</view>
  39. <view>当前压力:</view>
  40. <input v-model="form.currentPressure" @input="onKeyVinInput($event)" type="number" @change="calculateAmountFun()" placeholder="请输入当前压力值">
  41. </view>
  42. <view class="register_li_min" v-if="pageType==0">
  43. <view>*</view>
  44. <view>本次使用量:</view>
  45. <input v-model="form.usageAmount" placeholder="--" type="text" >
  46. </view>
  47. <view class="up-img-box">
  48. <view class="asterisk">*</view>
  49. <view class="title-view">气表照片:</view>
  50. <view class="img-max-box">
  51. <view class="img-box" v-for="(item,index) in imgList" :key="index">
  52. <img class="img-data" :src="baseUrl+item">
  53. <img class="position-img" src="@/pages_manage/images/icon_ssp_closure.png" @click="delImg(index)">
  54. </view>
  55. <img class="add-button" src="@/pages_manage/images/icon_07.png" @click="selectImage" v-if="imgList.length<1">
  56. <img class="add-button" src="@/pages_manage/images/Version3.0/img_sydj_sltp.png" >
  57. </view>
  58. </view>
  59. </view>
  60. <view class="btn" v-if="pageType==0">
  61. <view class="btn_l" @click="handleClick('gasApply')">气瓶出库</view>
  62. <view class="btn_r" @click="submitForm(1)">登记完成</view>
  63. </view>
  64. <view v-if="pageType==1" class="sub_btn" @click="submitForm(2)">提交余量不符并使用</view>
  65. <!-- 一遮罩-->
  66. <view class="shade-outfire" v-if="dialogVisible">
  67. <view class="null-box" @click="dialogOutfire()"></view>
  68. <view class="shade-outfire-n">
  69. <view class="btns">
  70. <text @click="dialogOutfire()">取消</text>
  71. <text @click="submitDate()">确认</text>
  72. </view>
  73. <DateTimePicker
  74. @onChange="onChangeStartDate"
  75. :defaultDate="startDate"
  76. :maxDate="endDate"
  77. :mode="4"
  78. @="StartDate"
  79. />
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import DateTimePicker from '@/components/dengrq-datetime-picker/dateTimePicker/index.vue';
  86. import {airbottleStockFindByBeaconTag,airbottleUsageRecordAdd} from '@/api/index.js'
  87. import { config } from '@/api/request/config.js'
  88. export default {
  89. name: "gasRecycle",
  90. components: {
  91. DateTimePicker
  92. },
  93. data() {
  94. return {
  95. baseUrl:config.base_url,
  96. pageType:0,//0气瓶使用 1余量不符
  97. //列表请求参数
  98. getData:{
  99. pageNum:1,
  100. pageSize:20,
  101. isCg:0,
  102. zgStatus:"",
  103. getType:true,
  104. nullDataType:true,
  105. },
  106. userType:uni.getStorageSync('userType'),
  107. gasBottleLevel:uni.getStorageSync('gasBottleLevel'),// 气瓶级别
  108. gasBottleSpecification:uni.getStorageSync('gasBottleSpecification'), // 气瓶规格
  109. form:{
  110. location:'10map'
  111. },
  112. dataList:[],
  113. imgList:[],
  114. specificationName:{},
  115. currentStatus:null,
  116. beaconTag:'',
  117. dialogVisible:false,
  118. //时间年月日时分秒
  119. dateTime: null,
  120. dateTimeArray: null,
  121. startYear: 0,
  122. endYear: 0,
  123. timeStr:'',
  124. usageTimeUnit:'分钟',
  125. currentDate:'',//开始时间默认当前时间
  126. startDate:'',
  127. endDate:'',
  128. dateType:0,//0开始时间 1结束时间
  129. }
  130. },
  131. onLoad(option) {
  132. this.currentDateStartFun()
  133. if(option.beaconTag){
  134. this.beaconTag=option.beaconTag;
  135. }
  136. },
  137. onShow() {
  138. },
  139. mounted(){
  140. this.getInfo()
  141. },
  142. methods: {
  143. //限制只能输入数字
  144. onKeyVinInput(e) {
  145. const o = e.detail.value
  146. const inputRule = /[^\-?\d.]/g
  147. this.$nextTick(() => {
  148. this.form.currentPressure = o.replace(inputRule, '');
  149. if (this.form.currentPressure == '') {
  150. return
  151. } else {
  152. //执行对应代码
  153. }
  154. })
  155. },
  156. //当前时间年月日时分
  157. currentDateStartFun(){
  158. var self = this;
  159. let yy = new Date().getFullYear();
  160. let mm = new Date().getMonth()+1;
  161. let dd = new Date().getDate();
  162. dd = (dd < 10 ? '0' : '') + dd
  163. let hh = new Date().getHours();
  164. let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
  165. let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
  166. self.currentDate=yy+'-'+mm+'-'+dd+' '+hh+':'+mf;
  167. },
  168. durationFun(){
  169. let self=this;
  170. let duration=new Date(self.form.usageEndTime).getTime()-new Date(self.form.usageStartTime).getTime()
  171. let minutes = parseInt(duration/(1000 * 60))
  172. this.$set(this.form,'usageTime',minutes);
  173. },
  174. //时间确定
  175. submitDate(){
  176. this.dialogVisible=false;
  177. },
  178. //弹出层关闭
  179. dialogOutfire() {
  180. this.dialogVisible = !this.dialogVisible
  181. },
  182. //选中的时间
  183. onChangeStartDate(date) {
  184. console.log(date)
  185. if(this.dateType==0){//开始时间
  186. if(new Date(date).getTime()>new Date(this.form.usageEndTime).getTime()){
  187. uni.showToast({
  188. title: '开始时间不能大于结束时间',
  189. icon:"none",
  190. mask:true,
  191. duration: 2000
  192. });
  193. }else{
  194. this.form.usageStartTime= date;
  195. }
  196. }else if(this.dateType==1){//结束时间
  197. if(new Date(date).getTime()<new Date(this.form.usageStartTime).getTime()){
  198. uni.showToast({
  199. title: '结束时间不能小于开始时间',
  200. icon:"none",
  201. mask:true,
  202. duration: 2000
  203. });
  204. }else{
  205. this.form.usageEndTime= date
  206. this.durationFun();//使用时长
  207. }
  208. }
  209. },
  210. //开始时间
  211. changeDateTime() {
  212. this.dateType=0;
  213. this.dialogVisible=true;
  214. },
  215. //结束时间
  216. changeDateTime2() {
  217. this.dateType=1;
  218. this.dialogVisible=true;
  219. },
  220. //点击事件
  221. handleClick(doType) {
  222. let _this=this;
  223. if(doType=='inconformity'){//余量不符
  224. _this.pageType=1;
  225. }else if(doType=='gasApply'){//气瓶出库
  226. uni.redirectTo({
  227. url:'/pages/gasBottle/gasOutstock/gasOutstock?id='+this.form.id
  228. })
  229. }
  230. },
  231. //输入当前压力值后计算本次使用量
  232. calculateAmountFun(){
  233. let num=parseFloat(this.form.gasPressure)-parseFloat(this.form.currentPressure)
  234. if(num<=0){
  235. num=0;
  236. }
  237. if(Object.is(num, NaN)){
  238. this.$set(this.form,'usageAmount','')
  239. }else{
  240. this.$set(this.form,'usageAmount',num.toFixed(2)?num.toFixed(2):'')
  241. }
  242. },
  243. // //开始时间选中事件
  244. // startChange(form,e){
  245. // if(new Date(e.target.value).getTime()>new Date(this.form.endTime).getTime()){
  246. // uni.showToast({
  247. // title: '结束时间不能小于开始时间',
  248. // icon:"none",
  249. // mask:true,
  250. // duration: 2000
  251. // });
  252. // }else{
  253. // this.$set(this.form,'startTime',e.target.value);
  254. // }
  255. // },
  256. // //结束时间选中事件
  257. // endChange(form,e){
  258. // if(new Date(this.form.startTime).getTime()>new Date(e.target.value).getTime()){
  259. // uni.showToast({
  260. // title: '结束时间不能小于开始时间',
  261. // icon:"none",
  262. // mask:true,
  263. // duration: 2000
  264. // });
  265. // }else{
  266. // this.$set(this.form,'endTime',e.target.value);
  267. // }
  268. // },
  269. // 图片上传
  270. selectImage(index) {
  271. let self = this;
  272. if(self.imgList.length>1){
  273. uni.showToast({
  274. title: '最多上传1张图片',
  275. icon:"none",
  276. mask:true,
  277. duration: 2000
  278. });
  279. return
  280. }
  281. wx.chooseImage({
  282. count: 1,
  283. sizeType: ["original", "compressed"],
  284. sourceType: ["album", "camera"],
  285. success: function(res) {
  286. let tempFilePaths = res.tempFilePaths[0];
  287. self.uploadImg(tempFilePaths,index);
  288. }
  289. });
  290. },
  291. async uploadImg(tempFilePaths,index){
  292. var self = this;
  293. uni.showLoading({
  294. title: '上传中',
  295. mask: true
  296. });
  297. uni.uploadFile({
  298. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  299. header:{'Authorization':uni.getStorageSync('token')},
  300. filePath: tempFilePaths,
  301. name: 'file',
  302. formData: {
  303. 'user': 'test'
  304. },
  305. success: (uploadFileRes) => {
  306. let res = JSON.parse(uploadFileRes.data);
  307. if(res.code == 200){
  308. self.imgList.push(res.data.url);
  309. }else{
  310. uni.showToast({
  311. title: res.msg,
  312. icon:"none",
  313. mask:true,
  314. duration: 2000
  315. });
  316. }
  317. },
  318. fail: err => {},
  319. complete: () => {
  320. uni.hideLoading()
  321. }
  322. });
  323. },
  324. //删除图片
  325. delImg(index){
  326. this.imgList.splice(index,1);
  327. },
  328. async getInfo(){
  329. let self=this;
  330. const {data} = await airbottleStockFindByBeaconTag({BeaconTag:self.beaconTag});
  331. if(data.code==200){
  332. for(let b=0;b<this.gasBottleSpecification.length;b++){
  333. if(this.gasBottleSpecification[b].dictValue==data.data.size){
  334. data.data.sizeName=this.gasBottleSpecification[b].dictLabel
  335. }
  336. }
  337. for(let t=0;t<this.gasBottleLevel.length;t++){
  338. if(this.gasBottleLevel[t].dictValue==data.data.level){
  339. data.data.levelName=this.gasBottleLevel[t].dictLabel
  340. }
  341. }
  342. self.form=data.data;
  343. this.$set(this.form,'usageTime',0);
  344. this.$set(this.form,'usageStartTime',self.currentDate);
  345. console.log(self.currentDate)
  346. }
  347. },
  348. //提交
  349. async submitForm(type){
  350. let _this = this;
  351. if(_this.imgList.length<=0){
  352. uni.showToast({
  353. title: '请选择气表图片!',
  354. icon:"none",
  355. mask:true,
  356. duration: 2000
  357. });
  358. return
  359. }
  360. if(!_this.form.usageAmount){
  361. uni.showToast({
  362. title: '请输入本次使用量!',
  363. icon:"none",
  364. mask:true,
  365. duration: 2000
  366. });
  367. return
  368. }
  369. this.$set(this.form,'stcokId',this.form.id);
  370. this.$set(this.form,'id','');
  371. this.$set(this.form,'usageImg',this.imgList.join(','));
  372. this.$set(this.form,'gasPressure',this.form.currentPressure);
  373. const {data} = await airbottleUsageRecordAdd(this.form);
  374. if(data.code == 200){
  375. uni.showToast({
  376. title: '提交成功',
  377. icon:"none",
  378. mask:true,
  379. duration: 2000
  380. });
  381. setTimeout(function(){
  382. uni.redirectTo({
  383. url: '/pages/gasBottle/gasManage/gasManage'
  384. });
  385. },2000);
  386. }
  387. },
  388. }
  389. }
  390. </script>
  391. <style lang="stylus" scoped>
  392. #gasRecycle {
  393. height: auto;
  394. width: 100%;
  395. flex :1;
  396. display flex;
  397. flex-direction column;
  398. overflow hidden;
  399. padding-bottom: 220rpx;
  400. .title{
  401. width: 750rpx;
  402. height: 100rpx;
  403. background: #FFFFFF;
  404. font-size: 28rpx;
  405. font-family: PingFang SC;
  406. font-weight: 500;
  407. color: #333333;
  408. line-height: 100rpx;
  409. padding-left: 40rpx;
  410. }
  411. .register_li{
  412. background #fff;
  413. border-radius:20rpx;
  414. margin:20rpx 20rpx 0;
  415. padding:20rpx 0;
  416. box-sizing: border-box;
  417. .register_li_min{
  418. margin:0 26rpx;
  419. display flex;
  420. align-items center;
  421. border-bottom: 1px solid #F5F5F5;
  422. .icon_img{
  423. width: 30rpx;
  424. height: 30rpx;
  425. margin-right: 12rpx;
  426. }
  427. view{
  428. //width:140rpx;
  429. font-size: 28rpx;
  430. font-family: PingFang SC;
  431. font-weight: 500;
  432. color: #999999;
  433. line-height: 100rpx;
  434. }
  435. >input{
  436. flex:1;
  437. text-align: right;
  438. font-size: 24rpx;
  439. font-family: PingFang SC;
  440. font-weight: 500;
  441. color: #333333;
  442. }
  443. .inconformity{
  444. font-size: 24rpx;
  445. font-family: PingFang SC;
  446. font-weight: 500;
  447. color: #D60000;
  448. margin-left: 40rpx;
  449. }
  450. }
  451. }
  452. .register_li2{
  453. background #fff;
  454. border-radius:20rpx;
  455. margin:20rpx 20rpx 0;
  456. padding:20rpx 0;
  457. box-sizing: border-box;
  458. .period{
  459. display: flex;
  460. justify-content: flex-start;
  461. align-items: center;
  462. margin: 0 26rpx;
  463. border-bottom: 1px solid #f5f5f5;
  464. .period_l{
  465. width: 146rpx;
  466. font-size: 30rpx;
  467. font-family: PingFang SC-Medium, PingFang SC;
  468. font-weight: 400;
  469. color: #333333;
  470. line-height: 42rpx;
  471. text-align: left;
  472. >i{
  473. display: inline-block;
  474. color: #f00;
  475. line-height: 28rpx;
  476. margin-right: 12rpx;
  477. }
  478. }
  479. .period_r{
  480. width: 490rpx;
  481. height: 80rpx;
  482. border-radius: 10rpx;
  483. display: flex;
  484. justify-content: flex-start;
  485. align-items: center;
  486. .picker-text{
  487. font-size: 30rpx;
  488. font-family: PingFang SC-Medium, PingFang SC;
  489. font-weight: 400;
  490. color: #999;
  491. line-height: 80rpx;
  492. width: 516rpx;
  493. text-align: right;
  494. }
  495. // .picker-text2{
  496. // font-size: 30rpx;
  497. // font-family: PingFang SC-Medium, PingFang SC;
  498. // font-weight: 400;
  499. // color: #333;
  500. // line-height: 80rpx;
  501. // width: 230rpx;
  502. // text-align: center;
  503. // }
  504. }
  505. }
  506. .register_li_min{
  507. margin:0 26rpx;
  508. display flex;
  509. align-items center;
  510. border-bottom: 1px solid #F5F5F5;
  511. .icon_img{
  512. width: 30rpx;
  513. height: 30rpx;
  514. margin-right: 12rpx;
  515. }
  516. view:nth-child(1){
  517. color:red;
  518. line-height:28rpx;
  519. margin-right: 12rpx;
  520. }
  521. view{
  522. //width:140rpx;
  523. font-size: 28rpx;
  524. font-family: PingFang SC;
  525. font-weight: 500;
  526. color: #333333;
  527. line-height: 100rpx;
  528. }
  529. >input{
  530. flex:1;
  531. text-align: right;
  532. font-size: 24rpx;
  533. font-family: PingFang SC;
  534. font-weight: 500;
  535. color: #999999;
  536. }
  537. }
  538. /* 照片 */
  539. .up-img-box{
  540. display flex
  541. margin:34rpx 26rpx;
  542. .asterisk{
  543. padding-top:30rpx;
  544. color:red;
  545. line-height:28rpx;
  546. margin-right: 12rpx;
  547. }
  548. .title-view{
  549. width:150rpx;
  550. line-height:80rpx;
  551. font-size: 30rpx;
  552. color:#333;
  553. }
  554. .img-max-box{
  555. width:480rpx;
  556. display: flex;
  557. .img-box{
  558. display inline-block
  559. height:150rpx;
  560. width:150rpx;
  561. position relative
  562. margin:0 20rpx 20rpx 0;
  563. .img-data{
  564. height:150rpx;
  565. width:150rpx;
  566. }
  567. .position-img{
  568. position absolute
  569. right:0;
  570. top:0;
  571. width:36rpx;
  572. height:36rpx;
  573. }
  574. }
  575. .add-button{
  576. display inline-block
  577. height:150rpx;
  578. width:150rpx;
  579. margin-right: 20rpx;
  580. }
  581. }
  582. }
  583. }
  584. /* 按钮 */
  585. .btn{
  586. display: flex;
  587. position: fixed;
  588. bottom: 40rpx;
  589. left: 50rpx;
  590. .btn_l{
  591. width: 324rpx;
  592. height: 100rpx;
  593. background: #F28E26;
  594. border-radius: 50rpx 0rpx 0rpx 50rpx;
  595. font-size: 28rpx;
  596. font-family: PingFang SC;
  597. font-weight: 500;
  598. color: #FFFFFF;
  599. line-height: 100rpx;
  600. text-align: center;
  601. }
  602. .btn_r{
  603. width: 324rpx;
  604. height: 100rpx;
  605. background: #0183FA;
  606. border-radius: 0rpx 50rpx 50rpx 0rpx;
  607. font-size: 28rpx;
  608. font-family: PingFang SC;
  609. font-weight: 500;
  610. color: #FFFFFF;
  611. line-height: 100rpx;
  612. text-align: center;
  613. }
  614. }
  615. /* 按钮 */
  616. .sub_btn{
  617. width: 650rpx;
  618. height: 100rpx;
  619. background: #0183FA;
  620. border-radius: 20rpx;
  621. font-size: 28rpx;
  622. font-family: PingFang SC;
  623. font-weight: 500;
  624. color: #FFFFFF;
  625. line-height: 100rpx;
  626. text-align: center;
  627. margin-left: 50rpx;
  628. position: fixed;
  629. bottom:30rpx;
  630. z-index: 1000;
  631. }
  632. /* 空 */
  633. .empty{
  634. background #fff;
  635. border-radius:20rpx;
  636. margin:20rpx 20rpx 0;
  637. padding:20rpx 0;
  638. box-sizing: border-box;
  639. >img{
  640. width: 100rpx;
  641. height: 100rpx;
  642. margin-top: 124rpx;
  643. margin-left: 300rpx;
  644. }
  645. >view{
  646. font-size: 28rpx;
  647. font-family: PingFang SC;
  648. font-weight: 500;
  649. color: #333333;
  650. line-height: 30rpx;
  651. text-align: center;
  652. margin-top: 42rpx;
  653. padding-bottom: 106rpx;
  654. }
  655. }
  656. /* 弹窗 */
  657. .shade-outfire {
  658. height: 100%;
  659. width: 100%;
  660. position: fixed;
  661. display: flex;
  662. flex-direction: column;
  663. z-index: 10;
  664. background: rgba(0, 0, 0, 0.2);
  665. .null-box {
  666. flex: 1;
  667. }
  668. /* 内容 */
  669. .shade-outfire-n {
  670. width: 100%;
  671. height: 450rpx;
  672. background: #FFFFFF;
  673. border-radius: 20rpx;
  674. position: absolute;
  675. bottom: 0rpx;
  676. left: 0rpx;
  677. .btns{
  678. width: 100%;
  679. height: 100rpx;
  680. display: flex;
  681. justify-content: space-between;
  682. align-items: center;
  683. padding: 0 30rpx;
  684. box-sizing: border-box;
  685. border-bottom: 1rpx solid #dedede;
  686. >text{
  687. color: #7f7f7f;
  688. font-size: 36rpx;
  689. display: inline-block;
  690. }
  691. >text:nth-of-type(2){
  692. color: #42a06c;
  693. }
  694. }
  695. }
  696. }
  697. }
  698. </style>