UNPKG

zcloud-ui

Version:

A Component Library for Vue.js.

653 lines (578 loc) 18.8 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/"; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 60); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; }); /* globals __VUE_SSR_CONTEXT__ */ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules). // This module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle. function normalizeComponent ( scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, /* server only */ shadowMode /* vue-cli only */ ) { // Vue.extend constructor export interop var options = typeof scriptExports === 'function' ? scriptExports.options : scriptExports // render functions if (render) { options.render = render options.staticRenderFns = staticRenderFns options._compiled = true } // functional template if (functionalTemplate) { options.functional = true } // scopedId if (scopeId) { options._scopeId = 'data-v-' + scopeId } var hook if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || // cached call (this.$vnode && this.$vnode.ssrContext) || // stateful (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional // 2.2 with runInNewContext: true if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { context = __VUE_SSR_CONTEXT__ } // inject component styles if (injectStyles) { injectStyles.call(this, context) } // register component module identifier for async chunk inferrence if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier) } } // used by ssr in case component is cached and beforeCreate // never gets called options._ssrRegister = hook } else if (injectStyles) { hook = shadowMode ? function () { injectStyles.call( this, (options.functional ? this.parent : this).$root.$options.shadowRoot ) } : injectStyles } if (hook) { if (options.functional) { // for template-only hot-reload because in that case the render fn doesn't // go through the normalizer options._injectStyles = hook // register for functional component in vue file var originalRender = options.render options.render = function renderWithStyleInjection (h, context) { hook.call(context) return originalRender(h, context) } } else { // inject component registration as beforeCreate hook var existing = options.beforeCreate options.beforeCreate = existing ? [].concat(existing, hook) : [hook] } } return { exports: scriptExports, options: options } } /***/ }), /***/ 24: /***/ (function(module, exports) { module.exports = require("@riophae/vue-treeselect"); /***/ }), /***/ 30: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/tree-select/src/main.vue?vue&type=template&id=5febe2cc& var render = function() { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "tree-select", _vm._g( _vm._b( { staticClass: "zl-tree-select", attrs: { "value-consists-of": _vm.valueConsistsOf, value: _vm.value, options: _vm.options, "limit-text": _vm.limitText, "no-results-text": _vm.noResultsText, "append-to-body": _vm.appendToBody, normalizer: _vm.normalizers, "no-options-text": _vm.noOptionsText }, on: { input: _vm.evenInput, select: function($event) { return _vm.handleSelect($event, "add") }, deselect: function($event) { return _vm.handleSelect($event, "del") }, open: _vm.handleOpen } }, "tree-select", _vm.$attrs, false ), _vm.listeners ), [_vm._t("default")], 2 ) } var staticRenderFns = [] render._withStripped = true // CONCATENATED MODULE: ./packages/tree-select/src/main.vue?vue&type=template&id=5febe2cc& // EXTERNAL MODULE: external "@riophae/vue-treeselect" var vue_treeselect_ = __webpack_require__(24); var vue_treeselect_default = /*#__PURE__*/__webpack_require__.n(vue_treeselect_); // EXTERNAL MODULE: external "@riophae/vue-treeselect/dist/vue-treeselect.css" var vue_treeselect_css_ = __webpack_require__(31); // EXTERNAL MODULE: external "zcloud-ui/lib/mixins/emitter" var emitter_ = __webpack_require__(6); var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_); // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/tree-select/src/main.vue?vue&type=script&lang=js& // // // // // // /* harmony default export */ var mainvue_type_script_lang_js_ = ({ mixins: [emitter_default.a], name: 'ZlTreeSelect', data: function data() { return { locked: false, normalizers: {}, listeners: {}, copyValue: this.value }; }, props: { value: { type: [Object, String, Number, Array] }, id: { type: String, default: 'id' }, label: { type: String, default: 'label' }, // 节点选中的形式返回的数据 valueConsistsOf: { type: String, default: 'BRANCH_PRIORITY' }, userRelevance: { // 是否开启自定义父子关联 type: Boolean, default: false }, hasDelete: { type: Boolean, default: false }, limitText: { type: Function, default: function _default(count) { return '+ ' + count; } }, noOptionsText: { type: String, default: '资源加载中...' }, noResultsText: { type: String, default: '无匹配数据' }, deleteId: { // 禁用的选项是需要设置该id=1/0或true/false type: String, default: 'isDelete' }, prarntCancelRelevance: { // 父级取消不关联子 type: Boolean, default: true }, normalizer: { type: [Object, Function] }, options: { type: [Array], default: function _default() { return []; } }, url: { type: Object, default: function _default() { return { get: '' }; } }, params: { type: Object, default: function _default() { return { getParams: {} }; } }, getCallback: { type: Function }, appendToBody: { type: Boolean, default: true }, init: { type: Boolean, default: false }, deleteParams: { // 需要删除的传参 type: [Array], default: function _default() { return ['id', 'ignore']; } }, custom: { // 用户自定义配置 type: Boolean, default: false } }, created: function created() { this.formatNormalizers(); this.filterListener(); if (this.init) { if (this.custom) { this.doGetCall(); } else { this.getList(); } } }, methods: { filterListener: function filterListener() { var _this = this; var blacklist = ['input', 'select', 'deselect', 'open'], // 重置了的相关事件排除 listeners = {}; Object.keys(this.$listeners).filter(function (item) { if (!blacklist.includes(item)) { listeners[item] = _this.$listeners[item]; } }); this.listeners = listeners; }, // https://github.com/riophae/vue-treeselect/issues/32 getList: function getList(type) { var _this2 = this; var params = {}; // 类型 if (this.getType(this.params.getParams) === 'Object') { params = this.params.getParams; } else if (this.getType(this.params.getParams) === 'Function') { params = this.params.getParams.call(this, this.value); } if (type === 'open') { params = this.formatParams(JSON.parse(JSON.stringify(params))); } this.Http(this.url.get, params, { inside: true, ignoreRepeat: true }).then(function (res) { _this2.$emit('update', res); }).catch(function (_) { _this2.locked = false; }); }, // 展开 handleOpen: function handleOpen(val) { if (this.locked) return; this.locked = true; // 用户应定义 if (this.custom) { this.doGetCall('open'); return; } this.$emit('update:options', []); this.getList('open'); }, // 发起自定义请求 doGetCall: function doGetCall(type) { var _this3 = this; // 处理编辑和新增 this.getCallback && this.getCallback(type === 'open' ? '' : this.value).then(function (res) { _this3.$emit('update', res); }); }, // input 事件 evenInput: function evenInput(val) { var _this4 = this; console.log('copyValue', this.copyValue, val); if (JSON.stringify(this.copyValue) === JSON.stringify(val)) return; this.copyValue = val; this.$nextTick(function () { // 异步处理 _this4.$emit('input', _this4.copyValue); // v-model var nodes = _this4.getNodes(_this4.copyValue instanceof Array ? _this4.copyValue : [_this4.copyValue], _this4.options); _this4.$emit('change', nodes, _this4.copyValue); _this4.$emit('select', nodes, _this4.copyValue); _this4.dispatch('ElFormItem', 'el.form.change', _this4.copyValue); }); }, // 获取绑定的节点 getNodes: function getNodes(ids, items) { var _this5 = this; var arr = []; items.forEach(function (item) { if (ids.includes(item[_this5.id])) { arr.push(item); } if (item.children && item.children.length) { arr = arr.concat(_this5.getNodes(ids, item.children)); } }); return arr; }, // 选中数据处理 handleSelect: function handleSelect(node, type) { var _this6 = this; // 只有flat和multiple设置true,才去判断 || 父取消不关联子 if (!this.userRelevance || !this.$attrs.flat || !this.$attrs.multiple || !this.prarntCancelRelevance && type === 'del') { return; } var arr = []; this.collectIds(node.children, type, arr); this.$nextTick(function () { var value = [].concat(_this6.copyValue); arr.forEach(function (val) { var findIndex = value.indexOf(val); if (type === 'add' && findIndex < 0) { value.push(val); } else if (type === 'del' && findIndex >= 0) { value.splice(findIndex, 1); } }); _this6.copyValue = value; }); }, // 收集id collectIds: function collectIds(node, type) { var _this7 = this; var arr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; if (node && node.length) { node.forEach(function (item) { if (!_this7.hasDelete) { arr.push(item[_this7.id]); } else if (_this7.hasDelete && !item[_this7.deleteId]) { arr.push(item[_this7.id]); } if (item.children && item.children.length) { _this7.collectIds(item.children, type, arr); } }); } }, formatParams: function formatParams(row) { for (var _iterator = Object.keys(row), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { var _ref; if (_isArray) { if (_i >= _iterator.length) break; _ref = _iterator[_i++]; } else { _i = _iterator.next(); if (_i.done) break; _ref = _i.value; } var item = _ref; if (this.deleteParams.includes(item)) { delete row[item]; } if (this.getType(row[item]) === 'Object') { row[item] = this.formatParams(row[item]); } } return row; }, // 获取类型 getType: function getType(obj) { return Object.prototype.toString.call(obj).slice(8, -1); }, // 处理显示格式 formatNormalizers: function formatNormalizers() { var _this8 = this; if (this.normalizer) { this.normalizers = this.normalizer; } else { this.normalizers = function (node) { if (!node.children || !node.children.length) { delete node.children; } var aJson = { id: node[_this8.id], label: node[_this8.label] || node.text, children: node.children // 暂时写死,更具需求在变化 }; if (_this8.hasDelete) { aJson.isDisabled = node[_this8.deleteId] === 1 || !!node[_this8.deleteId]; } return aJson; }; } } }, components: { treeSelect: vue_treeselect_default.a } }); // CONCATENATED MODULE: ./packages/tree-select/src/main.vue?vue&type=script&lang=js& /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(0); // CONCATENATED MODULE: ./packages/tree-select/src/main.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( src_mainvue_type_script_lang_js_, render, staticRenderFns, false, null, null, null ) /* hot reload */ if (false) { var api; } component.options.__file = "packages/tree-select/src/main.vue" /* harmony default export */ var main = __webpack_exports__["default"] = (component.exports); /***/ }), /***/ 31: /***/ (function(module, exports) { module.exports = require("@riophae/vue-treeselect/dist/vue-treeselect.css"); /***/ }), /***/ 6: /***/ (function(module, exports) { module.exports = require("zcloud-ui/lib/mixins/emitter"); /***/ }), /***/ 60: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _src_main__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(30); /* istanbul ignore next */ _src_main__WEBPACK_IMPORTED_MODULE_0__["default"].install = function (Vue) { Vue.component(_src_main__WEBPACK_IMPORTED_MODULE_0__["default"].name, _src_main__WEBPACK_IMPORTED_MODULE_0__["default"]); }; /* harmony default export */ __webpack_exports__["default"] = (_src_main__WEBPACK_IMPORTED_MODULE_0__["default"]); /***/ }) /******/ });