<!-- 网站信息 -->
<template>
  <div class="website-information">
    <el-form
      ref="formRef"
      class="ls-form"
      :model="formData"
      label-width="120px"
    >
      <el-card shadow="never" class="!border-none">
        <div class="text-xl font-medium mb-[20px]">平台信息</div>
        <el-form-item label="公司名称">
          <div class="w-80">
            <el-input
              v-model.trim="formData.company_name"
              placeholder="请输入公司名称"
              maxlength="30"
              show-word-limit
            />
          </div>
        </el-form-item>
        <el-form-item label="公司联系人">
          <div class="w-80">
            <el-input
              v-model.trim="formData.company_user"
              placeholder="请输入公司联系人"
              maxlength="30"
              show-word-limit
            />
          </div>
        </el-form-item>
        <el-form-item label="联系电话">
          <div class="w-80">
            <el-input
              v-model.trim="formData.company_phone"
              placeholder="请输入联系电话"
              maxlength="30"
              show-word-limit
            />
          </div>
        </el-form-item>
        <el-form-item label="联系邮箱">
          <div class="w-80">
            <el-input
              v-model.trim="formData.company_email"
              placeholder="请输入联系邮箱"
              maxlength="30"
              show-word-limit
            />
          </div>
        </el-form-item>
        <el-form-item label="组织机构代码">
          <div class="w-80">
            <el-input
              v-model.trim="formData.company_organization_code"
              placeholder="请输入组织机构代码"
              maxlength="30"
              show-word-limit
            />
          </div>
        </el-form-item>
        <el-form-item label="联系地址">
          <div class="w-80">
            <el-input
              v-model.trim="formData.company_address"
              placeholder="请输入联系地址"
              maxlength="30"
              show-word-limit
            />
          </div>
        </el-form-item>
      </el-card>
    </el-form>

    <el-button type="primary" v-if="flag" @click="handleSubmi">保存</el-button>
  </div>
</template>

<script lang="ts" setup name="webInformation">
import { getpla, setWebsite, setpla } from "@/api/setting/website";
// import useAppStore from "@/stores/modules/app";
import type { FormInstance } from "element-plus";
import { reactive, ref } from "vue";
const formRef = ref<FormInstance>();

// const appStore = useAppStore();
// 表单数据
const formData = reactive({
  company_name: "",
  company_user: "",
  company_phone: "",
  company_address: "",
  company_email: "",
  company_organization_code: "",
});
const handleSubmi = () => {
  console.log(5454);
  setpla({ ...formData });
};
// 表单验证
// const rules = {
//   name: [
//     {
//       required: true,
//       message: "请输入网站名称",
//       trigger: ["blur"],
//     },
//   ],
//   web_favicon: [
//     {
//       required: true,
//       message: "请选择网站图标",
//       trigger: ["change"],
//     },
//   ],
//   web_logo: [
//     {
//       required: true,
//       message: "请选择网站logo",
//       trigger: ["change"],
//     },
//   ],
//   login_image: [
//     {
//       required: true,
//       message: "请选择登录页广告图",
//       trigger: ["change"],
//     },
//   ],
//   shop_name: [
//     {
//       required: true,
//       message: "请输入店铺/商城名称",
//       trigger: ["blur"],
//     },
//   ],
//   shop_logo: [
//     {
//       required: true,
//       message: "请选择商城LOGO",
//       trigger: ["change"],
//     },
//   ],
//   pc_logo: [
//     {
//       required: true,
//       message: "请选择PC端LOGO",
//       trigger: ["change"],
//     },
//   ],
//   pc_title: [
//     {
//       required: true,
//       message: "请输入PC端网站标题",
//       trigger: ["blur"],
//     },
//   ],
//   pc_ico: [
//     {
//       required: true,
//       message: "请选择PC端网站图标",
//       trigger: ["change"],
//     },
//   ],
// };
const flag = ref(true);
// 获取备案信息
const getData = async () => {
  const data = await getpla();

  for (const key in formData) {
    //@ts-ignore
    formData[key] = data[key];
  }
};

// 设置备案信息
const handleSubmit = async () => {
  //   await formRef.value?.validate();
  await setpla(formData);
  appStore.getConfig();
  //   getData();
};

getData();
</script>

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