<template>
  <div class="addLinkage">

    <div class="item">
      <div><span>*</span>四邻对象</div>
      <AiSelect class="right" v-model="form.type" dict="agriculturalType"/>
    </div>

    <div class="item">
      <div><span>*</span>事件日期</div>
      <div @click="isShowDate = true">
        <span v-if="form.checkTime" >{{ form.checkTime }}</span>
        <span v-else style="color: #999;">请选择</span>
        <u-icon name="arrow-right" color="#ddd"/>
      </div>
    </div>
    <u-picker mode="time" :params="params" v-model="isShowDate" @confirm="onDateChange"></u-picker>

    <div>
      <div class="title"><span style="color: #FF4466">*</span>事件描述</div>
      <div>
        <u-input type="textarea" v-model="form.name" placeholder="请输入事件内容描述" height="200" maxlength="500"/>
      </div>
      <div class="tips">{{form.name.length}}/500</div>
    </div>

    <div class="btn">
      <div class="addBtn" @click="confirm">提交</div>
    </div>

  </div>
</template>

<script>
export default {
  name: "addLinkage",
  appName: "添加联动记录",
  data() {
    return {
      params: {
        year: true,
        month: true,
        day: true,
      },
      isShowDate: false,
      form: {
        type: '',
        checkTime: '',
        name: '',
        partyId: ''
      },
      userList: []
    }
  },
  onShow() {
    this.$dict.load('agriculturalType')
    this.getFourResident()
  },
  methods: {
    onDateChange(e) {
      this.form.checkTime = `${e.year}-${e.month}-${e.day}`
    },
    getFourResident() {
      this.$instance.post('/app/apppartyfourresident/listFourResident', null, {
        params: {
          size: 10,
          partyId: this.form.partyId,
        },
      }).then((res) => {
        if (res.code == 0) {
          this.userList = res.data.records
        }
      })
    },
    confirm() {
      if(!this.form.checkTime)
      this.$instance.post('/app/apppartyfourlinkage/addOrUpdate')
    }

  }
}
</script>

<style lang="scss" scoped>
.addLinkage {
  padding: 0 32px;
  box-sizing: border-box;
  background: #FFF;
  .item {
    display: flex;
    justify-content: space-between;
    padding: 32px 0;
    border-bottom: 1px solid #DDDDDD;
    div:first-child {
      span {
        color: #FF4466;
      }
    }
  }
  .title {
    padding: 32px 0
  }
  .tips {
    text-align: right;
    color: #999;
    padding: 15px 0;
  }
  .btn {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    padding: 16px 32px;
    box-sizing: border-box;
    background: #F3F6F9;
    .addBtn {
      width: 100%;
      height: 88px;
      line-height: 88px;
      text-align: center;
      background: #4181FF;
      border-radius: 16px;
      color: #FFF;
    }
  }
}
</style>