giveRegister.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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">
  17. <view>*</view>
  18. <view>当前气压:</view>
  19. <input v-model="form.afterUse" type="text" >
  20. </view>
  21. <view class="up-img-box">
  22. <view class="asterisk">*</view>
  23. <view class="title-view">气表图片:</view>
  24. <view class="img-max-box">
  25. <view class="img-box" v-for="(item,index) in imgList" :key="index">
  26. <img class="img-data" :src="baseUrl+item">
  27. <img class="position-img" src="@/images/basicsModules/icon_ssp_closure.png" @click="delImg(index)">
  28. </view>
  29. <img class="add-button" src="@/images/basicsModules/icon_07.png" @click="selectImage" v-if="imgList.length<1">
  30. <img class="add-button" src="@/pages_manage/images/img_sydj_sltp.png" >
  31. </view>
  32. </view>
  33. </view>
  34. <view class="sub_btn" @click="submitForm()">确认归还</view>
  35. </view>
  36. </template>
  37. <script>
  38. import { useRegisterDetail,giveRegisterAdd } from '@/api/apiDemo/index.js'
  39. import { config } from '@/api/request/config.js'
  40. export default {
  41. name: "gasRecycle",
  42. data() {
  43. return {
  44. baseUrl:config.base_url,
  45. pageType:0,
  46. //列表请求参数
  47. getData:{
  48. pageNum:1,
  49. pageSize:20,
  50. isCg:0,
  51. zgStatus:"",
  52. getType:true,
  53. nullDataType:true,
  54. },
  55. form:{
  56. afterUse:null,
  57. afterUsePic:'',
  58. storageId:'',
  59. },
  60. dataList:[],
  61. imgList:[],
  62. electronicTag:'',
  63. specificationName:{},
  64. }
  65. },
  66. onLoad(option) {
  67. this.electronicTag=option.code;
  68. },
  69. onShow() {
  70. },
  71. mounted(){
  72. this.getInfo()
  73. },
  74. methods: {
  75. // 图片上传
  76. selectImage(index) {
  77. let self = this;
  78. if(self.imgList.length>1){
  79. uni.showToast({
  80. title: '最多上传1张图片',
  81. icon:"none",
  82. mask:true,
  83. duration: 2000
  84. });
  85. return
  86. }
  87. wx.chooseImage({
  88. count: 1,
  89. sizeType: ["original", "compressed"],
  90. sourceType: ["album", "camera"],
  91. success: function(res) {
  92. let tempFilePaths = res.tempFilePaths[0];
  93. self.uploadImg(tempFilePaths,index);
  94. }
  95. });
  96. },
  97. async uploadImg(tempFilePaths,index){
  98. var self = this;
  99. uni.showLoading({
  100. title: '上传中',
  101. mask: true
  102. });
  103. uni.uploadFile({
  104. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  105. header:{'Authorization':uni.getStorageSync('token')},
  106. filePath: tempFilePaths,
  107. name: 'file',
  108. formData: {
  109. 'user': 'test'
  110. },
  111. success: (uploadFileRes) => {
  112. let res = JSON.parse(uploadFileRes.data);
  113. if(res.code == 200){
  114. self.imgList.push(res.data.url);
  115. }else{
  116. uni.showToast({
  117. title: res.msg,
  118. icon:"none",
  119. mask:true,
  120. duration: 2000
  121. });
  122. }
  123. },
  124. fail: err => {},
  125. complete: () => {
  126. uni.hideLoading()
  127. }
  128. });
  129. },
  130. //删除图片
  131. delImg(index){
  132. this.imgList.splice(index,1);
  133. },
  134. async getInfo(){
  135. let _this=this;
  136. const {data} = await useRegisterDetail({electronicTag:_this.electronicTag});
  137. if(data.code==200){
  138. let res = data.data;
  139. _this.form=res;
  140. _this.specificationName=JSON.parse(res.specificationName)
  141. }
  142. },
  143. //提交
  144. async submitForm(){
  145. let _this = this;
  146. if(!_this.form.afterUse){
  147. uni.showToast({
  148. title: '请输入当前气压!',
  149. icon:"none",
  150. mask:true,
  151. duration: 2000
  152. });
  153. return
  154. }
  155. if(_this.imgList.length<=0){
  156. uni.showToast({
  157. title: '请选择气表图片!',
  158. icon:"none",
  159. mask:true,
  160. duration: 2000
  161. });
  162. return
  163. }
  164. _this.form.afterUse=Number( _this.form.afterUse)
  165. _this.form.storageId=_this.form.id
  166. _this.form.afterUsePic=_this.imgList.join(',')
  167. const {data} = await giveRegisterAdd(_this.form);
  168. if(data.code == 200){
  169. uni.showToast({
  170. title: '提交成功',
  171. icon:"none",
  172. mask:true,
  173. duration: 2000
  174. });
  175. setTimeout(function(){
  176. uni.redirectTo({
  177. url: '/pages_manage/gasBottle/gasManage/gasManage'
  178. });
  179. },2000);
  180. }
  181. },
  182. }
  183. }
  184. </script>
  185. <style lang="stylus" scoped>
  186. #gasRecycle {
  187. height: auto;
  188. width: 100%;
  189. flex :1;
  190. display flex;
  191. flex-direction column;
  192. overflow hidden;
  193. padding-bottom: 220rpx;
  194. .title{
  195. width: 750rpx;
  196. height: 100rpx;
  197. background: #FFFFFF;
  198. font-size: 28rpx;
  199. font-family: PingFang SC;
  200. font-weight: 500;
  201. color: #333333;
  202. line-height: 100rpx;
  203. padding-left: 40rpx;
  204. }
  205. .register_li{
  206. background #fff;
  207. border-radius:20rpx;
  208. margin:20rpx 20rpx 0;
  209. padding:20rpx 0;
  210. box-sizing: border-box;
  211. .register_li_min{
  212. margin:0 26rpx;
  213. display flex;
  214. align-items center;
  215. border-bottom: 1px solid #F5F5F5;
  216. .icon_img{
  217. width: 30rpx;
  218. height: 30rpx;
  219. margin-right: 12rpx;
  220. }
  221. view{
  222. //width:140rpx;
  223. font-size: 28rpx;
  224. font-family: PingFang SC;
  225. font-weight: 500;
  226. color: #999999;
  227. line-height: 100rpx;
  228. }
  229. >input{
  230. flex:1;
  231. text-align: right;
  232. font-size: 24rpx;
  233. font-family: PingFang SC;
  234. font-weight: 500;
  235. color: #333333;
  236. }
  237. }
  238. }
  239. .register_li2{
  240. background #fff;
  241. border-radius:20rpx;
  242. margin:20rpx 20rpx 0;
  243. padding:20rpx 0;
  244. box-sizing: border-box;
  245. .register_li_min{
  246. margin:0 26rpx;
  247. display flex;
  248. align-items center;
  249. border-bottom: 1px solid #F5F5F5;
  250. .icon_img{
  251. width: 30rpx;
  252. height: 30rpx;
  253. margin-right: 12rpx;
  254. }
  255. view:nth-child(1){
  256. color:red;
  257. line-height:28rpx;
  258. margin-right: 12rpx;
  259. }
  260. view{
  261. //width:140rpx;
  262. font-size: 28rpx;
  263. font-family: PingFang SC;
  264. font-weight: 500;
  265. color: #333333;
  266. line-height: 100rpx;
  267. }
  268. >input{
  269. flex:1;
  270. text-align: right;
  271. font-size: 24rpx;
  272. font-family: PingFang SC;
  273. font-weight: 500;
  274. color: #999999;
  275. }
  276. }
  277. /* 照片 */
  278. .up-img-box{
  279. display flex
  280. margin:34rpx 26rpx;
  281. .asterisk{
  282. padding-top:30rpx;
  283. color:red;
  284. line-height:28rpx;
  285. margin-right: 12rpx;
  286. }
  287. .title-view{
  288. width:150rpx;
  289. line-height:80rpx;
  290. font-size: 30rpx;
  291. color:#333;
  292. }
  293. .img-max-box{
  294. width:480rpx;
  295. display: flex;
  296. .img-box{
  297. display inline-block
  298. height:150rpx;
  299. width:150rpx;
  300. position relative
  301. margin:0 20rpx 20rpx 0;
  302. .img-data{
  303. height:150rpx;
  304. width:150rpx;
  305. }
  306. .position-img{
  307. position absolute
  308. right:0;
  309. top:0;
  310. width:36rpx;
  311. height:36rpx;
  312. }
  313. }
  314. .add-button{
  315. display inline-block
  316. height:150rpx;
  317. width:150rpx;
  318. margin-right: 20rpx;
  319. }
  320. }
  321. }
  322. }
  323. /* 按钮 */
  324. .sub_btn{
  325. width: 650rpx;
  326. height: 100rpx;
  327. background: #0183FA;
  328. border-radius: 20rpx;
  329. font-size: 28rpx;
  330. font-family: PingFang SC;
  331. font-weight: 500;
  332. color: #FFFFFF;
  333. line-height: 100rpx;
  334. text-align: center;
  335. margin-left: 50rpx;
  336. position: fixed;
  337. bottom:30rpx;
  338. }
  339. }
  340. </style>