detail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <CusDialog
  3. :show="show"
  4. :title="titleCpt"
  5. @onClose="$emit('update:show', false)"
  6. width="400px"
  7. height="auto"
  8. @onSubmit="onSubmit"
  9. :loading="state.loading"
  10. >
  11. <div class="__cus-dialog-form">
  12. <CusForm ref="ref_form" label-width="80">
  13. <CusFormColumn
  14. :span="24"
  15. required
  16. label="账号"
  17. v-model:param="state.form.indexName"
  18. />
  19. <CusFormColumn
  20. :span="24"
  21. required
  22. label="用户名"
  23. v-model:param="state.form.indexName"
  24. />
  25. <CusFormColumn
  26. :span="24"
  27. required
  28. label="状态"
  29. v-model:param="state.form.shareMethod"
  30. link="select"
  31. :options="DictionaryStore.gxMethodList"
  32. />
  33. </CusForm>
  34. </div>
  35. </CusDialog>
  36. </template>
  37. <script setup lang="ts">
  38. import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue";
  39. import {useDictionaryStore} from "@/stores";
  40. import {ElMessage, ElMessageBox} from "element-plus";
  41. const emit = defineEmits(['update:show', 'refresh'])
  42. const {proxy} = getCurrentInstance()
  43. const DictionaryStore = useDictionaryStore()
  44. const props = defineProps({
  45. show: {default: false},
  46. transfer: {}
  47. })
  48. const state: any = reactive({
  49. form: {},
  50. loading: false
  51. })
  52. const ref_form = ref()
  53. const titleCpt = computed(() => {
  54. let t = ''
  55. switch (props.transfer.mode) {
  56. case 'add': t = '新增用户'
  57. break
  58. case 'edit': t = '编辑用户'
  59. break
  60. }
  61. return t
  62. })
  63. const onSubmit = () => {
  64. ref_form.value.submit().then(() => {
  65. ElMessageBox.confirm("是否提交?", "提示", {
  66. confirmButtonText: "确定",
  67. cancelButtonText: "取消",
  68. type: "warning",
  69. } as any).then(() => {
  70. // state.loading = true
  71. // sysIndexSaveOrUpdate(state.form).then(res => {
  72. // if (res.code === 200) {
  73. // ElMessage.success(props.transfer.mode === 'add' ? '新增成功!' : '编辑成功!')
  74. // emit('update:show', false)
  75. // emit('refresh')
  76. // } else {
  77. // ElMessage.error(res.msg)
  78. // }
  79. // state.loading = false
  80. // })
  81. }).catch(() => {})
  82. }).catch((e) => {
  83. ElMessage({
  84. message: e[0].message,
  85. grouping: true,
  86. type: 'warning',
  87. })
  88. })
  89. }
  90. const initDetail = () => {
  91. // state.loading = true
  92. // sysIndexGetDetail(props.transfer.id).then(res => {
  93. // if (res.code === 200) {
  94. // state.form = res.data
  95. // state.loading = false
  96. // } else {
  97. // ElMessage.error(res.msg)
  98. // }
  99. // })
  100. }
  101. watch(() => props.show, (n) => {
  102. if (n) {
  103. initDictionary()
  104. if (props.transfer.mode === 'add') {
  105. state.form = {}
  106. } else {
  107. initDetail()
  108. }
  109. nextTick(() => {
  110. ref_form.value.reset()
  111. })
  112. }
  113. })
  114. const initDictionary = () => {
  115. DictionaryStore.initDict('gx_method')
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. </style>