CustomizeFormButtonSelect.vue 2.64 KB
<template>
    <div>
        <div class="selectList">
            <div v-for="(col, index) in columnsList" :key="index" class="selectBut"
                :class="{ 'pitchOn': pickerValue.includes(col.value) }" @click="handleBut(col)">
                {{ col.text }}
                <div v-if="pickerValue.includes(col.value)" class="pitchImg"></div>
            </div>
        </div>
    </div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-facing-decorator";

@Component({ components: {} })

export default class CustomizeFormButtonSelect extends Vue {

    @Prop({ default: () => [] })
    columnsList: any = [];

    pickerValue = []


    handleBut(item: { value: string }) {
        // if (item.value) {
        //     props.item.resultStatus = false;
        // }
        if (this.pickerValue.includes(item.value)) {
            this.pickerValue = this.pickerValue.filter((i) => i !== item.value);
        } else {
            this.pickerValue.push(item.value);
        }
        this.setupdate();
    }

    setupdate() {
        const valueList = (this.pickerValue || []).map(item => {
            const object = (this.columnsList || []).find(finditem => finditem.value == item) || {};
            return { valueText: object.text || "", valueKey: item || "" };
        });
        if (valueList.length > 0) {
            this.$emit("update", JSON.stringify(valueList || []));
        } else {
            this.$emit("update", "");
        }
    }

}
</script>

<style scoped lang="less">
.buttonSelect {
    float: left;
    width: 100%;
    background: #fff;
}

.title {
    float: left;
    width: 100%;
    height: 24px;
    padding-left: 16px;
    margin-top: 16px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 24px;
    color: #141e34;
}

.isRequired {
    padding-right: 2px;
    font-size: 14px;
    color: #ee3040;
}

.selectList {
    width: 100%;
}

.selectBut {
    position: relative;
    float: left;
    min-width: 76px;
    padding: 0 24px;
    height: 36px;
    margin-right: 6px;
    margin-bottom: 12px;
    margin-left: 6px;
    font-size: 14px;
    font-weight: 400;
    line-height: 36px;
    color: #333;
    text-align: center;
    cursor: pointer;
    background: #f9f9f9;
    border: 1px solid #f9f9f9;
    border-radius: 6px;
}

.pitchOn {
    color: #185EFE !important;
    background: #ecf1ff !important;
    border: 1px solid #185efe !important;
}

.pitchImg {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 99;
    width: 16px;
    height: 16px;
    background-image: url("https://img02.glsx.com.cn/aus/images/preference/pitchOn.png");
    background-repeat: no-repeat;
    background-size: 100%;
}
</style>