DelLine.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div>
  3. <div>
  4. <el-dialog v-model="dialogVisible" title="删除信息" width="30%" @close="closes" :close-on-click-modal="false">
  5. <div style="display: flex;justify-content:center;align-items: center;">
  6. <el-icon style="color: red;font-size: 40px;display: block;">
  7. <WarningFilled />
  8. </el-icon>
  9. <span style="display: block;">是否确认删除该信息?</span>
  10. </div>
  11. <template #footer>
  12. <span class="dialog-footer">
  13. <el-button @click="cancels">取消</el-button>
  14. <el-button type="primary" @click="sureClick">
  15. 确定
  16. </el-button>
  17. </span>
  18. </template>
  19. </el-dialog>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { ref, onMounted, toRefs, watch } from 'vue';
  25. import { ElMessage } from 'element-plus';
  26. import litLine from '@/api/litLine';
  27. export default {
  28. props: {
  29. delModal: {
  30. type: Boolean,
  31. required: true
  32. },
  33. needList: {
  34. type: Object,
  35. required: true
  36. },
  37. sunSearch: {
  38. type: Function,
  39. required: true
  40. },
  41. flashId: {
  42. type: String,
  43. required: true,
  44. },//litline.vue传过来的电压id
  45. checkFlash: {
  46. type: Function,
  47. required: true,
  48. },//litline.vue传过来的便于刷新页面的方法
  49. },
  50. setup(props, { emit }) {
  51. let dialogVisible = ref(false)
  52. let result = props.delModal
  53. let lastList = props.needList
  54. let delId = ref('')
  55. let { cancels, sureClick } = toRefs(props)
  56. let flashIds = ref("")//本组件的电压等级id
  57. watch(() => props.flashId, (newVal) => {
  58. flashIds.value = newVal
  59. })
  60. function lineList() {
  61. delId.value = lastList.id
  62. dialogVisible.value = result
  63. flashIds.value = props.flashId
  64. }
  65. function canBack() {
  66. dialogVisible.value = false
  67. emit("delBack", dialogVisible.value)
  68. }
  69. function sureGet() {
  70. litLine.delLine({ id: delId.value - 0 }).then(res => {
  71. if (res.code == 0) {
  72. ElMessage({
  73. type: "success",
  74. message: "删除成功",
  75. duration: 1500
  76. })
  77. if (flashIds.value) {
  78. props.checkFlash(flashIds.value)
  79. } else {
  80. props.sunSearch()
  81. }
  82. dialogVisible.value = false
  83. emit("delBack", dialogVisible.value)
  84. }
  85. })
  86. }
  87. onMounted(() => {
  88. lineList()
  89. })
  90. return {
  91. dialogVisible,
  92. cancels: canBack,
  93. sureClick: sureGet,
  94. closes: canBack,
  95. flashIds,
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped></style>