12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <template>
- <div class="value-modify">
- <el-select
- v-if="available.options && available.options.length"
- v-model="inputValue"
- clearable
- @change="valChange"
- >
- <el-option
- v-for="item in available.options"
- :key="item"
- :value="item"
- :label="item"
- >
- </el-option>
- </el-select>
- <el-input-number
- v-else-if="available.type === 'number'"
- v-model="inputValue"
- :controls="false"
- @change="valChange"
- ></el-input-number>
- <el-switch
- v-else-if="available.type === 'boolean'"
- v-model="inputValue"
- active-color="#13ce66"
- inactive-color="#ff4949"
- @change="valChange"
- >
- </el-switch>
- <el-input
- v-else
- v-model="inputValue"
- :maxlength="500"
- @input="valChange"
- ></el-input>
- </div>
- </template>
- <script>
- export default {
- name: "value-modify",
- props: {
- value: {
- type: [String, Number, Boolean, Array],
- default: null
- },
- available: {
- type: Object,
- default() {
- return {
- type: "string",
- defaultValue: "",
- options: []
- };
- }
- }
- },
- data() {
- return {
- inputValue: null
- };
- },
- watch: {
- value: {
- immediate: true,
- handler(val) {
- this.inputValue = val;
- }
- }
- },
- methods: {
- valChange() {
- this.$emit("input", this.inputValue);
- this.$emit("change", this.inputValue);
- }
- }
- };
- </script>
|