Rap 原分销系统代码Web
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9KB

  1. <template>
  2. <div>
  3. <el-button v-permission="permission.edit" :loading="crud.status.cu === 2" :disabled="disabledEdit" size="mini" type="primary" icon="el-icon-edit" @click="crud.toEdit(data)" />
  4. <el-popover v-model="pop" v-permission="permission.del" placement="top" width="180" trigger="manual" @show="onPopoverShow" @hide="onPopoverHide">
  5. <p>{{ msg }}</p>
  6. <div style="text-align: right; margin: 0">
  7. <el-button size="mini" type="text" @click="doCancel">取消</el-button>
  8. <el-button :loading="crud.dataStatus[crud.getDataId(data)].delete === 2" type="primary" size="mini" @click="crud.doDelete(data)">确定</el-button>
  9. </div>
  10. <el-button slot="reference" :disabled="disabledDle" type="danger" icon="el-icon-delete" size="mini" @click="toDelete" />
  11. </el-popover>
  12. </div>
  13. </template>
  14. <script>
  15. import CRUD, { crud } from '@crud/crud'
  16. export default {
  17. mixins: [crud()],
  18. props: {
  19. data: {
  20. type: Object,
  21. required: true
  22. },
  23. permission: {
  24. type: Object,
  25. required: true
  26. },
  27. disabledEdit: {
  28. type: Boolean,
  29. default: false
  30. },
  31. disabledDle: {
  32. type: Boolean,
  33. default: false
  34. },
  35. msg: {
  36. type: String,
  37. default: '确定删除本条数据吗?'
  38. }
  39. },
  40. data() {
  41. return {
  42. pop: false
  43. }
  44. },
  45. methods: {
  46. doCancel() {
  47. this.pop = false
  48. this.crud.cancelDelete(this.data)
  49. },
  50. toDelete() {
  51. this.pop = true
  52. },
  53. [CRUD.HOOK.afterDelete](crud, data) {
  54. if (data === this.data) {
  55. this.pop = false
  56. }
  57. },
  58. onPopoverShow() {
  59. setTimeout(() => {
  60. document.addEventListener('click', this.handleDocumentClick)
  61. }, 0)
  62. },
  63. onPopoverHide() {
  64. document.removeEventListener('click', this.handleDocumentClick)
  65. },
  66. handleDocumentClick(event) {
  67. this.pop = false
  68. }
  69. }
  70. }
  71. </script>