useRegister.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <!--使用登记-->
  2. <template>
  3. <view id="gasRecycle">
  4. <view class="title">{{form.airName}}-{{form.configName}}</view>
  5. <view class="register_li">
  6. <view class="register_li_min">
  7. <view>实验地点:</view>
  8. <input v-model="form.location" disabled type="text" >
  9. </view>
  10. <view class="register_li_min" style="border: none;">
  11. <view>编号:</view>
  12. <input v-model="form.airNumber" disabled type="text" >
  13. </view>
  14. </view>
  15. <view class="register_li2" v-if="pageType==0 || pageType==1">
  16. <view class="register_li_min" v-if="pageType==0">
  17. <view>*</view>
  18. <view>当前压力:</view>
  19. <input v-model="form.currentPressure" disabled type="text" >
  20. </view>
  21. <view class="register_li_min" v-if="pageType==1">
  22. <view>*</view>
  23. <view>实际气压:</view>
  24. <input v-model="form.beforeUse" type="text" >
  25. </view>
  26. <view class="up-img-box">
  27. <view class="asterisk">*</view>
  28. <view class="title-view">气表照片:</view>
  29. <view class="img-max-box">
  30. <view class="img-box" v-for="(item,index) in imgList" :key="index">
  31. <img class="img-data" :src="baseUrl+item">
  32. <img class="position-img" src="@/pages_student/images/icon_ssp_closure.png" @click="delImg(index)">
  33. </view>
  34. <img class="add-button" src="@/pages_student/images/icon_07.png" @click="selectImage" v-if="imgList.length<1">
  35. <img class="add-button" src="@/pages_student/images/img_sydj_sltp.png" >
  36. </view>
  37. </view>
  38. </view>
  39. <view class="empty" v-if="pageType==2">
  40. <img class="add-button" src="@/pages_student/images/icon_sydj_sqyqzg.png" >
  41. <view>请您在申请用气资格后再使用气瓶</view>
  42. </view>
  43. <view class="empty" v-if="pageType==3">
  44. <img class="add-button" src="@/pages_student/images/icon_xgzl_shz.png" >
  45. <view>该气瓶正在使用中,请重新选择气瓶</view>
  46. </view>
  47. <view class="empty" v-if="pageType==4">
  48. <img class="add-button" src="@/pages_student/images/icon_sydj_yubz.png" >
  49. <view>气压余量不足,请使用其他气瓶</view>
  50. </view>
  51. <view v-if="pageType==0" class="sub_btn2" @click="handleClick('inconformity')">余量不符</view>
  52. <view v-if="pageType==0" class="sub_btn" @click="submitForm(1)">确认使用</view>
  53. <view v-if="pageType==1" class="sub_btn" @click="submitForm(2)">提交余量不符并使用</view>
  54. <view v-if="pageType==2" class="sub_btn" @click="handleClick('useGasApply')">申请用气资格</view>
  55. <view v-if="pageType==3" class="sub_btn" @click="handleClick('QRcode')">重新扫描</view>
  56. </view>
  57. </template>
  58. <script>
  59. import { useRegisterDetail,useRegisterAdd } from '@/api/apiDemo/index.js'
  60. import { config } from '@/api/request/config.js'
  61. export default {
  62. name: "gasRecycle",
  63. data() {
  64. return {
  65. baseUrl:config.base_url,
  66. pageType:0,
  67. //列表请求参数
  68. getData:{
  69. pageNum:1,
  70. pageSize:20,
  71. isCg:0,
  72. zgStatus:"",
  73. getType:true,
  74. nullDataType:true,
  75. },
  76. userType:uni.getStorageSync('userType'),
  77. form:{
  78. },
  79. dataList:[],
  80. imgList:[],
  81. specificationName:{},
  82. currentStatus:null,
  83. electronicTag:'333',
  84. }
  85. },
  86. onLoad(option) {
  87. this.electronicTag=option.code;
  88. },
  89. onShow() {
  90. },
  91. mounted(){
  92. this.getInfo()
  93. /* uni.showModal({
  94. showCancel:false,
  95. confirmColor:'#0183FA',
  96. content: '该气瓶最低安全气压值为1mPA,当前气压值即将达到安全值,请您使用气瓶中随时观察气压,避免发生风险。',
  97. success: function (res) {
  98. if (res.confirm) {
  99. console.log('用户点击确定');
  100. }
  101. }
  102. }); */
  103. },
  104. methods: {
  105. //点击事件
  106. handleClick(doType) {
  107. let _this=this;
  108. if(doType=='inconformity'){//余量不符
  109. _this.pageType=1;
  110. }else if(doType=='QRcode'){//重新扫描
  111. uni.scanCode({
  112. onlyFromCamera: true,
  113. success: function (res) {
  114. _this.electronicTag=res.result
  115. }
  116. });
  117. }else if(doType=='useGasApply'){//申请用气资格
  118. uni.redirectTo({
  119. url:'/pages_student/useGasApply/useGasApplyAdd?status=0'
  120. })
  121. }
  122. },
  123. // 图片上传
  124. selectImage(index) {
  125. let self = this;
  126. if(self.imgList.length>1){
  127. uni.showToast({
  128. title: '最多上传1张图片',
  129. icon:"none",
  130. mask:true,
  131. duration: 2000
  132. });
  133. return
  134. }
  135. wx.chooseImage({
  136. count: 1,
  137. sizeType: ["original", "compressed"],
  138. sourceType: ["album", "camera"],
  139. success: function(res) {
  140. let tempFilePaths = res.tempFilePaths[0];
  141. self.uploadImg(tempFilePaths,index);
  142. }
  143. });
  144. },
  145. async uploadImg(tempFilePaths,index){
  146. var self = this;
  147. uni.showLoading({
  148. title: '上传中',
  149. mask: true
  150. });
  151. uni.uploadFile({
  152. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  153. header:{'Authorization':uni.getStorageSync('token')},
  154. filePath: tempFilePaths,
  155. name: 'file',
  156. formData: {
  157. 'user': 'test'
  158. },
  159. success: (uploadFileRes) => {
  160. let res = JSON.parse(uploadFileRes.data);
  161. if(res.code == 200){
  162. self.imgList.push(res.data.url);
  163. }else{
  164. uni.showToast({
  165. title: res.msg,
  166. icon:"none",
  167. mask:true,
  168. duration: 2000
  169. });
  170. }
  171. },
  172. fail: err => {},
  173. complete: () => {
  174. uni.hideLoading()
  175. }
  176. });
  177. },
  178. //删除图片
  179. delImg(index){
  180. this.imgList.splice(index,1);
  181. },
  182. async getInfo(){
  183. let _this=this;
  184. const {data} = await useRegisterDetail({electronicTag:_this.electronicTag});
  185. if(data.code==200){
  186. let res = data.data;
  187. _this.form=res;
  188. _this.specificationName=JSON.parse(res.specificationName)
  189. if(res.currentStatus==1){//正常状态
  190. _this.pageType=0
  191. }else if(res.currentStatus==2){//余量不足
  192. _this.pageType=4
  193. }else if(res.currentStatus==3){//用户没有用气资格
  194. _this.pageType=2
  195. }else if(res.currentStatus==4){//气瓶正在使用中
  196. _this.pageType=3
  197. }
  198. }
  199. },
  200. //提交
  201. async submitForm(type){
  202. let _this = this;
  203. if(_this.imgList.length<=0){
  204. uni.showToast({
  205. title: '请选择气表图片!',
  206. icon:"none",
  207. mask:true,
  208. duration: 2000
  209. });
  210. return
  211. }
  212. let obj={
  213. bottleName:_this.form.airName,
  214. beforeUse:_this.form.currentPressure,
  215. beforeUsePic:_this.imgList.join(','),
  216. isSurplus:0,
  217. location:_this.form.location,
  218. storageId:_this.form.id,
  219. }
  220. if(type==1){//确认使用
  221. obj.isSurplus=0
  222. }else if(type==2){//余量不符
  223. obj.isSurplus=1
  224. obj.beforeUse=_this.form.beforeUse
  225. }
  226. const {data} = await useRegisterAdd(obj);
  227. if(data.code == 200){
  228. uni.showToast({
  229. title: '提交成功',
  230. icon:"none",
  231. mask:true,
  232. duration: 2000
  233. });
  234. setTimeout(function(){
  235. uni.redirectTo({
  236. url: '/pages_student/gasManage/gasManage'
  237. });
  238. },2000);
  239. }
  240. },
  241. }
  242. }
  243. </script>
  244. <style lang="stylus" scoped>
  245. #gasRecycle {
  246. height: auto;
  247. width: 100%;
  248. flex :1;
  249. display flex;
  250. flex-direction column;
  251. overflow hidden;
  252. padding-bottom: 220rpx;
  253. .title{
  254. width: 750rpx;
  255. height: 100rpx;
  256. background: #FFFFFF;
  257. font-size: 28rpx;
  258. font-family: PingFang SC;
  259. font-weight: 500;
  260. color: #333333;
  261. line-height: 100rpx;
  262. padding-left: 40rpx;
  263. }
  264. .register_li{
  265. background #fff;
  266. border-radius:20rpx;
  267. margin:20rpx 20rpx 0;
  268. padding:20rpx 0;
  269. box-sizing: border-box;
  270. .register_li_min{
  271. margin:0 26rpx;
  272. display flex;
  273. align-items center;
  274. border-bottom: 1px solid #F5F5F5;
  275. .icon_img{
  276. width: 30rpx;
  277. height: 30rpx;
  278. margin-right: 12rpx;
  279. }
  280. view{
  281. //width:140rpx;
  282. font-size: 28rpx;
  283. font-family: PingFang SC;
  284. font-weight: 500;
  285. color: #999999;
  286. line-height: 100rpx;
  287. }
  288. >input{
  289. flex:1;
  290. text-align: right;
  291. font-size: 24rpx;
  292. font-family: PingFang SC;
  293. font-weight: 500;
  294. color: #333333;
  295. }
  296. }
  297. }
  298. .register_li2{
  299. background #fff;
  300. border-radius:20rpx;
  301. margin:20rpx 20rpx 0;
  302. padding:20rpx 0;
  303. box-sizing: border-box;
  304. .register_li_min{
  305. margin:0 26rpx;
  306. display flex;
  307. align-items center;
  308. border-bottom: 1px solid #F5F5F5;
  309. .icon_img{
  310. width: 30rpx;
  311. height: 30rpx;
  312. margin-right: 12rpx;
  313. }
  314. view:nth-child(1){
  315. color:red;
  316. line-height:28rpx;
  317. margin-right: 12rpx;
  318. }
  319. view{
  320. //width:140rpx;
  321. font-size: 28rpx;
  322. font-family: PingFang SC;
  323. font-weight: 500;
  324. color: #333333;
  325. line-height: 100rpx;
  326. }
  327. >input{
  328. flex:1;
  329. text-align: right;
  330. font-size: 24rpx;
  331. font-family: PingFang SC;
  332. font-weight: 500;
  333. color: #999999;
  334. }
  335. }
  336. /* 照片 */
  337. .up-img-box{
  338. display flex
  339. margin:34rpx 26rpx;
  340. .asterisk{
  341. padding-top:30rpx;
  342. color:red;
  343. line-height:28rpx;
  344. margin-right: 12rpx;
  345. }
  346. .title-view{
  347. width:150rpx;
  348. line-height:80rpx;
  349. font-size: 30rpx;
  350. color:#333;
  351. }
  352. .img-max-box{
  353. width:480rpx;
  354. display: flex;
  355. .img-box{
  356. display inline-block
  357. height:150rpx;
  358. width:150rpx;
  359. position relative
  360. margin:0 20rpx 20rpx 0;
  361. .img-data{
  362. height:150rpx;
  363. width:150rpx;
  364. }
  365. .position-img{
  366. position absolute
  367. right:0;
  368. top:0;
  369. width:36rpx;
  370. height:36rpx;
  371. }
  372. }
  373. .add-button{
  374. display inline-block
  375. height:150rpx;
  376. width:150rpx;
  377. margin-right: 20rpx;
  378. }
  379. }
  380. }
  381. }
  382. /* 按钮 */
  383. .sub_btn{
  384. width: 650rpx;
  385. height: 100rpx;
  386. background: #0183FA;
  387. border-radius: 20rpx;
  388. font-size: 28rpx;
  389. font-family: PingFang SC;
  390. font-weight: 500;
  391. color: #FFFFFF;
  392. line-height: 100rpx;
  393. text-align: center;
  394. margin-left: 50rpx;
  395. position: fixed;
  396. bottom:30rpx;
  397. z-index: 1000;
  398. }
  399. .sub_btn2{
  400. width: 650rpx;
  401. height: 100rpx;
  402. border: 2rpx solid #0072DB;
  403. border-radius: 20rpx;
  404. font-size: 28rpx;
  405. font-family: PingFang SC;
  406. font-weight: 500;
  407. color: #0183FA;
  408. line-height: 100rpx;
  409. text-align: center;
  410. margin-left: 50rpx;
  411. position: fixed;
  412. bottom:158rpx;
  413. z-index: 1000;
  414. }
  415. /* 空 */
  416. .empty{
  417. background #fff;
  418. border-radius:20rpx;
  419. margin:20rpx 20rpx 0;
  420. padding:20rpx 0;
  421. box-sizing: border-box;
  422. >img{
  423. width: 100rpx;
  424. height: 100rpx;
  425. margin-top: 124rpx;
  426. margin-left: 300rpx;
  427. }
  428. >view{
  429. font-size: 28rpx;
  430. font-family: PingFang SC;
  431. font-weight: 500;
  432. color: #333333;
  433. line-height: 30rpx;
  434. text-align: center;
  435. margin-top: 42rpx;
  436. padding-bottom: 106rpx;
  437. }
  438. }
  439. }
  440. </style>