DelAbility.vue 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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, watch, toRef } from 'vue';
  19. import flow from '@/api/flow/flow';
  20. import { ElMessage } from 'element-plus';
  21. export default {
  22. props: {
  23. delModal: {
  24. type: Boolean,
  25. required: true
  26. },//父组件返回模态框状态
  27. modelIds: {
  28. type: String,
  29. required: true
  30. },//模型id
  31. delFcda: {
  32. type: String,
  33. required: true
  34. },//需要删除的fcdaid
  35. copyReload: {
  36. type: Function,
  37. required: true
  38. },//刷新父组件显示列表
  39. },
  40. setup(props, { emit }) {
  41. let dialogVisible = ref(false)//模态框开关
  42. let module = ref('')//本组件模型id
  43. let needDel = ref("")//本组件需要删除的fcdaid
  44. watch(() => props.modelIds, (newVal) => {
  45. module.value = newVal
  46. })
  47. watch(() => props.delFcda, (newVal) => {
  48. needDel.value = newVal
  49. })
  50. // 初始化函数
  51. function reload() {
  52. module.value = props.modelIds
  53. needDel.value = props.delFcda
  54. dialogVisible.value = props.delModal
  55. }
  56. function closeModal() {
  57. dialogVisible.value = false
  58. emit('delBack', dialogVisible.value)
  59. }
  60. function sureModal() {
  61. flow.delModelOn({
  62. model_id: module.value - 0,
  63. fcda_id: needDel.value - 0,
  64. }).then(res => {
  65. if (res.code == 0) {
  66. ElMessage({
  67. type: "success",
  68. message: "删除成功!"
  69. })
  70. props.copyReload()
  71. dialogVisible.value = false
  72. emit('delBack', dialogVisible.value)
  73. } else {
  74. ElMessage({
  75. message: res.msg,
  76. type: "error"
  77. })
  78. }
  79. })
  80. }
  81. onMounted(() => {
  82. reload()
  83. })
  84. return {
  85. reload,//初始化函数
  86. dialogVisible,//模态框开关
  87. closes: closeModal,//关闭模态框
  88. cancels: closeModal,//关闭模态框
  89. sureAdd: sureModal,//确认关闭模态框
  90. module,//本组件模型id
  91. needDel,//本组件需要删除的fcdaid
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped></style>