{$layout "layout_popup"}

<!-- <h3>修改密钥</h3> -->
<form class="ui form" data-tea-action="$" data-tea-success="success">
    <csrf-token></csrf-token>
    <input type="hidden" name="keyId" :value="key.id"/>
    <table class="ui table definition selectable">
        <tr>
            <td class="title">密钥名称 *</td>
            <td>
                <input type="text" name="name" ref="focus" v-model="key.name"/>
            </td>
        </tr>
        <tr>
            <td>算法 *</td>
            <td>
                <b-select
                    name="algo"
                    v-model="key.algo"
                    auto-width
                    :options="[
                        {label: '[选择算法]', value: ''},
                        ...algorithms.map(algo => ({
                            label: algo.name,
                            value: algo.code,
                        }))
                    ]"
                ></b-select>

                <!-- <select class="ui dropdown auto-width" name="algo" v-model="key.algo">
                    <option value="">[选择算法]</option>
                    <option v-for="algo in algorithms" :value="algo.code">{{algo.name}}</option>
                </select> -->
            </td>
        </tr>
        <tr>
            <td>密码 *</td>
            <td>
                <div style="margin-bottom: 1em">
                    <radio name="secretType" value="clear" :v-value="'clear'" v-model="secretType">明文密码</radio>
                    &nbsp; &nbsp;
                    <radio name="secretType" value="base64" :v-value="'base64'" v-model="secretType">Base64密码</radio>
                </div>
                <textarea name="secret" maxlength="256" v-model="secret" rows="3"></textarea>
                <p class="comment" v-if="secretType == 'clear'">客户端需要将明文转换为BASE64使用。</p>
                <div style="margin-top: 1em">
                    <a href="" @click.prevent="generateSecret">[随机生成]</a>
                </div>
            </td>
        </tr>
        <tr>
            <td>启用</td>
            <td>
                <checkbox name="isOn" v-model="key.isOn"></checkbox>
            </td>
        </tr>
    </table>
    <submit-btn></submit-btn>
</form>