zcloud-ui
Version:
A Component Library for Vue.js.
1,350 lines (1,253 loc) • 43.7 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 = "/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 76);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 2:
/***/ (function(module, exports) {
module.exports = require("zcloud-ui/lib/config/index");
/***/ }),
/***/ 47:
/***/ (function(module, exports) {
module.exports = require("babel-helper-vue-jsx-merge-props");
/***/ }),
/***/ 76:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: external "babel-helper-vue-jsx-merge-props"
var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(47);
var external_babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(external_babel_helper_vue_jsx_merge_props_);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/sectting.vue?vue&type=template&id=3cc0c4e1&
var secttingvue_type_template_id_3cc0c4e1_render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"zl-dialog",
{
staticClass: "app-wrapper",
attrs: {
title: "表格设置",
show: _vm.shows,
width: "960px",
classx: "custom-table-expand",
buttonSize: "mini",
"append-to-body": ""
},
on: {
submit: _vm.submit,
"update:show": function($event) {
_vm.shows = $event
}
}
},
[
_c(
"div",
[
_c(
"el-row",
{ attrs: { gutter: 10 } },
[
_c(
"el-col",
{ attrs: { span: 21 } },
[
_c(
"el-table",
{
ref: "tableRow",
staticStyle: { width: "100%" },
attrs: {
data: _vm.list,
size: "small",
border: "",
"max-height": _vm.maxHeight,
stripe: "",
"header-row-class-name": "table-header"
}
},
[
_c("el-table-column", {
attrs: { label: "选择", width: "60", align: "center" },
scopedSlots: _vm._u([
{
key: "default",
fn: function(scope) {
return [
_c("el-radio", {
attrs: {
disabled:
scope.row.fixed || !scope.row.isShow,
label: scope.row.index
},
model: {
value: _vm.currentIndex,
callback: function($$v) {
_vm.currentIndex = $$v
},
expression: "currentIndex"
}
})
]
}
}
])
}),
_c("el-table-column", {
attrs: { prop: "name", label: "列名" }
}),
_vm.isEditName
? _c("el-table-column", {
attrs: { label: "显示名称" },
scopedSlots: _vm._u(
[
{
key: "default",
fn: function(scope) {
return [
_c("el-input", {
attrs: { size: "small" },
model: {
value: scope.row.label,
callback: function($$v) {
_vm.$set(scope.row, "label", $$v)
},
expression: "scope.row.label"
}
})
]
}
}
],
null,
false,
18988287
)
})
: _vm._e(),
_c("el-table-column", {
attrs: { label: "宽度", width: "125" },
scopedSlots: _vm._u([
{
key: "default",
fn: function(scope) {
return [
_c("el-input-number", {
staticClass: "w100",
attrs: {
size: "small",
controls: false,
min: 50
},
model: {
value: scope.row.width,
callback: function($$v) {
_vm.$set(scope.row, "width", $$v)
},
expression: "scope.row.width"
}
})
]
}
}
])
}),
_c("el-table-column", {
attrs: {
prop: "date",
label: "显示",
width: "80",
align: "center"
},
scopedSlots: _vm._u([
{
key: "default",
fn: function(scope) {
return [
scope.row.isMastShow
? _c("el-switch", {
attrs: { disabled: "", size: "small" },
model: {
value: scope.row.isShow,
callback: function($$v) {
_vm.$set(scope.row, "isShow", $$v)
},
expression: "scope.row.isShow"
}
})
: _c("el-switch", {
attrs: {
disabled: scope.row.totalRow,
size: "small"
},
model: {
value: scope.row.isShow,
callback: function($$v) {
_vm.$set(scope.row, "isShow", $$v)
},
expression: "scope.row.isShow"
}
})
]
}
}
])
}),
_c("el-table-column", {
attrs: {
prop: "date",
label: "左锁列",
width: "70",
align: "center"
},
scopedSlots: _vm._u([
{
key: "default",
fn: function(scope) {
return [
_c("el-checkbox", {
attrs: { disabled: !scope.row.isShow },
on: {
change: function($event) {
return _vm.changeFixed(scope.row, "left")
}
},
model: {
value: scope.row.leftFixed,
callback: function($$v) {
_vm.$set(scope.row, "leftFixed", $$v)
},
expression: "scope.row.leftFixed"
}
})
]
}
}
])
}),
_c("el-table-column", {
attrs: {
prop: "date",
label: "右锁列",
width: "70",
align: "center"
},
scopedSlots: _vm._u([
{
key: "default",
fn: function(scope) {
return [
_c("el-checkbox", {
attrs: { disabled: !scope.row.isShow },
on: {
change: function($event) {
return _vm.changeFixed(scope.row, "right")
}
},
model: {
value: scope.row.rightFixed,
callback: function($$v) {
_vm.$set(scope.row, "rightFixed", $$v)
},
expression: "scope.row.rightFixed"
}
})
]
}
}
])
})
],
1
)
],
1
),
_c("el-col", { attrs: { span: 3 } }, [
_c("div", { staticClass: "right-btn" }, [
_c(
"p",
{ staticClass: "text-center mgb10" },
[
_c(
"el-button",
{ attrs: { size: "mini" }, on: { click: _vm.up } },
[_vm._v("上移")]
)
],
1
),
_c(
"p",
{ staticClass: "text-center mgb10" },
[
_c(
"el-button",
{ attrs: { size: "mini" }, on: { click: _vm.down } },
[_vm._v("下移")]
)
],
1
),
_c(
"p",
{ staticClass: "text-center mgb10" },
[
_c(
"el-button",
{ attrs: { size: "mini" }, on: { click: _vm.reset } },
[_vm._v("还原默认值")]
)
],
1
)
])
])
],
1
)
],
1
)
]
)
}
var staticRenderFns = []
secttingvue_type_template_id_3cc0c4e1_render._withStripped = true
// CONCATENATED MODULE: ./packages/table/src/sectting.vue?vue&type=template&id=3cc0c4e1&
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/sectting.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var secttingvue_type_script_lang_js_ = ({
data: function data() {
return {
maxHeight: null,
fixed: -1,
currentIndex: null,
list: []
};
},
props: {
isShow: {
type: Boolean,
required: true
},
// 远程保存的col, 如果远程没保存,就用页面的col 数据
columns: {
type: Array,
required: true
},
// 页面定义的col 数据
sourceColumns: {
type: Array,
required: true
},
// 是否可以修改列名称
isEditName: {
type: Boolean,
required: true
}
},
created: function created() {
this.list = this.initColumns(this.columns);
this.setHeigth();
},
methods: {
initColumns: function initColumns(list) {
var res = [],
i = 0,
unSet = [];
list.forEach(function (item, index) {
item.sortIndex = index + 1;
if (!item.unSet) {
item.index = i; // 编号
item.sourceIndex = typeof item.sourceIndex === 'number' ? item.sourceIndex : i; // 源编号.方便重置
item.name = item.name || item.label; // 名称
// item.fixed && (this.fixed = item.index); // 锁列
item.isShow = !item.isHide; // 是否显示
item.leftFixed = item.fixed === 'left' || item.fixed === true;
item.rightFixed = item.fixed === 'right';
res.push(item);
i++;
} else {
// 处理操作写在最末端,浮动居左问题
if (item.type === 'operate' && item.fixed === 'left') {
item.sortIndex = unSet.length + 0.5;
}
if (['indexX', 'index', 'sections'].includes(item.type)) {
unSet.push(1);
}
}
});
return JSON.parse(JSON.stringify(res));
},
setHeigth: function setHeigth() {
var height = window.innerHeight,
maxH = void 0;
if (height > 900) {
maxH = 600;
} else if (height > 800) {
maxH = 500;
} else if (height > 700) {
maxH = 400;
} else {
maxH = 350;
}
this.maxHeight = maxH;
},
// 锁列改变
changeFixed: function changeFixed(row, type) {
if (type === 'right' && row.rightFixed) {
row.leftFixed = false;
}
if (type === 'left' && row.leftFixed) {
row.rightFixed = false;
}
},
submit: function submit() {
this.list.forEach(function (item) {
item.isHide = !item.isShow;
delete item.isShow;
if (item.leftFixed) {
item.fixed = 'left';
} else if (item.rightFixed) {
item.fixed = 'right';
} else {
delete item.fixed;
}
});
var config = this.columns.filter(function (item) {
return item.unSet;
}).concat(this.list);
config.sort(function (a, b) {
if (!a.unSet && !b.unSet) {
return a.index - b.index;
} else {
return a.sortIndex - b.sortIndex;
}
});
this.$emit('change', config);
this.shows = false;
},
// 逻辑: 已经锁列的是不能上下移动的
up: function up() {
if (this.currentIndex > 0) {
var target = this.currentIndex - 1;
this.list[target].index = target + 1;
this.list[target + 1].index = target;
this.list[target] = this.list.splice(target + 1, 1, this.list[target])[0];
this.currentIndex = target;
}
},
down: function down() {
if (this.currentIndex < this.list.length - 1) {
var target = this.currentIndex + 1;
this.list[target].index = target - 1;
this.list[target - 1].index = target;
this.list[target] = this.list.splice(target - 1, 1, this.list[target])[0];
this.currentIndex = target;
}
},
reset: function reset() {
var columns = this.initColumns(this.sourceColumns);
columns.sort(function (a, b) {
return a.sourceIndex - b.sourceIndex;
});
columns.forEach(function (item) {
item.isShow = true;
});
this.list = columns;
this.list.forEach(function (item, index) {
item.label = item.name;
item.index = index;
});
this.currentIndex = null;
}
},
computed: {
shows: {
get: function get() {
return this.isShow;
},
set: function set(newValue) {
this.$emit('update:isShow', newValue); // 更新父组件shows
}
}
}
});
// CONCATENATED MODULE: ./packages/table/src/sectting.vue?vue&type=script&lang=js&
/* harmony default export */ var src_secttingvue_type_script_lang_js_ = (secttingvue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./packages/table/src/sectting.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
src_secttingvue_type_script_lang_js_,
secttingvue_type_template_id_3cc0c4e1_render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "packages/table/src/sectting.vue"
/* harmony default export */ var sectting = (component.exports);
// CONCATENATED MODULE: ./packages/table/src/indexDB.js
/*
* @Author: yangjj
* @Date: 2020-02-05 14:02:23
* @LastEditors : yangjj
* @LastEditTime : 2020-02-05 20:35:14
* @Description: file content
*/
var DATABASE = 'table_set';
var VERSION = 1;
var DATABASETABLE = 'table';
/* harmony default export */ var indexDB = ({
data: function data() {
return {
db: {},
isGetData: false // 是否能查到数据
};
},
methods: {
// 创建数据库
initIndexDB: function initIndexDB() {
var _this = this;
return new Promise(function (resolve) {
if (!window.indexedDB) {
window.indexedDB = window.mozIndexedDB || window.webkitIndexedDB || window.msIndexDB; // webkit是chrome
}
var request = indexedDB.open(DATABASE, VERSION);
request.onerror = function (event) {
console.log('打开数据库失败:' + event.target);
};
request.onsuccess = function (event) {
// console.log('打开数据库成功!');
_this.db = event.target.result;
if (_this.db) {
_this.getDataDB().then(function (_) {
resolve();
});
}
};
request.onupgradeneeded = function (event) {
console.log('版本变化!');
this.db = event.target.result;
if (!this.db.objectStoreNames.contains(DATABASETABLE)) {
this.db.createObjectStore(DATABASETABLE, {
keyPath: 'id',
autoIncrement: true
});
}
};
});
},
// 创建事务
createTransaction: function createTransaction() {
return this.db.transaction(DATABASETABLE, 'readwrite').objectStore(DATABASETABLE);
},
// 查
getDataDB: function getDataDB() {
var _this2 = this;
return new Promise(function (resolve) {
var objectStore = _this2.createTransaction();
var request = objectStore.get(_this2.pageKey);
request.onsuccess = function (e) {
var result = e.target.result;
if (result) {
_this2.isGetData = true; // 判断是否到获取数据
_this2.storeConfig = result;
_this2.getConfig(result);
}
resolve();
};
request.onerror = function (e) {
console.log('数据检索失败!');
};
});
},
// 增
addDataDB: function addDataDB(config) {
var objectStore = this.createTransaction();
objectStore.add(config);
objectStore.onsuccess = function (event) {
// console.log('数据写入成功');
};
objectStore.onerror = function (event) {
console.log('数据写入失败');
};
},
// 改
updateDataDB: function updateDataDB(config) {
var objectStore = this.createTransaction();
objectStore.put(config);
objectStore.onsuccess = function (event) {
// console.log('数据更新成功');
};
objectStore.onerror = function (event) {
console.log('数据更新失败');
};
},
// 删
removeDataDB: function removeDataDB(userId) {
var objectStore = this.createTransaction();
objectStore.delete(this.pageKey);
objectStore.onsuccess = function (event) {
console.log('删除成功');
};
}
}
});
// EXTERNAL MODULE: external "zcloud-ui/lib/config/index"
var index_ = __webpack_require__(2);
// CONCATENATED MODULE: ./src/utils/sha256/sha256.min.js
/**
* SHA256
* @version 2017年03月29日
* @author tot
*/
var SHA256 = function SHA256(s) {
var chrsz = 8;var hexcase = 0;function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);var msw = (x >> 16) + (y >> 16) + (lsw >> 16);return msw << 16 | lsw & 0xFFFF;
}function S(X, n) {
return X >>> n | X << 32 - n;
}function R(X, n) {
return X >>> n;
}function Ch(x, y, z) {
return x & y ^ ~x & z;
}function Maj(x, y, z) {
return x & y ^ x & z ^ y & z;
}function Sigma0256(x) {
return S(x, 2) ^ S(x, 13) ^ S(x, 22);
}function Sigma1256(x) {
return S(x, 6) ^ S(x, 11) ^ S(x, 25);
}function Gamma0256(x) {
return S(x, 7) ^ S(x, 18) ^ R(x, 3);
}function Gamma1256(x) {
return S(x, 17) ^ S(x, 19) ^ R(x, 10);
}function core_sha256(m, l) {
var K = [0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2];var HASH = [0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19];var W = [,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,];var a, b, c, d, e, f, g, h, i, j;var T1, T2;m[l >> 5] |= 0x80 << 24 - l % 32;m[(l + 64 >> 9 << 4) + 15] = l;for (var i = 0; i < m.length; i += 16) {
a = HASH[0];b = HASH[1];c = HASH[2];d = HASH[3];e = HASH[4];f = HASH[5];g = HASH[6];h = HASH[7];for (var j = 0; j < 64; j += 1) {
if (j < 16) {
W[j] = m[j + i];
} else {
W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
}T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);T2 = safe_add(Sigma0256(a), Maj(a, b, c));h = g;g = f;f = e;e = safe_add(d, T1);d = c;c = b;b = a;a = safe_add(T1, T2);
}HASH[0] = safe_add(a, HASH[0]);HASH[1] = safe_add(b, HASH[1]);HASH[2] = safe_add(c, HASH[2]);HASH[3] = safe_add(d, HASH[3]);HASH[4] = safe_add(e, HASH[4]);HASH[5] = safe_add(f, HASH[5]);HASH[6] = safe_add(g, HASH[6]);HASH[7] = safe_add(h, HASH[7]);
}return HASH;
}function str2binb(str) {
var bin = Array();var mask = (1 << chrsz) - 1;for (var i = 0; i < str.length * chrsz; i += chrsz) {
bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << 24 - i % 32;
}return bin;
}function Utf8Encode(string) {
string = string.replace(/\r\n/g, "\n");var utftext = "";for (var n = 0; n < string.length; n += 1) {
var c = string.charCodeAt(n);if (c < 128) {
utftext += String.fromCharCode(c);
} else if (c > 127 && c < 2048) {
utftext += String.fromCharCode(c >> 6 | 192);utftext += String.fromCharCode(c & 63 | 128);
} else {
utftext += String.fromCharCode(c >> 12 | 224);utftext += String.fromCharCode(c >> 6 & 63 | 128);utftext += String.fromCharCode(c & 63 | 128);
}
}return utftext;
}function binb2hex(binarray) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";var str = "";for (var i = 0; i < binarray.length * 4; i += 1) {
str += hex_tab.charAt(binarray[i >> 2] >> (3 - i % 4) * 8 + 4 & 0xF) + hex_tab.charAt(binarray[i >> 2] >> (3 - i % 4) * 8 & 0xF);
}return str;
}s = Utf8Encode(s);return binb2hex(core_sha256(str2binb(s), s.length * chrsz));
};
/* harmony default export */ var sha256_min = (SHA256);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/main.vue?vue&type=script&lang=js&
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
/* harmony default export */ var mainvue_type_script_lang_js_ = ({
name: 'ZlTable',
mixins: [indexDB],
data: function data() {
return {
config: [],
sourceConfig: [],
sourceSlots: [], // 原始solt数据
sSolts: [], // 展示solt数据
isTableSet: false, // 设置
showTable: true,
storeConfig: {},
isFristLoad: true
};
},
props: {
data: {
// 显示数据
type: Array,
required: true
},
showConfig: {
type: Boolean,
default: true
},
// 是否开启排序
sortable: {
type: Boolean,
default: false
},
name: {
type: String,
default: ''
},
setName: {
// 设置名称
type: String
},
// tips
showOverflowTooltip: {
type: Boolean,
default: true
},
// 依赖数据
depend: {
type: [Array, Boolean, String, Object, Number]
},
// 是否可以修改列名称
isEditName: {
type: Boolean,
default: false
}
},
created: function created() {
this.init();
},
watch: {
depend: {
deep: true,
handler: function handler(val, current) {
this.refresh();
}
}
},
render: function render(createElement, context) {
var _this = this;
var h = arguments[0];
var list = this.data;
var listeners = {
on: _extends({}, this.$listeners)
};
return h(
'div',
{ 'class': 'zl-table' },
[this.showTable ? h(
'el-table',
external_babel_helper_vue_jsx_merge_props_default()([{
attrs: { data: list, stripe: true, border: true, size: 'small' },
style: 'width: 100%', on: {
'sort-change': this.tableSort,
'header-dragend': this.headerDragend
},
ref: 'my-table' }, { attrs: this.$attrs }, listeners]),
[this.sSolts]
) : null, this.isTableSet ? h('sectting', external_babel_helper_vue_jsx_merge_props_default()([{
attrs: { isShow: true }
}, { on: { 'update:isShow': function updateIsShow(e) {
_this.isTableSet = e;
} } }, {
attrs: { columns: this.config,
isEditName: this.isEditName, sourceColumns: this.sourceConfig },
on: {
'change': this.changeTableColumns
}
}])) : null]
);
},
methods: _extends({
// 刷新视图
refresh: function refresh() {
var _this2 = this;
this.$nextTick(function () {
_this2.init();
});
},
// 拖拽后重新渲染
headerDragend: function headerDragend() {
// this.$refs['my-table'].doLayout();
},
// table排序
tableSort: function tableSort(_ref) {
var column = _ref.column,
prop = _ref.prop,
order = _ref.order;
var json = {
ascending: 'asc',
descending: 'desc'
};
this.$emit('sort-change', prop, json[order] || 'asc', { column: column, prop: prop, order: order });
},
// 初始化
init: function init() {
var _this3 = this;
var h = this.$createElement;
this.sourceSlots = this.$slots.default.filter(function (item) {
return item.tag;
});
this.formatProps().then(function (_) {
if (_this3.showConfig) {
var arr = [];
if (_this3.setName) {
arr = _this3.sourceSlots.filter(function (item) {
return item.componentOptions.propsData.prop === _this3.setName;
});
} else {
arr = _this3.sourceSlots.filter(function (item) {
var prop = item.componentOptions.propsData.prop || item.componentOptions.propsData.type;
return prop === 'index' || prop === 'indexX';
});
}
if (arr && arr.length) {
if (!arr[0].data.scopedSlots) {
arr[0].data.scopedSlots = {};
}
arr[0].data.scopedSlots.header = function () {
return h('i', { 'class': 'el-icon-s-tools pointer',
on: {
'click': function click() {
_this3.isTableSet = true;
}
}
});
};
}
}
_this3.columnCof();
});
},
// 处理props和attrs
formatProps: function formatProps() {
var _this4 = this;
return new Promise(function (resolve) {
var arr = [];
for (var _iterator = _this4.sourceSlots, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref2;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref2 = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref2 = _i.value;
}
var item = _ref2;
arr.push(_extends({}, item.componentOptions.propsData, item.data.attrs));
}
_this4.config = arr;
_this4.sourceConfig = JSON.parse(JSON.stringify(arr));
_this4.generateHash();
// 是否拿过配置信息
if (_this4.isFristLoad) {
_this4.isFristLoad = false;
// 判断类型
if (index_["Environment"].TABLE.mode === 'http') {
_this4.getPageConfig().then(function (_) {
resolve();
});
} else {
_this4.initIndexDB().then(function (_) {
resolve();
});
}
} else {
_this4.getConfig(_this4.storeConfig);
resolve();
}
});
},
// 添加个性配置
addProps: function addProps(temp) {
if (!temp.hasOwnProperty('showOverflowTooltip')) {
temp.showOverflowTooltip = this.showOverflowTooltip;
}
if (!temp.hasOwnProperty('sortable') && !temp.unSet && this.sortable) {
temp.sortable = 'custom';
}
return temp;
},
// 配置
columnCof: function columnCof() {
var _this5 = this;
var arr = [];
this.config.forEach(function (item, index) {
item.tempSort = index + 1;
});
this.sourceSlots.forEach(function (item) {
var temp = _this5.config.find(function (subItem) {
return subItem.prop && subItem.prop === item.componentOptions.propsData.prop || subItem.type && subItem.type === item.componentOptions.propsData.type;
});
temp = _this5.addProps(_extends({}, temp));
if (temp && !temp.isHide) {
item.componentOptions.propsData = temp;
item.tempSort = temp.tempSort;
arr.push(item);
}
if (!temp) {
arr.push(item);
}
});
this.showTable = false;
arr.sort(function (a, b) {
return a.tempSort - b.tempSort;
});
this.sSolts = [].concat(arr);
// hack
this.$nextTick(function () {
_this5.showTable = true;
});
},
// 列修改
changeTableColumns: function changeTableColumns(a) {
var _this6 = this;
this.showTable = false;
this.config = a;
this.columnCof();
// hack
this.$nextTick(function () {
_this6.showTable = true;
});
this.setConfig();
},
// 得到页面的key
generateHash: function generateHash() {
var path = window.location.pathname.split('/').slice(1);
if (this.name) {
path.push(this.name);
}
path = path.join('.');
// TODO 取值需要修改
var userInfo = index_["Environment"].USERINFO;
this.hash = sha256_min(JSON.stringify(this.sourceConfig.filter(function (item) {
return !item.unSet;
})));
this.pageKey = path + '_' + userInfo.username;
},
// 获取配置
getConfig: function getConfig(configDB) {
if (configDB.hash === this.hash) {
this.config = configDB.config;
}
},
// 获取table配置
getPageConfig: function getPageConfig() {
var _this7 = this;
if (Object.prototype.toString.call(index_["Environment"].TABLE.get).slice(8, -1) === 'Function') {
return index_["Environment"].TABLE.get.call(this, this.pageKey).then(function (res) {
if (res) {
_this7.storeConfig = res;
_this7.getConfig(res);
}
});
} else {
this.$message.error('远程请求时Environment.TABLE.get必须是个函数');
return Promise.reject();
}
},
// 保存配置
setConfig: function setConfig() {
var obj = {
id: this.pageKey,
hash: this.hash,
config: this.config
};
if (index_["Environment"].TABLE.mode === 'http') {
if (Object.prototype.toString.call(index_["Environment"].TABLE.save).slice(8, -1) === 'Function') {
index_["Environment"].TABLE.save.call(this, this.pageKey, obj);
} else {
this.$message.error('远程请求时Environment.TABLE.savet必须是个函数');
}
} else if (this.isGetData) {
this.updateDataDB(obj);
} else {
this.addDataDB(obj);
}
}
}, function () {
var methodKeys = ['clearSelection', 'toggleRowSelection', 'toggleAllSelection', 'setCurrentRow', 'clearSort', 'clearFilter', 'doLayout', 'sort'],
methods = [],
methodsJson = {};
methodKeys.forEach(function (key) {
var _methods$push;
methods.push((_methods$push = {}, _methods$push[key] = function () {
for (var _len = arguments.length, res = Array(_len), _key = 0; _key < _len; _key++) {
res[_key] = arguments[_key];
}
this.$refs['my-table'][key].apply(this, res);
}, _methods$push));
});
methods.forEach(function (item) {
methodsJson = _extends({}, methodsJson, item);
});
return methodsJson;
}()),
components: {
sectting: sectting
}
});
// CONCATENATED MODULE: ./packages/table/src/main.vue?vue&type=script&lang=js&
/* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
// CONCATENATED MODULE: ./packages/table/src/main.vue
var main_render, main_staticRenderFns
/* normalize component */
var main_component = Object(componentNormalizer["a" /* default */])(
src_mainvue_type_script_lang_js_,
main_render,
main_staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var main_api; }
main_component.options.__file = "packages/table/src/main.vue"
/* harmony default export */ var main = (main_component.exports);
// CONCATENATED MODULE: ./packages/table/index.js
/* istanbul ignore next */
main.install = function (Vue) {
Vue.component(main.name, main);
};
/* harmony default export */ var table = __webpack_exports__["default"] = (main);
/***/ })
/******/ });