<template>
  <div class="app-container add-box">
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="医共体ID" prop="name">
        <el-input v-model="form.name" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item label="医共体名称" prop="name">
        <el-input v-model="form.name" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item label="医共体密码" prop="pwd">
        <el-input v-model="form.pwd" placeholder="请输入密码" />
      </el-form-item>
      <el-form-item label="医共体说明" prop="remark">
        <el-input
          v-model="form.remark"
          type="textarea"
          placeholder="请输入内容"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('form')">确定</el-button>
        <el-button @click="resetForm('form')">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {} from "@/api/system/user";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {
  addCommunity,
  updateCommunity,
} from "@/api/system/community";

export default {
  name: "User",
  components: {},
  data() {
    return {
      // 表单参数
      form: {},
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "change" },
        ],
        date1: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
        date2: [
          {
            type: "date",
            required: true,
            message: "请选择时间",
            trigger: "change",
          },
        ],
        type: [
          {
            type: "array",
            required: true,
            message: "请至少选择一个活动性质",
            trigger: "change",
          },
        ],
      },
    };
  },
  created() {},
  methods: {
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        state: null,
        pwd: null,
        remark: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        del: null,
      };
      this.resetForm("form");
    },
    /** 提交按钮 */
    submitForm: function () {
      //console.log(this.form)
      // this.$refs["form"].validate((valid) => {
      //   if (valid) {
      //     if (this.form.id != null) {
      //       updateCommunity(this.form).then((response) => {
      //         this.msgSuccess("修改成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     } else {
      //       addCommunity(this.form).then((response) => {
      //         this.msgSuccess("新增成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     }
      //   }
      // });
    },
    resetForm() {
      this.$router.push({
        path: "/base/baseList/community",
      });
    },
  },
};
</script>
