<template>
  <div class="editNotice app-container">
    <el-form
      :model="setQuery"
      ref="setQuery"
      :rules="rules"
      label-width="130px"
    >
      <el-form-item label="标题：" prop="name">
        <el-input
          v-model="setQuery.name"
          :maxlength="11"
          class="item-width-500"
        ></el-input>
      </el-form-item>
   
       <el-form-item label="发送对象：" prop="name">
       <el-select
          v-model="setQuery.shopName"
          size="small"
          clearable
          class="item-width-200 ml10"
          placeholder="请选择"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>

       <el-form-item label="内容：" prop="name">
        <el-input
        type="textarea"
        class="item-width-500"
        placeholder="请输入内容"
        v-model="setQuery.name"
        maxlength="30"
        show-word-limit
        >
        </el-input>
      </el-form-item>

    </el-form>

    <div class="btn-group">
       <el-button>取 消</el-button>
     <el-button type="primary" :loading="loading"  @click="save">确 定</el-button>
    </div>
  </div>
</template>

<script>

export default {
  data() {
    return {
        loading:false,
      setQuery: {
        id: 4,
        name: "",
        shopName: 0,
        img:'',
        createTime: "2023-05-23 16:56",
        IDnumber: '',
        phone: '',
      },
      rules: {
        name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        shopName: [
          { required: true, message: "请输入商铺名称", trigger: "blur" },
        ],
        phone: [
          { required: true, message: "请输入商铺手机号", trigger: "blur" },
        ],
        IDnumber: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
        ],
      },
      options: [
        {
          value: "0",
          label: "全部人员",
        },
        {
          value: "1",
          label: "全部会员",
        },
        {
          value: "2",
          label: "全部商户",
        },
      ],
    };
  },
  methods: {
    save() {
      this.$refs.setQuery.validate((v) => {
        if (v) {
            this.$notify({
                title: '成功',
                message: '操作成功',
                type: 'success'
              });
              this.setQuery = {
                    id: 4,
                    name: "",
                    shopName: "",
                    img:'',
                    createTime: "2023-05-23 16:56",
                    IDnumber: '',
                    phone: '',
                }
                this.$router.push('/noticeManage/index')
              
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.editNotice {
  padding-bottom: 40px;
  .btn-group{
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>