Blame view

src/views/oa/addNoticeViewList.vue 4.17 KB
ec9ec2ce   wuxw   开发完成物业公告问题
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  <template>
    <div class="add-notice-view-container">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>{{ $t('addNoticeView.title') }}</span>
        </div>
  
        <el-form ref="form" :model="addNoticeViewInfo" label-width="120px">
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('addNoticeView.titleLabel')" prop="title">
                <el-input v-model="addNoticeViewInfo.title" :placeholder="$t('addNoticeView.titlePlaceholder')" clearable />
              </el-form-item>
            </el-col>
          </el-row>
  
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('addNoticeView.noticeTypeLabel')" prop="noticeTypeCd">
                <el-select v-model="addNoticeViewInfo.noticeTypeCd" :placeholder="$t('addNoticeView.noticeTypePlaceholder')"
                  style="width:100%">
                  <el-option :label="$t('addNoticeView.noticeTypeOption1')" value="1000" />
                  <el-option :label="$t('addNoticeView.noticeTypeOption2')" value="1001" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
  
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('addNoticeView.contentLabel')" prop="context">
                <div class="editor-wrapper">
                  <rich-text-editor ref="richTextEditor" v-model="addNoticeViewInfo.context" />
                </div>
              </el-form-item>
            </el-col>
          </el-row>
  
          <el-row>
            <el-col :span="24" class="button-group">
              
              <el-button type="warning" @click="closeNoticeInfo">
                <i class="el-icon-close"></i>
                {{ $t('addNoticeView.cancel') }}
              </el-button>
              <el-button type="primary" @click="saveNoticeInfo">
                <i class="el-icon-check"></i>
                {{ $t('addNoticeView.submit') }}
              </el-button>
            </el-col>
          </el-row>
        </el-form>
      </el-card>
    </div>
  </template>
  
  <script>
  import { saveNotice } from '@/api/oa/addNoticeViewApi'
  import { getCommunityId } from '@/api/community/communityApi'
  import RichTextEditor from "@/components/editor/RichTextEditor";
  
  export default {
    name: 'AddNoticeViewList',
    components: {
      RichTextEditor
    },
    data() {
      return {
        addNoticeViewInfo: {
          title: '',
          noticeTypeCd: '',
          context: '',
          startTime: '',
          endTime: '',
          objType: '',
          objId: '',
          floorId: '',
          unitId: '',
          roomId: '',
          state: '3000',
          isAll: 'N'
        },
      }
    },
    created() {
      this.addNoticeViewInfo.communityId = getCommunityId()
    },
    methods: {
      onEditorChange({ quill, html, text }) {
        console.log('editor change!', quill, html, text)
        this.addNoticeViewInfo.context = html
      },
      validateForm() {
        let isValid = true
        if (!this.addNoticeViewInfo.title) {
          this.$message.error(this.$t('addNoticeView.validate.title'))
          isValid = false
        }
        if (!this.addNoticeViewInfo.noticeTypeCd) {
          this.$message.error(this.$t('addNoticeView.validate.noticeType'))
          isValid = false
        }
        if (!this.addNoticeViewInfo.context) {
          this.$message.error(this.$t('addNoticeView.validate.content'))
          isValid = false
        }
        return isValid
      },
      async saveNoticeInfo() {
        if (!this.validateForm()) {
          return
        }
  
        try {
          const response = await saveNotice(this.addNoticeViewInfo)
          if (response.code === 0) {
            this.$message.success(this.$t('addNoticeView.saveSuccess'))
            this.$router.go(-1)
          } else {
            this.$message.error(response.msg)
          }
        } catch (error) {
          this.$message.error(this.$t('addNoticeView.saveError'))
        }
      },
      closeNoticeInfo() {
        this.$router.go(-1)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .add-notice-view-container {
    padding: 20px;
  
    .box-card {
      margin-bottom: 20px;
    }
  
    .button-group {
      text-align: right;
      margin-top: 20px;
    }
  
    .editor-wrapper {
      height: 300px;
      margin-bottom: 20px;
  
      .ql-container {
        height: 250px;
      }
    }
  }
  </style>