<template>
  <el-dialog
    title="账户详情"
    :visible.sync="visibleDialog"
    width="400px"
    @close="close"
  >
    <Form
      ref="form"
      class="form"
      :form-arr="formArr"
      :form-data="formData"
    />
  </el-dialog>
</template>

<script>
import Form from '@/components/form';
// import ScopeIdMixin from '../../../../mixins/ScopeIdMixin';
export default {
  components: {
    Form,
  },
  // mixins: [ScopeIdMixin],
  props: {
    isShow: {
      type: Boolean,
      default: false,
    },
    selectRow: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      formArr: [
        {
          type: 'input',
          prop: 'code',
          span: 24,
          attrs: {
            label: '编码',
            disabled: true,
            placeholder: ' ',
          },
        },
        {
          type: 'input',
          prop: 'name',
          span: 24,
          attrs: {
            label: '短名',
            disabled: true,
            placeholder: ' ',
          },
        },
        {
          type: 'input',
          prop: 'localName',
          span: 24,
          attrs: {
            label: '名称',
            disabled: true,
            placeholder: ' ',
          },
        },
        {
          type: 'input',
          prop: 'bookIdName',
          span: 24,
          attrs: {
            label: '所属账簿',
            disabled: true,
            placeholder: ' ',
          },
        },
        {
          type: 'select',
          prop: 'currencyId',
          span: 24,
          attrs: {
            label: '损益货币',
            optionValue: 'id',
            disabled: true,
            placeholder: ' ',
          },
          options: [],
        },
        {
          type: 'select',
          prop: 'folderStatus',
          span: 24,
          attrs: {
            label: '账户属性',
            disabled: true,
            placeholder: ' ',
          },
          options: [],
        },
        {
          type: 'select',
          prop: 'accountingSection',
          span: 24,
          attrs: {
            label: '会计分类',
            disabled: true,
            placeholder: ' ',
          },
          options: [],
        },
        {
          type: 'select',
          prop: 'homeType',
          span: 24,
          attrs: {
            label: '本/离岸',
            disabled: true,
            placeholder: ' ',
          },
          options: [],
        },
      ],
      formData: {},
      visibleDialog: false,
    };
  },
  watch: {
    isShow: {
      handler(nv) {
        this.visibleDialog = nv;
        if (nv) {
          this.getAccountInfo();
        }
      },
    },
  },
  async mounted() {
    await this.getOptions();
    // console.log('参数', this.loadOptions.extraParams);
  },
  methods: {
    close() {
      this.visibleDialog = false;
      this.$emit('update:isShow', false);
    },
    async getOptions() {
      await this.$apis.getForList().then(res => {
        const arr = res.data.result;
        this.formArr[4].options = arr.currencies;
        this.formArr[5].options = arr.FolderStatus;
        this.formArr[6].options = arr.AccountingSection;
        this.formArr[7].options = arr.HomeType;
      });
    },
    getAccountInfo() {
      console.log(this.selectRow, 'sss');
      this.$apis.getFolderInfo({ code:
      // this.loadOptions.extraParams._Folder ||
      this.selectRow._Folder }).then(res => {
        this.formData = { ...res.data.result, currencyId: String(res.data.result.currencyId) };
      });
    },
  },
};

</script>

<style lang="scss" scoped>
.footer-btns{
  display:flex;
  justify-content: end;
}
</style>
