((typeof self !== 'undefined' ? self : this)["webpackJsonpresource_management"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpresource_management"] || []).push([[6],{

/***/ 2:
/***/ (function(module, exports) {

/* (ignored) */

/***/ }),

/***/ "456b":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _node_modules_windicss_webpack_plugin_dist_loaders_windicss_style_pitcher_cjs_node_modules_vue_style_loader_index_js_ref_8_oneOf_1_0_node_modules_css_loader_index_js_ref_8_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_2_node_modules_windicss_webpack_plugin_dist_loaders_windicss_template_cjs_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_3_node_modules_sass_loader_dist_cjs_js_ref_8_oneOf_1_4_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_OperatePermissionDialog_vue_vue_type_style_index_0_id_57b8d1fb_prod_lang_scss_scoped_true__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("9a2e");
/* harmony import */ var _node_modules_windicss_webpack_plugin_dist_loaders_windicss_style_pitcher_cjs_node_modules_vue_style_loader_index_js_ref_8_oneOf_1_0_node_modules_css_loader_index_js_ref_8_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_2_node_modules_windicss_webpack_plugin_dist_loaders_windicss_template_cjs_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_3_node_modules_sass_loader_dist_cjs_js_ref_8_oneOf_1_4_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_OperatePermissionDialog_vue_vue_type_style_index_0_id_57b8d1fb_prod_lang_scss_scoped_true__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_windicss_webpack_plugin_dist_loaders_windicss_style_pitcher_cjs_node_modules_vue_style_loader_index_js_ref_8_oneOf_1_0_node_modules_css_loader_index_js_ref_8_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_2_node_modules_windicss_webpack_plugin_dist_loaders_windicss_template_cjs_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_3_node_modules_sass_loader_dist_cjs_js_ref_8_oneOf_1_4_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_OperatePermissionDialog_vue_vue_type_style_index_0_id_57b8d1fb_prod_lang_scss_scoped_true__WEBPACK_IMPORTED_MODULE_0__);
/* unused harmony reexport * */


/***/ }),

/***/ "731a":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"3f554254-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/windicss-webpack-plugin/dist/loaders/windicss-template.cjs!./src/modules/host/resource-management/components/OperatePermissionDialog.vue?vue&type=template&id=57b8d1fb&scoped=true
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('el-dialog',{directives:[{name:"dialogDrag",rawName:"v-dialogDrag"}],staticClass:"mini-dialog",attrs:{"width":"565px","append-to-body":true,"visible":_vm.permissionProps.visible,"title":_vm.permissionProps.title},on:{"update:visible":function($event){return _vm.$set(_vm.permissionProps, "visible", $event)}}},[_c('el-form',[_c('el-form-item',{attrs:{"label":"选择权限"}},[_c('el-card',{staticClass:"wraper--tree overflow-y-auto m-t-10"},[(_vm.permissionProps.visible)?_c('el-tree',{directives:[{name:"loading",rawName:"v-loading",value:(_vm.treeLoading),expression:"treeLoading"}],ref:"tree",attrs:{"data":_vm.permissionTreeData,"show-checkbox":"","node-key":"name","props":_vm.defaultProps}}):_vm._e()],1)],1)],1),_c('div',{staticClass:"flex justify-center",attrs:{"slot":"footer"},slot:"footer"},[_c('el-button',{staticClass:"iconfont icon-save",attrs:{"size":"small","type":"primary"},on:{"click":function($event){return _vm.save()}}},[_vm._v("保存")]),_c('el-button',{staticClass:"iconfont icon-close",attrs:{"size":"small"},on:{"click":function($event){return _vm.cancel()}}},[_vm._v("取消")])],1)],1)],1)}
var staticRenderFns = []


// CONCATENATED MODULE: ./src/modules/host/resource-management/components/OperatePermissionDialog.vue?vue&type=template&id=57b8d1fb&scoped=true

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js
var regeneratorRuntime = __webpack_require__("c7eb");

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 3 modules
var toConsumableArray = __webpack_require__("2909");

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 3 modules
var slicedToArray = __webpack_require__("3835");

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
var asyncToGenerator = __webpack_require__("1da1");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.concat.js
var es_array_concat = __webpack_require__("99af");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.filter.js
var es_array_filter = __webpack_require__("4de4");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.find.js
var es_array_find = __webpack_require__("7db0");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.map.js
var es_array_map = __webpack_require__("d81d");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.function.name.js
var es_function_name = __webpack_require__("b0c0");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.object.to-string.js
var es_object_to_string = __webpack_require__("d3b7");

// EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-collections.for-each.js
var web_dom_collections_for_each = __webpack_require__("159b");

// EXTERNAL MODULE: ./node_modules/@wiz-api/abp-permission-management/lib/abp-permission-management.umd.js
var abp_permission_management_umd = __webpack_require__("392c");

// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib??ref--12-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/windicss-webpack-plugin/dist/loaders/windicss-template.cjs!./src/modules/host/resource-management/components/OperatePermissionDialog.vue?vue&type=script&lang=js











//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//


var permissionsApi = new abp_permission_management_umd["PermissionsApi"]();
/* harmony default export */ var OperatePermissionDialogvue_type_script_lang_js = ({
  props: {
    permissionProps: {
      type: Object,
      default: function _default() {
        return {
          visible: true,
          providerKey: '',
          providerName: '',
          title: ''
        };
      }
    }
  },
  name: 'operateRolePerssionDialog',
  components: {},
  data: function data() {
    return {
      treeLoading: false,
      permissionTreeData: [],
      defaultProps: {
        label: 'displayName',
        children: 'permissions'
      },
      defaultCheckedNodes: []
    };
  },
  watch: {
    permissionProps: {
      deep: true,
      immediate: true,
      handler: function handler(props) {
        if (props.visible) {
          this.getPermissions();
        }
      }
    }
  },
  methods: {
    cancel: function cancel() {
      this.permissionProps.visible = false;
    },
    save: function save() {
      var _this = this;
      return Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/Object(regeneratorRuntime["a" /* default */])().mark(function _callee() {
        var checkedNodes, permissionDefalultCheckedNodes, _yield$permissionsApi, _yield$permissionsApi2, err, res;
        return Object(regeneratorRuntime["a" /* default */])().wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              checkedNodes = _.filter(_this.$refs.tree.getCheckedNodes(), function (item) {
                return _.has(item, 'isGranted');
              });
              checkedNodes = _.map(checkedNodes, function (item) {
                return {
                  isGranted: true,
                  name: item.name
                };
              });
              // 默认节点的isGranted置为false(设置过true的，想取消授权还得设置为false)
              permissionDefalultCheckedNodes = _.filter(_this.defaultCheckedNodes, function (item) {
                return !_.find(checkedNodes, ['name', item.name]);
              });
              permissionDefalultCheckedNodes = _.map(permissionDefalultCheckedNodes, function (item) {
                return {
                  isGranted: false,
                  name: item.name
                };
              });
              _context.next = 6;
              return permissionsApi.update({
                providerKey: _this.permissionProps.providerKey,
                providerName: _this.permissionProps.providerName,
                body: {
                  permissions: [].concat(Object(toConsumableArray["a" /* default */])(permissionDefalultCheckedNodes), Object(toConsumableArray["a" /* default */])(checkedNodes))
                }
              });
            case 6:
              _yield$permissionsApi = _context.sent;
              _yield$permissionsApi2 = Object(slicedToArray["a" /* default */])(_yield$permissionsApi, 2);
              err = _yield$permissionsApi2[0];
              res = _yield$permissionsApi2[1];
              if (!err) {
                _this.$message.success({
                  showClose: true,
                  message: '修改权限成功'
                });
                _this.permissionProps.visible = false;
              }
            case 11:
            case "end":
              return _context.stop();
          }
        }, _callee);
      }))();
    },
    // 获取用户所有权限
    getPermissions: function getPermissions() {
      var _this2 = this;
      return Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/Object(regeneratorRuntime["a" /* default */])().mark(function _callee2() {
        var _yield$permissionsApi3, _yield$permissionsApi4, err, res;
        return Object(regeneratorRuntime["a" /* default */])().wrap(function _callee2$(_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              _this2.treeLoading = true;
              _this2.defaultCheckedNodes = [];
              _context2.next = 4;
              return permissionsApi.get({
                providerName: _this2.permissionProps.providerName,
                providerKey: _this2.permissionProps.providerKey
              });
            case 4:
              _yield$permissionsApi3 = _context2.sent;
              _yield$permissionsApi4 = Object(slicedToArray["a" /* default */])(_yield$permissionsApi3, 2);
              err = _yield$permissionsApi4[0];
              res = _yield$permissionsApi4[1];
              if (!err) {
                _this2.permissionTreeData = res.groups;
                _.forEach(_this2.permissionTreeData, function (item) {
                  var permissions = _.cloneDeep(item.permissions);
                  // 用户继承角色的权限禁用
                  if (_this2.permissionProps.providerName === 'U') {
                    var rootItemDisabled = true;
                    _.forEach(item.permissions, function (permissionItem) {
                      permissionItem.disabled = permissionItem.isGranted && permissionItem.grantedProviders[0].providerName === 'R';
                      if (!permissionItem.disabled) {
                        rootItemDisabled = false;
                      }
                    });
                    item.disabled = rootItemDisabled;
                  }
                  // 获取默认选中节点
                  _this2.defaultCheckedNodes = [].concat(Object(toConsumableArray["a" /* default */])(_this2.defaultCheckedNodes), Object(toConsumableArray["a" /* default */])(_.filter(permissions, 'isGranted')));
                  // 过滤没有parentName的
                  item.permissions = _.filter(item.permissions, function (permissionItem) {
                    return _.isNil(permissionItem.parentName);
                  });
                  // 通过parentName找到并添加到模块permissions下
                  _.forEach(item.permissions, function (cItem) {
                    cItem.permissions = _.filter(permissions, function (permissionCItem) {
                      // 用户继承角色的权限禁用
                      if (_this2.permissionProps.providerName === 'U') {
                        permissionCItem.disabled = permissionCItem.isGranted && permissionCItem.grantedProviders[0].providerName === 'R';
                      }
                      return permissionCItem.parentName === cItem.name;
                    });
                  });
                });
                // 默认选中节点
                _this2.$nextTick(function () {
                  _this2.$refs.tree.setCheckedNodes(_this2.defaultCheckedNodes);
                  _this2.treeLoading = false;
                });
              }
            case 9:
            case "end":
              return _context2.stop();
          }
        }, _callee2);
      }))();
    }
  },
  created: function created() {}
});
// CONCATENATED MODULE: ./src/modules/host/resource-management/components/OperatePermissionDialog.vue?vue&type=script&lang=js
 /* harmony default export */ var components_OperatePermissionDialogvue_type_script_lang_js = (OperatePermissionDialogvue_type_script_lang_js); 
// EXTERNAL MODULE: ./src/modules/host/resource-management/components/OperatePermissionDialog.vue?vue&type=style&index=0&id=57b8d1fb&prod&lang=scss&scoped=true
var OperatePermissionDialogvue_type_style_index_0_id_57b8d1fb_prod_lang_scss_scoped_true = __webpack_require__("456b");

// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__("2877");

// CONCATENATED MODULE: ./src/modules/host/resource-management/components/OperatePermissionDialog.vue






/* normalize component */

var component = Object(componentNormalizer["a" /* default */])(
  components_OperatePermissionDialogvue_type_script_lang_js,
  render,
  staticRenderFns,
  false,
  null,
  "57b8d1fb",
  null
  
)

/* harmony default export */ var OperatePermissionDialog = __webpack_exports__["default"] = (component.exports);

/***/ }),

/***/ "7e53":
/***/ (function(module, exports, __webpack_require__) {

exports = module.exports = __webpack_require__("2350")(false);
// imports


// module
exports.push([module.i, ".wraper--tree[data-v-57b8d1fb]{height:500px}", ""]);

// exports


/***/ }),

/***/ "9a2e":
/***/ (function(module, exports, __webpack_require__) {

// style-loader: Adds some css to the DOM by adding a <style> tag

// load the styles
var content = __webpack_require__("7e53");
if(content.__esModule) content = content.default;
if(typeof content === 'string') content = [[module.i, content, '']];
if(content.locals) module.exports = content.locals;
// add the styles to the DOM
var add = __webpack_require__("499e").default
var update = add("5e0bc3e2", content, true, {"sourceMap":false,"shadowMode":false});

/***/ })

}]);
//# sourceMappingURL=resource-management.umd.6.js.map