<template>
  <div>
    <xy-dialog ref="dialog" :is-show.sync="isShow" type="form" :title="type === 'add' ? '新增详情' : '编辑详情'" :form="form"
      :rules="rules" @submit="submit">
      <template v-slot:studyName>
        <div class="xy-table-item">
          <div class="xy-table-item-label">
            <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>访客开放时间：
          </div>
          <div class="xy-table-item-content">
            <el-input v-model="form.studyName" placeholder="请输入访客开放时间" clearable style="width: 300px;"></el-input>
          </div>
        </div>
      </template>
      <template v-slot:studyName1>
        <div class="xy-table-item">
          <div class="xy-table-item-label">
            <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>随访人员最大数量：
          </div>
          <div class="xy-table-item-content">
            <el-input v-model="form.studyName1" type="number" placeholder="请输入随访人员最大数量" clearable style=""></el-input>
          </div>
        </div>
      </template>
      <template v-slot:studyName2>
        <div class="xy-table-item">
          <div class="xy-table-item-label">
            <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>单次预约可进车辆数量：
          </div>
          <div class="xy-table-item-content">
            <el-input v-model="form.studyName2" type="number" placeholder="请输入单次预约可进车辆数量" clearable style=""></el-input>
          </div>
        </div>
      </template>
      <template v-slot:recommend>
        <div class="xy-table-item">
          <div class="xy-table-item-label">
            普通访客须知：
          </div>
          <div class="xy-table-item-content">
            <el-input :autosize="{minRows:2}" type="textarea" v-model="form.recommend" placeholder="请输入学习内容" clearable
              style="width: 300px;"></el-input>
          </div>
        </div>
      </template>
      <template v-slot:recommend1>
        <div class="xy-table-item">
          <div class="xy-table-item-label">
            施工访客须知：
          </div>
          <div class="xy-table-item-content">
            <el-input :autosize="{minRows:2}" type="textarea" v-model="form.recommend1" placeholder="请输入学习内容" clearable
              style="width: 300px;"></el-input>
          </div>
        </div>
      </template>
      <template v-slot:recommend2>
        <div class="xy-table-item">
          <div class="xy-table-item-label">
            物流访客须知：
          </div>
          <div class="xy-table-item-content">
            <el-input :autosize="{minRows:2}" type="textarea" v-model="form.recommend2" placeholder="请输入学习内容" clearable
              style="width: 300px;"></el-input>
          </div>
        </div>
      </template>


    </xy-dialog>


  </div>
</template>

<script>
  import {
    store,
    show,
    save
  } from "@/api/resource/bd.js"
  export default {
    components: {},
    data() {
      return {
        isShow: false,
        type: 'add',
        id: '',

        form: {
          studyName:"",
          studyName1:"",
          studyName2:"",
          recommend:"",
          recommend1:"",
          recommend2:""
        },
        rules:{

        }
      }
    },
    created() {

    },
    methods: {

      async getDetail() {
        const res = await show({
          id: this.id
        })
        this.form = {

        }
      },
      submit() {

        if (this.type === 'add') {
          console.log(this.form)
          // return
          store({

          }).then(res => {
            this.$successMessage('add', '时段')
            this.isShow = false
            this.$emit('refresh')
          })
          return
        }
        if (this.type === 'editor') {
          save({
            id: this.id,

          }).then(res => {
            this.$successMessage('editor', '时段')
            this.isShow = false
            this.$emit('refresh')
          })
        }
      }
    },
    watch: {
      isShow(newVal) {
        if (newVal) {
          if (this.type === 'editor') {
            this.getDetail()
          }
        } else {
          this.id = ''
          this.type = ''
          this.$refs['dialog'].reset()
        }
      }
    }

  }
</script>

<style scoped lang="scss">
  .xy-table-item-label {
    width: 160px;
  }

  .img__delete {
    transform: scale(0.8, 0.8);

    position: absolute;
    top: 4px;
    right: 4px;
  }
</style>
