EditLine.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <el-dialog
  3. class="edit-line edit-dialog"
  4. :visible.sync="dialogIsShow"
  5. title="线条编辑"
  6. top="10vh"
  7. width="640px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="opened"
  12. @close="closed"
  13. >
  14. <el-form
  15. ref="modalFormComp"
  16. :model="modalForm"
  17. :key="modalForm.id"
  18. label-width="100px"
  19. >
  20. <el-form-item label="线条颜色:">
  21. <color-select v-model="modalForm.color"></color-select>
  22. </el-form-item>
  23. <el-form-item label="线条粗细:">
  24. <line-width-select v-model="modalForm.bold"></line-width-select>
  25. </el-form-item>
  26. <el-form-item label="线条形状:">
  27. <line-style-select v-model="modalForm.style"></line-style-select>
  28. </el-form-item>
  29. </el-form>
  30. <div slot="footer">
  31. <el-button type="primary" @click="submit">确认</el-button>
  32. <el-button @click="cancel" plain>取消</el-button>
  33. </div>
  34. </el-dialog>
  35. </template>
  36. <script>
  37. import ColorSelect from "../common/ColorSelect";
  38. import LineStyleSelect from "../common/LineStyleSelect";
  39. import LineWidthSelect from "../common/LineWidthSelect";
  40. const initModalForm = {
  41. id: "",
  42. bold: "1px",
  43. color: "#000000",
  44. style: "solid"
  45. };
  46. export default {
  47. name: "edit-line",
  48. components: { ColorSelect, LineStyleSelect, LineWidthSelect },
  49. props: {
  50. instance: {
  51. type: Object,
  52. default() {
  53. return {};
  54. }
  55. }
  56. },
  57. data() {
  58. return {
  59. dialogIsShow: false,
  60. modalForm: { ...initModalForm }
  61. };
  62. },
  63. methods: {
  64. initData(val) {
  65. this.modalForm = { ...val };
  66. },
  67. opened() {
  68. this.initData(this.instance);
  69. },
  70. closed() {
  71. this.$emit("closed");
  72. },
  73. cancel() {
  74. this.dialogIsShow = false;
  75. },
  76. open() {
  77. this.dialogIsShow = true;
  78. },
  79. submit() {
  80. this.$emit("modified", this.modalForm);
  81. this.cancel();
  82. }
  83. }
  84. };
  85. </script>