Delrm.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div>
  3. <el-dialog v-model="dialogVisible" title="删除" width="30%" @close="closes" :close-on-click-modal="false">
  4. <div style="display: flex;justify-content:center;align-items: center;">
  5. <el-icon style="color: red;font-size: 40px;display: block;">
  6. <WarningFilled />
  7. </el-icon>
  8. <span style="display: block;">是否确认删除该信息?</span>
  9. </div>
  10. <div style="display: flex;justify-content:center;align-items: center;margin-top: 40px;">
  11. <el-button style="display: block;width: 150px;height: 30px;" @click="cancels">取消</el-button>
  12. <el-button style="display: block;width: 150px;height: 30px;" type="primary" @click="sureAdd">确认</el-button>
  13. </div>
  14. </el-dialog>
  15. </div>
  16. </template>
  17. <script>
  18. import { ref, onMounted, toRefs, watch } from 'vue'
  19. import report from '@/api/report'
  20. import { ElMessage } from 'element-plus'
  21. export default {
  22. props: {
  23. delModal: {
  24. type: Boolean,
  25. required: true
  26. },
  27. delId: {
  28. type: String,
  29. required: true
  30. },
  31. searchReport: {
  32. type: Function,
  33. required: true
  34. }
  35. },
  36. setup(props, { emit }) {
  37. let dialogVisible = ref(false)
  38. let result = props.delModal
  39. let resultId = props.delId
  40. let lete = ref('')
  41. watch(() => props.delId, (newVal) => {
  42. lete.value = newVal
  43. })
  44. function reload() {
  45. dialogVisible.value = result
  46. lete.value = props.delId
  47. }
  48. function allClose() {
  49. dialogVisible.value = false
  50. emit("delrmBack", dialogVisible.value)
  51. }
  52. function allTrue() {
  53. report.delReport({ id: lete.value - 0 }).then(res => {
  54. if (res.code == 0) {
  55. ElMessage({
  56. type: "success",
  57. message: "删除成功"
  58. })
  59. props.searchReport()
  60. dialogVisible.value = false
  61. emit("delrmBack", dialogVisible.value)
  62. }
  63. })
  64. }
  65. onMounted(() => {
  66. reload()
  67. })
  68. return {
  69. dialogVisible,
  70. reload,
  71. closes: allClose,
  72. cancels: allClose,
  73. sureAdd: allTrue,
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped></style>