index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <script>
  2. export default {
  3. name: "DrInputDialog",
  4. props: ["value", "title", "type", "dataMapping", "source"],
  5. components: {
  6. InputDialog: () => import("./components/index.vue"),
  7. },
  8. data() {
  9. return {};
  10. },
  11. computed: {},
  12. watch: {},
  13. methods: {
  14. handleAsyncOpenDialog() {
  15. this.$emit("before-open");
  16. this.$nextTick(() => {
  17. const { setVisible } = this.$refs.InputDialogFef;
  18. setVisible(true);
  19. });
  20. },
  21. handleUpdateSource(prop) {
  22. const { source, dataMapping } = this.$props;
  23. for (let key in dataMapping) {
  24. source[key] = prop[dataMapping[key]];
  25. }
  26. this.$emit("update:source", source);
  27. },
  28. },
  29. created() {
  30. console.log("prop", this.$props);
  31. },
  32. mounted() {},
  33. destroyed() {},
  34. };
  35. </script>
  36. <template>
  37. <el-input
  38. v-model="value"
  39. style="width: 100%; cursor: pointer"
  40. @click.native.stop="handleAsyncOpenDialog"
  41. >
  42. <template #suffix>
  43. <el-icon class="el-icon-thumb"></el-icon>
  44. <input-dialog
  45. ref="InputDialogFef"
  46. :title="title"
  47. :type="type"
  48. @confirm="handleUpdateSource"
  49. ></input-dialog>
  50. </template>
  51. </el-input>
  52. </template>
  53. <style scoped></style>