元气智驾官网后台前端页面
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

83 строки
2.6 KiB

  1. <!--
  2. * @Date: 2021-07-08 11:02:40
  3. * @LastEditTime: 2022-07-27 10:48:43
  4. * @Description: 广告位
  5. -->
  6. <template>
  7. <div class="app-container">
  8. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="resetform">
  9. <el-form-item label="图片" prop="image">
  10. <uploadFile :url.sync="ruleForm.image" type="image" />
  11. </el-form-item>
  12. <el-form-item label="链接" prop="link">
  13. <el-input v-model="ruleForm.link"></el-input>
  14. </el-form-item>
  15. <el-form-item label="是否新开页面打开">
  16. <el-radio-group v-model="ruleForm.newOpen">
  17. <el-radio :label="1">是</el-radio>
  18. <el-radio :label="0">否</el-radio>
  19. </el-radio-group>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
  23. </el-form-item>
  24. </el-form>
  25. </div>
  26. </template>
  27. <script>
  28. import { guanggao1, saveGuangGao } from '@/api/homePage'
  29. import uploadFile from '@/components/uploadFile'
  30. export default {
  31. components: {
  32. uploadFile
  33. },
  34. data() {
  35. return {
  36. ruleForm: {
  37. id: '',
  38. image: '',
  39. link: '',
  40. newOpen: '1'
  41. },
  42. rules: {
  43. image: [
  44. { required: true, message: '请上传图片', trigger: 'blur' }
  45. ],
  46. link: [
  47. { required: true, message: '请输入链接', trigger: 'blur' }
  48. ]
  49. }
  50. }
  51. },
  52. created() {
  53. this.getData()
  54. },
  55. methods: {
  56. getData() {
  57. guanggao1().then(res => {
  58. this.ruleForm.id = res.id
  59. this.ruleForm.image = res.image
  60. this.ruleForm.link = res.link
  61. this.ruleForm.newOpen = res.newOpen
  62. })
  63. },
  64. submitForm(formName) {
  65. this.$refs[formName].validate((valid) => {
  66. if (valid) {
  67. saveGuangGao(this.ruleForm).then(res => {
  68. this.$message({
  69. message: '操作成功!',
  70. type: 'success'
  71. })
  72. })
  73. } else {
  74. console.log('error submit!!')
  75. return false
  76. }
  77. })
  78. }
  79. }
  80. }
  81. </script>