<template>
    <el-card shadow="never" header="其他配置">
        <el-form
            ref="form"
            :model="form"
            label-width="auto"
            style="margin-top: 20px"
            >
            <el-form-item label="领料时校验是否检验(总开关,物料可单独设为免检)">
                <el-switch v-model="form.mes.check_test_when_do_out"></el-switch>
            </el-form-item>
            <el-divider />
            <el-form-item label="小牛短信名">
                <el-input v-model="form.sms.xn_sign"></el-input>
            </el-form-item>
            <el-form-item label="小牛短信key">
                <el-input v-model="form.sms.xn_key"></el-input>
            </el-form-item>
            <el-form-item label="小牛短信secret">
                <el-input v-model="form.sms.xn_secret"></el-input>
            </el-form-item>
            <el-form-item label="_">
                <el-button type="primary" @click="submitForm" :loading="saveLoading">提交</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</template>
<script>
export default {
    name: 'otherSet',
    data() {
        return {
            saveLoading: false,
            form: {
                mes: {},
                apk: {},
                sms: {}
            }
        }
    },
    mounted() {
        this.getSysConfig();
    },
    methods: {
        getSysConfig() {
            this.$API.system.config.getInfo.req().then(res=>{
                this.form = {
                    mes: res.mes || {},
                    sms: res.sms || {}
                }
            })
        },
        submitForm() {
            this.saveLoading = true;
            this.$API.system.config.updateInfo.req({
                mes: this.form.mes,
                sms: this.form.sms
            }).then(() => {
                this.$message.success("保存成功");
                this.saveLoading = false;
            }).catch(() => {
                this.saveLoading = false;
            })
        }
    }
}

</script>