mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-05-06 22:57:57 +08:00
449 lines
10 KiB
JavaScript
449 lines
10 KiB
JavaScript
![]() |
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] = {
|
||
|
/******/ exports: {},
|
||
|
/******/ id: moduleId,
|
||
|
/******/ loaded: false
|
||
|
/******/ };
|
||
|
|
||
|
/******/ // Execute the module function
|
||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||
|
|
||
|
/******/ // Flag the module as loaded
|
||
|
/******/ module.loaded = 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;
|
||
|
|
||
|
/******/ // __webpack_public_path__
|
||
|
/******/ __webpack_require__.p = "/dist/";
|
||
|
|
||
|
/******/ // Load entry module and return exports
|
||
|
/******/ return __webpack_require__(0);
|
||
|
/******/ })
|
||
|
/************************************************************************/
|
||
|
/******/ ({
|
||
|
|
||
|
/***/ 0:
|
||
|
/***/ function(module, exports, __webpack_require__) {
|
||
|
|
||
|
module.exports = __webpack_require__(151);
|
||
|
|
||
|
|
||
|
/***/ },
|
||
|
|
||
|
/***/ 3:
|
||
|
/***/ function(module, exports) {
|
||
|
|
||
|
module.exports = function normalizeComponent (
|
||
|
rawScriptExports,
|
||
|
compiledTemplate,
|
||
|
scopeId,
|
||
|
cssModules
|
||
|
) {
|
||
|
var esModule
|
||
|
var scriptExports = rawScriptExports = rawScriptExports || {}
|
||
|
|
||
|
// ES6 modules interop
|
||
|
var type = typeof rawScriptExports.default
|
||
|
if (type === 'object' || type === 'function') {
|
||
|
esModule = rawScriptExports
|
||
|
scriptExports = rawScriptExports.default
|
||
|
}
|
||
|
|
||
|
// Vue.extend constructor export interop
|
||
|
var options = typeof scriptExports === 'function'
|
||
|
? scriptExports.options
|
||
|
: scriptExports
|
||
|
|
||
|
// render functions
|
||
|
if (compiledTemplate) {
|
||
|
options.render = compiledTemplate.render
|
||
|
options.staticRenderFns = compiledTemplate.staticRenderFns
|
||
|
}
|
||
|
|
||
|
// scopedId
|
||
|
if (scopeId) {
|
||
|
options._scopeId = scopeId
|
||
|
}
|
||
|
|
||
|
// inject cssModules
|
||
|
if (cssModules) {
|
||
|
var computed = options.computed || (options.computed = {})
|
||
|
Object.keys(cssModules).forEach(function (key) {
|
||
|
var module = cssModules[key]
|
||
|
computed[key] = function () { return module }
|
||
|
})
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
esModule: esModule,
|
||
|
exports: scriptExports,
|
||
|
options: options
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/***/ },
|
||
|
|
||
|
/***/ 14:
|
||
|
/***/ function(module, exports) {
|
||
|
|
||
|
module.exports = require("element-ui/lib/mixins/emitter");
|
||
|
|
||
|
/***/ },
|
||
|
|
||
|
/***/ 151:
|
||
|
/***/ function(module, exports, __webpack_require__) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
exports.__esModule = true;
|
||
|
|
||
|
var _formItem = __webpack_require__(152);
|
||
|
|
||
|
var _formItem2 = _interopRequireDefault(_formItem);
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
/* istanbul ignore next */
|
||
|
_formItem2.default.install = function (Vue) {
|
||
|
Vue.component(_formItem2.default.name, _formItem2.default);
|
||
|
};
|
||
|
|
||
|
exports.default = _formItem2.default;
|
||
|
|
||
|
/***/ },
|
||
|
|
||
|
/***/ 152:
|
||
|
/***/ function(module, exports, __webpack_require__) {
|
||
|
|
||
|
var Component = __webpack_require__(3)(
|
||
|
/* script */
|
||
|
__webpack_require__(153),
|
||
|
/* template */
|
||
|
__webpack_require__(155),
|
||
|
/* scopeId */
|
||
|
null,
|
||
|
/* cssModules */
|
||
|
null
|
||
|
)
|
||
|
|
||
|
module.exports = Component.exports
|
||
|
|
||
|
|
||
|
/***/ },
|
||
|
|
||
|
/***/ 153:
|
||
|
/***/ function(module, exports, __webpack_require__) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
exports.__esModule = true;
|
||
|
|
||
|
var _asyncValidator = __webpack_require__(154);
|
||
|
|
||
|
var _asyncValidator2 = _interopRequireDefault(_asyncValidator);
|
||
|
|
||
|
var _emitter = __webpack_require__(14);
|
||
|
|
||
|
var _emitter2 = _interopRequireDefault(_emitter);
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
|
||
|
function noop() {}
|
||
|
|
||
|
function getPropByPath(obj, path) {
|
||
|
var tempObj = obj;
|
||
|
path = path.replace(/\[(\w+)\]/g, '.$1');
|
||
|
path = path.replace(/^\./, '');
|
||
|
|
||
|
var keyArr = path.split('.');
|
||
|
var i = 0;
|
||
|
|
||
|
for (var len = keyArr.length; i < len - 1; ++i) {
|
||
|
var key = keyArr[i];
|
||
|
if (key in tempObj) {
|
||
|
tempObj = tempObj[key];
|
||
|
} else {
|
||
|
throw new Error('please transfer a valid prop path to form item!');
|
||
|
}
|
||
|
}
|
||
|
return {
|
||
|
o: tempObj,
|
||
|
k: keyArr[i],
|
||
|
v: tempObj[keyArr[i]]
|
||
|
};
|
||
|
}
|
||
|
|
||
|
exports.default = {
|
||
|
name: 'ElFormItem',
|
||
|
|
||
|
componentName: 'ElFormItem',
|
||
|
|
||
|
mixins: [_emitter2.default],
|
||
|
|
||
|
props: {
|
||
|
label: String,
|
||
|
labelWidth: String,
|
||
|
prop: String,
|
||
|
required: Boolean,
|
||
|
rules: [Object, Array],
|
||
|
error: String,
|
||
|
validateStatus: String,
|
||
|
showMessage: {
|
||
|
type: Boolean,
|
||
|
default: true
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
error: function error(value) {
|
||
|
this.validateMessage = value;
|
||
|
this.validateState = value ? 'error' : '';
|
||
|
},
|
||
|
validateStatus: function validateStatus(value) {
|
||
|
this.validateState = value;
|
||
|
}
|
||
|
},
|
||
|
computed: {
|
||
|
labelStyle: function labelStyle() {
|
||
|
var ret = {};
|
||
|
if (this.form.labelPosition === 'top') return ret;
|
||
|
var labelWidth = this.labelWidth || this.form.labelWidth;
|
||
|
if (labelWidth) {
|
||
|
ret.width = labelWidth;
|
||
|
}
|
||
|
return ret;
|
||
|
},
|
||
|
contentStyle: function contentStyle() {
|
||
|
var ret = {};
|
||
|
if (this.form.labelPosition === 'top' || this.form.inline) return ret;
|
||
|
var labelWidth = this.labelWidth || this.form.labelWidth;
|
||
|
if (labelWidth) {
|
||
|
ret.marginLeft = labelWidth;
|
||
|
}
|
||
|
return ret;
|
||
|
},
|
||
|
form: function form() {
|
||
|
var parent = this.$parent;
|
||
|
while (parent.$options.componentName !== 'ElForm') {
|
||
|
parent = parent.$parent;
|
||
|
}
|
||
|
return parent;
|
||
|
},
|
||
|
|
||
|
fieldValue: {
|
||
|
cache: false,
|
||
|
get: function get() {
|
||
|
var model = this.form.model;
|
||
|
if (!model || !this.prop) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var path = this.prop;
|
||
|
if (path.indexOf(':') !== -1) {
|
||
|
path = path.replace(/:/, '.');
|
||
|
}
|
||
|
|
||
|
return getPropByPath(model, path).v;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
data: function data() {
|
||
|
return {
|
||
|
validateState: '',
|
||
|
validateMessage: '',
|
||
|
validateDisabled: false,
|
||
|
validator: {},
|
||
|
isRequired: false
|
||
|
};
|
||
|
},
|
||
|
|
||
|
methods: {
|
||
|
validate: function validate(trigger) {
|
||
|
var _this = this;
|
||
|
|
||
|
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
||
|
|
||
|
var rules = this.getFilteredRule(trigger);
|
||
|
if (!rules || rules.length === 0) {
|
||
|
callback();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
this.validateState = 'validating';
|
||
|
|
||
|
var descriptor = {};
|
||
|
descriptor[this.prop] = rules;
|
||
|
|
||
|
var validator = new _asyncValidator2.default(descriptor);
|
||
|
var model = {};
|
||
|
|
||
|
model[this.prop] = this.fieldValue;
|
||
|
|
||
|
validator.validate(model, { firstFields: true }, function (errors, fields) {
|
||
|
_this.validateState = !errors ? 'success' : 'error';
|
||
|
_this.validateMessage = errors ? errors[0].message : '';
|
||
|
|
||
|
callback(_this.validateMessage);
|
||
|
});
|
||
|
},
|
||
|
resetField: function resetField() {
|
||
|
this.validateState = '';
|
||
|
this.validateMessage = '';
|
||
|
|
||
|
var model = this.form.model;
|
||
|
var value = this.fieldValue;
|
||
|
var path = this.prop;
|
||
|
if (path.indexOf(':') !== -1) {
|
||
|
path = path.replace(/:/, '.');
|
||
|
}
|
||
|
|
||
|
var prop = getPropByPath(model, path);
|
||
|
|
||
|
if (Array.isArray(value)) {
|
||
|
this.validateDisabled = true;
|
||
|
prop.o[prop.k] = [].concat(this.initialValue);
|
||
|
} else {
|
||
|
this.validateDisabled = true;
|
||
|
prop.o[prop.k] = this.initialValue;
|
||
|
}
|
||
|
},
|
||
|
getRules: function getRules() {
|
||
|
var formRules = this.form.rules;
|
||
|
var selfRuels = this.rules;
|
||
|
|
||
|
formRules = formRules ? formRules[this.prop] : [];
|
||
|
|
||
|
return [].concat(selfRuels || formRules || []);
|
||
|
},
|
||
|
getFilteredRule: function getFilteredRule(trigger) {
|
||
|
var rules = this.getRules();
|
||
|
|
||
|
return rules.filter(function (rule) {
|
||
|
return !rule.trigger || rule.trigger.indexOf(trigger) !== -1;
|
||
|
});
|
||
|
},
|
||
|
onFieldBlur: function onFieldBlur() {
|
||
|
this.validate('blur');
|
||
|
},
|
||
|
onFieldChange: function onFieldChange() {
|
||
|
if (this.validateDisabled) {
|
||
|
this.validateDisabled = false;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
this.validate('change');
|
||
|
}
|
||
|
},
|
||
|
mounted: function mounted() {
|
||
|
var _this2 = this;
|
||
|
|
||
|
if (this.prop) {
|
||
|
this.dispatch('ElForm', 'el.form.addField', [this]);
|
||
|
|
||
|
var initialValue = this.fieldValue;
|
||
|
if (Array.isArray(initialValue)) {
|
||
|
initialValue = [].concat(initialValue);
|
||
|
}
|
||
|
Object.defineProperty(this, 'initialValue', {
|
||
|
value: initialValue
|
||
|
});
|
||
|
|
||
|
var rules = this.getRules();
|
||
|
|
||
|
if (rules.length) {
|
||
|
rules.every(function (rule) {
|
||
|
if (rule.required) {
|
||
|
_this2.isRequired = true;
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
this.$on('el.form.blur', this.onFieldBlur);
|
||
|
this.$on('el.form.change', this.onFieldChange);
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
beforeDestroy: function beforeDestroy() {
|
||
|
this.dispatch('ElForm', 'el.form.removeField', [this]);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/***/ },
|
||
|
|
||
|
/***/ 154:
|
||
|
/***/ function(module, exports) {
|
||
|
|
||
|
module.exports = require("async-validator");
|
||
|
|
||
|
/***/ },
|
||
|
|
||
|
/***/ 155:
|
||
|
/***/ function(module, exports) {
|
||
|
|
||
|
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
|
||
|
return _c('div', {
|
||
|
staticClass: "el-form-item",
|
||
|
class: {
|
||
|
'is-error': _vm.validateState === 'error',
|
||
|
'is-validating': _vm.validateState === 'validating',
|
||
|
'is-required': _vm.isRequired || _vm.required
|
||
|
}
|
||
|
}, [(_vm.label) ? _c('label', {
|
||
|
staticClass: "el-form-item__label",
|
||
|
style: (_vm.labelStyle),
|
||
|
attrs: {
|
||
|
"for": _vm.prop
|
||
|
}
|
||
|
}, [_vm._v("\n " + _vm._s(_vm.label + _vm.form.labelSuffix) + "\n ")]) : _vm._e(), _c('div', {
|
||
|
staticClass: "el-form-item__content",
|
||
|
style: (_vm.contentStyle)
|
||
|
}, [_vm._t("default"), _c('transition', {
|
||
|
attrs: {
|
||
|
"name": "el-zoom-in-top"
|
||
|
}
|
||
|
}, [(_vm.validateState === 'error' && _vm.showMessage && _vm.form.showMessage) ? _c('div', {
|
||
|
staticClass: "el-form-item__error"
|
||
|
}, [_vm._v(_vm._s(_vm.validateMessage))]) : _vm._e()])], 2)])
|
||
|
},staticRenderFns: []}
|
||
|
|
||
|
/***/ }
|
||
|
|
||
|
/******/ });
|