Geen omschrijving

index.vue 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div>
  3. <el-dialog title="系统消息编辑" :visible.sync="dialogFormVisible">
  4. <el-form :model="formNotice" ref="formNotice" :rules="rules">
  5. <el-input type="textarea" rows="6" maxlength="100" v-model="formNotice.desc" @input="limitFn"></el-input>
  6. </el-form>
  7. <div class="limit_num">还可以输入{{ableNum}}字</div>
  8. <div slot="footer" class="dialog-footer">
  9. <el-button v-waves @click="dialogFormVisible = false">取 消</el-button>
  10. <el-button type="primary" v-waves @click="setNotice('formNotice')">确 定</el-button>
  11. </div>
  12. </el-dialog>
  13. <el-menu class="message-box" mode="horizontal">
  14. <div class="marquee_box">
  15. <span class="tit">系统公告:</span>
  16. <el-tooltip placement="bottom-end" effect="dark">
  17. <div slot="content" class="popper-tips">{{formNotice.desc}}</div>
  18. <div class="marquee_text">{{formNotice.desc}}</div>
  19. </el-tooltip>
  20. <span class="btn-span" v-if="isShow" @click="openNoticeDialog">设置</span>
  21. </div>
  22. </el-menu>
  23. </div>
  24. </template>
  25. <script>
  26. import waves from '@/directive/waves'
  27. import { getNotice, updateNotice } from '@/api/login'
  28. export default {
  29. props: {
  30. isShow: {
  31. type: Boolean
  32. }
  33. },
  34. directives: {
  35. waves
  36. },
  37. data() {
  38. return {
  39. dialogFormVisible: false,
  40. ableNum: 100,
  41. formNotice: {
  42. desc: ''
  43. },
  44. rules: {
  45. desc: [
  46. { required: true, message: '请编辑内容发送', trigger: 'blur' },
  47. { max: 100, message: '不得超过100个字', trigger: 'blur' }
  48. ]
  49. }
  50. }
  51. },
  52. created() {
  53. this.getNotice()
  54. },
  55. methods: {
  56. limitFn() {
  57. this.ableNum = 100 - this.formNotice.desc.length
  58. },
  59. getNotice() {
  60. getNotice().then(res => {
  61. if (res.success) {
  62. this.formNotice.desc = res.data
  63. this.limitFn()
  64. }
  65. })
  66. },
  67. openNoticeDialog() {
  68. this.dialogFormVisible = true
  69. },
  70. setNotice(formName) {
  71. this.$refs[formName].validate((valid) => {
  72. if (valid) {
  73. const param = {
  74. cnt: this.formNotice.desc
  75. }
  76. updateNotice(param).then(res => {
  77. if (res.success) {
  78. this.dialogFormVisible = false
  79. this.$refs[formName].resetFields()
  80. }
  81. })
  82. } else {
  83. return false
  84. }
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style rel="stylesheet/scss" lang="scss" scoped>
  91. .message-box{
  92. height: 50px;
  93. line-height: 50px;
  94. border-radius: 0px !important;
  95. color: #303133;
  96. background: #c7e3ff;
  97. padding: 0 20px;
  98. font-size: 14px;
  99. .marquee_box {
  100. width: 100%;
  101. position: relative;
  102. height: 50px;
  103. overflow: hidden;
  104. .marquee_text {
  105. line-height: 50px;
  106. position:absolute;
  107. top:0;
  108. padding-left: 0;
  109. left:68px;
  110. right:80px;
  111. box-sizing: border-box;
  112. text-overflow: ellipsis;
  113. white-space:nowrap;
  114. overflow: hidden;
  115. }
  116. .btn-span{
  117. position:absolute;
  118. top:0;
  119. right:0;
  120. cursor: pointer;
  121. }
  122. }
  123. }
  124. .limit_num{
  125. font-size: 14px;
  126. color: #ff0000;
  127. text-align: right;
  128. }
  129. .popper-tips{
  130. font-size: 13px;
  131. line-height: 20px;
  132. display:block;
  133. max-width: 500px;
  134. word-break: break-all;
  135. }
  136. </style>