qualificationApplyAdd.vue 17 KB

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