<template lang="">
  <div>
    <el-dialog
      v-model="centerDialogVisible"
      width="500"
      align-center
      :show-close="false"
    >
      <template #header="{ close }">
        <div class="my-header">
          创建密码
          <el-icon @click="close"><Close /></el-icon>
        </div>
      </template>

      <div class="scroll-container">
        <el-form
          ref="formRef1"
          style="max-width: 600px"
          :model="pasForm"
          status-icon
          :rules="passwordRules"
          label-width="auto"
          class="demo-ruleForm"
        >
          <el-form-item prop="password">
            <div class="label"><div>密码</div><div class="red">*</div></div>
            <el-input
              v-model="pasForm.password"
              autocomplete="on"
              placeholder="请输入字母、数字组合"
              type="password"
              show-password
            />
          </el-form-item>
          <el-form-item prop="confPassword">
            <div class="label"><div>重置密码</div><div class="red">*</div></div>
            <el-input
              v-model="pasForm.confPassword"
              type="password"
              autocomplete="on"
              placeholder="请输入字母、数字组合"
              show-password
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              class="el-button_one"
              @click="resetPassword"
            >
              确定
            </el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import {} from '@/api/login'
import { useUserStore } from '@/store/modules/user'
const changeCode = () => {
  centerDialogVisible.value = true
}
const userStore = useUserStore()

const centerDialogVisible = ref(false)

const pasForm = reactive({
  password: '',
  confPassword: '',
})
const passwordRules = {
  password: [
    { required: true, message: '密码不能为空', trigger: 'blur' },
    {
      min: 6,
      max: 16,
      message: '密码长度应在 6 到 16 位之间',
      trigger: 'blur',
    },
    {
      pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,16}$/,
      message: '密码必须包含字母和数字的组合',
      trigger: 'blur',
    },
  ],
  confPassword: [
    { required: true, message: '确认密码不能为空', trigger: 'blur' },
    {
      validator: (rule, value, callback) => {
        if (value !== pasForm.password) {
          callback(new Error('确认密码与密码不一致'))
        } else {
          callback()
        }
      },
      trigger: 'blur',
    },
  ],
}
const resetPassword = () => {}

const close = () => {
  centerDialogVisible.value = false
}
defineExpose({
  changeCode,
})
</script>
<style lang="scss" scoped>
//切换企业有关样式
.my-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 16px;
  color: #1d2129;
  font-size: 18px;
  font-weight: bold;
  margin: 16px 0 24px;
}

.scroll-container {
    height: 320px; /* 根据需要调整容器高度 */
    overflow-y: auto; /* 允许垂直滚动 */
}
.el-button_one {
  margin-top: 24px;
  width: 100%;
  color: #fff;
  background-color: #3062F6;
}
:deep(.el-dialog.is-align-center) {
  padding: 20px 24px 0;
}
:deep(.el-input__wrapper) {
  height: 32px;
}
.label {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 14px;
color: #1F2329;
  .red{
    color: #FF3535;
  }
}
</style>
