<!-- redis key 添加 -->
<template>
    <div class="vue-box submit-box--dialog" style="width: 600px;">
        <!-- ------- 内容部分 ------- -->
        <div class="c-card">
            <el-form v-if="state.model" label-width="7em">
                <in-input name="key：" v-model="state.model.key"></in-input>
                <in-input name="value：" v-model="state.model.value" type="textarea"></in-input>
                <in-input name="ttl：" v-model="state.model.ttl" type="num" placeholder="过期时间 单位/毫秒"></in-input>
            </el-form>
        </div>
    </div>
</template>

<script setup name="redis-key-add">
import {reactive} from "vue";


// ------------------ 数据 ------------------
const state = reactive({
    model: {
        key: '',
        value: '',
        ttl: '',
        is_show: true
    }
})

// ------------------ 函数 ------------------

// 修改
const ok = function(){
    // 开始验证
    var model = state.model;
    sa.checkNull(model.key, '请输入键');
    sa.checkNull(model.value, '请输入值');
    sa.checkNull(model.ttl, '请输入ttl (过期时间)');
    sa.check(isNaN(model.ttl), 'ttl 必须是一个数字 ');

    // 添加
    model.ttl = parseInt(model.ttl);
    sa.ajax('/RedisConsole/set', model, function(){
        sa.closeModel();
        sa.currView().state.dataListShow.unshift(model);
        sa.msg('添加成功');
    });
};
defineExpose({ok})

</script>

<style scoped lang="scss">
  
</style>
