<template>
    <el-table
        :data="tableData"
        border
        stripe
        :show-header="false"
        :cell-style="cellSttyle"
    >
        <el-table-column prop="label" align="center">
            <template slot-scope="scope">
                <c-button
                    @click="onNarBtnClick(scope.row.url, scope.row.label)"
                    :label="scope.row.label"
                    :disabled="scope.row.disabled"
                    >{{ scope.row.label }}</c-button
                >
                <!-- <el-link
          :disabled="scope.row.disabled"
          :href="scope.row.url"
          v-if="scope.row.title"
          >{{ scope.row.title }}</el-link
        > -->
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
import commonProcess from "~/mixin/commonProcess";
export default {
    inject: ["root"],
    props: ["data", "model"],
    mixins: [commonProcess], // 里面包含了Default、Check等的公共处理
    data() {
        return {
            cellSttyle: { height: "25px" },
            meumItem: [],
        };
    },
    methods: {
        //各入口按钮请求
        async onNarBtnClick(url, label) {
            let key = 0;
            for(let i = 1; i <= 11 ; i++){
                let temp_label = this.model.cfgfil['subtxt'+i];
                if(temp_label == label){
                    key = i;
                    break;
                }
            }
            //跳转后得执行请求。
            let rtnmsg = await this.executeRule("cfgfil.hotsub"+key);
            if (rtnmsg.respCode == SUCCESS) {
                this.updateModel(rtnmsg.data);
                url = url.toLowerCase();
                this.$router.history.push("/business/" + url);
            } else {
                this.$notify.error({
                    title: "错误",
                    message: "服务请求失败!",
                });
            }
        },
    },
    computed: {
        tableData() {
            const arr = [];
            var data = this.data;
            for (let i = 0; i < data.length; i++) {
                const items = data[i].split("\t");
                arr.push({
                    url: items[0],
                    label: items[1],
                    disabled: items[2] == "N" ? true : false,
                    other: items[3],
                });
            }
            return arr;
        },
    },
};
</script>

<style>
a {
    text-decoration-line: none;
    color: #606266;
}
a:hover {
    color: blue;
}
</style>