<template>
    <ap-container>
        <ap-main margin="1111">
            <ap-table ref="tSysConfigQywxRef" :options.sync="tSysConfigQywxOpt"></ap-table>
        </ap-main>
    </ap-container>
</template>

<script>
export default {
    name: 'SysConfigQywx',
    data() {
        let columns = [
            {
                prop: 'fdType',
                label: '类型',
                type: 'select',
                width: 120,
                selectOptions: [{label: "corpId", value: 1}, {label: "应用", value: 2}]
            }, {
                prop: 'fdCode',
                label: '编码',
                type: 'input',
                edit: this.editApp
            }, {
                prop: 'fdAgentId',
                label: '应用Id',
                type: 'input',
                edit: this.editApp
            }, {
                prop: 'fdSecret',
                label: '秘钥',
                type: 'input',
                edit: this.editApp
            }, {
                prop: 'fdValue',
                label: '键值',
                type: 'input',
                edit: this.editCronId
            }
        ];
        let tableOpt = {
            title: "企业微信配置",
            columns: columns,
            editPk: "fdId", //默认fdId
            deletePk: "fdId", // 默认fdId
            dataUrl: "/apm/sys/TSysConfigQywx/getTSysConfigQywxGridList",
            saveUrl: "/apm/sys/TSysConfigQywx/saveTSysConfigQywxGridData",
            deleteUrl: "/apm/sys/TSysConfigQywx/deleteTSysConfigQywxGridData",
            toolbarBtn: [{
                btnType: "primary",
                text: "刷新缓存",
                icon: "el-icon-magic-stick",
                onClick: this.refreshCache
            }, "separator", "add", "edit", "del", "cancel", "refresh", "save"],
            initData: true, // 默认false
            params: {}
        };
        return {
            tSysConfigQywxOpt: tableOpt,
        }
    },
    methods: {
        editCronId(rowData) {
            return rowData.fdType == 1;
        },
        editApp(rowData) {
            return rowData.fdType == 2;
        },
        refreshCache(){
            this.$request({
                url: '/apm/sys/TSysConfigQywx/refreshQywxConfigCache',
                method: 'post',
            }).then(response => {
                this.$message.success(`缓存刷新成功！`)
            })
        }
    }
}
</script>

<style scoped>
</style>
