giveRegister.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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="@/pages_manage/images/icon_ssp_closure.png" @click="delImg(index)">
  28. </view>
  29. <img class="add-button" src="@/pages_manage/images/icon_07.png" @click="selectImage" v-if="imgList.length<1">
  30. <img class="add-button" src="@/pages_manage/images/Version3.0/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/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. console.log(_this.form)
  168. const {data} = await giveRegisterAdd(_this.form);
  169. if(data.code == 200){
  170. uni.showToast({
  171. title: '提交成功',
  172. icon:"none",
  173. mask:true,
  174. duration: 2000
  175. });
  176. setTimeout(function(){
  177. uni.redirectTo({
  178. url: '/pages_manage/gasManage/gasManage'
  179. });
  180. },2000);
  181. }
  182. },
  183. }
  184. }
  185. </script>
  186. <style lang="stylus" scoped>
  187. #gasRecycle {
  188. height: auto;
  189. width: 100%;
  190. flex :1;
  191. display flex;
  192. flex-direction column;
  193. overflow hidden;
  194. padding-bottom: 220rpx;
  195. .title{
  196. width: 750rpx;
  197. height: 100rpx;
  198. background: #FFFFFF;
  199. font-size: 28rpx;
  200. font-family: PingFang SC;
  201. font-weight: 500;
  202. color: #333333;
  203. line-height: 100rpx;
  204. padding-left: 40rpx;
  205. }
  206. .register_li{
  207. background #fff;
  208. border-radius:20rpx;
  209. margin:20rpx 20rpx 0;
  210. padding:20rpx 0;
  211. box-sizing: border-box;
  212. .register_li_min{
  213. margin:0 26rpx;
  214. display flex;
  215. align-items center;
  216. border-bottom: 1px solid #F5F5F5;
  217. .icon_img{
  218. width: 30rpx;
  219. height: 30rpx;
  220. margin-right: 12rpx;
  221. }
  222. view{
  223. //width:140rpx;
  224. font-size: 28rpx;
  225. font-family: PingFang SC;
  226. font-weight: 500;
  227. color: #999999;
  228. line-height: 100rpx;
  229. }
  230. >input{
  231. flex:1;
  232. text-align: right;
  233. font-size: 24rpx;
  234. font-family: PingFang SC;
  235. font-weight: 500;
  236. color: #333333;
  237. }
  238. }
  239. }
  240. .register_li2{
  241. background #fff;
  242. border-radius:20rpx;
  243. margin:20rpx 20rpx 0;
  244. padding:20rpx 0;
  245. box-sizing: border-box;
  246. .register_li_min{
  247. margin:0 26rpx;
  248. display flex;
  249. align-items center;
  250. border-bottom: 1px solid #F5F5F5;
  251. .icon_img{
  252. width: 30rpx;
  253. height: 30rpx;
  254. margin-right: 12rpx;
  255. }
  256. view:nth-child(1){
  257. color:red;
  258. line-height:28rpx;
  259. margin-right: 12rpx;
  260. }
  261. view{
  262. //width:140rpx;
  263. font-size: 28rpx;
  264. font-family: PingFang SC;
  265. font-weight: 500;
  266. color: #333333;
  267. line-height: 100rpx;
  268. }
  269. >input{
  270. flex:1;
  271. text-align: right;
  272. font-size: 24rpx;
  273. font-family: PingFang SC;
  274. font-weight: 500;
  275. color: #999999;
  276. }
  277. }
  278. /* 照片 */
  279. .up-img-box{
  280. display flex
  281. margin:34rpx 26rpx;
  282. .asterisk{
  283. padding-top:30rpx;
  284. color:red;
  285. line-height:28rpx;
  286. margin-right: 12rpx;
  287. }
  288. .title-view{
  289. width:150rpx;
  290. line-height:80rpx;
  291. font-size: 30rpx;
  292. color:#333;
  293. }
  294. .img-max-box{
  295. width:480rpx;
  296. display: flex;
  297. .img-box{
  298. display inline-block
  299. height:150rpx;
  300. width:150rpx;
  301. position relative
  302. margin:0 20rpx 20rpx 0;
  303. .img-data{
  304. height:150rpx;
  305. width:150rpx;
  306. }
  307. .position-img{
  308. position absolute
  309. right:0;
  310. top:0;
  311. width:36rpx;
  312. height:36rpx;
  313. }
  314. }
  315. .add-button{
  316. display inline-block
  317. height:150rpx;
  318. width:150rpx;
  319. margin-right: 20rpx;
  320. }
  321. }
  322. }
  323. }
  324. /* 按钮 */
  325. .sub_btn{
  326. width: 650rpx;
  327. height: 100rpx;
  328. background: #0183FA;
  329. border-radius: 20rpx;
  330. font-size: 28rpx;
  331. font-family: PingFang SC;
  332. font-weight: 500;
  333. color: #FFFFFF;
  334. line-height: 100rpx;
  335. text-align: center;
  336. margin-left: 50rpx;
  337. position: fixed;
  338. bottom:30rpx;
  339. }
  340. }
  341. </style>