useGasAdd.vue 11 KB

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