index.vue 3.19 KB
Newer Older
何虹's avatar
何虹 committed
1
<template>
何虹's avatar
何虹 committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  <div
    :id='elId'
    class="selectBoxPlus"
    style='width:100%;height:100%;'
  >
    <div
      class="contarnBox"
      style='width:100%;height:100%;'
    >
      <div
        class="selectTitle"
        v-show='configData.title'
      >{{configData.title}}</div>
      <div
        class="selectCurr"
        style='width:80%;height:100%;'
      >
        <el-date-picker
          @change='changed'
          size='mini'
          v-model="value_inner"
          :type="configData.type"
          :value-format="configData.valueFormat"
          :placeholder="configData.placeholder"
          :range-separator="configData.rangeSeparator"
          :start-placeholder="configData.startPlaceholder"
          :end-placeholder="configData.endPlaceholder"
        >
        </el-date-picker>
      </div>
何虹's avatar
何虹 committed
32
    </div>
何虹's avatar
何虹 committed
33 34 35 36 37 38 39
    <jsoneditor
      v-model='jsoneditorVisible'
      :elInfo='elInfo'
      :layout='layout'
      :jsoneditorCloseAfter='jsoneditorCloseAfter'
      :jsoneditorOpenAfter='jsoneditorOpenAfter'
    >
何虹's avatar
何虹 committed
40 41 42 43
    </jsoneditor>
  </div>
</template>
<script>
何虹's avatar
何虹 committed
44 45
import jsoneditor from "../common/jsoneditor";
import ucComponent from "../ucClass/uc_component";
何虹's avatar
何虹 committed
46 47 48 49 50
export default {
  mixins: [ucComponent],
  components: {
    jsoneditor
  },
何虹's avatar
何虹 committed
51
  name: "hs-date-picker",
何虹's avatar
何虹 committed
52 53 54 55
  props: {
    elInfo: {
      type: Object,
      default() {
何虹's avatar
何虹 committed
56
        return {};
何虹's avatar
何虹 committed
57 58 59 60 61
      }
    },
    allSourceData: {
      type: Object,
      default() {
何虹's avatar
何虹 committed
62
        return {};
何虹's avatar
何虹 committed
63 64
      }
    },
何虹's avatar
何虹 committed
65
    value: "",
何虹's avatar
何虹 committed
66 67 68 69 70 71 72 73 74 75 76
    layout: {},
    jsoneditorCloseAfter: {
      type: Function
    },
    jsoneditorOpenAfter: {
      type: Function
    }
  },
  watch: {
    allSourceData: {
      handler: function(newVal, oldVal) {
何虹's avatar
何虹 committed
77 78
        const { config } = newVal;
        this.initConfig(config);
何虹's avatar
何虹 committed
79 80 81 82
      },
      deep: true
    },
    value(val) {
何虹's avatar
何虹 committed
83
      this.value_inner = val;
何虹's avatar
何虹 committed
84 85
    },
    value_inner(val) {
何虹's avatar
何虹 committed
86
      this.$emit("input", val);
何虹's avatar
何虹 committed
87 88 89 90
    }
  },
  data() {
    return {
何虹's avatar
何虹 committed
91 92
      elId: "",
      value_inner: "",
何虹's avatar
何虹 committed
93 94
      jsoneditorVisible: false,
      configData: {}
何虹's avatar
何虹 committed
95
    };
何虹's avatar
何虹 committed
96 97
  },
  mounted() {
何虹's avatar
何虹 committed
98 99
    const { config } = this.allSourceData;
    this.initConfig(config);
何虹's avatar
何虹 committed
100 101
  },
  methods: {
何虹's avatar
何虹 committed
102 103 104 105 106 107 108 109 110 111 112
    execAction(actionName, value) {
      const type = typeof actionName;
      if (type === "function") {
        actionName(value, this.formData);
      }
    },
    changed(value) {
      this.$emit('changed',value);
      const { changed } = this.configData;
      this.execAction(changed,value)
    },
何虹's avatar
何虹 committed
113
    initConfig(config) {
何虹's avatar
何虹 committed
114 115
      if (!config) return;
      this.configData = config;
何虹's avatar
何虹 committed
116 117
    }
  }
何虹's avatar
何虹 committed
118
};
何虹's avatar
何虹 committed
119 120
</script>
<style scoped>
何虹's avatar
何虹 committed
121
.hsInputBox {
何虹's avatar
何虹 committed
122
  padding: 1px;
何虹's avatar
何虹 committed
123 124
  width: 100%;
  height: 100%;
何虹's avatar
何虹 committed
125 126
  display: flex;
}
何虹's avatar
何虹 committed
127
.hsInputInner {
何虹's avatar
何虹 committed
128 129 130
  height: 80%;
  width: 80%;
}
何虹's avatar
何虹 committed
131 132
.inputTitle {
  flex: 1;
何虹's avatar
何虹 committed
133 134 135 136
  display: flex;
  justify-content: center;
  align-items: center;
}
何虹's avatar
何虹 committed
137 138
.inputCurr {
  flex: 1;
何虹's avatar
何虹 committed
139 140 141 142 143
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}
何虹's avatar
何虹 committed
144
.contarnBox {
何虹's avatar
何虹 committed
145 146
  display: flex;
}
何虹's avatar
何虹 committed
147 148
.selectTitle {
  flex: 1;
何虹's avatar
何虹 committed
149 150 151 152
  display: flex;
  justify-content: center;
  align-items: center;
}
何虹's avatar
何虹 committed
153
.selectCurr {
何虹's avatar
何虹 committed
154 155 156 157 158
  flex: 3;
  display: flex;
  justify-content: center;
  align-items: center;
}
何虹's avatar
何虹 committed
159 160
.selectBoxPlus >>> .el-select > .el-input {
  height: 100%;
何虹's avatar
何虹 committed
161
}
何虹's avatar
何虹 committed
162
.selectBoxPlus >>> .el-select .el-input__inner {
何虹's avatar
何虹 committed
163 164 165
  height: 100%;
}
</style>