useGasApplyAdd.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <!-- 用气申请-->
  2. <template>
  3. <view id="register">
  4. <view class="register_li">
  5. <view class="register_li_min">
  6. <img class="icon_img" src="@/pages_manage/images/icon_zgsq_sqr.png">
  7. <view>申请人:</view>
  8. <input v-model="form.applyUser" disabled type="text" >
  9. </view>
  10. <view class="register_li_min" style="border: none;">
  11. <img class="icon_img" src="@/pages_manage/images/icon_zgsq_dhh.png">
  12. <view>联系方式:</view>
  13. <input v-model="form.phone" type="text" >
  14. </view>
  15. </view>
  16. <view class="register_li2">
  17. <picker @change="bindPickerChange" :value="pickerIndex" :range="pickerArray">
  18. <view class="register_li_min">
  19. <view>*</view>
  20. <view>实验地点:</view>
  21. <input v-model="form.location" disabled type="text" placeholder="请选择实验地点" placeholder-style="color:#999;">
  22. </view>
  23. </picker>
  24. <picker @change="bindPickerChange2" :value="pickerIndex2" :range="pickerArray2">
  25. <view class="register_li_min">
  26. <view>*</view>
  27. <view>使用气体:</view>
  28. <input v-model="form.useGasName" disabled type="text" placeholder="请选择使用气体" placeholder-style="color:#999;">
  29. </view>
  30. </picker>
  31. <!-- 使用期限 -->
  32. <view class="register_li_min2">
  33. <view><text style="color: #f00;margin-right: 10rpx;">*</text>使用期限:</view>
  34. <picker mode="date" @change="startChange($event)">
  35. <input class="picker-text" v-model="form.startTime" disabled type="text" placeholder="开始时间" placeholder-style="color:#999;">
  36. </picker>
  37. <view>-</view>
  38. <picker mode="date" @change="endChange($event)">
  39. <input class="picker-text2" v-model="form.endTime" disabled type="text" placeholder="结束时间" placeholder-style="color:#999;">
  40. </picker>
  41. </view>
  42. <view class="register_li_min">
  43. <view>*</view>
  44. <view>气体用途:</view>
  45. <input v-model="form.gasUse" type="text" placeholder="请输入气体用途" placeholder-style="color:#999;">
  46. </view>
  47. <view class="register_li_min">
  48. <view>*</view>
  49. <view>安全措施:</view>
  50. <input v-model="form.safetyPrecautions" type="text" placeholder="请输入主要安全管理措施" placeholder-style="color:#999;">
  51. </view>
  52. <view class="issue_li" style="border-bottom:0;">
  53. <view>*</view>
  54. <view>用气申请表:</view>
  55. <view @click="selectImage">
  56. <img :src="baseUrl+form.applyCertificate">
  57. <text>+上传图片</text>
  58. </view>
  59. </view>
  60. </view>
  61. <view v-if="listType==0" class="sub_btn" @click="submitForm()">提交</view>
  62. <view v-if="listType==2" class="sub_btn">重新申请</view>
  63. </view>
  64. </template>
  65. <script>
  66. import {labList,getLoginUser,useAgsApplyAdd,useAgsApplyDetail,useAgsApplyAmend,qualificationVerify,googsList} from '@/api/apiDemo/index.js'
  67. import { config } from '@/api/request/config.js'
  68. export default {
  69. data() {
  70. return {
  71. baseUrl:config.base_url,
  72. listType:0,
  73. form:{
  74. applyUser:'',//申请人
  75. applyUserid:'',//申请人id
  76. phone:'',// 联系方式
  77. location:'',//实验地点
  78. useGasName:'',//气体名称
  79. useGasId:'',//气体名称Id
  80. subjectId:'',//实验地点Id
  81. startTime:'',//期限开始
  82. endTime:'',//期限结束
  83. gasUse:'',//气体用途
  84. safetyPrecautions:'',//安全措施
  85. applyCertificate:'',//用气申请表
  86. },
  87. checkStatus:0,
  88. pickerArray:[],
  89. pickerArrayList:[],
  90. pickerArray2:[],//气体名称
  91. pickerArrayList2:[],//气体名称
  92. status:null,//0添加1编辑
  93. id:null,
  94. }
  95. },
  96. onLoad(option) {
  97. this.status=option.status;
  98. this.id=option.id;
  99. },
  100. onShow(){
  101. },
  102. methods: {
  103. //查询实验室
  104. async labList(){
  105. const {data} = await labList()
  106. if(data.code == 200){
  107. let _this=this;
  108. let res=data.data
  109. _this.pickerArrayList=res;
  110. res.forEach(function(item){
  111. _this.pickerArray.push(item.name);
  112. })
  113. }
  114. },
  115. //获取气体名称列表
  116. async googsList(){
  117. let _this = this;
  118. const {data} = await googsList({id:this.id})
  119. if(data.code==200){
  120. let _this=this;
  121. let res=data.rows
  122. _this.pickerArrayList2=res;
  123. res.forEach(function(item){
  124. _this.pickerArray2.push(item.goodsName);
  125. })
  126. }
  127. },
  128. //查询用户信息
  129. async getLoginUser(){
  130. const {data} = await getLoginUser()
  131. if(data.code == 200){
  132. let _this=this;
  133. let res=data.data;
  134. _this.form.applyUser=res.nickName;
  135. _this.form.applyUserid=res.id;
  136. _this.form.phone=res.phonenumber;
  137. }
  138. },
  139. //选择气体名称
  140. async bindPickerChange2(e){
  141. let _this=this;
  142. let index=e.target.value
  143. //获取实验室名称
  144. _this.form.useGasName=_this.pickerArray2[index]
  145. //循环获取实验室id
  146. _this.pickerArrayList2.forEach(function(item){
  147. if(_this.pickerArray2[index]==item.goodsName){
  148. _this.form.useGasId=item.id;
  149. }
  150. })
  151. },
  152. //选择实验室
  153. async bindPickerChange(e){
  154. let _this=this;
  155. let index=e.target.value
  156. //获取实验室名称
  157. _this.form.location=_this.pickerArray[index]
  158. //循环获取实验室id
  159. _this.pickerArrayList.forEach(function(item){
  160. if(_this.pickerArray[index]==item.name){
  161. _this.form.subjectId=item.id;
  162. }
  163. })
  164. //校验当前用户有乜有当前实验室使用 权限
  165. const {data} = await qualificationVerify({subjectId:_this.form.subjectId})
  166. if(data.code==200){
  167. let res=data.data
  168. if(res.count>0){//有资格
  169. }else{//没资格
  170. uni.showToast({
  171. title:'申请用气资格前需要先申请对应实验地点的安全准人资格!',
  172. icon:"none",
  173. mask:true,
  174. duration: 2000
  175. });
  176. _this.form.location='';
  177. _this.form.subjectId='';
  178. }
  179. }
  180. },
  181. //时间选中
  182. startChange(e){
  183. if(new Date(e.target.value).getTime()>=new Date(this.form.endTime).getTime()){
  184. uni.showToast({
  185. title: '结束时间不能小于开始时间',
  186. icon:"none",
  187. mask:true,
  188. duration: 2000
  189. });
  190. }else{
  191. this.form.startTime = e.target.value
  192. }
  193. },
  194. endChange(e){
  195. if(new Date(this.form.startTime).getTime()>=new Date(e.target.value).getTime()){
  196. uni.showToast({
  197. title: '结束时间不能小于开始时间',
  198. icon:"none",
  199. mask:true,
  200. duration: 2000
  201. });
  202. }else{
  203. this.form.endTime = e.target.value
  204. }
  205. },
  206. // 图片上传
  207. selectImage() {
  208. let self = this;
  209. wx.chooseImage({
  210. count: 1,
  211. sizeType: ["original", "compressed"],
  212. sourceType: ["album", "camera"],
  213. success: function(res) {
  214. let tempFilePaths = res.tempFilePaths[0];
  215. self.uploadImg(tempFilePaths);
  216. }
  217. });
  218. },
  219. async uploadImg(tempFilePaths){
  220. var self = this;
  221. uni.showLoading({
  222. title: '上传中',
  223. mask: true
  224. });
  225. uni.uploadFile({
  226. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  227. header:{'Authorization':uni.getStorageSync('token')},
  228. filePath: tempFilePaths,
  229. name: 'file',
  230. formData: {
  231. 'user': 'test'
  232. },
  233. success: (uploadFileRes) => {
  234. let res = JSON.parse(uploadFileRes.data);
  235. if(res.code == 200){
  236. self.form.applyCertificate=res.data.url
  237. }else{
  238. uni.showToast({
  239. title: res.msg,
  240. icon:"none",
  241. mask:true,
  242. duration: 2000
  243. });
  244. }
  245. },
  246. fail: err => {},
  247. complete: () => {
  248. uni.hideLoading()
  249. }
  250. });
  251. },
  252. //删除图片
  253. delImg(index){
  254. this.newData.imgList.splice(index,1);
  255. },
  256. //获取详情
  257. async getInfo(){
  258. let _this = this;
  259. const {data} = await useAgsApplyDetail({id:this.id})
  260. if(data.code==200){
  261. let res=data.data
  262. _this.form=res.apply;
  263. }
  264. },
  265. //提交
  266. async submitForm(){
  267. let _this = this;
  268. if(!this.form.applyUser){
  269. uni.showToast({
  270. title: '请输入申请人',
  271. icon:"none",
  272. mask:true,
  273. duration: 2000
  274. });
  275. return
  276. }
  277. if(!this.form.phone){
  278. uni.showToast({
  279. title: '请输入联系方式',
  280. icon:"none",
  281. mask:true,
  282. duration: 2000
  283. });
  284. return
  285. }
  286. if(!this.form.location){
  287. uni.showToast({
  288. title: '请输入实验地点',
  289. icon:"none",
  290. mask:true,
  291. duration: 2000
  292. });
  293. return
  294. }
  295. if(!this.form.startTime){
  296. uni.showToast({
  297. title: '请输入期限开始',
  298. icon:"none",
  299. mask:true,
  300. duration: 2000
  301. });
  302. return
  303. }
  304. if(!this.form.endTime){
  305. uni.showToast({
  306. title: '请输入期限结束',
  307. icon:"none",
  308. mask:true,
  309. duration: 2000
  310. });
  311. return
  312. }
  313. if(!this.form.gasUse){
  314. uni.showToast({
  315. title: '请输入气体用途',
  316. icon:"none",
  317. mask:true,
  318. duration: 2000
  319. });
  320. return
  321. }
  322. if(!this.form.safetyPrecautions){
  323. uni.showToast({
  324. title: '请输入安全措施',
  325. icon:"none",
  326. mask:true,
  327. duration: 2000
  328. });
  329. return
  330. }
  331. if(!this.form.applyCertificate){
  332. uni.showToast({
  333. title: '请输入用气申请表',
  334. icon:"none",
  335. mask:true,
  336. duration: 2000
  337. });
  338. return
  339. }
  340. _this.form.listDetail=_this.listDetailArr;
  341. if(_this.status==0){//添加
  342. const {data} = await useAgsApplyAdd(_this.form);
  343. if(data.code == 200){
  344. uni.showToast({
  345. title: '提交成功',
  346. icon:"none",
  347. mask:true,
  348. duration: 2000
  349. });
  350. setTimeout(function(){
  351. uni.redirectTo({
  352. url: '/pages_manage/gasBottle/useGasApply/useGasApply'
  353. });
  354. },2000);
  355. }
  356. }else if(_this.status==1){//编辑
  357. const {data} = await useAgsApplyAmend(_this.form);
  358. if(data.code == 200){
  359. uni.showToast({
  360. title: '提交成功',
  361. icon:"none",
  362. mask:true,
  363. duration: 2000
  364. });
  365. setTimeout(function(){
  366. uni.redirectTo({
  367. url: '/pages_manage/gasBottle/useGasApply/useGasApply'
  368. });
  369. },2000);
  370. }
  371. }
  372. },
  373. },
  374. mounted(){
  375. this.googsList()
  376. this.labList()
  377. this.getLoginUser()
  378. if(this.status==1){
  379. this.getInfo();
  380. }
  381. },
  382. }
  383. </script>
  384. <style lang="stylus" scoped>
  385. #register{
  386. height:auto;
  387. width:100%;
  388. display flex;
  389. flex-direction column;
  390. padding-bottom: 220rpx;
  391. .register_li{
  392. background #fff;
  393. border-radius:20rpx;
  394. margin:20rpx 20rpx 0;
  395. padding:20rpx 0;
  396. box-sizing: border-box;
  397. .register_li_min{
  398. margin:0 26rpx;
  399. display flex;
  400. align-items center;
  401. border-bottom: 1px solid #F5F5F5;
  402. .icon_img{
  403. width: 30rpx;
  404. height: 30rpx;
  405. margin-right: 12rpx;
  406. }
  407. view{
  408. line-height:100rpx;
  409. font-size:28rpx;
  410. }
  411. view:nth-child(1){
  412. color:red;
  413. line-height:28rpx;
  414. margin-right: 12rpx;
  415. }
  416. view:nth-child(2){
  417. //width:140rpx;
  418. font-size: 28rpx;
  419. font-family: PingFang SC;
  420. font-weight: 500;
  421. color: #999999;
  422. }
  423. >input{
  424. flex:1;
  425. text-align: right;
  426. font-size: 24rpx;
  427. font-family: PingFang SC;
  428. font-weight: 500;
  429. color: #333333;
  430. }
  431. }
  432. }
  433. .register_li2{
  434. background #fff;
  435. border-radius:20rpx;
  436. margin:20rpx 20rpx 0;
  437. padding:20rpx 0;
  438. box-sizing: border-box;
  439. .register_li_min{
  440. margin:0 26rpx;
  441. display flex;
  442. align-items center;
  443. border-bottom: 1px solid #F5F5F5;
  444. .icon_img{
  445. width: 30rpx;
  446. height: 30rpx;
  447. margin-right: 12rpx;
  448. }
  449. view{
  450. line-height:100rpx;
  451. font-size:28rpx;
  452. }
  453. view:nth-child(1){
  454. color:red;
  455. line-height:28rpx;
  456. margin-right: 12rpx;
  457. }
  458. view:nth-child(2){
  459. //width:140rpx;
  460. font-size: 28rpx;
  461. font-family: PingFang SC;
  462. font-weight: 500;
  463. color: #333;
  464. }
  465. >input{
  466. flex:1;
  467. text-align: right;
  468. font-size: 24rpx;
  469. font-family: PingFang SC;
  470. font-weight: 500;
  471. color: #333333;
  472. }
  473. }
  474. /* 时间 */
  475. .register_li_min2{
  476. margin:0 26rpx;
  477. border-bottom: 1px solid #f5f5f5;
  478. height: 100rpx;
  479. display: flex;
  480. justify-content: flex-start;
  481. align-items: center;
  482. >view:nth-child(1){
  483. font-size: 28rpx;
  484. font-family: PingFang SC;
  485. font-weight: 500;
  486. color: #333;
  487. line-height: 100rpx;
  488. margin-right: 110rpx;
  489. }
  490. .picker-text{
  491. font-size: 24rpx;
  492. font-family: PingFang SC;
  493. font-weight: 500;
  494. color: #333333;
  495. line-height: 100rpx;
  496. width: 188rpx;
  497. }
  498. >view:nth-child(2){
  499. font-size: 24rpx;
  500. font-family: PingFang SC;
  501. font-weight: 500;
  502. color: #333333;
  503. line-height: 100rpx;
  504. }
  505. .picker-text2{
  506. font-size: 24rpx;
  507. font-family: PingFang SC;
  508. font-weight: 500;
  509. color: #333333;
  510. line-height: 100rpx;
  511. width: 188rpx;
  512. text-align: right;
  513. }
  514. }
  515. .issue_li{
  516. margin:34rpx 26rpx 0;
  517. view:nth-child(1){
  518. color:red;
  519. line-height:28rpx;
  520. margin-right: 12rpx;
  521. display: inline-block;
  522. }
  523. view:nth-child(2){
  524. //width:140rpx;
  525. font-size: 28rpx;
  526. font-family: PingFang SC;
  527. font-weight: 500;
  528. color: #333;
  529. display: inline-block;
  530. }
  531. view:nth-child(3){
  532. width: 668rpx;
  533. height: 270rpx;
  534. border: 1px solid #E0E0E0;
  535. border-radius: 10rpx;
  536. text-align: center;
  537. margin-top: 34rpx;
  538. position: relative;
  539. >img{
  540. width: 668rpx;
  541. height: 270rpx;
  542. position: absolute;
  543. z-index: 10;
  544. }
  545. >text{
  546. font-size: 24rpx;
  547. font-family: PingFang SC;
  548. font-weight: 500;
  549. color: #999999;
  550. line-height: 270rpx;
  551. position: absolute;
  552. left: 278rpx;
  553. z-index: 20;
  554. }
  555. }
  556. .issue_img{
  557. width: 210rpx;
  558. height: 210rpx;
  559. border-radius: 10rpx;
  560. margin-left:250rpx;
  561. }
  562. }
  563. }
  564. /* 按钮 */
  565. .sub_btn{
  566. width: 650rpx;
  567. height: 100rpx;
  568. background: #0183FA;
  569. border-radius: 20rpx;
  570. font-size: 28rpx;
  571. font-family: PingFang SC;
  572. font-weight: 500;
  573. color: #FFFFFF;
  574. line-height: 100rpx;
  575. text-align: center;
  576. margin-left: 50rpx;
  577. position: fixed;
  578. bottom:30rpx;
  579. }
  580. }
  581. /deep/.input-value-border{
  582. display :none !important;
  583. }
  584. </style>