@varonervar/components
Version:
> 基于[Element-UI](https://element.eleme.cn/#/zh-CN/component/quickstart) 封装常用组件,部分组件参考[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
977 lines (916 loc) • 27.5 kB
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] = {
/******/ 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 = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 14);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 10:
/***/ (function(module, exports) {
module.exports = require("dayjs");
/***/ }),
/***/ 14:
/***/ (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/z-table/body/ZTable.vue?vue&type=template&id=b0f170b6&
var render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ staticClass: "wl-ztable" },
[
_c(
"el-table",
_vm._g(
_vm._b(
{
ref: "table",
staticStyle: { width: "100%" },
attrs: {
data: _vm.tableData,
"header-row-class-name": "table-header",
},
scopedSlots: _vm._u(
[
{
key: "append",
fn: function () {
return [_vm._t("append")]
},
proxy: true,
},
],
null,
true
),
},
"el-table",
_vm.$attrs,
false
),
_vm.$listeners
),
[
_vm.isShowCheck
? _c("el-table-column", {
attrs: {
"is-show-check": _vm.isShowCheck,
type: "selection",
width: "55",
},
})
: _vm._e(),
_vm.isShowIndex
? _c("el-table-column", {
attrs: { type: "index", width: "55", label: _vm.indexLabel },
})
: _vm._e(),
_vm._l(_vm.showTableFormat, function (column) {
return [
_c(
"el-table-column",
_vm._b(
{
key: column.value,
attrs: {
label: column.label,
prop: column.value,
"show-overflow-tooltip": true,
},
scopedSlots: _vm._u(
[
column.template === "slot"
? {
key: "default",
fn: function (ref) {
var row = ref.row
var col = ref.column
return [
_vm._t(column.slotName, null, {
row: row,
column: col,
}),
]
},
}
: column.template === "enumer"
? {
key: "default",
fn: function (ref) {
var row = ref.row
var col = ref.column
return [
_c("span", [
_vm._v(
_vm._s(
(typeof column.enumer[
row[col.property]
] === "function"
? column.enumer[row[col.property]](
row
)
: column.enumer[row[col.property]]) ||
col.def ||
"-"
)
),
]),
]
},
}
: column.list &&
[
"select",
"radio",
"radioButton",
"checkbox",
].includes(column.template)
? {
key: "default",
fn: function (ref) {
var row = ref.row
var col = ref.column
return _vm._l(
column.list,
function (valueEnumItem, index) {
return _c(
"div",
{ key: index },
[
row[col.property] == valueEnumItem.value
? [
valueEnumItem.status
? _c(
"el-link",
{
attrs: {
underline: false,
type: valueEnumItem.status,
},
},
[
_vm._v(
_vm._s(
valueEnumItem.label
)
),
]
)
: _c("span", [
_vm._v(
_vm._s(
valueEnumItem.label ||
col.def ||
"-"
)
),
]),
]
: _vm._e(),
],
2
)
}
)
},
}
: column.template === "time"
? {
key: "default",
fn: function (ref) {
var row = ref.row
return [
_c("span", [
_vm._v(
_vm._s(
_vm._f("dateFormat")(
(column.value || "")
.split(/,|,/g)
.map(function (v) {
return row[v]
}),
{
def: column.def,
format: column.format,
flag: column.connectFlag,
}
)
)
),
]),
]
},
}
: {
key: "default",
fn: function (ref) {
var row = ref.row
var col = ref.column
return [
column.iconfont
? _c("i", {
class: column.iconfont,
attrs: { classs: "table-item-icon" },
})
: _vm._e(),
_c("span", { staticClass: "span" }, [
_vm._v(
_vm._s(
row[col.property] == null ||
row[col.property] === ""
? col.def || "-"
: row[col.property]
)
),
]),
]
},
},
],
null,
true
),
},
"el-table-column",
Object.assign({}, column.bind, column.config),
false
)
),
]
}),
_vm.isShowOpions
? _c("el-table-column", {
staticClass: "options-col",
attrs: {
label: _vm.optionsLabel,
"header-align": "left",
fixed: _vm.optionsFixed,
width: _vm.optionsWidth,
},
scopedSlots: _vm._u(
[
{
key: "default",
fn: function (scope) {
return [
_vm._t("options", null, {
row: scope.row,
column: scope.column,
$index: scope.$index,
}),
]
},
},
],
null,
true
),
})
: _vm._e(),
],
2
),
_vm.isShowPagination
? _c(
"div",
{ staticClass: "pagination flex-align-center" },
[
_c(
"el-dropdown",
{ on: { command: _vm.sizeChange } },
[
_c("span", { staticClass: "page-info" }, [
_vm._v(
"\n 每页显示 " +
_vm._s(_vm.paginationObj.pageSize) +
" 项"
),
_c("i", {
staticClass: "el-icon-arrow-down el-icon--right",
}),
]),
_c(
"el-dropdown-menu",
{ attrs: { slot: "dropdown" }, slot: "dropdown" },
_vm._l(_vm.pageSizes, function (item) {
return _c(
"el-dropdown-item",
{ key: item, attrs: { command: item } },
[_vm._v("每页显示 " + _vm._s(item) + " 项")]
)
}),
1
),
],
1
),
_c("span", { staticClass: "page-info total" }, [
_vm._v("总计" + _vm._s(_vm.paginationObj.total) + "项"),
]),
_c("el-pagination", {
attrs: {
layout: "prev, pager, next",
"page-size": _vm.paginationObj.pageSize,
"current-page": _vm.paginationObj.pageNum,
"page-sizes": _vm.pageSizes,
total: _vm.paginationObj.total,
},
on: {
"size-change": _vm.sizeChange,
"current-change": _vm.currentChange,
},
}),
_c(
"div",
{
staticClass:
"el-input el-pagination__editor is-in-pagination",
},
[
_c("input", {
ref: "number",
staticClass: "el-input__inner",
attrs: {
type: "number",
autocomplete: "off",
min: "1",
max: "2",
},
domProps: { value: _vm.jumpPage },
on: {
change: _vm.jumpNumberChange,
keyup: function ($event) {
if (
!$event.type.indexOf("key") &&
_vm._k(
$event.keyCode,
"enter",
13,
$event.key,
"Enter"
)
) {
return null
}
return _vm.jumpGo.apply(null, arguments)
},
},
}),
]
),
_c("p", { staticClass: "jumpbtn", on: { click: _vm.jumpGo } }, [
_vm._v("跳转"),
]),
],
1
)
: _vm._e(),
],
1
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/z-table/body/ZTable.vue?vue&type=template&id=b0f170b6&
// EXTERNAL MODULE: external "dayjs"
var external_dayjs_ = __webpack_require__(10);
var external_dayjs_default = /*#__PURE__*/__webpack_require__.n(external_dayjs_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--0!./node_modules/vue-loader/lib??vue-loader-options!./packages/z-table/body/ZTable.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
const _pageSize = 30;
const _pageNum = 1;
const _pageTotal = 0;
/* harmony default export */ var ZTablevue_type_script_lang_js_ = ({
name: 'ZTable',
filters: {
dateFormat(arr, _ref) {
let {
def,
format = 'YYYY-MM-DD HH:mm:ss',
flag = '-'
} = _ref;
try {
if (arr.some(v => !v)) return def || '-';
return arr.map(t => external_dayjs_default()(new Date(t)).format(format)).join(flag);
} catch (error) {
return def || '-';
}
}
},
inheritAttrs: false,
props: {
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 40, 50, 100];
}
},
tableData: {
// table数据
type: Array,
required: true
},
// 请求函数
getTableData: {
type: Function,
required: true
},
/**
* label:必需
* value:必需
* template: 决定column的种类
* width:宽度
*/
tableFormat: {
// table格式
type: Array,
required: true
},
// 是否初始调用函数
isInitGetData: {
type: Boolean,
default: true
},
isShowCheck: {
// 是否显示选择行
type: Boolean,
default: false
},
isShowIndex: {
// 是否显示序号
type: Boolean,
default: false
},
indexLabel: {
type: String,
default: '序号'
},
isShowOpions: {
// 是否显示操作列
type: Boolean,
default: true
},
optionsLabel: {
// 操作的label
type: String,
default: '操作'
},
optionsFixed: {
type: [String, Boolean],
default: false
},
optionsWidth: {
// 操作的宽度
type: [String, Number],
default: '160'
},
isShowPagination: {
// 是否显示分页
type: Boolean,
default: true
},
value: {
type: Object,
default() {
return {
pageNum: _pageNum,
pageSize: _pageSize,
total: _pageTotal
};
}
}
},
data() {
return {
jumpPage: '',
paginationObj: {
total: _pageTotal,
pageSize: _pageSize,
pageNum: _pageNum
}
};
},
methods: {
jumpNumberChange(e) {
const eVal = e.target.value;
const {
total,
pageSize
} = this.paginationObj;
const max = Math.ceil(total / pageSize);
if (eVal > max) {
e.target.value = max;
} else if (eVal <= 0) {
this.jumpPage = 1;
e.target.value = 1;
} else {
this.jumpPage = +eVal;
}
},
jumpGo() {
if (!this.jumpPage) return;
this.paginationObj.pageNum = this.jumpPage;
this.$emit('input', { ...this.paginationObj
});
typeof this.getTableData === 'function' && this.getTableData(this._setTotal.bind(this));
},
sizeChange(size) {
this.paginationObj.pageNum = 1;
this.paginationObj.pageSize = size;
this.$emit('input', { ...this.paginationObj
});
typeof this.getTableData === 'function' && this.getTableData(this._setTotal.bind(this));
},
currentChange(page) {
this.paginationObj.pageNum = page;
this.$emit('input', { ...this.paginationObj
});
typeof this.getTableData === 'function' && this.getTableData(this._setTotal.bind(this));
},
toSearch() {
this.paginationObj.pageNum = 1;
this.$emit('input', { ...this.paginationObj
});
typeof this.getTableData === 'function' && this.getTableData(this._setTotal.bind(this));
},
// 设置总数
_setTotal(total) {
if (typeof total !== 'number' || !(+total >= 0)) {
console.error('总条数必须是正整数!');
return;
}
this.paginationObj.total = total;
this.$emit('input', { ...this.paginationObj
});
},
table() {
return this.$refs.table;
},
clearSelection() {
return this.$refs.table.clearSelection();
},
toggleRowSelection(row) {
return this.$refs.table.toggleRowSelection(row);
}
},
mounted() {
if (this.isInitGetData) {
this.$nextTick(() => {
typeof this.getTableData === 'function' && this.getTableData(this._setTotal.bind(this));
});
}
},
computed: {
showTableFormat(_ref2) {
let {
tableFormat
} = _ref2;
return tableFormat.filter(v => !v.hidden);
}
},
watch: {
value: {
handler(v) {
this.paginationObj.pageNum = v.pageNum || _pageNum;
this.paginationObj.pageSize = v.pageSize || _pageSize;
this.paginationObj.total = v.total || _pageTotal;
},
immediate: true,
deep: true
}
}
});
// CONCATENATED MODULE: ./packages/z-table/body/ZTable.vue?vue&type=script&lang=js&
/* harmony default export */ var body_ZTablevue_type_script_lang_js_ = (ZTablevue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./packages/z-table/body/ZTable.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
body_ZTablevue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var ZTable = (component.exports);
// CONCATENATED MODULE: ./packages/z-table/index.js
/* istanbul ignore next */
ZTable.install = function install(Vue) {
Vue.component(ZTable.name, ZTable);
};
/* harmony default export */ var z_table = __webpack_exports__["default"] = (ZTable);
/***/ })
/******/ });