gasUse.vue 13 KB

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