ModifyAppBaselineItem.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <el-dialog
  3. class="modify-app-baseline-item"
  4. :visible.sync="modalIsShow"
  5. title="应用配置基线配置项修改"
  6. top="10vh"
  7. width="540px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @opened="visibleChange"
  12. >
  13. <el-form ref="modalFormComp" :model="modalForm" label-width="80px">
  14. <el-form-item prop="key" label="配置项:">
  15. {{ modalForm.key }}
  16. </el-form-item>
  17. <el-form-item prop="mode" label="模式:">
  18. <el-select v-model="modalForm.mode" placeholder="请选择模式" clearable>
  19. <el-option
  20. v-for="item in modes"
  21. :key="item.code"
  22. :value="item.code"
  23. :label="item.name"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item prop="comment" label="注释:">
  28. <el-input
  29. v-model.trim="modalForm.comment"
  30. placeholder="请输入编码"
  31. clearable
  32. ></el-input>
  33. </el-form-item>
  34. </el-form>
  35. <div slot="footer">
  36. <el-button type="danger" @click="cancel" plain>取消</el-button>
  37. <el-button type="primary" :disabled="isSubmit" @click="submit"
  38. >确认</el-button
  39. >
  40. </div>
  41. </el-dialog>
  42. </template>
  43. <script>
  44. import { appConfigBaselineItemUpdate } from "../api";
  45. const initModalForm = {
  46. appId: "",
  47. moduleId: "",
  48. versionId: "",
  49. key: "",
  50. mode: "",
  51. comment: "",
  52. };
  53. export default {
  54. name: "modify-app-baseline-item",
  55. props: {
  56. instance: {
  57. type: Object,
  58. default() {
  59. return {};
  60. },
  61. },
  62. modes: {
  63. type: Array,
  64. default() {
  65. return [];
  66. },
  67. },
  68. },
  69. data() {
  70. return {
  71. modalIsShow: false,
  72. isSubmit: false,
  73. modalForm: { ...initModalForm },
  74. };
  75. },
  76. methods: {
  77. initData(val) {
  78. this.modalForm = this.$objAssign(initModalForm, val);
  79. this.$refs.modalFormComp.clearValidate();
  80. },
  81. visibleChange() {
  82. this.initData(this.instance);
  83. },
  84. cancel() {
  85. this.modalIsShow = false;
  86. },
  87. open() {
  88. this.modalIsShow = true;
  89. },
  90. async submit() {
  91. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  92. if (!valid) return;
  93. if (this.isSubmit) return;
  94. this.isSubmit = true;
  95. let datas = { ...this.modalForm };
  96. const data = await appConfigBaselineItemUpdate(datas).catch(() => {});
  97. this.isSubmit = false;
  98. if (!data) return;
  99. this.$message.success("修改成功!");
  100. this.$emit("modified", data);
  101. this.cancel();
  102. },
  103. },
  104. };
  105. </script>