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

84 рядки
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 { guanggao2 } from '@/api/car'
  29. import { saveGuangGao } from '@/api/homePage'
  30. import uploadFile from '@/components/uploadFile'
  31. export default {
  32. components: {
  33. uploadFile
  34. },
  35. data() {
  36. return {
  37. ruleForm: {
  38. id: '',
  39. image: '',
  40. link: '',
  41. newOpen: '1'
  42. },
  43. rules: {
  44. image: [
  45. { required: true, message: '请上传图片', trigger: 'blur' }
  46. ],
  47. link: [
  48. { required: true, message: '请输入链接', trigger: 'blur' }
  49. ]
  50. }
  51. }
  52. },
  53. created() {
  54. this.getData()
  55. },
  56. methods: {
  57. getData() {
  58. guanggao2().then(res => {
  59. this.ruleForm.id = res.id
  60. this.ruleForm.image = res.image
  61. this.ruleForm.link = res.link
  62. this.ruleForm.newOpen = res.newOpen
  63. })
  64. },
  65. submitForm(formName) {
  66. this.$refs[formName].validate((valid) => {
  67. if (valid) {
  68. saveGuangGao(this.ruleForm).then(res => {
  69. this.$message({
  70. message: '操作成功!',
  71. type: 'success'
  72. })
  73. })
  74. } else {
  75. console.log('error submit!!')
  76. return false
  77. }
  78. })
  79. }
  80. }
  81. }
  82. </script>