<template>
  <div class="app-container" style="overflow-y: auto">
    <div class="cmain">
      <el-row>
        <el-col :span="16">
          <el-form ref="form" :model="form" :rules="rules" label-width="130px">
            <div class="bos">
              <div class="lab">
                <div class="bsg"></div>
                <div class="tit">医院基本信息</div>
              </div>
              <el-form-item label="医院电话" prop="phone">
                <el-input v-model="form.phone" placeholder="请输入" clearable />
              </el-form-item>
              <el-form-item label="医院邮箱" prop="email">
                <el-input v-model="form.email" placeholder="请输入" clearable />
              </el-form-item>
              <el-form-item label="医院介绍" prop="brief">
                <editor v-model="form.brief" placeholder="请输入"></editor>
              </el-form-item>
            </div>
          </el-form>
        </el-col>
        <el-col :span="8">
          <div class="div-mc">
            <div class="guise-mobile">
              <div class="guise-mobile-show" ref="scrollbar">
                <div class="js">
                  <div class="introduce" v-html="form.brief" v-if="form.brief"></div>
                  <el-empty v-else description="暂无个人介绍" :image-size="80" v-else></el-empty>
                </div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>

      <div>
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="$layer.close(layerid)">取 消</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {},
      rules: {
        address: [{ required: true, message: '不能为空', trigger: 'blur' }],
        phone: [{ required: true, message: '不能为空', trigger: 'blur' }],
        email: [{ required: true, message: '不能为空', trigger: 'blur' }],
        brief: [{ required: true, message: '不能为空', trigger: 'blur' }],
        privacy: [{ required: true, message: '不能为空', trigger: 'blur' }],
        agreement: [{ required: true, message: '不能为空', trigger: 'blur' }]
      }
    };
  },
  mounted() {
    this.ajax({ url: '/work/introduction/detail' }).then((response) => {
      this.form = response.data;
    });
  },
  methods: {
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.form.id) {
            this.ajax({ method: 'post', url: '/work/introduction/edit', data: this.form }).then((response) => {
              this.$modal.msgSuccess('修改成功');
            });
          }
        }
      });
    }
  }
};
</script>
