useGasAdd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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. } 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: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
  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. console.log(_this.form.useGasId)
  242. console.log(_this.form.useGasName)
  243. },
  244. //懒加载实验室
  245. userSelectList(e){
  246. subjectList({name:e,deptId:this.form.deptId}).then(response => {
  247. this.laboratoryOptions = response.data;
  248. });
  249. },
  250. //实验室选择
  251. selectChange(e){
  252. let self = this;
  253. for(let i=0;i<self.laboratoryOptions.length;i++){
  254. if(self.laboratoryOptions[i].id == e){
  255. this.$set(this.form,"subject",self.laboratoryOptions[i]);
  256. this.$set(this.form,"location",self.laboratoryOptions[i].name);
  257. }
  258. }
  259. this.$set(this.form,"subjectId",e);
  260. },
  261. //上传
  262. handleAvatarSuccess(res, file) {
  263. console.log(res.data.url);
  264. this.form.applyCertificate = res.data.url;
  265. this.$forceUpdate()
  266. },
  267. beforeAvatarUpload(file) {
  268. let type = false;
  269. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  270. type = true;
  271. }else{
  272. this.$message.error('只能上传png/jpeg/gif格式图片');
  273. type = false;
  274. }
  275. return type;
  276. },
  277. /* 详情 */
  278. getInfo(id){
  279. let _this=this;
  280. useAgsApplyDetail({id:id}).then( response => {
  281. let res=response.data;
  282. if(response.code==200){
  283. let dateRange=[];
  284. _this.totalNum=0;
  285. dateRange.push(res.apply.startTime,res.apply.endTime)
  286. _this.form.id=res.apply.id;
  287. _this.form.applyUser=res.apply.applyUser;
  288. _this.form.phone=res.apply.phone;
  289. _this.form.location=res.apply.location;
  290. _this.form.subjectId=String(res.apply.subjectId);
  291. _this.form.startTime=res.apply.startTime;
  292. _this.form.endTime=res.apply.endTime;
  293. _this.form.gasUse=res.apply.gasUse;
  294. _this.form.applyCertificate=res.apply.applyCertificate;
  295. _this.form.safetyPrecautions=res.apply.safetyPrecautions;
  296. _this.form.useGasId=res.apply.useGasId;
  297. _this.form.useGasName=res.apply.useGasName;
  298. _this.form.dateRange=dateRange;
  299. }
  300. });
  301. },
  302. //提交
  303. submitForm(){
  304. let _this = this;
  305. _this.loading = true;
  306. if(_this.status==0){//新增
  307. useAgsApplyAdd(_this.form).then(res => {
  308. this.msgSuccess(res.msg);
  309. _this.backPage();
  310. });
  311. }else if(_this.status==1){
  312. useAgsApplyAnew(_this.form).then(res => {
  313. this.msgSuccess(res.msg);
  314. _this.backPage();
  315. });
  316. }
  317. },
  318. //返回
  319. backPage(){
  320. this.$parent.handleClick('','','back');
  321. this.$parent.getList();
  322. },
  323. },
  324. mounted() {
  325. this.getLoginUser()
  326. this.googsListGoogs()
  327. this.status=this.pageData.status;
  328. if(this.status==1){
  329. this.getInfo(this.pageData.id)
  330. }
  331. }
  332. };
  333. </script>
  334. <style scoped lang="scss">
  335. .addPage {
  336. flex:1;
  337. display: flex!important;
  338. flex-direction: column;
  339. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  340. border-radius:10px;
  341. /*顶部*/
  342. .addPage_title{
  343. display: flex;
  344. align-items: center;
  345. border-bottom: 1px solid #E0E0E0;
  346. padding-top:20px;
  347. p:nth-child(1){
  348. line-height:60px;
  349. color: #0045AF;
  350. font-size:18px;
  351. margin:0 12px 0 20px;
  352. }
  353. p:nth-child(2){
  354. font-size: 14px;
  355. font-family: Source Han Sans CN;
  356. font-weight: 400;
  357. color: #999999;
  358. flex: 1;
  359. }
  360. p:nth-child(3){
  361. margin-right:20px;
  362. }
  363. }
  364. .addPage_b{
  365. flex: 1;
  366. display: flex!important;
  367. flex-direction: column;
  368. .addPage_b_b{
  369. margin-top: 58px;
  370. margin-left: 36%;
  371. }
  372. /*申请二*/
  373. .apply_tow{
  374. padding: 0 20px;
  375. box-sizing: border-box;
  376. flex: 1;
  377. display: flex!important;
  378. flex-direction: column;
  379. .selected{
  380. display: inline-block;
  381. font-size: 14px;
  382. font-family: Microsoft YaHei;
  383. font-weight: 400;
  384. color: #0045AF;
  385. float: right;
  386. cursor: pointer;
  387. }
  388. .sub_btn{
  389. display: flex;
  390. justify-content: center;
  391. margin: 30px 0;
  392. }
  393. }
  394. }
  395. }
  396. </style>