index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <script>
  2. export default {
  3. name: "DrInputDialog",
  4. props: [
  5. "value",
  6. "title",
  7. "type",
  8. "dataMapping",
  9. "source",
  10. "placeholder",
  11. "clearable",
  12. "disabled",
  13. "readonly",
  14. "size",
  15. ],
  16. components: {
  17. InputDialog: () => import("./components/index.vue"),
  18. },
  19. data() {
  20. return {};
  21. },
  22. computed: {},
  23. watch: {},
  24. methods: {
  25. handleAsyncOpenDialog() {
  26. this.$nextTick(() => {
  27. const { setVisible } = this.$refs.InputDialogFef;
  28. setVisible(true);
  29. });
  30. },
  31. handleUpdateSource(prop) {
  32. const { source, dataMapping } = this.$props;
  33. for (let key in dataMapping) {
  34. source[key] = prop[dataMapping[key]];
  35. }
  36. this.$emit("update:source", source);
  37. console.log("type", this.$props.type);
  38. console.log("dataMapping", dataMapping);
  39. console.log("prop", prop);
  40. console.log("source", this.$props.source);
  41. },
  42. },
  43. created() {
  44. console.log("prop", this.$props);
  45. },
  46. mounted() {},
  47. destroyed() {},
  48. };
  49. </script>
  50. <template>
  51. <el-input
  52. v-model="value"
  53. :placeholder="placeholder"
  54. :clearable="clearable"
  55. :disabled="disabled"
  56. :readonly="readonly"
  57. :size="size"
  58. style="width: 100%; cursor: pointer"
  59. @click.native.stop="handleAsyncOpenDialog"
  60. >
  61. <template #suffix>
  62. <el-icon class="el-icon-thumb"></el-icon>
  63. <input-dialog
  64. ref="InputDialogFef"
  65. :title="title"
  66. :type="type"
  67. @confirm="handleUpdateSource"
  68. ></input-dialog>
  69. </template>
  70. </el-input>
  71. </template>
  72. <style scoped>
  73. ::v-deep.el-input .el-input__suffix {
  74. display: flex;
  75. align-items: center;
  76. }
  77. </style>