<template>
  <ui-form :model="formData" :rules="formRules" ref="form" label-width="100px">
    <ui-form-item prop="filePath" label="文件夹名称">
      <ui-textbox
        placeholder="请输入文件夹名称"
        v-model="formData.filePath"
      ></ui-textbox>
    </ui-form-item>
    <ui-toolbar slot="toolbar" align="right">
      <ui-toolbar-item>
        <ui-button>取消</ui-button>
      </ui-toolbar-item>
      <ui-toolbar-item>
        <ui-button type="primary" :click="handleConfirmClick">确认</ui-button>
      </ui-toolbar-item>
    </ui-toolbar>
  </ui-form>
</template>
<script>
export default {
  name: 'BiDiskManageFolder',
  props: {
    createDiskFolderMethod: {
      type: Function
    },
    parentPathId: {
      type: String
    }
  },
  data() {
    return {
      formData: {
        filePath: '',
        parentPath: null
      }
    }
  },
  computed: {
    formRules() {
      return {
        filePath: [{
          required: true,
          message: '文件夹名称不能为空',
          trigger: 'blur'
        }]
      }
    }
  },
  created() {
    // if (!this.formData.parentPath) {
    //   this.formData.parentPath = `/controller/${this.loginUserData.companyId}/item/${this.projectId}`
    // }
  },
  methods: {
    handleConfirmClick() {
      return this.$refs.form.validate().then(() => {
        return this.createDiskFolderMethod(Object.assign({}, this.formData, {
          parentPathId: this.parentPathId
        })).then(() => {
          this.$success('创建成功')
          this.$emit('success')
        })
      })
    }
  }
}
</script>
