gasUse.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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. <picker mode="multiSelector" @change="changeDateTime" @columnchange="changeDateTimeColumn" :range="dateTimeArray">
  24. <input class="picker-text" disabled type="text" v-model="form.usageStartTime" placeholder="开始时间">
  25. </picker>
  26. </view>
  27. </view>
  28. <view class="period" v-if="pageType==0">
  29. <view class="period_l"><i>*</i>结束时间</view>
  30. <view class="period_r">
  31. <picker mode="multiSelector" @change="changeDateTime2" @columnchange="changeDateTimeColumn" :range="dateTimeArray">
  32. <input class="picker-text" disabled type="text" v-model="form.usageEndTime" placeholder="结束时间">
  33. </picker>
  34. </view>
  35. </view>
  36. <view class="register_li_min" v-if="pageType==0">
  37. <view>*</view>
  38. <view>当前压力:</view>
  39. <input v-model="form.currentPressure" @change="calculateAmountFun()" placeholder="请输入当前压力值" type="text" >
  40. </view>
  41. <view class="register_li_min" v-if="pageType==0">
  42. <view>*</view>
  43. <view>本次使用量:</view>
  44. <input v-model="form.usageAmount" placeholder="--" type="text" >
  45. </view>
  46. <view class="up-img-box">
  47. <view class="asterisk">*</view>
  48. <view class="title-view">气表照片:</view>
  49. <view class="img-max-box">
  50. <view class="img-box" v-for="(item,index) in imgList" :key="index">
  51. <img class="img-data" :src="baseUrl+item">
  52. <img class="position-img" src="@/pages_manage/images/icon_ssp_closure.png" @click="delImg(index)">
  53. </view>
  54. <img class="add-button" src="@/pages_manage/images/icon_07.png" @click="selectImage" v-if="imgList.length<1">
  55. <img class="add-button" src="@/pages_manage/images/Version3.0/img_sydj_sltp.png" >
  56. </view>
  57. </view>
  58. </view>
  59. <view class="btn" v-if="pageType==0">
  60. <view class="btn_l" @click="handleClick('gasApply')">气瓶出库</view>
  61. <view class="btn_r" @click="submitForm(1)">登记完成</view>
  62. </view>
  63. <view v-if="pageType==1" class="sub_btn" @click="submitForm(2)">提交余量不符并使用</view>
  64. </view>
  65. </template>
  66. <script>
  67. import { useRegisterDetail,useRegisterAdd,airbottleStockFindByBeaconTag,airbottleUsageRecordAdd} from '@/api/index.js'
  68. import { config } from '@/api/request/config.js'
  69. import { dateTimePicker,getMonthDay} from '@/api/../component/date.js'
  70. export default {
  71. name: "gasRecycle",
  72. data() {
  73. return {
  74. baseUrl:config.base_url,
  75. pageType:0,//0气瓶使用 1余量不符
  76. //列表请求参数
  77. getData:{
  78. pageNum:1,
  79. pageSize:20,
  80. isCg:0,
  81. zgStatus:"",
  82. getType:true,
  83. nullDataType:true,
  84. },
  85. userType:uni.getStorageSync('userType'),
  86. gasBottleLevel:uni.getStorageSync('gasBottleLevel'),// 气瓶级别
  87. gasBottleSpecification:uni.getStorageSync('gasBottleSpecification'), // 气瓶规格
  88. form:{
  89. location:'10map'
  90. },
  91. dataList:[],
  92. imgList:[],
  93. specificationName:{},
  94. currentStatus:null,
  95. beaconTag:'',
  96. //时间年月日时分秒
  97. dateTime: null,
  98. dateTimeArray: null,
  99. startYear: 0,
  100. endYear: 0,
  101. timeStr:''
  102. }
  103. },
  104. onLoad(option) {
  105. this.currentDateFun()
  106. this.initTime()
  107. if(option.beaconTag){
  108. this.beaconTag=option.beaconTag;
  109. }
  110. },
  111. onShow() {
  112. },
  113. mounted(){
  114. this.getInfo()
  115. },
  116. methods: {
  117. currentDateFun(){
  118. let date = new Date(); //Fri Oct 29 2021 16:37:56 GMT+0800 (CST)
  119. this.startYear= date.getFullYear(); //获取完整的年份(4位)
  120. this.endYear= date.getFullYear()+70;
  121. },
  122. initTime(){
  123. let date = new Date();
  124. let endYear = date.getFullYear();
  125. // 获取完整的年月日 时分秒,以及默认显示的数组
  126. let obj = dateTimePicker(this.startYear, this.endYear);
  127. // 精确到分的处理,将数组的秒去掉
  128. // let lastArray = obj.dateTimeArray.pop();
  129. // let lastTime = obj.dateTime.pop();
  130. this.dateTimeArray=obj.dateTimeArray
  131. this.dateTime=obj.dateTime
  132. },
  133. //开始时间
  134. changeDateTime(e) {
  135. this.dateTime = e.detail.value;
  136. this.form.usageStartTime= this.createTimeStr(this.dateTimeArray,this.dateTime);
  137. //ios时间不能用'-'解析成时间戳
  138. },
  139. //结束时间
  140. changeDateTime2(e) {
  141. this.dateTime = e.detail.value;
  142. this.form.usageEndTime= this.createTimeStr(this.dateTimeArray,this.dateTime);
  143. //ios时间不能用'-'解析成时间戳
  144. },
  145. /*年,月切换时重新更新计算*/
  146. changeDateTimeColumn(e) {
  147. //let {id} = e.target;
  148. let {column,value} = e.detail;
  149. if(column==0 || column==1){
  150. //直接修改数组下标视图不更新,用深拷贝之后替换数组
  151. let dateTime = JSON.parse(JSON.stringify(this.dateTime));
  152. let dateTimeArray = JSON.parse(JSON.stringify(this.dateTimeArray));
  153. dateTime[column] = value;
  154. dateTimeArray[2] = getMonthDay(dateTimeArray[0][dateTime[0]], dateTimeArray[1][dateTime[1]]);
  155. this.dateTime = dateTime;
  156. this.dateTimeArray = dateTimeArray;
  157. }
  158. },
  159. createTimeStr(dateTimeArray,dateTime){
  160. let timeStr = dateTimeArray[0][dateTime[0]]+'-'+dateTimeArray[1][dateTime[1]]+'-'+dateTimeArray[2][dateTime[2]]+' '+dateTimeArray[3][dateTime[3]]+":"+dateTimeArray[4][dateTime[4]];
  161. return timeStr
  162. },
  163. //点击事件
  164. handleClick(doType) {
  165. let _this=this;
  166. if(doType=='inconformity'){//余量不符
  167. _this.pageType=1;
  168. }else if(doType=='gasApply'){//气瓶出库
  169. uni.redirectTo({
  170. url:'/pages/gasBottle/gasOutstock/gasOutstock?id='+this.form.id
  171. })
  172. }
  173. },
  174. //输入当前压力值后计算本次使用量
  175. calculateAmountFun(){
  176. let num=parseInt(this.form.gasPressure)-parseInt(this.form.currentPressure)
  177. if(num<=0){
  178. num=0;
  179. }
  180. this.$set(this.form,'usageAmount',num)
  181. },
  182. // //开始时间选中事件
  183. // startChange(form,e){
  184. // if(new Date(e.target.value).getTime()>new Date(this.form.endTime).getTime()){
  185. // uni.showToast({
  186. // title: '结束时间不能小于开始时间',
  187. // icon:"none",
  188. // mask:true,
  189. // duration: 2000
  190. // });
  191. // }else{
  192. // this.$set(this.form,'startTime',e.target.value);
  193. // }
  194. // },
  195. // //结束时间选中事件
  196. // endChange(form,e){
  197. // if(new Date(this.form.startTime).getTime()>new Date(e.target.value).getTime()){
  198. // uni.showToast({
  199. // title: '结束时间不能小于开始时间',
  200. // icon:"none",
  201. // mask:true,
  202. // duration: 2000
  203. // });
  204. // }else{
  205. // this.$set(this.form,'endTime',e.target.value);
  206. // }
  207. // },
  208. // 图片上传
  209. selectImage(index) {
  210. let self = this;
  211. if(self.imgList.length>1){
  212. uni.showToast({
  213. title: '最多上传1张图片',
  214. icon:"none",
  215. mask:true,
  216. duration: 2000
  217. });
  218. return
  219. }
  220. wx.chooseImage({
  221. count: 1,
  222. sizeType: ["original", "compressed"],
  223. sourceType: ["album", "camera"],
  224. success: function(res) {
  225. let tempFilePaths = res.tempFilePaths[0];
  226. self.uploadImg(tempFilePaths,index);
  227. }
  228. });
  229. },
  230. async uploadImg(tempFilePaths,index){
  231. var self = this;
  232. uni.showLoading({
  233. title: '上传中',
  234. mask: true
  235. });
  236. uni.uploadFile({
  237. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  238. header:{'Authorization':uni.getStorageSync('token')},
  239. filePath: tempFilePaths,
  240. name: 'file',
  241. formData: {
  242. 'user': 'test'
  243. },
  244. success: (uploadFileRes) => {
  245. let res = JSON.parse(uploadFileRes.data);
  246. if(res.code == 200){
  247. self.imgList.push(res.data.url);
  248. }else{
  249. uni.showToast({
  250. title: res.msg,
  251. icon:"none",
  252. mask:true,
  253. duration: 2000
  254. });
  255. }
  256. },
  257. fail: err => {},
  258. complete: () => {
  259. uni.hideLoading()
  260. }
  261. });
  262. },
  263. //删除图片
  264. delImg(index){
  265. this.imgList.splice(index,1);
  266. },
  267. async getInfo(){
  268. let _this=this;
  269. const {data} = await airbottleStockFindByBeaconTag({BeaconTag:_this.beaconTag});
  270. if(data.code==200){
  271. for(let b=0;b<this.gasBottleSpecification.length;b++){
  272. if(this.gasBottleSpecification[b].dictValue==data.data.size){
  273. data.data.sizeName=this.gasBottleSpecification[b].dictLabel
  274. }
  275. }
  276. for(let t=0;t<this.gasBottleLevel.length;t++){
  277. if(this.gasBottleLevel[t].dictValue==data.data.level){
  278. data.data.levelName=this.gasBottleLevel[t].dictLabel
  279. }
  280. }
  281. _this.form=data.data;
  282. }
  283. },
  284. //提交
  285. async submitForm(type){
  286. let _this = this;
  287. if(_this.imgList.length<=0){
  288. uni.showToast({
  289. title: '请选择气表图片!',
  290. icon:"none",
  291. mask:true,
  292. duration: 2000
  293. });
  294. return
  295. }
  296. this.$set(this.form,'stcokId',this.form.id);
  297. this.$set(this.form,'id','');
  298. this.$set(this.form,'usageImg',this.imgList.join(','));
  299. this.$set(this.form,'gasPressure',this.form.currentPressure);
  300. const {data} = await airbottleUsageRecordAdd(this.form);
  301. if(data.code == 200){
  302. uni.showToast({
  303. title: '提交成功',
  304. icon:"none",
  305. mask:true,
  306. duration: 2000
  307. });
  308. setTimeout(function(){
  309. uni.redirectTo({
  310. url: '/pages/gasBottle/gasManage/gasManage'
  311. });
  312. },2000);
  313. }
  314. },
  315. }
  316. }
  317. </script>
  318. <style lang="stylus" scoped>
  319. #gasRecycle {
  320. height: auto;
  321. width: 100%;
  322. flex :1;
  323. display flex;
  324. flex-direction column;
  325. overflow hidden;
  326. padding-bottom: 220rpx;
  327. .title{
  328. width: 750rpx;
  329. height: 100rpx;
  330. background: #FFFFFF;
  331. font-size: 28rpx;
  332. font-family: PingFang SC;
  333. font-weight: 500;
  334. color: #333333;
  335. line-height: 100rpx;
  336. padding-left: 40rpx;
  337. }
  338. .register_li{
  339. background #fff;
  340. border-radius:20rpx;
  341. margin:20rpx 20rpx 0;
  342. padding:20rpx 0;
  343. box-sizing: border-box;
  344. .register_li_min{
  345. margin:0 26rpx;
  346. display flex;
  347. align-items center;
  348. border-bottom: 1px solid #F5F5F5;
  349. .icon_img{
  350. width: 30rpx;
  351. height: 30rpx;
  352. margin-right: 12rpx;
  353. }
  354. view{
  355. //width:140rpx;
  356. font-size: 28rpx;
  357. font-family: PingFang SC;
  358. font-weight: 500;
  359. color: #999999;
  360. line-height: 100rpx;
  361. }
  362. >input{
  363. flex:1;
  364. text-align: right;
  365. font-size: 24rpx;
  366. font-family: PingFang SC;
  367. font-weight: 500;
  368. color: #333333;
  369. }
  370. .inconformity{
  371. font-size: 24rpx;
  372. font-family: PingFang SC;
  373. font-weight: 500;
  374. color: #D60000;
  375. margin-left: 40rpx;
  376. }
  377. }
  378. }
  379. .register_li2{
  380. background #fff;
  381. border-radius:20rpx;
  382. margin:20rpx 20rpx 0;
  383. padding:20rpx 0;
  384. box-sizing: border-box;
  385. .period{
  386. display: flex;
  387. justify-content: flex-start;
  388. align-items: center;
  389. margin: 0 26rpx;
  390. border-bottom: 1px solid #f5f5f5;
  391. .period_l{
  392. width: 146rpx;
  393. font-size: 30rpx;
  394. font-family: PingFang SC-Medium, PingFang SC;
  395. font-weight: 400;
  396. color: #333333;
  397. line-height: 42rpx;
  398. text-align: left;
  399. >i{
  400. display: inline-block;
  401. color: #f00;
  402. line-height: 28rpx;
  403. margin-right: 12rpx;
  404. }
  405. }
  406. .period_r{
  407. width: 490rpx;
  408. height: 80rpx;
  409. border-radius: 10rpx;
  410. display: flex;
  411. justify-content: flex-start;
  412. align-items: center;
  413. .picker-text{
  414. font-size: 30rpx;
  415. font-family: PingFang SC-Medium, PingFang SC;
  416. font-weight: 400;
  417. color: #999;
  418. line-height: 80rpx;
  419. width: 516rpx;
  420. text-align: right;
  421. }
  422. // .picker-text2{
  423. // font-size: 30rpx;
  424. // font-family: PingFang SC-Medium, PingFang SC;
  425. // font-weight: 400;
  426. // color: #333;
  427. // line-height: 80rpx;
  428. // width: 230rpx;
  429. // text-align: center;
  430. // }
  431. }
  432. }
  433. .register_li_min{
  434. margin:0 26rpx;
  435. display flex;
  436. align-items center;
  437. border-bottom: 1px solid #F5F5F5;
  438. .icon_img{
  439. width: 30rpx;
  440. height: 30rpx;
  441. margin-right: 12rpx;
  442. }
  443. view:nth-child(1){
  444. color:red;
  445. line-height:28rpx;
  446. margin-right: 12rpx;
  447. }
  448. view{
  449. //width:140rpx;
  450. font-size: 28rpx;
  451. font-family: PingFang SC;
  452. font-weight: 500;
  453. color: #333333;
  454. line-height: 100rpx;
  455. }
  456. >input{
  457. flex:1;
  458. text-align: right;
  459. font-size: 24rpx;
  460. font-family: PingFang SC;
  461. font-weight: 500;
  462. color: #999999;
  463. }
  464. }
  465. /* 照片 */
  466. .up-img-box{
  467. display flex
  468. margin:34rpx 26rpx;
  469. .asterisk{
  470. padding-top:30rpx;
  471. color:red;
  472. line-height:28rpx;
  473. margin-right: 12rpx;
  474. }
  475. .title-view{
  476. width:150rpx;
  477. line-height:80rpx;
  478. font-size: 30rpx;
  479. color:#333;
  480. }
  481. .img-max-box{
  482. width:480rpx;
  483. display: flex;
  484. .img-box{
  485. display inline-block
  486. height:150rpx;
  487. width:150rpx;
  488. position relative
  489. margin:0 20rpx 20rpx 0;
  490. .img-data{
  491. height:150rpx;
  492. width:150rpx;
  493. }
  494. .position-img{
  495. position absolute
  496. right:0;
  497. top:0;
  498. width:36rpx;
  499. height:36rpx;
  500. }
  501. }
  502. .add-button{
  503. display inline-block
  504. height:150rpx;
  505. width:150rpx;
  506. margin-right: 20rpx;
  507. }
  508. }
  509. }
  510. }
  511. /* 按钮 */
  512. .btn{
  513. display: flex;
  514. position: fixed;
  515. bottom: 40rpx;
  516. left: 50rpx;
  517. .btn_l{
  518. width: 324rpx;
  519. height: 100rpx;
  520. background: #F28E26;
  521. border-radius: 50rpx 0rpx 0rpx 50rpx;
  522. font-size: 28rpx;
  523. font-family: PingFang SC;
  524. font-weight: 500;
  525. color: #FFFFFF;
  526. line-height: 100rpx;
  527. text-align: center;
  528. }
  529. .btn_r{
  530. width: 324rpx;
  531. height: 100rpx;
  532. background: #0183FA;
  533. border-radius: 0rpx 50rpx 50rpx 0rpx;
  534. font-size: 28rpx;
  535. font-family: PingFang SC;
  536. font-weight: 500;
  537. color: #FFFFFF;
  538. line-height: 100rpx;
  539. text-align: center;
  540. }
  541. }
  542. /* 按钮 */
  543. .sub_btn{
  544. width: 650rpx;
  545. height: 100rpx;
  546. background: #0183FA;
  547. border-radius: 20rpx;
  548. font-size: 28rpx;
  549. font-family: PingFang SC;
  550. font-weight: 500;
  551. color: #FFFFFF;
  552. line-height: 100rpx;
  553. text-align: center;
  554. margin-left: 50rpx;
  555. position: fixed;
  556. bottom:30rpx;
  557. z-index: 1000;
  558. }
  559. /* 空 */
  560. .empty{
  561. background #fff;
  562. border-radius:20rpx;
  563. margin:20rpx 20rpx 0;
  564. padding:20rpx 0;
  565. box-sizing: border-box;
  566. >img{
  567. width: 100rpx;
  568. height: 100rpx;
  569. margin-top: 124rpx;
  570. margin-left: 300rpx;
  571. }
  572. >view{
  573. font-size: 28rpx;
  574. font-family: PingFang SC;
  575. font-weight: 500;
  576. color: #333333;
  577. line-height: 30rpx;
  578. text-align: center;
  579. margin-top: 42rpx;
  580. padding-bottom: 106rpx;
  581. }
  582. }
  583. }
  584. </style>