<template>
  <div class="app-container">
    <van-nav-bar
      left-arrow
      fixed
      placeholder
      @click-left="$router.back(-1)"
    >
      <template #title>
        <p style="font-weight: bold;">添加支付收款账户</p>
      </template>
    </van-nav-bar>
    <p class="main_title">基础信息</p>
    <div class="main_box">
      <van-field label="收款方" placeholder="请输入收款方" input-align="right" label-width="auto"/>
      <van-field label="收款账户" placeholder="请输入收款账户" input-align="right" label-width="auto"/>
      <van-field
        readonly
        clickable
        label="所属银行"
        placeholder="请选择"
        v-model="sfzjjzw"
        @click="showSys = true"
        input-align="right"
        right-icon="arrow-down"
        label-width="auto"
      />
      <van-popup v-model="showSys" position="bottom">
        <van-picker
          show-toolbar
          :columns="sysDictionaries"
          @confirm="onConfirmSys"
          @cancel="showSys = false"
        />
      </van-popup>
      <van-field label="开户银行" placeholder="请输入开户银行" input-align="right" label-width="auto"/>
    </div>

    <div class="main_box" style="margin-top: 10px;">
      <van-field label="备注" type="textarea" placeholder="请输入备注" input-align="right" rows="3" label-width="auto"/>
    </div>

    <div class="main_box" style="margin-top: 10px;">
      <van-cell title="账户类型">
        <template #right-icon>
          <van-radio-group direction="horizontal">
            <van-radio name="1">公户</van-radio>
            <van-radio name="2">私户</van-radio>
          </van-radio-group>
        </template>
      </van-cell>
      <van-cell title="数据状态">
        <template #right-icon>
          <van-radio-group direction="horizontal">
            <van-radio name="1">正常</van-radio>
            <van-radio name="2">停用</van-radio>
          </van-radio-group>
        </template>
      </van-cell>
    </div>
    <div style="padding: 16px 0;">
      <van-row>
        <van-col span="24" align="center">
          <van-button type="info" native-type="submit" @click="goBack" class="submitButton">保<i style="margin-right: 1em;"></i>存</van-button>
        </van-col>
      </van-row>
      <div class="clear"></div>
    </div>
  </div>
</template>

<script>
  import { jgAdd } from "@/api/onlineHome/homestead/reporting";
  export default {
    name: "approvalAdd",
    data() {
      return {
        showSys:false,
        showjglx:false,
        showlasj:false,
        showinspectorTime:false,
        showwfydlx:false,
        showReformDeadline:false,

        minDate: new Date(),
        maxDate: new Date(2025, 10, 1),
        currentDate: new Date(),
        jgList:{},

        sfzjjzw:'',
        jglx:'',
        wfydlx:'',

        wfydlxDictionaries:[],
        jglxDictionaries:[],
        sysDictionaries:[],

      };
    },
    created() {
      this.getDictionaries();
    },
    methods: {
      getDictionaries(){
        //违法用地类型
        this.houseGetDicts("villations_type").then((res) => {
          for(var i = 0 ; i < res.data.length ; i++){
            this.wfydlxDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
          }
        });
        //监管类型
        this.houseGetDicts("jglx").then((res) => {
          for(var i = 0 ; i < res.data.length ; i++){
            this.jglxDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
          }
        });
        //是否在建建筑物
        this.houseGetDicts("sys_yes_no").then((res) => {
          for(var i = 0 ; i < res.data.length ; i++){
            this.sysDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
          }
        });

      },
      onConfirmSys(data){
        this.sfzjjzw = data.text;
        this.jgList.sfzjjzw = data.value;
        this.showSys = false;
      },
      onConfirmJglx(data){
        this.jglx = data.text;
        this.jgList.jglx = data.value;
        this.showjglx = false;
      },
      onConfirmWfydlx(data){
        this.wfydlx = data.text;
        this.jgList.wfydlx = data.value;
        this.showwfydlx = false;
      },
      onConfirmLasj(data){
        this.jgList.lasj = this.getNowFormatDate(data).substr(0,10);
        this.showlasj = false;
      },
      onConfirmInspectorTime(data){
        this.jgList.inspectorTime = this.getNowFormatDate(data).substr(0,10);
        this.showinspectorTime = false;
      },
      onConfirmReformDeadline(data){
        this.jgList.reformDeadline = this.getNowFormatDate(data).substr(0,10);
        this.showReformDeadline = false;
      },
      goAdd(){
        console.log(this.jgList)
        jgAdd(this.jgList).then(response => {
          console.log(response);
          this.$toast.success('保存成功');
          setTimeout(function(){
            history.go(-1)
          },2000)
        });
      },
      goBack(){
        window.history.go(-1)
      }
    },
  }
</script>

<style scoped lang="scss">
  .app-container {
    padding: 2% 0;
  }
  .main_title{
    font-size: 0.4rem;
    color: #1D6FE9;
    margin: 0.2rem 6%;
    margin-top: 0;
    position: relative;
  }
  .main_box{
    width: 96%;
    margin: 0 auto;
    border-radius: 6px;
    box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
    overflow: hidden;
    background-color: #FFF;
  }
  .submitButton{
    width: 80%;
    margin: 0 auto;
    background-color: #1D6FE9;
  }

  .addFamily{
    position: absolute;
    top: -2px;
    right: 0;
    border-radius: 50%;
  }
</style>
