main.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div>
  3. <el-dialog :title="title" v-dialogDrag :visible.sync="visible" class="avue-dialog avue-dialog--top"
  4. width="500px" append-to-body @closed="closed">
  5. <span>
  6. <avue-form ref="form" :key="reload" v-model="form" :option="option"></avue-form>
  7. </span>
  8. <div class="avue-dialog__footer">
  9. <el-button @click="visible = false">取 消</el-button>
  10. <el-button @click="save" type="primary">确 定</el-button>
  11. </div>
  12. </el-dialog>
  13. </div>
  14. </template>
  15. <script>
  16. import {
  17. add
  18. } from '@/api/system/dictbiz'
  19. export default {
  20. data() {
  21. return {
  22. visible: false,
  23. form: {},
  24. option: {
  25. menuBtn: false,
  26. column: [
  27. {
  28. label: '字典名称',
  29. prop: 'dictValue',
  30. rules: [
  31. {
  32. required: true,
  33. message: "",
  34. trigger: "blur"
  35. }
  36. ],
  37. span: 24
  38. },
  39. {
  40. label: '字典键值',
  41. prop: 'dictKey',
  42. rules: [
  43. {
  44. required: true,
  45. message: "",
  46. trigger: "blur"
  47. }
  48. ],
  49. span: 24
  50. },
  51. {
  52. label: '字典排序',
  53. prop: 'sort',
  54. rules: [
  55. {
  56. required: true,
  57. message: "",
  58. trigger: "blur"
  59. }
  60. ],
  61. span: 24
  62. }
  63. ]
  64. }
  65. };
  66. },
  67. props: {
  68. title: {
  69. type: String,
  70. default: '添加字典'
  71. },
  72. code: {
  73. type: String,
  74. default: '添加字典'
  75. },
  76. parentId: {
  77. type: String,
  78. default: '0'
  79. }
  80. },
  81. created() { },
  82. methods: {
  83. open() {
  84. this.visible = true
  85. },
  86. closed() {
  87. this.reload = Math.random();
  88. this.form = this.$options.data().form
  89. this.$emit('closed')
  90. },
  91. save() {
  92. this.$refs["form"].validate((valid, done) => {
  93. done();
  94. if (valid) {
  95. let data = {
  96. ...this.form,
  97. code: this.code,
  98. isSealed: 0,
  99. parentId: this.parentId
  100. }
  101. add(data).then(res => {
  102. this.visible = false
  103. })
  104. } else {
  105. return false;
  106. }
  107. });
  108. }
  109. }
  110. };
  111. </script>
  112. <style scoped lang="scss">
  113. </style>