123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <template>
- <div class="card-name-edit">
- <div class="style-edit mb-2">
- <el-button
- size="small"
- :type="isBold ? 'primary' : 'default'"
- @click="boldChange"
- >B</el-button
- >
- <size-select
- v-model="modalForm.nameFontSize"
- :predefine="PREDEFINE_OPTIONS"
- class="ml-2 escape"
- @change="emitChange"
- >
- </size-select>
- </div>
- <el-input
- v-model="modalForm.topicName"
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 5 }"
- resize="none"
- placeholder="请输入题目名称"
- clearable
- :style="styles"
- @input="emitChange"
- ></el-input>
- </div>
- </template>
- <script>
- import { objAssign } from "../../plugins/utils";
- import SizeSelect from "./SizeSelect.vue";
- const initModalForm = {
- topicName: "",
- nameFontSize: "14px",
- nameFontWeight: 400,
- };
- export default {
- name: "CardNameEdit",
- components: { SizeSelect },
- props: {
- value: {
- type: Object,
- default() {
- return {
- topicName: "",
- nameFontSize: "14px",
- nameFontWeight: 400,
- };
- },
- },
- },
- data() {
- return {
- modalForm: { ...initModalForm },
- PREDEFINE_OPTIONS: [
- {
- value: "14px",
- label: "小",
- },
- {
- value: "18px",
- label: "中",
- },
- {
- value: "21px",
- label: "大",
- },
- ],
- };
- },
- watch: {
- value: {
- immediate: true,
- handler(val) {
- this.initData(val);
- },
- },
- },
- computed: {
- isBold() {
- return this.modalForm.nameFontWeight === 700;
- },
- styles() {
- return {
- fontWeight: this.modalForm.nameFontWeight,
- fontSize: this.modalForm.nameFontSize,
- };
- },
- },
- methods: {
- initData() {
- this.modalForm = objAssign(initModalForm, this.value);
- },
- boldChange() {
- this.modalForm.nameFontWeight = this.isBold ? 400 : 700;
- this.emitChange();
- },
- emitChange() {
- const val = objAssign(this.value, this.modalForm);
- this.$emit("input", val);
- this.$emit("change", val);
- },
- },
- };
- </script>
- <style lang="scss">
- .card-name-edit textarea {
- font-weight: inherit;
- }
- </style>
|