qualificationApplyAdd.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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">
  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
  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: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
  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. /** 获取气瓶列表 */
  292. getListGood() {
  293. let _this=this;
  294. getListGood(_this.queryParams).then( response => {
  295. let res=response.rows;
  296. if(this.status==0){//新增
  297. _this.tableData=res;
  298. _this.total=response.total
  299. }else if(this.status==1){//编辑
  300. _this.tableData=res;
  301. _this.total=response.total
  302. //渲染气瓶信息数据
  303. _this.tableData.forEach(function(item){
  304. _this.form.listDetailVo.forEach(function(item2){
  305. if(item.id==item2.airBottleConfigId){
  306. item.bottleNumber=item2.bottleNumber
  307. _this.totalNum+=item2.bottleNumber;
  308. }
  309. })
  310. })
  311. }
  312. });
  313. },
  314. /* 计算所选气瓶 */
  315. numberFun(){
  316. let _this=this;
  317. _this.totalNum=0;
  318. _this.form.listDetailVo=[];
  319. _this.tableData.forEach(function(item){
  320. if(item.bottleNumber){
  321. _this.totalNum+=item.bottleNumber;
  322. _this.form.listDetailVo.push(item);
  323. _this.form.listDetailVo.forEach(function(item){
  324. item.gasLevel=item.parent
  325. item.gasNorms=item.specValue
  326. })
  327. }
  328. })
  329. },
  330. /** 搜索按钮操作 */
  331. handleQuery() {
  332. this.queryParams.pageNum = 1;
  333. this.getListGood();
  334. },
  335. /** 重置按钮操作 */
  336. resetQuery() {
  337. this.queryParams.searchValue = "";
  338. this.handleQuery();
  339. },
  340. //上传
  341. handleAvatarSuccess(res, file) {
  342. console.log(res.data.url);
  343. this.form.applyCertificate = res.data.url;
  344. this.$forceUpdate()
  345. },
  346. beforeAvatarUpload(file) {
  347. let type = false;
  348. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  349. type = true;
  350. }else{
  351. this.$message.error('只能上传png/jpeg/gif格式图片');
  352. type = false;
  353. }
  354. return type;
  355. },
  356. /* 详情 */
  357. getInfo(id){
  358. let _this=this;
  359. qualificationApplyDetail({id:id}).then( response => {
  360. let res=response.data;
  361. if(response.code==200){
  362. let dateRange=[];
  363. _this.totalNum=0;
  364. dateRange.push(res.apply.startTime,res.apply.endTime)
  365. _this.form.id=res.apply.id;
  366. _this.form.applyUser=res.apply.applyUser;
  367. _this.form.phone=res.apply.phone;
  368. _this.form.location=res.apply.location;
  369. _this.form.subjectId=String(res.apply.subjectId);
  370. _this.form.startTime=res.apply.startTime;
  371. _this.form.endTime=res.apply.endTime;
  372. _this.form.gasUse=res.apply.gasUse;
  373. _this.form.applyCertificate=res.apply.applyCertificate;
  374. _this.form.safetyPrecautions=res.apply.safetyPrecautions;
  375. _this.form.dateRange=dateRange;
  376. _this.form.listDetailVo=res.airBottlelist;
  377. _this.getListGood()
  378. }
  379. });
  380. },
  381. //提交
  382. submitForm(){
  383. let _this = this;
  384. _this.loading = true;
  385. if(_this.status==0){//新增
  386. qualificationApplyAdd(_this.form).then(res => {
  387. this.msgSuccess(res.msg);
  388. _this.backPage();
  389. });
  390. }else if(_this.status==1){
  391. qualificationApplyAnew(_this.form).then(res => {
  392. this.msgSuccess(res.msg);
  393. _this.backPage();
  394. });
  395. }
  396. },
  397. //返回
  398. backPage(){
  399. this.$parent.handleClick('','','back');
  400. this.$parent.getList();
  401. },
  402. },
  403. mounted() {
  404. this.status=this.pageData.status;
  405. if(this.status==1){
  406. this.getInfo(this.pageData.id)
  407. }else{
  408. this.getLoginUser()
  409. this.getListGood()
  410. }
  411. }
  412. };
  413. </script>
  414. <style scoped lang="scss">
  415. .addPage {
  416. flex:1;
  417. display: flex!important;
  418. flex-direction: column;
  419. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  420. border-radius:10px;
  421. /*顶部*/
  422. .addPage_title{
  423. display: flex;
  424. align-items: center;
  425. border-bottom: 1px solid #E0E0E0;
  426. padding-top:20px;
  427. p:nth-child(1){
  428. line-height:60px;
  429. color: #0045AF;
  430. font-size:18px;
  431. margin:0 12px 0 20px;
  432. }
  433. p:nth-child(2){
  434. font-size: 14px;
  435. font-family: Source Han Sans CN;
  436. font-weight: 400;
  437. color: #999999;
  438. flex: 1;
  439. }
  440. p:nth-child(3){
  441. margin-right:20px;
  442. }
  443. }
  444. .addPage_b{
  445. flex: 1;
  446. display: flex!important;
  447. flex-direction: column;
  448. /*时间轴*/
  449. .addPage_b_t{
  450. display: flex;
  451. justify-content: center;
  452. align-items: center;
  453. margin-top: 36px;
  454. >li{
  455. width: 120px;
  456. text-align: center;
  457. list-style-type: none;
  458. >img{
  459. width: 60px;
  460. height:60px;
  461. }
  462. >p{
  463. font-size: 16px;
  464. font-family: Microsoft YaHei;
  465. font-weight: 400;
  466. color: #333333;
  467. line-height: 16px;
  468. }
  469. }
  470. >i{
  471. display: inline-block;
  472. width: 250px;
  473. height: 2px;
  474. background: #E0E0E0;
  475. position: relative;
  476. top: -24px;
  477. }
  478. }
  479. .addPage_b_b{
  480. margin-top: 58px;
  481. margin-left: 36%;
  482. }
  483. /*申请二*/
  484. .apply_tow{
  485. padding: 0 20px;
  486. box-sizing: border-box;
  487. flex: 1;
  488. display: flex!important;
  489. flex-direction: column;
  490. .selected{
  491. display: inline-block;
  492. font-size: 14px;
  493. font-family: Microsoft YaHei;
  494. font-weight: 400;
  495. color: #0045AF;
  496. float: right;
  497. cursor: pointer;
  498. }
  499. .sub_btn{
  500. display: flex;
  501. justify-content: center;
  502. margin: 30px 0;
  503. }
  504. }
  505. }
  506. }
  507. </style>