qualificationApplyAdd.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <!--资格申请-添加-->
  2. <template>
  3. <div class="addPage">
  4. <div class="addPage_title">
  5. <p>资格申请</p>
  6. <P>填写申请信息,内容提交后需要进行审核,通过审核才能够申请气瓶进行使用。如课题组申请,仅需一人进行填报即可。 </P>
  7. <p class="button-p reset-button-one" @click="backPage">返回</p>
  8. </div>
  9. <div class="addPage_b">
  10. <div class="addPage_b_t">
  11. <li>
  12. <img src="@/assets/ZDimages/icon_jbxx_xz.png"/>
  13. <p>填写基本信息</p>
  14. </li>
  15. <i></i>
  16. <li>
  17. <img v-if="pageType==1" src="@/assets/ZDimages/icon_xxrp_zc.png"/>
  18. <img v-if="pageType==2" src="@/assets/ZDimages/icon_xxrp_xz.png"/>
  19. <p>选择气瓶</p>
  20. </li>
  21. </div>
  22. <!--申请1-->
  23. <div v-if="pageType==1">
  24. <el-form class="addPage_b_b" :model="form" ref="form" :rules="rules" label-position="right" label-width="100px">
  25. <el-form-item label="申请人" prop="applyCause" >
  26. <el-input style="width: 300px" v-model="form.applyUser" disabled maxlength="50" />
  27. </el-form-item>
  28. <el-form-item label="联系方式" prop="phone" >
  29. <el-input style="width: 300px" v-model="form.phone" placeholder="请输入联系方式" maxlength="50" />
  30. </el-form-item>
  31. <el-form-item label="实验地点" prop="subjectId">
  32. <el-select
  33. style="width:300px;"
  34. v-model="form.location"
  35. filterable
  36. remote
  37. clearable
  38. reserve-keyword
  39. @focus="selectFocus"
  40. @change="selectChange"
  41. placeholder="请选择实验地点"
  42. :remote-method="userSelectList"
  43. :loading="loading">
  44. <el-option
  45. v-for="item in laboratoryOptions"
  46. :key="item.id"
  47. :label="item.name"
  48. :value="item.id">
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="使用期限" prop="dateRange" >
  53. <el-date-picker
  54. :clearable="false"
  55. v-model="form.dateRange"
  56. size="small"
  57. style="width: 300px"
  58. value-format="yyyy-MM-dd"
  59. type="daterange"
  60. range-separator="-"
  61. :picker-options="pickerOptions0"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期"
  64. ></el-date-picker>
  65. </el-form-item>
  66. <el-form-item label="气体用途" prop="gasUse" >
  67. <el-input style="width: 300px" v-model="form.gasUse" placeholder="请输入气体用途" maxlength="50" />
  68. </el-form-item>
  69. <el-form-item label="安全措施" prop="safetyPrecautions" >
  70. <el-input style="width: 300px" v-model="form.safetyPrecautions" placeholder="请输入安全措施" maxlength="50" />
  71. </el-form-item>
  72. <el-form-item label="用气申请表" prop="applyCertificate" >
  73. <el-upload
  74. class="certificate-avatar-uploader"
  75. :action="uploadImgUrl"
  76. :show-file-list="false"
  77. :on-success="handleAvatarSuccess"
  78. :headers="headers"
  79. :before-upload="beforeAvatarUpload">
  80. <div style="display: flex;">
  81. <img v-if="form.applyCertificate" :src="form.applyCertificate" style="width: 80px;height: 80px;margin-right: 10px">
  82. <i v-if="!form.applyCertificate" class="el-icon-plus avatar-uploader-icon"></i>
  83. </div>
  84. </el-upload>
  85. </el-form-item>
  86. </el-form>
  87. <p class="inquire-button-one" style="width:400px;margin:36px 0 16px 38%;" @click="handleClick('','form','next')">下一步</p>
  88. </div>
  89. <!--申请2-->
  90. <div v-if="pageType==2" class="apply_tow">
  91. <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true">
  92. <el-form-item label="关键字" prop="name">
  93. <el-input
  94. v-model="queryParams.searchValue"
  95. placeholder="气体名称/气瓶厂家"
  96. clearable
  97. maxLength="30"
  98. size="small"
  99. />
  100. </el-form-item>
  101. <el-form-item>
  102. <p class="inquire-button-one" @click="handleQuery">查询</p>
  103. <p class="reset-button-one" @click="resetQuery">重置</p>
  104. </el-form-item>
  105. <div class="selected" @click="handleClick('','','selected')">已选气瓶 {{totalNum}}</div>
  106. </el-form>
  107. <el-table v-loading="loading" border :data="tableData">
  108. <el-table-column label="气体名称" align="left" prop="airName"/>
  109. <el-table-column label="气体级别/规格" align="left" prop="configName"></el-table-column>
  110. <el-table-column label="气瓶厂家" align="left" prop="companyName"></el-table-column>
  111. <el-table-column label="气体组分" align="left" prop="airConstituents"></el-table-column>
  112. <el-table-column label="操作" align="left" prop="bottleNumber" width="240">
  113. <template slot-scope="scope">
  114. <template>
  115. <el-input-number v-model="scope.row.bottleNumber" @change="numberFun()" :min="0" size="mini"></el-input-number>
  116. </template>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <pagination
  121. :total="total"
  122. layout="total, prev, pager, next, sizes, jumper"
  123. :page.sync="queryParams.pageNum"
  124. :limit.sync="queryParams.pageSize"
  125. @pagination="getListGood"
  126. />
  127. <div class="sub_btn">
  128. <p class="reset-button-one" style="width:150px;margin-right: 30px" @click="handleClick('','','last')">返回上一步</p>
  129. <p class="inquire-button-one" style="width:150px;" @click="submitForm">提交申请</p>
  130. </div>
  131. </div>
  132. </div>
  133. <el-dialog :title="'已选气瓶 '+totalNum" border :visible.sync="dialogVisible">
  134. <el-table border v-loading="loading" :data="form.listDetailVo" height="500">
  135. <el-table-column label="气体名称" align="left" prop="airName"/>
  136. <el-table-column label="气体级别/规格" align="left" prop="configName"></el-table-column>
  137. <el-table-column label="气瓶厂家" align="left" prop="companyName"></el-table-column>
  138. <el-table-column label="气体组分" align="left" prop="airConstituents"></el-table-column>
  139. <el-table-column label="数量" align="left" prop="bottleNumber"></el-table-column>
  140. </el-table>
  141. </el-dialog>
  142. </div>
  143. </template>
  144. <script>
  145. import { getToken } from "@/utils/auth";
  146. import {
  147. getListGood,
  148. getLoginUser,
  149. qualificationApplyAdd,
  150. qualificationApplyDetail,
  151. subjectList,
  152. qualificationApplyAnew, getValidApply
  153. } from '@/api/gasManage3_0/gasManage'
  154. export default {
  155. name: "addPage",
  156. props:{
  157. pageData:{},
  158. },
  159. data() {
  160. // 时间的校验
  161. const validateTime = (rule, value, callback) => {
  162. console.log(value)
  163. if(value && value.length>0){
  164. this.form.startTime=value[0]
  165. this.form.endTime=value[1]
  166. callback();
  167. }else{
  168. this.form.startTime=null;
  169. this.form.endTime=null
  170. callback(new Error('请选择使用期限'))
  171. }
  172. }
  173. return {
  174. pageType:1,
  175. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  176. headers: {
  177. Authorization: "Bearer " + getToken(),
  178. },
  179. // 设置只能选择当前日期及之后的日期
  180. pickerOptions0: {
  181. disabledDate(time) {
  182. return time.getTime() < Date.now() - 8.64e7;//如果没有后面的-8.64e7就是不可以选择今天的
  183. }
  184. },
  185. loading:false,
  186. form:{
  187. deptId:'',
  188. applyUser:'',
  189. applyUserid:'',
  190. phone:'',
  191. location:'',
  192. subjectId:'',
  193. startTime:'',
  194. endTime:'',
  195. gasUse:'',
  196. safetyPrecautions:'',
  197. applyCertificate:'',
  198. dateRange:[],
  199. listDetailVo:[],
  200. },
  201. laboratoryOptions:[],
  202. // 查询参数
  203. queryParams: {
  204. pageNum: 1,
  205. pageSize:20,
  206. searchValue:'',
  207. },
  208. total:0,
  209. tableData:[],
  210. dialogVisible:false,
  211. totalNum:0,//所选气瓶总数
  212. status:0,//0添加1编辑
  213. // 表单校验
  214. rules: {
  215. phone: [
  216. { required: true, message: "请输入联系方式", trigger: "blur" },
  217. { required: true, message: "请输入联系方式", validator: this.spaceJudgment, trigger: "blur" },
  218. { pattern:/^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(16[0-9])|(17[0,3,5-8])|(18[0-9])|(147))+\d{8}$/, message: "请输入正确的联系方式", trigger: "blur" }
  219. ],
  220. subjectId: [
  221. { required: true, message: "请选择实验地点", trigger: "blur" }
  222. ],
  223. gasUse: [
  224. { required: true, message: "请输入气体用途", trigger: "blur" },
  225. { required: true, message: "请输入气体用途", validator: this.spaceJudgment, trigger: "blur" }
  226. ],
  227. safetyPrecautions: [
  228. { required: true, message: "请输入安全措施", trigger: "change" },
  229. { required: true, message: "请输入安全措施", validator: this.spaceJudgment, trigger: "blur" }
  230. ],
  231. applyCertificate: [
  232. { required: true, message: "请上传用气申请表", trigger: "change" }
  233. ],
  234. dateRange: [
  235. {required: true, validator: validateTime, trigger: 'blur' },
  236. ],
  237. },
  238. };
  239. },
  240. methods: {
  241. selectFocus(){
  242. if(!this.laboratoryOptions[0]){
  243. this.userSelectList("");
  244. }
  245. },
  246. handleClick(index,row,doType){
  247. let _this=this;
  248. if(doType=='next'){//下一步
  249. //非空校验
  250. this.$refs[row].validate((valid) => {
  251. if (valid) {
  252. _this.pageType=2;
  253. } else {
  254. return false;
  255. }
  256. });
  257. }else if(doType=='last'){//上一步
  258. _this.pageType=1;
  259. }else if(doType=='selected'){//已选气瓶
  260. _this.dialogVisible=true
  261. }
  262. },
  263. /** 获取当前用户信息 */
  264. getLoginUser() {
  265. let _this=this;
  266. getLoginUser().then( response => {
  267. let res=response.data
  268. _this.form.applyUser=res.nickName
  269. _this.form.phone=res.phonenumber
  270. _this.form.applyUserid=res.userId
  271. _this.form.deptId=res.deptId
  272. });
  273. },
  274. //懒加载实验室
  275. userSelectList(e){
  276. subjectList({name:e,deptId:this.form.deptId}).then(response => {
  277. this.laboratoryOptions = response.data;
  278. });
  279. },
  280. //实验室选择
  281. selectChange(e){
  282. let self = this;
  283. for(let i=0;i<self.laboratoryOptions.length;i++){
  284. if(self.laboratoryOptions[i].id == e){
  285. this.$set(this.form,"subject",self.laboratoryOptions[i]);
  286. this.$set(this.form,"location",self.laboratoryOptions[i].name);
  287. }
  288. }
  289. this.$set(this.form,"subjectId",e);
  290. //校验实验室的准入资格
  291. this.getValidApply();
  292. },
  293. //校验实验室的准入资格
  294. getValidApply(){
  295. let _this = this;
  296. let obj={
  297. userId:_this.form.applyUserid,
  298. subjectId:_this.form.subjectId
  299. }
  300. getValidApply(obj).then(res => {
  301. if(res.data.length<=0){
  302. this.$message.error('请先申请('+this.form.location+')实验室准入资格!');
  303. this.form.location='';
  304. }
  305. });
  306. },
  307. /** 获取气瓶列表 */
  308. getListGood() {
  309. let _this=this;
  310. getListGood(_this.queryParams).then( response => {
  311. let res=response.rows;
  312. if(this.status==0){//新增
  313. _this.tableData=res;
  314. _this.total=response.total
  315. }else if(this.status==1){//编辑
  316. _this.tableData=res;
  317. _this.total=response.total
  318. //渲染气瓶信息数据
  319. _this.tableData.forEach(function(item){
  320. _this.form.listDetailVo.forEach(function(item2){
  321. if(item.id==item2.airBottleConfigId){
  322. item.bottleNumber=item2.bottleNumber
  323. _this.totalNum+=item2.bottleNumber;
  324. }
  325. })
  326. })
  327. }
  328. });
  329. },
  330. /* 计算所选气瓶 */
  331. numberFun(){
  332. let _this=this;
  333. _this.totalNum=0;
  334. _this.form.listDetailVo=[];
  335. _this.tableData.forEach(function(item){
  336. if(item.bottleNumber){
  337. _this.totalNum+=item.bottleNumber;
  338. _this.form.listDetailVo.push(item);
  339. _this.form.listDetailVo.forEach(function(item){
  340. item.gasLevel=item.parent
  341. item.gasNorms=item.specValue
  342. })
  343. }
  344. })
  345. },
  346. /** 搜索按钮操作 */
  347. handleQuery() {
  348. this.queryParams.pageNum = 1;
  349. this.getListGood();
  350. },
  351. /** 重置按钮操作 */
  352. resetQuery() {
  353. this.queryParams.searchValue = "";
  354. this.handleQuery();
  355. },
  356. //上传
  357. handleAvatarSuccess(res, file) {
  358. console.log(res.data.url);
  359. this.form.applyCertificate = res.data.url;
  360. this.$forceUpdate()
  361. },
  362. beforeAvatarUpload(file) {
  363. let type = false;
  364. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  365. type = true;
  366. }else{
  367. this.$message.error('只能上传png/jpeg/gif格式图片');
  368. type = false;
  369. }
  370. return type;
  371. },
  372. /* 详情 */
  373. getInfo(id){
  374. let _this=this;
  375. qualificationApplyDetail({id:id}).then( response => {
  376. let res=response.data;
  377. if(response.code==200){
  378. let dateRange=[];
  379. _this.totalNum=0;
  380. dateRange.push(res.apply.startTime,res.apply.endTime)
  381. _this.form.id=res.apply.id;
  382. _this.form.applyUser=res.apply.applyUser;
  383. _this.form.phone=res.apply.phone;
  384. _this.form.location=res.apply.location;
  385. _this.form.subjectId=String(res.apply.subjectId);
  386. _this.form.startTime=res.apply.startTime;
  387. _this.form.endTime=res.apply.endTime;
  388. _this.form.gasUse=res.apply.gasUse;
  389. _this.form.applyCertificate=res.apply.applyCertificate;
  390. _this.form.safetyPrecautions=res.apply.safetyPrecautions;
  391. _this.form.dateRange=dateRange;
  392. _this.form.listDetailVo=res.airBottlelist;
  393. _this.getListGood()
  394. }
  395. });
  396. },
  397. //提交
  398. submitForm(){
  399. let _this = this;
  400. if(_this.form.listDetailVo.length>0){
  401. _this.loading = true;
  402. if(_this.status==0){//新增
  403. qualificationApplyAdd(_this.form).then(res => {
  404. this.msgSuccess(res.msg);
  405. _this.backPage();
  406. });
  407. }else if(_this.status==1){
  408. qualificationApplyAnew(_this.form).then(res => {
  409. this.msgSuccess(res.msg);
  410. _this.backPage();
  411. });
  412. }
  413. }else{
  414. _this.msgError('请先选择气瓶!')
  415. }
  416. },
  417. //返回
  418. backPage(){
  419. this.$parent.handleClick('','','back');
  420. this.$parent.getList();
  421. },
  422. },
  423. mounted() {
  424. this.status=this.pageData.status;
  425. if(this.status==1){
  426. this.getInfo(this.pageData.id)
  427. }else{
  428. this.getLoginUser()
  429. this.getListGood()
  430. }
  431. }
  432. };
  433. </script>
  434. <style scoped lang="scss">
  435. .addPage {
  436. flex:1;
  437. display: flex!important;
  438. flex-direction: column;
  439. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  440. border-radius:10px;
  441. /*顶部*/
  442. .addPage_title{
  443. display: flex;
  444. align-items: center;
  445. border-bottom: 1px solid #E0E0E0;
  446. padding-top:20px;
  447. p:nth-child(1){
  448. line-height:60px;
  449. color: #0045AF;
  450. font-size:18px;
  451. margin:0 12px 0 20px;
  452. }
  453. p:nth-child(2){
  454. font-size: 14px;
  455. font-family: Source Han Sans CN;
  456. font-weight: 400;
  457. color: #999999;
  458. flex: 1;
  459. }
  460. p:nth-child(3){
  461. margin-right:20px;
  462. }
  463. }
  464. .addPage_b{
  465. flex: 1;
  466. display: flex!important;
  467. flex-direction: column;
  468. /*时间轴*/
  469. .addPage_b_t{
  470. display: flex;
  471. justify-content: center;
  472. align-items: center;
  473. margin-top: 36px;
  474. >li{
  475. width: 120px;
  476. text-align: center;
  477. list-style-type: none;
  478. >img{
  479. width: 60px;
  480. height:60px;
  481. }
  482. >p{
  483. font-size: 16px;
  484. font-family: Microsoft YaHei;
  485. font-weight: 400;
  486. color: #333333;
  487. line-height: 16px;
  488. }
  489. }
  490. >i{
  491. display: inline-block;
  492. width: 250px;
  493. height: 2px;
  494. background: #E0E0E0;
  495. position: relative;
  496. top: -24px;
  497. }
  498. }
  499. .addPage_b_b{
  500. margin-top: 58px;
  501. margin-left: 36%;
  502. }
  503. /*申请二*/
  504. .apply_tow{
  505. padding: 0 20px;
  506. box-sizing: border-box;
  507. flex: 1;
  508. display: flex!important;
  509. flex-direction: column;
  510. .selected{
  511. display: inline-block;
  512. font-size: 14px;
  513. font-family: Microsoft YaHei;
  514. font-weight: 400;
  515. color: #0045AF;
  516. float: right;
  517. cursor: pointer;
  518. }
  519. .sub_btn{
  520. display: flex;
  521. justify-content: center;
  522. margin: 30px 0;
  523. }
  524. }
  525. }
  526. }
  527. </style>