ModifyRequirementNode.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <el-dialog
  3. :visible.sync="modalIsShow"
  4. :title="title"
  5. top="10vh"
  6. width="400px"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. @open="visibleChange"
  11. >
  12. <el-form ref="modalFormComp" :model="modalForm" label-width="80px">
  13. <el-form-item label="子节点数:">
  14. <el-input-number
  15. v-model="modalForm.nodeCount"
  16. :min="0"
  17. :max="10"
  18. :step="1"
  19. step-strictly
  20. :controls="false"
  21. ></el-input-number>
  22. </el-form-item>
  23. </el-form>
  24. <div slot="footer">
  25. <el-button type="primary" :disabled="isSubmit" @click="submit"
  26. >确认</el-button
  27. >
  28. <el-button @click="cancel">取消</el-button>
  29. </div>
  30. </el-dialog>
  31. </template>
  32. <script>
  33. import { professionalRequirementSave } from "../../api";
  34. const initModalForm = {
  35. id: null,
  36. professionalId: "",
  37. name: "",
  38. sortNum: "",
  39. nodeCount: 0,
  40. };
  41. export default {
  42. name: "modify-requirement-node",
  43. props: {
  44. instance: {
  45. type: Object,
  46. default() {
  47. return {};
  48. },
  49. },
  50. },
  51. computed: {
  52. isEdit() {
  53. return !!this.instance.nodeCount;
  54. },
  55. title() {
  56. return (this.isEdit ? "编辑" : "新增") + "子节点";
  57. },
  58. },
  59. data() {
  60. return {
  61. modalIsShow: false,
  62. isSubmit: false,
  63. modalForm: { ...initModalForm },
  64. };
  65. },
  66. methods: {
  67. initData(val) {
  68. this.modalForm = this.$objAssign(initModalForm, val);
  69. },
  70. visibleChange() {
  71. this.initData(this.instance);
  72. },
  73. cancel() {
  74. this.modalIsShow = false;
  75. },
  76. open() {
  77. this.modalIsShow = true;
  78. },
  79. async submit() {
  80. if (this.isSubmit) return;
  81. this.isSubmit = true;
  82. let datas = { ...this.modalForm };
  83. const data = await professionalRequirementSave(datas).catch(() => {});
  84. this.isSubmit = false;
  85. if (!data) return;
  86. this.$message.success("操作成功!");
  87. this.$emit("modified");
  88. this.cancel();
  89. },
  90. },
  91. };
  92. </script>