gasUse.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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. this.$set(this.form,'usageAmount',num.toFixed(2))
  238. },
  239. // //开始时间选中事件
  240. // startChange(form,e){
  241. // if(new Date(e.target.value).getTime()>new Date(this.form.endTime).getTime()){
  242. // uni.showToast({
  243. // title: '结束时间不能小于开始时间',
  244. // icon:"none",
  245. // mask:true,
  246. // duration: 2000
  247. // });
  248. // }else{
  249. // this.$set(this.form,'startTime',e.target.value);
  250. // }
  251. // },
  252. // //结束时间选中事件
  253. // endChange(form,e){
  254. // if(new Date(this.form.startTime).getTime()>new Date(e.target.value).getTime()){
  255. // uni.showToast({
  256. // title: '结束时间不能小于开始时间',
  257. // icon:"none",
  258. // mask:true,
  259. // duration: 2000
  260. // });
  261. // }else{
  262. // this.$set(this.form,'endTime',e.target.value);
  263. // }
  264. // },
  265. // 图片上传
  266. selectImage(index) {
  267. let self = this;
  268. if(self.imgList.length>1){
  269. uni.showToast({
  270. title: '最多上传1张图片',
  271. icon:"none",
  272. mask:true,
  273. duration: 2000
  274. });
  275. return
  276. }
  277. wx.chooseImage({
  278. count: 1,
  279. sizeType: ["original", "compressed"],
  280. sourceType: ["album", "camera"],
  281. success: function(res) {
  282. let tempFilePaths = res.tempFilePaths[0];
  283. self.uploadImg(tempFilePaths,index);
  284. }
  285. });
  286. },
  287. async uploadImg(tempFilePaths,index){
  288. var self = this;
  289. uni.showLoading({
  290. title: '上传中',
  291. mask: true
  292. });
  293. uni.uploadFile({
  294. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  295. header:{'Authorization':uni.getStorageSync('token')},
  296. filePath: tempFilePaths,
  297. name: 'file',
  298. formData: {
  299. 'user': 'test'
  300. },
  301. success: (uploadFileRes) => {
  302. let res = JSON.parse(uploadFileRes.data);
  303. if(res.code == 200){
  304. self.imgList.push(res.data.url);
  305. }else{
  306. uni.showToast({
  307. title: res.msg,
  308. icon:"none",
  309. mask:true,
  310. duration: 2000
  311. });
  312. }
  313. },
  314. fail: err => {},
  315. complete: () => {
  316. uni.hideLoading()
  317. }
  318. });
  319. },
  320. //删除图片
  321. delImg(index){
  322. this.imgList.splice(index,1);
  323. },
  324. async getInfo(){
  325. let self=this;
  326. const {data} = await airbottleStockFindByBeaconTag({BeaconTag:self.beaconTag});
  327. if(data.code==200){
  328. for(let b=0;b<this.gasBottleSpecification.length;b++){
  329. if(this.gasBottleSpecification[b].dictValue==data.data.size){
  330. data.data.sizeName=this.gasBottleSpecification[b].dictLabel
  331. }
  332. }
  333. for(let t=0;t<this.gasBottleLevel.length;t++){
  334. if(this.gasBottleLevel[t].dictValue==data.data.level){
  335. data.data.levelName=this.gasBottleLevel[t].dictLabel
  336. }
  337. }
  338. self.form=data.data;
  339. this.$set(this.form,'usageTime',0);
  340. this.$set(this.form,'usageStartTime',self.currentDate);
  341. console.log(self.currentDate)
  342. }
  343. },
  344. //提交
  345. async submitForm(type){
  346. let _this = this;
  347. if(_this.imgList.length<=0){
  348. uni.showToast({
  349. title: '请选择气表图片!',
  350. icon:"none",
  351. mask:true,
  352. duration: 2000
  353. });
  354. return
  355. }
  356. this.$set(this.form,'stcokId',this.form.id);
  357. this.$set(this.form,'id','');
  358. this.$set(this.form,'usageImg',this.imgList.join(','));
  359. this.$set(this.form,'gasPressure',this.form.currentPressure);
  360. const {data} = await airbottleUsageRecordAdd(this.form);
  361. if(data.code == 200){
  362. uni.showToast({
  363. title: '提交成功',
  364. icon:"none",
  365. mask:true,
  366. duration: 2000
  367. });
  368. setTimeout(function(){
  369. uni.redirectTo({
  370. url: '/pages/gasBottle/gasManage/gasManage'
  371. });
  372. },2000);
  373. }
  374. },
  375. }
  376. }
  377. </script>
  378. <style lang="stylus" scoped>
  379. #gasRecycle {
  380. height: auto;
  381. width: 100%;
  382. flex :1;
  383. display flex;
  384. flex-direction column;
  385. overflow hidden;
  386. padding-bottom: 220rpx;
  387. .title{
  388. width: 750rpx;
  389. height: 100rpx;
  390. background: #FFFFFF;
  391. font-size: 28rpx;
  392. font-family: PingFang SC;
  393. font-weight: 500;
  394. color: #333333;
  395. line-height: 100rpx;
  396. padding-left: 40rpx;
  397. }
  398. .register_li{
  399. background #fff;
  400. border-radius:20rpx;
  401. margin:20rpx 20rpx 0;
  402. padding:20rpx 0;
  403. box-sizing: border-box;
  404. .register_li_min{
  405. margin:0 26rpx;
  406. display flex;
  407. align-items center;
  408. border-bottom: 1px solid #F5F5F5;
  409. .icon_img{
  410. width: 30rpx;
  411. height: 30rpx;
  412. margin-right: 12rpx;
  413. }
  414. view{
  415. //width:140rpx;
  416. font-size: 28rpx;
  417. font-family: PingFang SC;
  418. font-weight: 500;
  419. color: #999999;
  420. line-height: 100rpx;
  421. }
  422. >input{
  423. flex:1;
  424. text-align: right;
  425. font-size: 24rpx;
  426. font-family: PingFang SC;
  427. font-weight: 500;
  428. color: #333333;
  429. }
  430. .inconformity{
  431. font-size: 24rpx;
  432. font-family: PingFang SC;
  433. font-weight: 500;
  434. color: #D60000;
  435. margin-left: 40rpx;
  436. }
  437. }
  438. }
  439. .register_li2{
  440. background #fff;
  441. border-radius:20rpx;
  442. margin:20rpx 20rpx 0;
  443. padding:20rpx 0;
  444. box-sizing: border-box;
  445. .period{
  446. display: flex;
  447. justify-content: flex-start;
  448. align-items: center;
  449. margin: 0 26rpx;
  450. border-bottom: 1px solid #f5f5f5;
  451. .period_l{
  452. width: 146rpx;
  453. font-size: 30rpx;
  454. font-family: PingFang SC-Medium, PingFang SC;
  455. font-weight: 400;
  456. color: #333333;
  457. line-height: 42rpx;
  458. text-align: left;
  459. >i{
  460. display: inline-block;
  461. color: #f00;
  462. line-height: 28rpx;
  463. margin-right: 12rpx;
  464. }
  465. }
  466. .period_r{
  467. width: 490rpx;
  468. height: 80rpx;
  469. border-radius: 10rpx;
  470. display: flex;
  471. justify-content: flex-start;
  472. align-items: center;
  473. .picker-text{
  474. font-size: 30rpx;
  475. font-family: PingFang SC-Medium, PingFang SC;
  476. font-weight: 400;
  477. color: #999;
  478. line-height: 80rpx;
  479. width: 516rpx;
  480. text-align: right;
  481. }
  482. // .picker-text2{
  483. // font-size: 30rpx;
  484. // font-family: PingFang SC-Medium, PingFang SC;
  485. // font-weight: 400;
  486. // color: #333;
  487. // line-height: 80rpx;
  488. // width: 230rpx;
  489. // text-align: center;
  490. // }
  491. }
  492. }
  493. .register_li_min{
  494. margin:0 26rpx;
  495. display flex;
  496. align-items center;
  497. border-bottom: 1px solid #F5F5F5;
  498. .icon_img{
  499. width: 30rpx;
  500. height: 30rpx;
  501. margin-right: 12rpx;
  502. }
  503. view:nth-child(1){
  504. color:red;
  505. line-height:28rpx;
  506. margin-right: 12rpx;
  507. }
  508. view{
  509. //width:140rpx;
  510. font-size: 28rpx;
  511. font-family: PingFang SC;
  512. font-weight: 500;
  513. color: #333333;
  514. line-height: 100rpx;
  515. }
  516. >input{
  517. flex:1;
  518. text-align: right;
  519. font-size: 24rpx;
  520. font-family: PingFang SC;
  521. font-weight: 500;
  522. color: #999999;
  523. }
  524. }
  525. /* 照片 */
  526. .up-img-box{
  527. display flex
  528. margin:34rpx 26rpx;
  529. .asterisk{
  530. padding-top:30rpx;
  531. color:red;
  532. line-height:28rpx;
  533. margin-right: 12rpx;
  534. }
  535. .title-view{
  536. width:150rpx;
  537. line-height:80rpx;
  538. font-size: 30rpx;
  539. color:#333;
  540. }
  541. .img-max-box{
  542. width:480rpx;
  543. display: flex;
  544. .img-box{
  545. display inline-block
  546. height:150rpx;
  547. width:150rpx;
  548. position relative
  549. margin:0 20rpx 20rpx 0;
  550. .img-data{
  551. height:150rpx;
  552. width:150rpx;
  553. }
  554. .position-img{
  555. position absolute
  556. right:0;
  557. top:0;
  558. width:36rpx;
  559. height:36rpx;
  560. }
  561. }
  562. .add-button{
  563. display inline-block
  564. height:150rpx;
  565. width:150rpx;
  566. margin-right: 20rpx;
  567. }
  568. }
  569. }
  570. }
  571. /* 按钮 */
  572. .btn{
  573. display: flex;
  574. position: fixed;
  575. bottom: 40rpx;
  576. left: 50rpx;
  577. .btn_l{
  578. width: 324rpx;
  579. height: 100rpx;
  580. background: #F28E26;
  581. border-radius: 50rpx 0rpx 0rpx 50rpx;
  582. font-size: 28rpx;
  583. font-family: PingFang SC;
  584. font-weight: 500;
  585. color: #FFFFFF;
  586. line-height: 100rpx;
  587. text-align: center;
  588. }
  589. .btn_r{
  590. width: 324rpx;
  591. height: 100rpx;
  592. background: #0183FA;
  593. border-radius: 0rpx 50rpx 50rpx 0rpx;
  594. font-size: 28rpx;
  595. font-family: PingFang SC;
  596. font-weight: 500;
  597. color: #FFFFFF;
  598. line-height: 100rpx;
  599. text-align: center;
  600. }
  601. }
  602. /* 按钮 */
  603. .sub_btn{
  604. width: 650rpx;
  605. height: 100rpx;
  606. background: #0183FA;
  607. border-radius: 20rpx;
  608. font-size: 28rpx;
  609. font-family: PingFang SC;
  610. font-weight: 500;
  611. color: #FFFFFF;
  612. line-height: 100rpx;
  613. text-align: center;
  614. margin-left: 50rpx;
  615. position: fixed;
  616. bottom:30rpx;
  617. z-index: 1000;
  618. }
  619. /* 空 */
  620. .empty{
  621. background #fff;
  622. border-radius:20rpx;
  623. margin:20rpx 20rpx 0;
  624. padding:20rpx 0;
  625. box-sizing: border-box;
  626. >img{
  627. width: 100rpx;
  628. height: 100rpx;
  629. margin-top: 124rpx;
  630. margin-left: 300rpx;
  631. }
  632. >view{
  633. font-size: 28rpx;
  634. font-family: PingFang SC;
  635. font-weight: 500;
  636. color: #333333;
  637. line-height: 30rpx;
  638. text-align: center;
  639. margin-top: 42rpx;
  640. padding-bottom: 106rpx;
  641. }
  642. }
  643. /* 弹窗 */
  644. .shade-outfire {
  645. height: 100%;
  646. width: 100%;
  647. position: fixed;
  648. display: flex;
  649. flex-direction: column;
  650. z-index: 10;
  651. background: rgba(0, 0, 0, 0.2);
  652. .null-box {
  653. flex: 1;
  654. }
  655. /* 内容 */
  656. .shade-outfire-n {
  657. width: 100%;
  658. height: 450rpx;
  659. background: #FFFFFF;
  660. border-radius: 20rpx;
  661. position: absolute;
  662. bottom: 0rpx;
  663. left: 0rpx;
  664. .btns{
  665. width: 100%;
  666. height: 100rpx;
  667. display: flex;
  668. justify-content: space-between;
  669. align-items: center;
  670. padding: 0 30rpx;
  671. box-sizing: border-box;
  672. border-bottom: 1rpx solid #dedede;
  673. >text{
  674. color: #7f7f7f;
  675. font-size: 36rpx;
  676. display: inline-block;
  677. }
  678. >text:nth-of-type(2){
  679. color: #42a06c;
  680. }
  681. }
  682. }
  683. }
  684. }
  685. </style>