useGasAdd.vue 13 KB

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