createdMonthly.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <el-dialog :show="show" :title="title" :visible.sync="monthly_show" width="60%" class="public_task" @close="$emit('update:show', false)">
  3. <div class="blueStripe" />
  4. <div class="monthly-justify">
  5. <div class="monthly-thumb"><span style="color: #F56C6C;">*</span> 标题</div>
  6. <el-input v-model="monthly_form.title" placeholder="请输入" @input="getInput(monthly_form.title)" />
  7. </div>
  8. <div v-show="titles" class="monthly-tip"> 标题不能为空</div>
  9. <div class="monthly-justify">
  10. <div class="monthly-thumb"><span style="color: #F56C6C;">*</span> 缩略图</div>
  11. <el-upload action="http://star.xiaojukeji.com/upload/img.node" list-type="picture-card" :limit="1" :multiple="false" :on-success="handlePictureCardPreview">
  12. <i class="el-icon-plus" />
  13. <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过5MB</div>
  14. </el-upload>
  15. </div>
  16. <div v-show="thumb" class="monthly-tip"> 缩略图不能为空</div>
  17. <div class="monthly-justify">
  18. <div class="monthly-thumb"><span style="color: #F56C6C;">*</span> 素材</div>
  19. <el-upload action="http://star.xiaojukeji.com/upload/img.node" list-type="picture-card" :limit="1" :multiple="false" :on-success="handlePictureCardPreviewTow">
  20. <i class="el-icon-plus" />
  21. <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过5MB</div>
  22. </el-upload>
  23. </div>
  24. <div v-show="content" class="monthly-tip"> 素材不能为空</div>
  25. <span slot="footer" class="dialog-footer">
  26. <el-button @click="monthly_show = false">取 消</el-button>
  27. <el-button type="primary" @click="monthly_dialog">创 建</el-button>
  28. </span>
  29. </el-dialog>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. show: { type: Boolean, default: false },
  35. title: { type: String, required: true }
  36. },
  37. data() {
  38. return {
  39. monthly_show: this.show,
  40. monthly_form: {},
  41. content: false,
  42. thumb: false,
  43. titles: false
  44. }
  45. },
  46. watch: {
  47. show: {
  48. handler(newV) {
  49. this.monthly_show = newV
  50. },
  51. immediate: true
  52. }
  53. },
  54. methods: {
  55. monthly_dialog() {
  56. !this.monthly_form.title ? this.titles = true : ''
  57. !this.monthly_form.thumb ? this.thumb = true : ''
  58. !this.monthly_form.content ? this.content = true : ''
  59. if (!this.monthly_form.content || !this.monthly_form.thumb || !this.monthly_form.title) {
  60. return false
  61. }
  62. this.$emit('monthly_created', this.monthly_form)
  63. this.$emit('update:show', false)
  64. },
  65. getInput(one) {
  66. one ? this.titles = false : this.titles = true
  67. },
  68. handlePictureCardPreviewTow(file) {
  69. this.monthly_form.content = 'http:' + file.url
  70. this.content = false
  71. },
  72. handlePictureCardPreview(file) {
  73. this.monthly_form.thumb = 'http:' + file.url
  74. this.thumb = false
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .public_task {
  81. /deep/ .el-dialog__title {
  82. line-height: 24px;
  83. font-size: 16px;
  84. color: #303133;
  85. padding-left: 10px;
  86. }
  87. .monthly-justify {
  88. display: flex;
  89. justify-content: flex-start;
  90. margin-bottom: 20px;
  91. }
  92. .monthly-tip {
  93. color: #F56C6C;
  94. font-size: 12px;
  95. line-height: 1;
  96. padding-bottom: 20px;
  97. margin-left: 80px;
  98. }
  99. .monthly-thumb {
  100. width: 80px;
  101. font-size: 14px;
  102. color: #606266;
  103. font-weight: 700;
  104. line-height: 40px;
  105. padding: 0 12px 0 0;
  106. box-sizing: border-box;
  107. }
  108. .blueStripe {
  109. width:4px;
  110. height:17px;
  111. background:#409EFF;
  112. border-radius:1px;
  113. position: absolute;
  114. top: 23px;
  115. left: 20px;
  116. }
  117. }
  118. </style>