<template>
  <div class="AddSet">
    <div class="contents">
      <div class="event">
        <div class="event-info">
          <span style="color: red;">*</span>
          <span>事件描述</span>
        </div>
        <textarea placeholder="请输入事件描述,最多200个字" :maxlength="200" v-model="form.content" style="width: 100%;"/>
      </div>
      <div class="upload">
        <div class="upload-title">图片上传<span>（最多9张）</span></div>
        <AiUploader :def.sync="form.files" multiple placeholder="上传图片" :limit="9" action="/admin/file/add2"></AiUploader>
      </div>
    </div>

    <div class="footer">上报</div>
  </div>
</template>

<script>
export default {
  name: 'AddSet',
  components: {},
  props: {},
  data() {
    return {
      form: {
        content: '',
        files: [],
      },
      flag: false,
      show: false,
    }
  },
  methods: {
    submit() {
      if (this.flag) return

      this.$refs.uForm.validate((valid) => {
        if (valid) {
          if (!this.forms.title) {
            return this.$u.toast('请输入事项分组')
          }

          const imgs = []
          if (this.forms.fileIds) {
            this.forms.fileIds.map((e) => {
              imgs.push({ url: e.url, id: e.id })
            })
          }

          this.flag = true
          this.$http
            .post(`/app/appclapeventgroup/addOrUpdate`, {
              title: this.forms.title,
              content: this.forms.content,
              // images: JSON.stringify(imgs) || [],
              images: imgs || [],

              people: this.forms.people,
              phone: this.forms.phone,
              id: this.id,
            })
            .then((res) => {
              if (res.code == 0) {
                this.$u.toast('发布成功')
                this.flag = false
                uni.navigateTo({ url: `./AppHandSnapshot` })
              }
            })
        } else {
          this.$u.toast('失败')
        }
      })
    },

    toSelectUser() {
      console.log(123)
      uni.navigateTo({ url: './SelectUser' })
    },
  },
}
</script>

<style scoped lang="scss">
.AddSet {
  height: 100%;
  .contents {

    .event {
      background: #FFFFFF;
      padding: 32px;
      margin-bottom: 16px;

      .event-info {
        font-size: 32px;
        color: #333333;
      }
    }

    .upload {
      padding: 30px 32px;
      background: #FFFFFF;

      .upload-title {
        font-size: 34px;
        color: #666666;
        margin-bottom: 30px;

        span {
          font-size: 28px;
          color: #999999;
        }
      }
    }
  }

  .footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 120px;
    line-height: 120px;
    text-align: center;
    font-size: 32px;
    color: #FFFFFF;
    background: #3975C6;
  }
}
</style>
