元气智驾官网后台前端页面
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

85 wiersze
2.8 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" width="1200" height="120"/>
  11. <p style="color: #909399;">*请上传1200*120的图片</p>
  12. </el-form-item>
  13. <el-form-item label="链接" prop="link">
  14. <el-input v-model="ruleForm.link"></el-input>
  15. </el-form-item>
  16. <el-form-item label="是否新开页面打开">
  17. <el-radio-group v-model="ruleForm.newOpen">
  18. <el-radio :label="1">是</el-radio>
  19. <el-radio :label="0">否</el-radio>
  20. </el-radio-group>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
  24. </el-form-item>
  25. </el-form>
  26. </div>
  27. </template>
  28. <script>
  29. import { guanggao2 } from '@/api/yyzrb'
  30. import { saveGuangGao } from '@/api/homePage'
  31. import uploadFile from '@/components/uploadFile'
  32. export default {
  33. components: {
  34. uploadFile
  35. },
  36. data() {
  37. return {
  38. ruleForm: {
  39. id: '',
  40. image: '',
  41. link: '',
  42. newOpen: '1'
  43. },
  44. rules: {
  45. image: [
  46. { required: true, message: '请上传图片', trigger: 'blur' }
  47. ],
  48. link: [
  49. { required: true, message: '请输入链接', trigger: 'blur' }
  50. ]
  51. }
  52. }
  53. },
  54. created() {
  55. this.getData()
  56. },
  57. methods: {
  58. getData() {
  59. guanggao2().then(res => {
  60. this.ruleForm.id = res.id
  61. this.ruleForm.image = res.image
  62. this.ruleForm.link = res.link
  63. this.ruleForm.newOpen = res.newOpen
  64. })
  65. },
  66. submitForm(formName) {
  67. this.$refs[formName].validate((valid) => {
  68. if (valid) {
  69. saveGuangGao(this.ruleForm).then(res => {
  70. this.$message({
  71. message: '操作成功!',
  72. type: 'success'
  73. })
  74. })
  75. } else {
  76. console.log('error submit!!')
  77. return false
  78. }
  79. })
  80. }
  81. }
  82. }
  83. </script>