<template>
  <div class="addPrisonUser">
    <div class="pad-l32">
      <div class="item">
        <span class="label"><span class="tips">*</span>类型</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips">*</span>姓名</span>
        <div class="value">
          <u-input type="text" placeholder="请输入" v-model="form.houseArea" input-align="right"  placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="15" :clearable="false" />
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips">*</span>身份证号</span>
        <div class="value">
          <u-input type="idcard" placeholder="请输入" v-model="form.houseArea" input-align="right"  placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="15" :clearable="false" />
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips">*</span>性别</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips">*</span>出生日期</span>
        <div class="value" @click="selectTime('startDate')">
          <span :class="form.startDate === '' ? 'color-999' : ''">{{ $dateFormat(form.startDate,'YYYY-MM-DD') || '请选择' }}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips">*</span>联系电话</span>
        <div class="value">
          <u-input type="number" placeholder="请输入" v-model="form.houseArea" input-align="right"  placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="11" :clearable="false" />
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips">*</span>所属区域</span>
        <div class="value">
          <u-input type="text" placeholder="请输入" v-model="form.houseArea" input-align="right"  placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="15"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>详细地址</span>
        <div class="value">
          <u-input type="text" placeholder="请输入" v-model="form.houseArea" input-align="right"  placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="15" :clearable="false" />
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>所属网格</span>
        <div class="value">
          <u-input type="text" placeholder="请输入" v-model="form.houseArea" input-align="right"  placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="15"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>是否累犯</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>原罪名</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>服刑场所</span>
        <div class="value">
          <u-input type="text" placeholder="请输入" v-model="form.houseArea" input-align="right"  placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="15" :clearable="false" />
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>危险性评估</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>安置情况</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>安置时间</span>
        <div class="value" @click="selectTime('startDate')">
          <span :class="form.startDate === '' ? 'color-999' : ''">{{ $dateFormat(form.startDate,'YYYY-MM-DD') || '请选择' }}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>衔接情况</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>衔接时间</span>
        <div class="value" @click="selectTime('startDate')">
          <span :class="form.startDate === '' ? 'color-999' : ''">{{ $dateFormat(form.startDate,'YYYY-MM-DD') || '请选择' }}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
      <div class="item">
        <span class="label"><span class="tips"></span>是否重新犯罪</span>
        <div class="value" @click="selectClick('houselivingStatus', 'livingStatus')">
          <span :class="form.livingStatus === '' ? 'color-999' : ''">{{ $dict.getLabel('houselivingStatus', form.livingStatus) || '请选择'}}</span>
          <u-icon name="arrow-right" color="#cccccc" size="14"/>
        </div>
      </div>
    </div>
    <div class="footer" @click="submit">
      <div class="btn">保存</div>
    </div>

    <u-picker mode="time" v-model="dateShow" :params="deteParams" start-year="2010" @confirm="dateConfirm">请选择</u-picker>
    <u-select v-model="showSelect" :list="$dict.getDict(selectDict)" label-name="dictName" value-name="dictValue" @confirm="confirmRelation"/>
  </div>
</template>

<script>
import {mapActions, mapState} from 'vuex'

export default {

  data() {
    return {
      form: {

      },
      dateShow: false,
      deteParams: {year: true, month: true, day: true, hour: false, minute: false, second: false},
      showSelect: false,
      selectDict: '',
      selectName: ''
    }
  },
  computed: {...mapState(['user'])},
  created() {
    this.$dict.load('householdRelation', 'houselivingStatus', 'houseLeaseSituation', 'houseUseStatus',
        'isFilingCertificateStatus', 'communityBuildingType', 'yesOrNo', 'BulidResidentType').then(() => {
      // this.getDetail()
    })
  },
  onShow() {
    document.title = '新增人员'
  },

  methods: {
    submit() {
      this.$http.post(`app/appcommunityform/update`, this.form).then(res => {
        if (res?.code == 0) {
          this.$u.toast('提交成功')
          setTimeout(() => {
            uni.navigateBack({})
          }, 600)
        }
      })
    },

    selectClick(dictName, formName) {
      this.dictName = dictName
      this.selectName = formName
      this.showSelect = true
    },
    confirmSelect(e) {
      this.form[this.selectName] = e[0].value
    },
    selectTime(formName) {
      this.selectName = formName
      this.dateShow = true
    },
    dateConfirm(e) {
      this.form[this.selectName] = `${e.year}-${e.month}-${e.day} 00:00:00`
    }
  }
}
</script>

<style lang="scss" scoped>
.addPrisonUser {
  padding-bottom: 112px;

  .item {
    width: 100%;
    padding: 34px 32px 34px 0;
    background: #FFFFFF;
    border-bottom: 1px solid #D8DDE6;
    display: flex;
    justify-content: space-between;
    font-size: 32px;
    font-family: PingFangSC-Regular, PingFang SC;
    color: #333;
    line-height: 44px;
    box-sizing: border-box;

    .color-999 {
      color: #999;
    }

    .value {
      .u-icon {
        margin-left: 16px;
      }
    }

    .tips{
      display: inline-block;
      width: 16px;
      font-size: 32px;
      font-family: PingFangSC-Regular, PingFang SC;
      color: #F46;
      line-height: 44px;
    }
  }

  .footer {
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
  }

  .btn {
    width: 100%;
    height: 112px;
    line-height: 112px;
    text-align: center;
    background: #1365DD;
    font-size: 32px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #FFF;
  }

  .line-bg {
    width: 100%;
    height: 16px;
    background: #F5F5F5;
  }

  .pad-l32 {
    padding-left: 32px;
    background-color: #fff;
  }
}
</style>
