zjf
2023-03-08 92b359a6458fb985b78431e0a2f54b548e01b1ca
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
  <create-view :body-style="{height: '100%'}">
    <div class="details-box">
      <div
        slot="header"
        class="header">
        <span class="text">公告详情</span>
        <span
          class="el-icon-close rt"
          @click="close"/>
      </div>
      <div class="content">
        <div class="title">{{ titleList.title }}</div>
        <div class="time">{{ titleList.createTime }}</div>
        <div class="text">{{ titleList.content }}</div>
      </div>
      <div
        v-if="btnShow"
        class="btn-box">
        <el-button
          v-if="permissionUpdate"
          type="primary"
          @click="onEdit">编辑</el-button>
        <el-button
          v-if="permissionDelete"
          type="danger"
          @click="deleteFun">删除</el-button>
      </div>
    </div>
    <v-edit
      v-if="showEdit"
      :form-data="formData"
      :loading="loading"
      @editSubmit="editSubmit"
      @editClose="editClose"/>
  </create-view>
</template>
 
<script>
import CreateView from '@/components/CreateView'
import VEdit from './edit'
// API
// import { noticeDelete, noticeAdd } from '@/api/oamanagement/notice'
import { mapGetters } from 'vuex'
 
export default {
  components: {
    CreateView,
    VEdit
  },
  props: {
    titleList: Object,
    btnShow: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      showEdit: false,
      formData: {},
      loading: false
    }
  },
  computed: {
    ...mapGetters(['oa']),
    permissionUpdate () {
      return this.oa && this.oa.announcement && this.oa.announcement.update
    },
    permissionDelete () {
      return this.oa && this.oa.announcement && this.oa.announcement.delete
    }
  },
  methods: {
    onEdit () {
      this.formData = Object.assign({}, this.titleList)
      this.showEdit = true
    },
    close () {
      this.$emit('close')
    },
    deleteFun () {
      this.$confirm('确定删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // noticeDelete({
          //   id: this.titleList.announcementId
          // }).then(res => {
          //   this.$emit('deleteFun')
          //   this.$message({
          //     type: 'success',
          //     message: '删除成功!'
          //   })
          // })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 编辑 -- 取消
    editClose () {
      this.showEdit = false
    },
    // 编辑 -- 确定
    editSubmit () {
      this.loading = true
      // noticeAdd({
      //   announcementId: this.formData.announcementId,
      //   title: this.formData.title,
      //   content: this.formData.content,
      //   startTime: this.formData.startTime,
      //   endTime: this.formData.endTime
      // })
      //   .then(res => {
      //     this.$emit('editSubmit', this.formData)
      //     this.editClose()
      //     this.$message.success('公告编辑成功')
      //     this.loading = false
      //   })
      //   .catch(() => {
      //     this.loading = false
      //     this.$message.error('公告编辑失败')
      //   })
    }
  }
}
</script>
 
<style scoped lang="scss">
$size16: 16px;
.details-box {
  display: flex;
  flex-direction: column;
  height: 100%;
  .header {
    .text {
      font-size: $size16;
    }
    .el-icon-close {
      font-size: 20px;
      color: #ccc;
      margin-right: 0;
      cursor: pointer;
    }
  }
  .content {
    margin-top: 10px;
    flex: 1;
    overflow: auto;
    .title {
      font-size: $size16;
      text-align: center;
    }
    .time {
      color: #999;
      text-align: center;
      font-size: 12px;
      margin-top: 8px;
    }
    .text {
      margin-top: 20px;
      line-height: 24px;
      color: #333;
      padding: 0 20px;
      white-space: pre-wrap;
      word-wrap: break-word;
    }
  }
  .btn-box {
    text-align: right;
    padding-right: 20px;
  }
}
</style>