fix my own fault (previous version of bindings did not work)

This commit is contained in:
Alexey Vorobev 2022-06-16 04:20:02 +04:00
parent 3b632252fb
commit 517d834876

View file

@ -68,19 +68,19 @@
<a-divider type="vertical"/> <a-divider type="vertical"/>
<a-popconfirm <a-popconfirm
v-if="soft_delete&&params.trashed" v-if="soft_delete&&params.trashed"
cancelText="{{restore.cancel_text}}" :cancelText="cancel_text"
okText="{{restore.ok_text}}" :okText="ok_text"
title="{{restore.title_text}}" :title="restore_title_text"
@confirm="restore.exec(record[rowKey])"> @confirm="restore(record[rowKey])">
<a href="javascript:;">{{restore.action_text}}</a> <a href="javascript:;">{{restore_action_text}}</a>
</a-popconfirm> </a-popconfirm>
<a-popconfirm <a-popconfirm
v-else v-else
cancelText="{{destroy.cancel_text}}" :cancelText="cancel_text"
okText="{{destroy.ok_text}}" :okText="ok_text"
title="{{destroy.title_text}}" :title="destroy_title_text"
@confirm="destroy.exec(record[rowKey])"> @confirm="destroy(record[rowKey])">
<a href="javascript:;">{{destroy.action_text}}</a> <a href="javascript:;">{{destroy_action_text}}</a>
</a-popconfirm> </a-popconfirm>
</template> </template>
</div> </div>
@ -129,14 +129,13 @@ export default {
return this.$gettext('Edit') return this.$gettext('Edit')
} }
}, },
restore: { restore_title_text: {
title_text: {
type: String, type: String,
default() { default() {
return this.$gettext('Are you sure you want to restore?') return this.$gettext('Are you sure you want to restore?')
} }
}, },
action_text: { restore_action_text: {
type: String, type: String,
default() { default() {
return this.$gettext('Restore') return this.$gettext('Restore')
@ -154,51 +153,18 @@ export default {
return this.$gettext('No, I\'m rethink') return this.$gettext('No, I\'m rethink')
} }
}, },
exec(id) { destroy_title_text: {
this.api.restore(id).then(() => {
this.get_list()
this.$message.success('反删除 ID: ' + id + ' 成功')
}).catch(e => {
console.log(e)
this.$message.error(e?.message ?? '系统错误')
})
},
},
destroy: {
title_text: {
type: String, type: String,
default() { default() {
return this.$gettext('Are you sure you want to destroy?') return this.$gettext('Are you sure you want to destroy?')
} }
}, },
action_text: { destroy_action_text: {
type: String, type: String,
default() { default() {
return this.$gettext('Destroy') return this.$gettext('Destroy')
} }
}, },
ok_text: {
type: String,
default() {
return this.$gettext('Yes, I\'m sure')
}
},
cancel_text: {
type: String,
default() {
return this.$gettext('No, I\'m rethink')
}
},
exec(id) {
this.api.destroy(id).then(() => {
this.get_list()
this.$message.success('删除 ID: ' + id + ' 成功')
}).catch(e => {
console.log(e)
this.$message.error(e?.message ?? '系统错误')
})
},
},
deletable: { deletable: {
type: Boolean, type: Boolean,
default: true default: true
@ -252,6 +218,24 @@ export default {
this.get_list() this.get_list()
}, },
methods: { methods: {
restore(id) {
this.api.restore(id).then(() => {
this.get_list()
this.$message.success('反删除 ID: ' + id + ' 成功')
}).catch(e => {
console.log(e)
this.$message.error(e?.message ?? '系统错误')
})
},
destroy(id) {
this.api.destroy(id).then(() => {
this.get_list()
this.$message.success('删除 ID: ' + id + ' 成功')
}).catch(e => {
console.log(e)
this.$message.error(e?.message ?? '系统错误')
})
},
get_list(page_num = null) { get_list(page_num = null) {
this.loading = true this.loading = true
if (page_num) { if (page_num) {