useGasAdd.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. <!--申请1-->
  11. <div v-if="pageType==1">
  12. <el-form class="addPage_b_b" :model="form" ref="form" :rules="rules" label-position="right" label-width="100px">
  13. <el-form-item label="申请人" prop="applyCause" >
  14. <el-input style="width: 300px" v-model="form.applyUser" disabled maxlength="50" />
  15. </el-form-item>
  16. <el-form-item label="联系方式" prop="phone" >
  17. <el-input style="width: 300px" v-model="form.phone" placeholder="请输入联系方式" maxlength="50" />
  18. </el-form-item>
  19. <el-form-item label="实验地点" prop="subjectId">
  20. <el-select
  21. style="width:300px;"
  22. v-model="form.location"
  23. filterable
  24. remote
  25. clearable
  26. reserve-keyword
  27. @focus="selectFocus"
  28. @change="selectChange"
  29. placeholder="请选择实验地点"
  30. :remote-method="userSelectList"
  31. :loading="loading">
  32. <el-option
  33. v-for="item in laboratoryOptions"
  34. :key="item.id"
  35. :label="item.name"
  36. :value="item.id">
  37. </el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="使用期限" prop="dateRange" >
  41. <el-date-picker
  42. :clearable="false"
  43. v-model="form.dateRange"
  44. size="small"
  45. style="width: 300px"
  46. value-format="yyyy-MM-dd"
  47. type="daterange"
  48. range-separator="-"
  49. :picker-options="pickerOptions0"
  50. start-placeholder="开始日期"
  51. end-placeholder="结束日期"
  52. ></el-date-picker>
  53. </el-form-item>
  54. <el-form-item label="使用气体" prop="useGasId" >
  55. <el-select class="min-width" placeholder="请选择使用气体" v-model="form.useGasId" filterable clearable @change="useGasFun" style="width: 300px">
  56. <el-option
  57. v-for="(item,index) in useGasList"
  58. :key="item.id"
  59. :label="item.goodsName"
  60. :value="item.id">
  61. </el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="气体用途" prop="gasUse" >
  65. <el-input style="width: 300px" v-model="form.gasUse" placeholder="请输入气体用途" maxlength="50" />
  66. </el-form-item>
  67. <el-form-item label="安全措施" prop="safetyPrecautions" >
  68. <el-input style="width: 300px" v-model="form.safetyPrecautions" placeholder="请输入安全措施" maxlength="50" />
  69. </el-form-item>
  70. <el-form-item label="用气申请表" prop="applyCertificate" >
  71. <el-upload
  72. class="certificate-avatar-uploader"
  73. :action="uploadImgUrl"
  74. :show-file-list="false"
  75. :on-success="handleAvatarSuccess"
  76. :headers="headers"
  77. :before-upload="beforeAvatarUpload">
  78. <div style="display: flex;">
  79. <img v-if="form.applyCertificate" :src="form.applyCertificate" style="width: 80px;height: 80px;margin-right: 10px">
  80. <i v-if="!form.applyCertificate" class="el-icon-plus avatar-uploader-icon"></i>
  81. </div>
  82. </el-upload>
  83. </el-form-item>
  84. </el-form>
  85. <p class="inquire-button-one" style="width:400px;margin:36px 0 16px 38%;" @click="handleClick('','form','next')">提交申请</p>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import { getToken } from "@/utils/auth";
  92. import {
  93. bottleList,
  94. getLoginUser, getValidApply, googsListGoogs,
  95. subjectList,
  96. useAgsApplyAdd,
  97. useAgsApplyAnew,
  98. useAgsApplyDetail
  99. } from '@/api/gasManage3_0/gasManage'
  100. export default {
  101. name: "addPage",
  102. props:{
  103. pageData:{},
  104. },
  105. data() {
  106. // 时间的校验
  107. const validateTime = (rule, value, callback) => {
  108. console.log(value)
  109. if(value && value.length>0){
  110. this.form.startTime=value[0]
  111. this.form.endTime=value[1]
  112. callback();
  113. }else{
  114. this.form.startTime=null;
  115. this.form.endTime=null
  116. callback(new Error('请选择使用期限'))
  117. }
  118. }
  119. return {
  120. pageType:1,
  121. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  122. headers: {
  123. Authorization: "Bearer " + getToken(),
  124. },
  125. // 设置只能选择当前日期及之后的日期
  126. pickerOptions0: {
  127. disabledDate(time) {
  128. return time.getTime() < Date.now() - 8.64e7;//如果没有后面的-8.64e7就是不可以选择今天的
  129. }
  130. },
  131. loading:false,
  132. form:{
  133. deptId:'',
  134. applyUser:'',
  135. applyUserid:'',
  136. phone:'',
  137. location:'',
  138. subjectId:'',
  139. startTime:'',
  140. endTime:'',
  141. useGasName:'',
  142. useGasId:'',
  143. gasUse:'',
  144. safetyPrecautions:'',
  145. applyCertificate:'',
  146. dateRange:[],
  147. },
  148. laboratoryOptions:[],
  149. useGasList:[],
  150. // 查询参数
  151. queryParams: {
  152. pageNum: 1,
  153. pageSize:20,
  154. searchValue:'',
  155. },
  156. total:0,
  157. tableData:[],
  158. dialogVisible:false,
  159. totalNum:0,//所选气瓶总数
  160. status:0,//0添加1编辑
  161. // 表单校验
  162. rules: {
  163. phone: [
  164. { required: true, message: "请输入联系方式", trigger: "blur" },
  165. { required: true, message: "请输入联系方式", validator: this.spaceJudgment, trigger: "blur" },
  166. { 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" }
  167. ],
  168. subjectId: [
  169. { required: true, message: "请选择实验地点", trigger: "blur" }
  170. ],
  171. useGasId: [
  172. { required: true, message: "请选择使用气体", trigger: "blur" }
  173. ],
  174. gasUse: [
  175. { required: true, message: "请输入气体用途", trigger: "blur" },
  176. { required: true, message: "请输入气体用途", validator: this.spaceJudgment, trigger: "blur" }
  177. ],
  178. safetyPrecautions: [
  179. { required: true, message: "请输入安全措施", trigger: "change" },
  180. { required: true, message: "请输入安全措施", validator: this.spaceJudgment, trigger: "blur" }
  181. ],
  182. applyCertificate: [
  183. { required: true, message: "请上传用气申请表", trigger: "change" }
  184. ],
  185. dateRange: [
  186. {required: true, validator: validateTime, trigger: 'blur' },
  187. ],
  188. },
  189. };
  190. },
  191. methods: {
  192. selectFocus(){
  193. console.log("123");
  194. if(!this.laboratoryOptions[0]){
  195. this.userSelectList("");
  196. }
  197. },
  198. handleClick(index,row,doType){
  199. let _this=this;
  200. if(doType=='next'){//下一步
  201. //非空校验
  202. this.$refs[row].validate((valid) => {
  203. if (valid) {
  204. _this.submitForm();
  205. } else {
  206. return false;
  207. }
  208. });
  209. }else if(doType=='last'){//上一步
  210. _this.pageType=1;
  211. }else if(doType=='selected'){//已选气瓶
  212. _this.dialogVisible=true
  213. }
  214. },
  215. /** 获取当前用户信息 */
  216. getLoginUser() {
  217. let _this=this;
  218. getLoginUser().then( response => {
  219. let res=response.data
  220. _this.form.applyUser=res.nickName
  221. _this.form.applyUserid=res.userId
  222. _this.form.phone=res.phonenumber
  223. _this.form.deptId=res.deptId
  224. });
  225. },
  226. /** 获取使用气体信息 */
  227. googsListGoogs() {
  228. let _this=this;
  229. googsListGoogs().then( response => {
  230. let res=response.rows
  231. _this.useGasList=res;
  232. });
  233. },
  234. useGasFun(){
  235. let _this=this;
  236. _this.useGasList.forEach(function(item){
  237. if(_this.form.useGasId==item.id){
  238. _this.form.useGasName=item.goodsName;
  239. }
  240. })
  241. },
  242. //懒加载实验室
  243. userSelectList(e){
  244. subjectList({name:e}).then(response => {
  245. this.laboratoryOptions = response.data;
  246. });
  247. },
  248. //实验室选择
  249. selectChange(e){
  250. let self = this;
  251. for(let i=0;i<self.laboratoryOptions.length;i++){
  252. if(self.laboratoryOptions[i].id == e){
  253. this.$set(this.form,"subject",self.laboratoryOptions[i]);
  254. this.$set(this.form,"location",self.laboratoryOptions[i].name);
  255. }
  256. }
  257. this.$set(this.form,"subjectId",e);
  258. //校验实验室的准入资格
  259. this.getValidApply();
  260. },
  261. //校验实验室的准入资格
  262. getValidApply(){
  263. let _this = this;
  264. let obj={
  265. userId:_this.form.applyUserid,
  266. subjectId:_this.form.subjectId
  267. }
  268. getValidApply(obj).then(res => {
  269. if(res.data.length<=0){
  270. this.$message.error('请先申请('+this.form.location+')实验室准入资格!');
  271. this.form.location='';
  272. }
  273. });
  274. },
  275. //上传
  276. handleAvatarSuccess(res, file) {
  277. console.log(res.data.url);
  278. this.form.applyCertificate = res.data.url;
  279. this.$forceUpdate()
  280. },
  281. beforeAvatarUpload(file) {
  282. let type = false;
  283. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  284. type = true;
  285. }else{
  286. this.$message.error('只能上传png/jpeg/gif格式图片');
  287. type = false;
  288. }
  289. return type;
  290. },
  291. /* 详情 */
  292. getInfo(id){
  293. let _this=this;
  294. useAgsApplyDetail({id:id}).then( response => {
  295. let res=response.data;
  296. if(response.code==200){
  297. let dateRange=[];
  298. _this.totalNum=0;
  299. dateRange.push(res.apply.startTime,res.apply.endTime)
  300. _this.form.id=res.apply.id;
  301. _this.form.applyUser=res.apply.applyUser;
  302. _this.form.phone=res.apply.phone;
  303. _this.form.location=res.apply.location;
  304. _this.form.subjectId=String(res.apply.subjectId);
  305. _this.form.startTime=res.apply.startTime;
  306. _this.form.endTime=res.apply.endTime;
  307. _this.form.gasUse=res.apply.gasUse;
  308. _this.form.applyCertificate=res.apply.applyCertificate;
  309. _this.form.safetyPrecautions=res.apply.safetyPrecautions;
  310. _this.form.useGasId=res.apply.useGasId;
  311. _this.form.useGasName=res.apply.useGasName;
  312. _this.form.dateRange=dateRange;
  313. }
  314. });
  315. },
  316. //提交
  317. submitForm(){
  318. let _this = this;
  319. _this.loading = true;
  320. if(_this.status==0){//新增
  321. useAgsApplyAdd(_this.form).then(res => {
  322. this.msgSuccess(res.msg);
  323. _this.backPage();
  324. });
  325. }else if(_this.status==1){
  326. useAgsApplyAnew(_this.form).then(res => {
  327. this.msgSuccess(res.msg);
  328. _this.backPage();
  329. });
  330. }
  331. },
  332. //返回
  333. backPage(){
  334. this.$parent.handleClick('','','back');
  335. this.$parent.getList();
  336. },
  337. },
  338. mounted() {
  339. this.getLoginUser()
  340. this.googsListGoogs()
  341. this.status=this.pageData.status;
  342. if(this.status==1){
  343. this.getInfo(this.pageData.id)
  344. }
  345. }
  346. };
  347. </script>
  348. <style scoped lang="scss">
  349. .addPage {
  350. flex:1;
  351. display: flex!important;
  352. flex-direction: column;
  353. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  354. border-radius:10px;
  355. /*顶部*/
  356. .addPage_title{
  357. display: flex;
  358. align-items: center;
  359. border-bottom: 1px solid #E0E0E0;
  360. padding-top:20px;
  361. p:nth-child(1){
  362. line-height:60px;
  363. color: #0045AF;
  364. font-size:18px;
  365. margin:0 12px 0 20px;
  366. }
  367. p:nth-child(2){
  368. font-size: 14px;
  369. font-family: Source Han Sans CN;
  370. font-weight: 400;
  371. color: #999999;
  372. flex: 1;
  373. }
  374. p:nth-child(3){
  375. margin-right:20px;
  376. }
  377. }
  378. .addPage_b{
  379. flex: 1;
  380. display: flex!important;
  381. flex-direction: column;
  382. .addPage_b_b{
  383. margin-top: 58px;
  384. margin-left: 36%;
  385. }
  386. /*申请二*/
  387. .apply_tow{
  388. padding: 0 20px;
  389. box-sizing: border-box;
  390. flex: 1;
  391. display: flex!important;
  392. flex-direction: column;
  393. .selected{
  394. display: inline-block;
  395. font-size: 14px;
  396. font-family: Microsoft YaHei;
  397. font-weight: 400;
  398. color: #0045AF;
  399. float: right;
  400. cursor: pointer;
  401. }
  402. .sub_btn{
  403. display: flex;
  404. justify-content: center;
  405. margin: 30px 0;
  406. }
  407. }
  408. }
  409. }
  410. </style>