Skip to content

Instantly share code, notes, and snippets.

@wisetc
Last active August 9, 2019 10:04
Show Gist options
  • Select an option

  • Save wisetc/aebffa1cac04377a7062f3bd68621be2 to your computer and use it in GitHub Desktop.

Select an option

Save wisetc/aebffa1cac04377a7062f3bd68621be2 to your computer and use it in GitHub Desktop.
增删改查报告结果
import { Message } from 'element-ui'
function noop {}
export default function report (data, type='', callback=noop) {
let map = {
create: '新增',
update: '修改',
destroy: '删除'
}
let msg = map[type] || type || '操作'
if (data.code === 1) {
Message.success(msg + '成功')
typeof callback === 'function' && callback(data)
} else {
Message.error(msg + '失败。' + data.msg)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment