feat: add buttons that update journal type directly (#610)

pull/619/head
zjy4fun 2022-09-13 23:43:45 +08:00 committed by GitHub
parent 3bdecc30dd
commit 1b225858bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 2 deletions

View File

@ -49,10 +49,16 @@
<a-icon type="message" /> <a-icon type="message" />
{{ item.commentCount }} {{ item.commentCount }}
</a-button> </a-button>
<a-button v-if="item.type === 'INTIMATE'" class="!p-0" disabled type="link"> <a-button
v-if="item.type === 'INTIMATE'"
class="!p-0"
type="link"
@click="handleJournalTypeUpdate(item)"
style="color: grey"
>
<a-icon type="lock" /> <a-icon type="lock" />
</a-button> </a-button>
<a-button v-else class="!p-0" type="link"> <a-button v-else class="!p-0" type="link" @click="handleJournalTypeUpdate(item)">
<a-icon type="unlock" /> <a-icon type="unlock" />
</a-button> </a-button>
</template> </template>
@ -321,6 +327,18 @@ export default {
this.form.model.content = renderContent this.form.model.content = renderContent
}, },
handleJournalTypeUpdate(item) {
this.form.model = deepClone(item)
this.form.model.type = item.type === 'PUBLIC' ? 'INTIMATE' : 'PUBLIC'
apiClient.journal
.update(this.form.model.id, this.form.model)
.catch(e => {
this.$log.error(e)
})
.finally(() => {
this.handleListJournals()
})
},
handleSaveOrUpdate() { handleSaveOrUpdate() {
const _this = this const _this = this
_this.$refs.journalForm.validate(valid => { _this.$refs.journalForm.validate(valid => {