<template>
    <div>
        <el-form
            ref="form"
            :model="form"
            :rules="rules"
            label-width="220px"
            class="flexBox"
        >
            <div class="formItemBox">
                <el-form-item label="字典类型:" prop="dictTypes">
                    <el-input
                        placeholder="请输入，多个字典类型用英文逗号隔开"
                        v-autoTrim="{ obj: form, key: 'dictTypes' }"
                        v-model="form.dictTypes"
                    >
                    </el-input>
                </el-form-item>
                <el-form-item label="刷新结果:" prop="info">
                    {{form.info}}
                </el-form-item>
            </div>
        </el-form>
        <div class="btns">
            <el-button type="primary" @click="refresh">刷新</el-button>
        </div>
    </div>
</template>

<script>
export default {
    name: "dictManagement",
    components: {},
    data() {
        return {
            form: {
                dictTypes:"",
                info: ""
            },
            rules: {
                dictTypes:  [{ required: true, message: "请输入", trigger: "blur" }]
            }
        };
    },
    methods: {
        refresh(){
            this.$refs.form.validate((valid) => {
                if(valid){
                    this.$axios({
                    method:'POST',
                    url:this.$api.systemManagement.refreshDictsByTypes,
                    data:{
                        ...this.form
                    }
                    }).then(res => {
                        if(res.code == 200){
                            this.$message.success("刷新成功");
                            this.form.info = res.info;
                        }else{
                            this.$message.error(res.message || "刷新失败");
                        }
                    })
                }
            })
        }
    },
};
</script>

<style lang="less" scoped>
.el-form {
    width: 60%;
    min-width: 900px;
    padding-top: 60px;
    margin: 0 auto;

    .formItemBox {
        flex: 1;

        /deep/ .el-input,
        .el-select {
            width: 100%;
        }
    }
}

.btns {
    padding-top: 30px;
    text-align: center;
}
/deep/ input::-webkit-outer-spin-button,
/deep/ input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
}
</style>