edit.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <el-row>
  3. <el-row style="padding-top: 50px;width: 1500px;padding-left: 30px">
  4. <el-form ref="form" :model="form" :rules="formRules" label-width="120px">
  5. <el-row>
  6. <el-col :span="12">
  7. <el-row>
  8. <el-form-item label="标题" prop="bannerTitle">
  9. <el-input v-model="form.bannerTitle" placeholder="在这里输入标题" show-word-limit maxlength="40"></el-input>
  10. </el-form-item>
  11. </el-row>
  12. <el-row style="height: 350px;width: 615px;margin-top: 10px">
  13. <el-form-item label="缩略图" prop="imageUrl">
  14. <material-dialog v-model="form.imageUrl" sourceType="banner" style="height: 350px;width: 615px;border-radius: 4px"></material-dialog>
  15. </el-form-item>
  16. </el-row>
  17. <el-row style="margin-top: 30px">
  18. <el-form-item label="网址">
  19. <el-input v-model="form.bannerUrl" placeholder="在这里输入URL"></el-input>
  20. </el-form-item>
  21. </el-row>
  22. </el-col>
  23. <el-col :span="11" :offset="1" style="margin-top: 61px">
  24. <el-row>
  25. <div style="height: 350px;width: 615px;"><img :src="OSS_URL + form.imageUrl" style="height: 350px;width: 615px;border-radius: 4px"></div>
  26. </el-row>
  27. </el-col>
  28. </el-row>
  29. </el-form>
  30. </el-row>
  31. <el-row style="padding: 3px 150px;text-align: left;">
  32. <el-button type="primary" @click="toBack">取消</el-button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  33. <el-button type="primary" @click="handleSave">保存</el-button>
  34. </el-row>
  35. </el-row>
  36. </template>
  37. <script>
  38. import materialDialog from '@/views/material/dialog'
  39. import bannerDetailApi from '@/api/bannerDetailApi'
  40. export default {
  41. name: 'bannerDetail',
  42. components: {
  43. 'material-dialog': materialDialog
  44. },
  45. data () {
  46. return {
  47. form: {
  48. id: '',
  49. bannerTitle: '',
  50. imageUrl: '',
  51. bannerUrl: '',
  52. bannerOn: 0
  53. },
  54. formRules: {
  55. bannerTitle: { required: true, message: '请输入标题', trigger: 'blur' },
  56. imageUrl: { required: true, message: '请选择缩略图', trigger: 'blur' }
  57. }
  58. }
  59. },
  60. mounted () {
  61. this.form['id'] = this.$route.params.msgKey
  62. this.findById()
  63. var s = document.getElementsByClassName('el-card is-hover-shadow')
  64. s[0].style.height = '350px'
  65. s[1].style.height = '350px'
  66. },
  67. methods: {
  68. toBack () {
  69. this.$confirm('是否取消创建/修改文章?,并退出编辑页面', {
  70. confirmButtonText: '继续退出',
  71. cancelButtonText: '留下',
  72. type: 'primary'
  73. }).then(() => {
  74. this.$router.push({name: 'Banner'})
  75. }).catch(() => {
  76. this.$message({
  77. type: 'info',
  78. message: '已退出编辑页面'
  79. })
  80. })
  81. },
  82. handleSave () {
  83. this.$refs['form'].validate((valid) => {
  84. if (!valid) {
  85. return false
  86. }
  87. this.$confirm('是否马上发布文章?', {
  88. confirmButtonText: '是',
  89. cancelButtonText: '否',
  90. type: 'primary'
  91. }).then(() => {
  92. bannerDetailApi.save(this.form).then(data => {
  93. this.$router.push({name: 'Banner'})
  94. })
  95. }).catch(() => {
  96. this.$message({
  97. type: 'info',
  98. message: '已取消发布'
  99. })
  100. })
  101. })
  102. },
  103. findById () {
  104. if (this.form['id']) {
  105. bannerDetailApi.findById(this.form['id']).then(data => {
  106. this.form['id'] = data.id
  107. this.form['bannerTitle'] = data.bannerTitle
  108. this.form['imageUrl'] = data.imageUrl
  109. this.form['bannerUrl'] = data.bannerUrl
  110. this.form['bannerOn'] = data.bannerOn
  111. })
  112. }
  113. }
  114. }
  115. }
  116. </script>
  117. <style scoped>
  118. .el-icon-circle-plus {
  119. font-size: 50px;
  120. }
  121. /deep/ .el-dialog {
  122. margin-top: 10vh
  123. }
  124. /deep/ .el-button--primary {
  125. background-color: #2493e5;
  126. border-color: #2493e5;
  127. }
  128. /deep/ .el-button--mini, .el-button--mini.is-round{
  129. padding: 9px 19px;
  130. }
  131. /deep/ .el-input--mini .el-input__inner{
  132. height: 32px;
  133. }
  134. /deep/ .el-icon-circle-plus-outline{
  135. margin-top: 100px;
  136. }
  137. </style>