EditUndertaking.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <el-dialog
  3. class="edit-undertaking edit-dialog"
  4. :visible.sync="modalIsShow"
  5. title="编辑承诺书"
  6. top="10vh"
  7. width="640px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. :before-close="cancel"
  11. append-to-body
  12. @open="initData"
  13. >
  14. <h3 class="ut-title">考生承诺书</h3>
  15. <p>本人郑重承诺:</p>
  16. <el-form
  17. ref="modalFormComp"
  18. :model="modalForm"
  19. :rules="rules"
  20. label-width="0"
  21. >
  22. <el-form-item prop="undertakingBody">
  23. <el-input
  24. type="textarea"
  25. :rows="4"
  26. placeholder="请输入内容"
  27. v-model="modalForm.undertakingBody"
  28. maxlength="100"
  29. show-word-limit
  30. class="ut-textarea"
  31. @input="contentChange"
  32. >
  33. </el-input>
  34. </el-form-item>
  35. </el-form>
  36. <p class="ut-std">承诺人(签名):</p>
  37. <div slot="footer">
  38. <el-button type="primary" @click="submit">确认</el-button>
  39. <el-button @click="cancel">取消</el-button>
  40. </div>
  41. </el-dialog>
  42. </template>
  43. <script>
  44. import { mapState, mapMutations } from "vuex";
  45. export default {
  46. name: "edit-undertaking",
  47. props: {
  48. instance: {
  49. type: Object,
  50. default() {
  51. return {};
  52. },
  53. },
  54. },
  55. data() {
  56. return {
  57. modalForm: { undertakingBody: "" },
  58. modalIsShow: false,
  59. rules: {
  60. undertakingBody: [
  61. {
  62. required: true,
  63. message: "请输入文本内容",
  64. trigger: "change",
  65. },
  66. ],
  67. },
  68. };
  69. },
  70. computed: {
  71. ...mapState("card", ["cardConfig"]),
  72. },
  73. methods: {
  74. ...mapMutations("card", ["setCardConfig"]),
  75. initData() {
  76. this.modalForm = {
  77. undertakingBody: this.cardConfig.undertakingBody,
  78. };
  79. },
  80. contentChange() {
  81. this.modalForm.undertakingBody = this.modalForm.undertakingBody.replace(
  82. "\n",
  83. ""
  84. );
  85. },
  86. cancel() {
  87. this.modalIsShow = false;
  88. },
  89. open() {
  90. this.modalIsShow = true;
  91. },
  92. async submit() {
  93. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  94. if (!valid) return;
  95. this.setCardConfig(this.modalForm);
  96. this.cancel();
  97. },
  98. },
  99. };
  100. </script>
  101. <style scoped>
  102. .ut-title {
  103. text-align: center;
  104. }
  105. .ut-std {
  106. text-align: right;
  107. margin-right: 100px;
  108. }
  109. .ut-textarea >>> .el-textarea__inner {
  110. padding: 5px;
  111. text-indent: 28px;
  112. font-size: 14px;
  113. margin: 0 -5px;
  114. }
  115. </style>