<template>
  <basic-container>
    <avue-form :option="option" v-model="form" ref="form" @submit="rowUpdate">

    </avue-form>
  </basic-container>
</template>

<script>
  import { update} from "@/api/system/orgposition";


  export default {
    props:{
      orgId:{
        type: Object
      }
    },
    data() {
      return {
        option: {
          height:'auto',
          calcHeight: 30,
          tip: false,
          searchShow: true,
          searchMenuSpan: 6,
          border: true,
          index: true,
          viewBtn: true,
          selection: true,
          dialogClickModal: false,
          column: [
            {
              label: "所属省",
              prop: "provinceCode",
              type: "select",
              dicUrl: "/api/blade-system/region/lazy-tree?parentCode=000000",
              cascaderItem:["cityCode"],
              props:{
                label:"title",
                value: "id"
              },
              value: "null",
              rules: [{
                required: false,
                message: "请输入省行政编码",
                trigger: "blur"
              }]
            },
            {
              label: "所属市",
              prop: "cityCode",
              type: "select",
              cascaderItem: ["areaCode"],
              dicUrl: `/api/blade-system/region/lazy-tree?parentCode={{key}}`,

              props:{
                label: "title",
                value: "id"
              },
              value: "null",
              rules: [{
                required: false,
                message: "请输入市行政编码",
                trigger: "blur"
              }]
            },
            {
              label: "所属区",
              prop: "areaCode",
              type: "select",
              value: "null",
              cascaderItem: ["streetCode"],
              dicUrl:  `/api/blade-system/region/lazy-tree?parentCode={{key}}`,
              props: {
                label: "title",
                value: "id"
              },
              rules: [{
                required: false,
                message: "请输入区行政编码",
                trigger: "blur"
              }]
            },
            {
              label: "所属街道",
              prop: "streetCode",
              type:"select",
              cascaderItem: ["agencyId"],
              dicUrl: `/api/blade-system/region/lazy-tree?parentCode={{key}}`,
              props: {
                label: "title",
                value: "id"
              },
              value: "null",
              rules: [{
                required: false,
                message: "请输入街道id",
                trigger: "blur"
              }]
            },
            {
              label: "社区",
              prop: "agencyId",
              type: "select",
              cascaderItem: ["residentialId"],
              dicUrl: "/api/cyzh-community/agency/list?size=100000&regionStreet={{key}}",
              props: {
                label: "name",
                value: "id"
              },
              value: "null",
              dicFormatter:(res)=>{
                return res.data.records;
              },
              rules: [{
                required: false,
                message: "请输入社区id",
                trigger: "blur"
              }]
            },
            {
              label: "小区",
              prop: "residentialId",
              type: "select",
              dicUrl: "/api/cyzh-community/residential/list?agencyId={{key}}",
              props:{
                label: "name",
                value: "id"
              },
              value: "null",
              dicFormatter:(res)=>{
                return res.data.records;
              },
              rules: [{
                required: false,
                message: "请输入小区id",
                trigger: "blur"
              }]
            },

          ]
        },
        data: []
      };
    },
    methods: {
      init(orgId){
        this.orgId = orgId;
      },
      rowUpdate(done, loading) {
        this.form.orgId = this.orgId;
        update(this.form).then(() => {
          this.$emit("close",'true');
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          console.log(error);
        });
      }
    }
  };
</script>

<style>
</style>
