// import MenuKindDialog from "@base/views/bd/setting/menu_kind/dialog.vue";

let modules = {};
modules = {
  props: {
    _dataId: [String, Number],
    currentFormType: Object
  },
  components: {/*MenuKindDialog*/},
  data() {
    return {
      isEdit: false,
      tabIndex: 'first',
      dataId: '',
      bdAttachSetting: {
        type: "importTemplate",
        menuKindName: null,
        menuKindCode: null
      },
      showMenuKindDialog: false,
      menuKindAuth: {
        editAuth: 0
      }
    };
  },
  created() {
    if (this._dataId && !isNaN(this._dataId)) {
      this.dataId = this._dataId;
    }/* else {
      this.bdAttachSetting.menuKindName = this.currentFormType?.name || null;
      this.bdAttachSetting.menuKindCode = this.currentFormType?.menuKindCode || null;
    }*/
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      if (this.dataId && !isNaN(this.dataId)) {
        this.isEdit = true;
        this.$commonHttp({
          aes: true,
          url: USER_PREFIX + `/bd_attach_setting/get`,
          method: `post`,
          data: {
            id: this.dataId
          },
          isLoading: true,
          modalStrictly: true,
          success: res => {
            this.bdAttachSetting = res.objx || {};
            // this.getMenuKindAuth(this.bdAttachSetting.menuKindCode);
          }
        });
      } else {
        this.menuKindAuth.editAuth = 1;
      }
    },
    saveData() {
      this.$refs.editForm.$baseValidate(valid => {
        if (valid) {
          this.$baseConfirm(this.$t1('您确定要保存吗？')).then(() => {
            var url = USER_PREFIX + (this.isEdit ? `/bd_attach_setting/update` : `/bd_attach_setting/save`);
            this.$http({
              aes: true,
              url: url,
              method: `post`,
              data: this.bdAttachSetting,
              isLoading: true,
              success: res => {
                this.$message({
                  message: res.content,
                  type: 'success',
                  duration: 500,
                  onClose: t => {
                    if (this.isEdit) {
                      this.$baseReload();
                    } else {
                      this.$baseReload({
                        updateParam: {
                          _dataId: res.objx
                        }
                      });
                    }
                  }
                });
              }
            });
          });
        }
      });
    },
    confirmInsertMenuKind(rows) {
      if (rows.length > 0) {
        let row = rows[0];
        this.$set(this.bdAttachSetting, 'menuKindCode', row.menuKindCode);
        this.$set(this.bdAttachSetting, 'menuKindName', row.name);
      }
    },
    getMenuKindAuth(menuKindCode) {
      if (menuKindCode) {
        this.$http({
          aes: true,
          url: USER_PREFIX + '/menu_kind_auth/getAuth',
          method: `post`,
          data: {stringOne: menuKindCode},
          isLoading: true,
          success: res => {
            this.menuKindAuth = res.objx || {}
          }
        });
      }
    }
  }
};
export default modules
