重写 iView
中Modal对话框取消和确定按钮
需求:点击审核按钮弹出对话框,对话框中取消按钮和确定按钮分为改为审核不通过和审核通过按钮,从而实现审核功能。
<Modal v-model="showAuditModal" :mask-closeable="false" @on-cancel="cancel" width="410">
<p class="audit-title">
<Icon type="ios-help-circle" size="28" style="margin-right:10px;color:#ff9900;"></Icon>
<span>审核图片</span>
</p>
<div style="text-align:center;height:50px;">
<p>已选择{{ids.length}}条数据,是否通过审核?</p>
</div>
<div slot="footer">
<Button @click="handleSubmit(2)" :loading="saveLoading">审核不通过</Button>
<Button type="primary" @click="handleSubmit(1)" :loading="saveLoading">审核通过</Button>
</div>
</Modal>
<script>
// 审核
handleAudit() {
let rows = this.$refs.table.getSelection()
if(!row.length) {
this.$Notice.warning({
title: '错误提示',
desc: '请选择要审核的数据'
})
return false
}
for(let i = 0; i < rows.length; i++) {
if(rows[i].status != 1) {
this.$Notice.warning({
title: '错误提示',
desc: '只能操作审核中状态的数据,请重新选择'
})
return false
}
}
this.ids = rows.map(item => item.id)
this.showAuditModal = true
}
handleSubmit(type) {
this.saveLoading = true
approveImage({
ids: this.ids,
status: type
}).then(res => {
this.$Notice.success({
title: '成功提示',
desc: '操作成功'
})
this.showAuditModal = false
this.saveLoading = false
this.refresh(true)
}).catch(res => {
this.saveLoading = false
})
}
// 右上角关闭
cancel() {
this.saveLoading = false
this.showAuditModal = false
this.ids = []
}