examinationAdd.vue 17 KB

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