You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UD.operation.vue 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!-- 默认插槽值 -->
  2. <template>
  3. <el-button v-if="isEdit" size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  4. <!-- 弹出框提示 trigger="click" -->
  5. <el-popover v-if="isDelete" trigger="click" v-model:visible="scope.row.visible" placement="top" :width="160">
  6. <div>
  7. <div style="margin-bottom: 10px;">
  8. <span>是否确认删除该条数据?</span>
  9. </div>
  10. <div class="as-layout-horizontal">
  11. <el-button type="text" @click="scope.row.visible = false" style="width: 100%;">取消</el-button>
  12. <el-button type="primary" @click="handleDelete(scope.$index, scope.row)" style="color: #fff;
  13. margin-right: 10px;">确认</el-button>
  14. </div>
  15. </div>
  16. <template #reference>
  17. <el-button size="small" type="danger" @click="hintDelete(scope.$index,data)">删除</el-button>
  18. </template>
  19. </el-popover>
  20. </template>
  21. <script>
  22. import CRUD, {
  23. crudConfig
  24. } from "@/crud/crud"
  25. export default {
  26. mixins: [crudConfig()], //运用混入的的方法
  27. emits: ['handleDelete', 'handleEdit'],
  28. props: { //插值
  29. scope: {
  30. default: null,
  31. type: Object
  32. },
  33. data: {
  34. default: null,
  35. type: Object
  36. },
  37. isEdit: {
  38. default: true,
  39. type: Boolean
  40. },
  41. isDelete: {
  42. default: true,
  43. type: Boolean
  44. }
  45. },
  46. data() { //字段
  47. return {
  48. that: this
  49. }
  50. },
  51. methods: { //方法
  52. handleDelete(idx, data) {
  53. this.$emit('handleDelete', idx, data)
  54. },
  55. //编辑
  56. handleEdit(idx, row) {
  57. this.$emit('handleEdit', idx, row)
  58. },
  59. //删除弹窗
  60. hintDelete(idx, data) {
  61. data.forEach((element, index) => {
  62. if (idx === index) {
  63. element.visible = true
  64. } else {
  65. element.visible = false
  66. }
  67. });
  68. }
  69. }
  70. }
  71. </script>
  72. <style scoped>
  73. </style>