hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<template>
  <div class="status_add">
    <v-header title="社区宣传"></v-header>
    <div class="edit">
      <editor-bar
        :disabled="!checked"
        v-model="content"
        :isClear="isClear"
        @change="change"
      ></editor-bar>
    </div>
    <div class="btn">
      <el-button type="primary" size="small" @click="sub">
        {{ checked ? "保存" : "编辑" }}
      </el-button>
    </div>
  </div>
</template>
 
<script>
import EditorBar from "com/wangEnduit/index"; //富文本组件
export default {
  components: { EditorBar },
  data() {
    return {
      checked: false,
      isClear: false,
      edit: false,
      detail: "",
      content: ""
    };
  },
 
  methods: {
    sub() {
      if (!this.checked) {
        this.checked = true;
        return;
      }
 
      // if (!this.content) {
      //   demo.toast("请输入内容");
      //   return 0;
      // }
 
      let method = "post";
      let url = "common/data/addCommunityPublicityDate";
      // if (this.edit) {
      //   method = "post";
      //   url = "common/data/editCommunityPublicityDate";
      // }
      const USER_INFO = demo.$session.get("user");
      this.$api[method](
        url,
        { communityId: USER_INFO.communityId, content: this.content },
        e => {
          demo.toast("保存成功");
          this.reset();
        }
      );
    },
    reset() {
      this.checked = false;
    },
    //编辑富文本
    change(val) {
      this.content = val;
    },
    getDetail() {
      const USER_INFO = demo.$session.get("user");
 
      this.$api.get(
        "common/data/getCommunityPublicityData",
        { communityId: USER_INFO.communityId },
        e => {
          this.content = e.content;
          this.edit = this.content.length > 0;
        }
      );
    }
  },
  mounted() {
    this.getDetail();
  }
};
</script>
<style lang="less" scoped>
.image-box {
  position: relative;
  /*overflow: hidden;*/
  max-width: 300px;
}
.clear-icon {
  cursor: pointer;
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
}
.image {
  width: 100%;
  object-fit: cover;
  /*width: 300px;*/
}
.status_add {
  overflow-y: auto;
  .edit,
  .zd,
  .btn {
    margin-bottom: 10px;
    padding: 0 40px;
  }
  .sec:last-child {
    margin-bottom: 0;
  }
  article {
    max-width: 300px;
  }
  .article-maxwidth {
    .el-radio {
      margin-bottom: 10px;
    }
  }
}
.radio-text {
  width: 100%;
  font-size: 10px;
  color: #7f7f7f;
}
</style>