<script setup name="Algorithm">
import { ref, toRefs } from 'vue'
import { Split, Switch } from 'view-ui-plus';

import CollapseView from '@/components/CollapseView/index.vue'
const splitNum = ref(0.31)

const data = reactive({
  form: {
    name: "",
  },
  rules: {},
});

const { form, rules } = toRefs(data);
const readOnly = ref(true);

</script>
<template>
  <div class="app-container scroller">
    <PageTitle>
      <template #title>
        <span id="badDebt" class="title-icon">
          脱敏算法
        </span>
      </template>
    </PageTitle>
    <div class="app-container__body">
      <Split v-model="splitNum">
        <template #left>
          <div class="demo-split-pane" style="padding: 0 38px 10px 0;width: 100%;overflow: auto;height: 100%;">
            <el-input class="mb20" placeholder="脱敏规则搜索">
              <template #suffix>
                <el-icon style="vertical-align: middle;">
                  <search />
                </el-icon>
              </template>
            </el-input>
            <CollapseView />
          </div>
        </template>
        <template #right>
          <div class="demo-split-pane">
            <div class="right">
              <div class="right-title">
                <el-icon>
                  <info-filled />
                </el-icon>
                <span style="margin-left: 5px;">脱敏规则</span>
              </div>
              <div class="right-content">
                <el-form ref="formRef" :model="form" label-width="100px" :disabled="readOnly">
                  <el-form-item label="算法名称" required>
                    <el-input v-model="form.name"></el-input>
                  </el-form-item>
                  <el-form-item label="表达式" required>
                    <el-input type="textarea" rows="8" v-model="form.desc"></el-input>
                    <el-button class="openEditor" type="primary">打开编辑器</el-button>
                  </el-form-item>
                  <el-form-item label="默认规则">
                    <Switch  :disabled="readOnly">
                      <template #open>
                        <span>是</span>
                      </template>
                      <template #close>
                        <span>否</span>
                      </template>
                    </Switch>
                  </el-form-item>
                </el-form>
              </div>
              <div class="right-btn">
                <el-button type="primary" style="width: 150px;" @click="readOnly = false" v-if="readOnly">编辑</el-button>
                <el-button type="info" style="width: 150px;" @click="readOnly = true" v-if="!readOnly">取消</el-button>
                <el-button type="primary" style="width: 150px;" v-if="!readOnly">确认</el-button>
              </div>
            </div>
          </div>
        </template>
      </Split>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.app-container__body {
  height: calc(
    100vh - var(--navbar-height) - var(--container-pd) - var(--container-pd)
  ) !important;
  .right {
    padding: 6px 10px 10px;
    height: 100%;
    &-title {
      padding: 0px 0px 10px 10px;
      display: flex;
      align-items: center;
      font-weight: 700;
      color: #515a6e;
    }
    &-content {
      padding: 10px 0px;
      width: 80%;
      margin: 20px auto;
      .openEditor{
        position: absolute;
        bottom: 0;
        right: 0;
      }
    }
    &-btn{
      padding: 20px 20px 20px 100px; 
      display: flex; 
      justify-content: center;
    }
  }
}
</style>