2018-04-01 14:33:01 +00:00
|
|
|
<template>
|
2019-02-01 09:23:00 +00:00
|
|
|
<div class="editable-cell">
|
2019-09-28 12:45:07 +00:00
|
|
|
<div v-if="editable" class="editable-cell-input-wrapper">
|
|
|
|
<a-input :value="value" @change="handleChange" @pressEnter="check" /><a-icon
|
2019-02-01 09:23:00 +00:00
|
|
|
type="check"
|
|
|
|
class="editable-cell-icon-check"
|
|
|
|
@click="check"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-09-28 12:45:07 +00:00
|
|
|
<div v-else class="editable-cell-text-wrapper">
|
2019-02-01 09:23:00 +00:00
|
|
|
{{ value || ' ' }}
|
2019-09-28 12:45:07 +00:00
|
|
|
<a-icon type="edit" class="editable-cell-icon" @click="edit" />
|
2019-02-01 09:23:00 +00:00
|
|
|
</div>
|
2018-04-01 14:33:01 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
text: String,
|
|
|
|
},
|
2019-09-28 12:45:07 +00:00
|
|
|
data() {
|
2018-04-01 14:33:01 +00:00
|
|
|
return {
|
|
|
|
value: this.text,
|
|
|
|
editable: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-04-01 14:33:01 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2019-09-28 12:45:07 +00:00
|
|
|
handleChange(e) {
|
2019-01-12 03:33:27 +00:00
|
|
|
const value = e.target.value;
|
|
|
|
this.value = value;
|
2018-04-01 14:33:01 +00:00
|
|
|
},
|
2019-09-28 12:45:07 +00:00
|
|
|
check() {
|
2019-01-12 03:33:27 +00:00
|
|
|
this.editable = false;
|
|
|
|
this.$emit('change', this.value);
|
2018-04-01 14:33:01 +00:00
|
|
|
},
|
2019-09-28 12:45:07 +00:00
|
|
|
edit() {
|
2019-01-12 03:33:27 +00:00
|
|
|
this.editable = true;
|
2018-04-01 14:33:01 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2019-09-28 12:45:07 +00:00
|
|
|
</script>
|