addCollectClassifyDia.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <el-dialog
  3. :visible.sync="show"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body='false'
  6. :title="form.classifyId?'编辑目录':'新增目录'"
  7. @close="closeDia"
  8. custom-class="edbCollect-classify-dialog"
  9. center
  10. width="650px"
  11. v-dialogDrag
  12. >
  13. <el-form
  14. :model="classifyForm"
  15. :rules="formRules"
  16. ref="formRef"
  17. hide-required-asterisk
  18. label-width="auto"
  19. >
  20. <!-- 目录名称 -->
  21. <el-form-item prop="classifyName" label="目录名称">
  22. <el-input
  23. type="text"
  24. v-model="classifyForm.classifyName"
  25. placeholder="请输入目录名称"
  26. style="width:80%"
  27. />
  28. </el-form-item>
  29. </el-form>
  30. <div class="footer" style="margin-top: 20px;">
  31. <el-button
  32. @click="closeDia"
  33. >{{ $t('Dialog.cancel_btn') }}</el-button>
  34. <el-button
  35. @click="saveClassifyHandle"
  36. type="primary"
  37. >{{ $t('Dialog.confirm_save_btn') }}</el-button>
  38. </div>
  39. </el-dialog>
  40. </template>
  41. <script>
  42. import { edbCollectInterface } from '@/api/modules/chartApi'
  43. export default {
  44. props: {
  45. show: {
  46. type: Boolean
  47. },
  48. form: {
  49. type:Object
  50. }
  51. },
  52. watch: {
  53. show(newVal) {
  54. if(!newVal) return
  55. this.classifyForm.classifyName = this.form.name;
  56. }
  57. },
  58. data() {
  59. return {
  60. classifyForm: {
  61. classifyName:""
  62. },
  63. formRules: {
  64. classifyName: [{ required:true,message:'目录名称不能为空',trigger:'blur'}]
  65. }
  66. }
  67. },
  68. methods: {
  69. closeDia() {
  70. this.$refs.formRef.resetFields()
  71. this.$emit('update:show',false)
  72. },
  73. async saveClassifyHandle() {
  74. await this.$refs.formRef.validate()
  75. const res = this.form.classifyId
  76. ? await edbCollectInterface.editCollectClassify({
  77. ClassifyName: this.classifyForm.classifyName,
  78. ClassifyId: this.form.classifyId
  79. })
  80. : await edbCollectInterface.addCollectClassify({
  81. ClassifyName: this.classifyForm.classifyName,
  82. })
  83. if(res.Ret !== 200) return
  84. this.$message.success(this.form.classifyId?'编辑成功':'新增成功');
  85. this.closeDia()
  86. this.$emit('confirm')
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .edbCollect-classify-dialog {
  93. .el-form {
  94. padding: 0 40px;
  95. }
  96. .footer {
  97. display: flex;
  98. justify-content: center;
  99. margin: 40px 0;
  100. .el-button {
  101. width: 130px;
  102. }
  103. }
  104. }
  105. </style>