<!-- banner管理 -->
<template>
  <div class="detail_container">
    <bg-breadcrumb></bg-breadcrumb>
    <div class="main_container">
      <div class="content_top">
        <el-form
          :model="formData"
          :rules="formRules"
          ref="formRef"
          style="max-width: 1048px"
          class="form"
        >
          <el-form-item label="公司名称" prop="company_name">
            <el-input v-model="formData.company_name" placeholder="请输入公司名称" show-word-limit maxlength="50"/>
          </el-form-item>
          <el-form-item label="公司地址" prop="company_address">
            <el-input v-model="formData.company_address" placeholder="请输入公司地址" show-word-limit maxlength="100"/>
          </el-form-item>
          <el-form-item label="公司logo" prop="company_logo">
             <bg-upload-image v-model="formData.company_logo" :limit="1" listType="picture-card" :accept="['.jpg','.jpeg','.png']"></bg-upload-image>
          </el-form-item>
          <el-form-item label="公司电话" prop="company_phone">
            <el-input v-model="formData.company_phone" placeholder="请输入公司电话" show-word-limit maxlength="20" />
          </el-form-item>
        </el-form>
      </div>
      <div class="content_bottom">
        <div>
          <el-button type="primary" @click="submit">保存</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, toRefs, ref, onBeforeMount, nextTick } from 'vue'
import axios from '../../../../request/http.js'
import { ElMessage } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
const router = useRouter()
const route = useRoute()
const formRef = ref(null);
const state = reactive({
  formData: {
    company_name: "",
    company_address: "",
    company_logo: [],
    company_phone: ""
  },
  formRules: {
    company_name: [
      { required: true, message: "请输入公司名称", trigger: "blur"},
      { max: 50, message: "长度最大为50个字符", trigger: "blur"}
    ],
    company_address: [

    ],
    company_logo: [

    ],
    company_phone: [

    ],
  }
})

const getFootInfo = () => {
  // axios
  //   .get(`/apaas/system/v5/banner/${id}`)
  //   .then(res => {
  //     if (res.data.code == 200) {
  //       const data = res.data.data
  //       bannerFormRef.value.setForm({
  //         company_name: data.company_name,
  //         company_address: data.company_address,
  //         company_logo: data.company_logo ? [{url: data.company_logo}] : [],
  //         company_phone: data.company_phone
  //       })
  //     }else {
  //       ElMessage.error(res.data.data)
  //     }
  //   })
  //   .catch(err => {
  //     console.log(err)
  //   })
}

const submit = () => {
  formRef.value.validate((valid, fields) => {
    if (valid) {
      
    }
  })
}

onBeforeMount(() => {
  getFootInfo()
})
    
const {
  formData,
  formRules,
} = toRefs(state)

</script>

<style lang="scss" scoped>
.detail_container {
  width: 100%;
  padding: 0 24px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  .main_container {
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    background-color: #fff;
    box-shadow: 0px 1px 4px 0px rgba(0,7,101,0.15);
    border-radius: 6px;
    margin: 0 0 16px;
    position: relative;
    height: calc(100% - 62px);
    // padding: 24px;
    .content_top {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: auto;
      padding: 24px;
      .form {
        .el-form-item {
          display: block;
        }
      }
    }
    .content_bottom {
      height: 68px;
      line-height: 68px;
      text-align: right;
      padding: 0 20px;
      border-top: 1px solid #e6e9ef;
      .el-button {
        width: 92px;
      }
    }
  }
}
</style>