更新拖拽
This commit is contained in:
parent
d53314b523
commit
5110bd6d57
78
src/main.js
78
src/main.js
|
|
@ -1,60 +1,72 @@
|
||||||
import Vue from 'vue'
|
import Vue from "vue";
|
||||||
|
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
import 'normalize.css/normalize.css'
|
import "normalize.css/normalize.css";
|
||||||
|
|
||||||
import Element from 'element-ui'
|
import Element from "element-ui";
|
||||||
|
|
||||||
// 数据字典
|
// 数据字典
|
||||||
import dict from './components/Dict'
|
import dict from "./components/Dict";
|
||||||
import Editor from "@/components/Editor"
|
import Editor from "@/components/Editor";
|
||||||
|
|
||||||
// 权限指令
|
// 权限指令
|
||||||
import checkPer from '@/utils/permission'
|
import checkPer from "@/utils/permission";
|
||||||
import permission from './components/Permission'
|
import permission from "./components/Permission";
|
||||||
import './assets/styles/element-variables.scss'
|
import "./assets/styles/element-variables.scss";
|
||||||
|
|
||||||
// global css
|
// global css
|
||||||
import './assets/styles/index.scss'
|
import "./assets/styles/index.scss";
|
||||||
|
|
||||||
import App from './App'
|
import App from "./App";
|
||||||
import store from './store'
|
import store from "./store";
|
||||||
import router from './router/routers'
|
import router from "./router/routers";
|
||||||
|
|
||||||
import './assets/icons' // icon
|
import "./assets/icons"; // icon
|
||||||
import './router/index' // permission control
|
import "./router/index"; // permission control
|
||||||
|
|
||||||
// 全局引入
|
// 全局引入
|
||||||
import EleUploadImage from 'vue-ele-upload-image'
|
import EleUploadImage from "vue-ele-upload-image";
|
||||||
import VueAMap from 'vue-amap';
|
import VueAMap from "vue-amap";
|
||||||
|
|
||||||
import VueClipboard from 'vue-clipboard2'
|
import VueClipboard from "vue-clipboard2";
|
||||||
|
|
||||||
|
import { isPcBowser } from "@/utils/index";
|
||||||
|
|
||||||
Vue.component(EleUploadImage.name, EleUploadImage)
|
Vue.component(EleUploadImage.name, EleUploadImage);
|
||||||
Vue.component('Editor', Editor)
|
Vue.component("Editor", Editor);
|
||||||
|
|
||||||
Vue.use(checkPer)
|
Vue.use(checkPer);
|
||||||
Vue.use(permission)
|
Vue.use(permission);
|
||||||
Vue.use(dict)
|
Vue.use(dict);
|
||||||
Vue.use(Element, {
|
Vue.use(Element, {
|
||||||
size: Cookies.get('size') || 'small' // set element-ui default size
|
size: Cookies.get("size") || "small" // set element-ui default size
|
||||||
})
|
});
|
||||||
Vue.use(VueAMap)
|
Vue.use(VueAMap);
|
||||||
Vue.use(VueClipboard)
|
Vue.use(VueClipboard);
|
||||||
|
|
||||||
|
Vue.prototype.isPcBowser = isPcBowser();
|
||||||
|
|
||||||
VueAMap.initAMapApiLoader({
|
VueAMap.initAMapApiLoader({
|
||||||
key: '6033c97e67bf2e9ceac306e1a3fa35f8',
|
key: "6033c97e67bf2e9ceac306e1a3fa35f8",
|
||||||
// securityJsCode: '0547b69252ef0ed14e11f5c4ac152f07',
|
// securityJsCode: '0547b69252ef0ed14e11f5c4ac152f07',
|
||||||
plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor']
|
plugin: [
|
||||||
})
|
"AMap.Autocomplete",
|
||||||
|
"AMap.PlaceSearch",
|
||||||
|
"AMap.Scale",
|
||||||
|
"AMap.OverView",
|
||||||
|
"AMap.ToolBar",
|
||||||
|
"AMap.MapType",
|
||||||
|
"AMap.PolyEditor",
|
||||||
|
"AMap.CircleEditor"
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: "#app",
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
render: h => h(App)
|
render: h => h(App)
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,22 @@
|
||||||
*/
|
*/
|
||||||
export function parseTime(time, cFormat) {
|
export function parseTime(time, cFormat) {
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
return null
|
return null;
|
||||||
}
|
}
|
||||||
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
|
const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
|
||||||
let date
|
let date;
|
||||||
if (typeof time === 'undefined' || time === null || time === 'null') {
|
if (typeof time === "undefined" || time === null || time === "null") {
|
||||||
return ''
|
return "";
|
||||||
} else if (typeof time === 'object') {
|
} else if (typeof time === "object") {
|
||||||
date = time
|
date = time;
|
||||||
} else {
|
} else {
|
||||||
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
|
if (typeof time === "string" && /^[0-9]+$/.test(time)) {
|
||||||
time = parseInt(time)
|
time = parseInt(time);
|
||||||
}
|
}
|
||||||
if ((typeof time === 'number') && (time.toString().length === 10)) {
|
if (typeof time === "number" && time.toString().length === 10) {
|
||||||
time = time * 1000
|
time = time * 1000;
|
||||||
}
|
}
|
||||||
date = new Date(time)
|
date = new Date(time);
|
||||||
}
|
}
|
||||||
const formatObj = {
|
const formatObj = {
|
||||||
y: date.getFullYear(),
|
y: date.getFullYear(),
|
||||||
|
|
@ -35,17 +35,19 @@ export function parseTime(time, cFormat) {
|
||||||
i: date.getMinutes(),
|
i: date.getMinutes(),
|
||||||
s: date.getSeconds(),
|
s: date.getSeconds(),
|
||||||
a: date.getDay()
|
a: date.getDay()
|
||||||
}
|
};
|
||||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
||||||
let value = formatObj[key]
|
let value = formatObj[key];
|
||||||
// Note: getDay() returns 0 on Sunday
|
// Note: getDay() returns 0 on Sunday
|
||||||
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
|
if (key === "a") {
|
||||||
if (result.length > 0 && value < 10) {
|
return ["日", "一", "二", "三", "四", "五", "六"][value];
|
||||||
value = '0' + value
|
|
||||||
}
|
}
|
||||||
return value || 0
|
if (result.length > 0 && value < 10) {
|
||||||
})
|
value = "0" + value;
|
||||||
return time_str
|
}
|
||||||
|
return value || 0;
|
||||||
|
});
|
||||||
|
return time_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,40 +56,40 @@ export function parseTime(time, cFormat) {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function formatTime(time, option) {
|
export function formatTime(time, option) {
|
||||||
if (('' + time).length === 10) {
|
if (("" + time).length === 10) {
|
||||||
time = parseInt(time) * 1000
|
time = parseInt(time) * 1000;
|
||||||
} else {
|
} else {
|
||||||
time = +time
|
time = +time;
|
||||||
}
|
}
|
||||||
const d = new Date(time)
|
const d = new Date(time);
|
||||||
const now = Date.now()
|
const now = Date.now();
|
||||||
|
|
||||||
const diff = (now - d) / 1000
|
const diff = (now - d) / 1000;
|
||||||
|
|
||||||
if (diff < 30) {
|
if (diff < 30) {
|
||||||
return '刚刚'
|
return "刚刚";
|
||||||
} else if (diff < 3600) {
|
} else if (diff < 3600) {
|
||||||
// less 1 hour
|
// less 1 hour
|
||||||
return Math.ceil(diff / 60) + '分钟前'
|
return Math.ceil(diff / 60) + "分钟前";
|
||||||
} else if (diff < 3600 * 24) {
|
} else if (diff < 3600 * 24) {
|
||||||
return Math.ceil(diff / 3600) + '小时前'
|
return Math.ceil(diff / 3600) + "小时前";
|
||||||
} else if (diff < 3600 * 24 * 2) {
|
} else if (diff < 3600 * 24 * 2) {
|
||||||
return '1天前'
|
return "1天前";
|
||||||
}
|
}
|
||||||
if (option) {
|
if (option) {
|
||||||
return parseTime(time, option)
|
return parseTime(time, option);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
d.getMonth() +
|
d.getMonth() +
|
||||||
1 +
|
1 +
|
||||||
'月' +
|
"月" +
|
||||||
d.getDate() +
|
d.getDate() +
|
||||||
'日' +
|
"日" +
|
||||||
d.getHours() +
|
d.getHours() +
|
||||||
'时' +
|
"时" +
|
||||||
d.getMinutes() +
|
d.getMinutes() +
|
||||||
'分'
|
"分"
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,18 +98,18 @@ export function formatTime(time, option) {
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function getQueryObject(url) {
|
export function getQueryObject(url) {
|
||||||
url = url == null ? window.location.href : url
|
url = url == null ? window.location.href : url;
|
||||||
const search = url.substring(url.lastIndexOf('?') + 1)
|
const search = url.substring(url.lastIndexOf("?") + 1);
|
||||||
const obj = {}
|
const obj = {};
|
||||||
const reg = /([^?&=]+)=([^?&=]*)/g
|
const reg = /([^?&=]+)=([^?&=]*)/g;
|
||||||
search.replace(reg, (rs, $1, $2) => {
|
search.replace(reg, (rs, $1, $2) => {
|
||||||
const name = decodeURIComponent($1)
|
const name = decodeURIComponent($1);
|
||||||
let val = decodeURIComponent($2)
|
let val = decodeURIComponent($2);
|
||||||
val = String(val)
|
val = String(val);
|
||||||
obj[name] = val
|
obj[name] = val;
|
||||||
return rs
|
return rs;
|
||||||
})
|
});
|
||||||
return obj
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,14 +118,14 @@ export function getQueryObject(url) {
|
||||||
*/
|
*/
|
||||||
export function byteLength(str) {
|
export function byteLength(str) {
|
||||||
// returns the byte length of an utf8 string
|
// returns the byte length of an utf8 string
|
||||||
let s = str.length
|
let s = str.length;
|
||||||
for (var i = str.length - 1; i >= 0; i--) {
|
for (var i = str.length - 1; i >= 0; i--) {
|
||||||
const code = str.charCodeAt(i)
|
const code = str.charCodeAt(i);
|
||||||
if (code > 0x7f && code <= 0x7ff) s++
|
if (code > 0x7f && code <= 0x7ff) s++;
|
||||||
else if (code > 0x7ff && code <= 0xffff) s += 2
|
else if (code > 0x7ff && code <= 0xffff) s += 2;
|
||||||
if (code >= 0xDC00 && code <= 0xDFFF) i--
|
if (code >= 0xdc00 && code <= 0xdfff) i--;
|
||||||
}
|
}
|
||||||
return s
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -131,13 +133,13 @@ export function byteLength(str) {
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function cleanArray(actual) {
|
export function cleanArray(actual) {
|
||||||
const newArray = []
|
const newArray = [];
|
||||||
for (let i = 0; i < actual.length; i++) {
|
for (let i = 0; i < actual.length; i++) {
|
||||||
if (actual[i]) {
|
if (actual[i]) {
|
||||||
newArray.push(actual[i])
|
newArray.push(actual[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newArray
|
return newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -145,13 +147,13 @@ export function cleanArray(actual) {
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function param(json) {
|
export function param(json) {
|
||||||
if (!json) return ''
|
if (!json) return "";
|
||||||
return cleanArray(
|
return cleanArray(
|
||||||
Object.keys(json).map(key => {
|
Object.keys(json).map(key => {
|
||||||
if (json[key] === undefined) return ''
|
if (json[key] === undefined) return "";
|
||||||
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
|
return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
|
||||||
})
|
})
|
||||||
).join('&')
|
).join("&");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -159,19 +161,19 @@ export function param(json) {
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function param2Obj(url) {
|
export function param2Obj(url) {
|
||||||
const search = url.split('?')[1]
|
const search = url.split("?")[1];
|
||||||
if (!search) {
|
if (!search) {
|
||||||
return {}
|
return {};
|
||||||
}
|
}
|
||||||
return JSON.parse(
|
return JSON.parse(
|
||||||
'{"' +
|
'{"' +
|
||||||
decodeURIComponent(search)
|
decodeURIComponent(search)
|
||||||
.replace(/"/g, '\\"')
|
.replace(/"/g, '\\"')
|
||||||
.replace(/&/g, '","')
|
.replace(/&/g, '","')
|
||||||
.replace(/=/g, '":"')
|
.replace(/=/g, '":"')
|
||||||
.replace(/\+/g, ' ') +
|
.replace(/\+/g, " ") +
|
||||||
'"}'
|
'"}'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -179,9 +181,9 @@ export function param2Obj(url) {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function html2Text(val) {
|
export function html2Text(val) {
|
||||||
const div = document.createElement('div')
|
const div = document.createElement("div");
|
||||||
div.innerHTML = val
|
div.innerHTML = val;
|
||||||
return div.textContent || div.innerText
|
return div.textContent || div.innerText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -191,21 +193,21 @@ export function html2Text(val) {
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function objectMerge(target, source) {
|
export function objectMerge(target, source) {
|
||||||
if (typeof target !== 'object') {
|
if (typeof target !== "object") {
|
||||||
target = {}
|
target = {};
|
||||||
}
|
}
|
||||||
if (Array.isArray(source)) {
|
if (Array.isArray(source)) {
|
||||||
return source.slice()
|
return source.slice();
|
||||||
}
|
}
|
||||||
Object.keys(source).forEach(property => {
|
Object.keys(source).forEach(property => {
|
||||||
const sourceProperty = source[property]
|
const sourceProperty = source[property];
|
||||||
if (typeof sourceProperty === 'object') {
|
if (typeof sourceProperty === "object") {
|
||||||
target[property] = objectMerge(target[property], sourceProperty)
|
target[property] = objectMerge(target[property], sourceProperty);
|
||||||
} else {
|
} else {
|
||||||
target[property] = sourceProperty
|
target[property] = sourceProperty;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return target
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -214,18 +216,18 @@ export function objectMerge(target, source) {
|
||||||
*/
|
*/
|
||||||
export function toggleClass(element, className) {
|
export function toggleClass(element, className) {
|
||||||
if (!element || !className) {
|
if (!element || !className) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let classString = element.className
|
let classString = element.className;
|
||||||
const nameIndex = classString.indexOf(className)
|
const nameIndex = classString.indexOf(className);
|
||||||
if (nameIndex === -1) {
|
if (nameIndex === -1) {
|
||||||
classString += '' + className
|
classString += "" + className;
|
||||||
} else {
|
} else {
|
||||||
classString =
|
classString =
|
||||||
classString.substr(0, nameIndex) +
|
classString.substr(0, nameIndex) +
|
||||||
classString.substr(nameIndex + className.length)
|
classString.substr(nameIndex + className.length);
|
||||||
}
|
}
|
||||||
element.className = classString
|
element.className = classString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -233,10 +235,10 @@ export function toggleClass(element, className) {
|
||||||
* @returns {Date}
|
* @returns {Date}
|
||||||
*/
|
*/
|
||||||
export function getTime(type) {
|
export function getTime(type) {
|
||||||
if (type === 'start') {
|
if (type === "start") {
|
||||||
return new Date().getTime() - 3600 * 1000 * 24 * 90
|
return new Date().getTime() - 3600 * 1000 * 24 * 90;
|
||||||
} else {
|
} else {
|
||||||
return new Date(new Date().toDateString())
|
return new Date(new Date().toDateString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,38 +249,38 @@ export function getTime(type) {
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
export function debounce(func, wait, immediate) {
|
export function debounce(func, wait, immediate) {
|
||||||
let timeout, args, context, timestamp, result
|
let timeout, args, context, timestamp, result;
|
||||||
|
|
||||||
const later = function () {
|
const later = function() {
|
||||||
// 据上一次触发时间间隔
|
// 据上一次触发时间间隔
|
||||||
const last = +new Date() - timestamp
|
const last = +new Date() - timestamp;
|
||||||
|
|
||||||
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
||||||
if (last < wait && last > 0) {
|
if (last < wait && last > 0) {
|
||||||
timeout = setTimeout(later, wait - last)
|
timeout = setTimeout(later, wait - last);
|
||||||
} else {
|
} else {
|
||||||
timeout = null
|
timeout = null;
|
||||||
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
||||||
if (!immediate) {
|
if (!immediate) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args);
|
||||||
if (!timeout) context = args = null
|
if (!timeout) context = args = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return function (...args) {
|
return function(...args) {
|
||||||
context = this
|
context = this;
|
||||||
timestamp = +new Date()
|
timestamp = +new Date();
|
||||||
const callNow = immediate && !timeout
|
const callNow = immediate && !timeout;
|
||||||
// 如果延时不存在,重新设定延时
|
// 如果延时不存在,重新设定延时
|
||||||
if (!timeout) timeout = setTimeout(later, wait)
|
if (!timeout) timeout = setTimeout(later, wait);
|
||||||
if (callNow) {
|
if (callNow) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args);
|
||||||
context = args = null
|
context = args = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -289,18 +291,18 @@ export function debounce(func, wait, immediate) {
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function deepClone(source) {
|
export function deepClone(source) {
|
||||||
if (!source && typeof source !== 'object') {
|
if (!source && typeof source !== "object") {
|
||||||
throw new Error('error arguments', 'deepClone')
|
throw new Error("error arguments", "deepClone");
|
||||||
}
|
}
|
||||||
const targetObj = source.constructor === Array ? [] : {}
|
const targetObj = source.constructor === Array ? [] : {};
|
||||||
Object.keys(source).forEach(keys => {
|
Object.keys(source).forEach(keys => {
|
||||||
if (source[keys] && typeof source[keys] === 'object') {
|
if (source[keys] && typeof source[keys] === "object") {
|
||||||
targetObj[keys] = deepClone(source[keys])
|
targetObj[keys] = deepClone(source[keys]);
|
||||||
} else {
|
} else {
|
||||||
targetObj[keys] = source[keys]
|
targetObj[keys] = source[keys];
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return targetObj
|
return targetObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -308,16 +310,16 @@ export function deepClone(source) {
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function uniqueArr(arr) {
|
export function uniqueArr(arr) {
|
||||||
return Array.from(new Set(arr))
|
return Array.from(new Set(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function createUniqueString() {
|
export function createUniqueString() {
|
||||||
const timestamp = +new Date() + ''
|
const timestamp = +new Date() + "";
|
||||||
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
const randomNum = parseInt((1 + Math.random()) * 65536) + "";
|
||||||
return (+(randomNum + timestamp)).toString(32)
|
return (+(randomNum + timestamp)).toString(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -327,7 +329,7 @@ export function createUniqueString() {
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function hasClass(ele, cls) {
|
export function hasClass(ele, cls) {
|
||||||
return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
|
return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -336,7 +338,7 @@ export function hasClass(ele, cls) {
|
||||||
* @param {string} cls
|
* @param {string} cls
|
||||||
*/
|
*/
|
||||||
export function addClass(ele, cls) {
|
export function addClass(ele, cls) {
|
||||||
if (!hasClass(ele, cls)) ele.className += ' ' + cls
|
if (!hasClass(ele, cls)) ele.className += " " + cls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -346,45 +348,45 @@ export function addClass(ele, cls) {
|
||||||
*/
|
*/
|
||||||
export function removeClass(ele, cls) {
|
export function removeClass(ele, cls) {
|
||||||
if (hasClass(ele, cls)) {
|
if (hasClass(ele, cls)) {
|
||||||
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
|
const reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
||||||
ele.className = ele.className.replace(reg, ' ')
|
ele.className = ele.className.replace(reg, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 替换邮箱字符
|
// 替换邮箱字符
|
||||||
export function regEmail(email) {
|
export function regEmail(email) {
|
||||||
if (String(email).indexOf('@') > 0) {
|
if (String(email).indexOf("@") > 0) {
|
||||||
const str = email.split('@')
|
const str = email.split("@");
|
||||||
let _s = ''
|
let _s = "";
|
||||||
if (str[0].length > 3) {
|
if (str[0].length > 3) {
|
||||||
for (var i = 0; i < str[0].length - 3; i++) {
|
for (var i = 0; i < str[0].length - 3; i++) {
|
||||||
_s += '*'
|
_s += "*";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var new_email = str[0].substr(0, 3) + _s + '@' + str[1]
|
var new_email = str[0].substr(0, 3) + _s + "@" + str[1];
|
||||||
}
|
}
|
||||||
return new_email
|
return new_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 替换手机字符
|
// 替换手机字符
|
||||||
export function regMobile(mobile) {
|
export function regMobile(mobile) {
|
||||||
if (mobile.length > 7) {
|
if (mobile.length > 7) {
|
||||||
var new_mobile = mobile.substr(0, 3) + '****' + mobile.substr(7)
|
var new_mobile = mobile.substr(0, 3) + "****" + mobile.substr(7);
|
||||||
}
|
}
|
||||||
return new_mobile
|
return new_mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
export function downloadFile(obj, name, suffix) {
|
export function downloadFile(obj, name, suffix) {
|
||||||
const url = window.URL.createObjectURL(new Blob([obj]))
|
const url = window.URL.createObjectURL(new Blob([obj]));
|
||||||
const link = document.createElement('a')
|
const link = document.createElement("a");
|
||||||
link.style.display = 'none'
|
link.style.display = "none";
|
||||||
link.href = url
|
link.href = url;
|
||||||
const fileName = parseTime(new Date()) + '-' + name + '.' + suffix
|
const fileName = parseTime(new Date()) + "-" + name + "." + suffix;
|
||||||
link.setAttribute('download', fileName)
|
link.setAttribute("download", fileName);
|
||||||
document.body.appendChild(link)
|
document.body.appendChild(link);
|
||||||
link.click()
|
link.click();
|
||||||
document.body.removeChild(link)
|
document.body.removeChild(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -398,3 +400,19 @@ export function RandomNumBoth(Max, Min = 0) {
|
||||||
var num = Min + Math.round(Rand * Range); //四舍五入
|
var num = Min + Math.round(Rand * Range); //四舍五入
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是不是PC浏览器
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function isPcBowser() {
|
||||||
|
if (!window.navigator) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (/Mobile|Android|webOS|iPhone|iPad|Phone/i.test(navigator.userAgent)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="240">
|
<el-table-column label="操作" width="240">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button type="text" icon="el-icon-rank">排序</el-button>
|
<el-button type="text" icon="el-icon-rank" v-if="isPcBowser">排序</el-button>
|
||||||
<el-button type="text" size="mini" round icon="el-icon-edit" @click="$refs.addGroupRef.show(scope.row)"
|
<el-button type="text" size="mini" round icon="el-icon-edit" @click="$refs.addGroupRef.show(scope.row)"
|
||||||
style="margin-left: 20px !important;">编辑</el-button>
|
style="margin-left: 20px !important;">编辑</el-button>
|
||||||
<el-popconfirm title="确定删除吗?" @confirm="delHandle([scope.row.id])">
|
<el-popconfirm title="确定删除吗?" @confirm="delHandle([scope.row.id])">
|
||||||
|
|
@ -56,9 +56,11 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getTableData()
|
this.getTableData()
|
||||||
this.$nextTick(() => {
|
if (this.isPcBowser) {
|
||||||
this.tableDrag()
|
this.$nextTick(() => {
|
||||||
})
|
this.tableDrag()
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
//表格拖拽
|
//表格拖拽
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-button type="primary" @click="getTableData">查询</el-button>
|
<el-button type="primary" @click="queryHandle">查询</el-button>
|
||||||
<el-button @click="resetHandle">重置</el-button>
|
<el-button @click="resetHandle">重置</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="200">
|
<el-table-column label="操作" width="200">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button type="text" icon="el-icon-rank">排序</el-button>
|
<el-button type="text" icon="el-icon-rank" v-if="isPcBowser">排序</el-button>
|
||||||
<router-link :to="{ path: '/product/add_shop', query: { goods_id: scope.row.id } }"
|
<router-link :to="{ path: '/product/add_shop', query: { goods_id: scope.row.id } }"
|
||||||
style="margin-left: 20px !important;">
|
style="margin-left: 20px !important;">
|
||||||
<el-button type="text" icon="el-icon-edit">编辑</el-button>
|
<el-button type="text" icon="el-icon-edit">编辑</el-button>
|
||||||
|
|
@ -125,14 +125,21 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
this.getTableData()
|
await this.tbShopCategoryGet()
|
||||||
this.tbShopCategoryGet()
|
await this.getTableData()
|
||||||
this.$nextTick(() => {
|
if (this.isPcBowser) {
|
||||||
this.tableDrag()
|
this.$nextTick(() => {
|
||||||
})
|
this.tableDrag()
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 选择分类
|
||||||
|
queryHandle() {
|
||||||
|
localStorage.setItem('shopIndexQuery', JSON.stringify(this.query))
|
||||||
|
this.getTableData()
|
||||||
|
},
|
||||||
//表格拖拽
|
//表格拖拽
|
||||||
tableDrag() {
|
tableDrag() {
|
||||||
const el = document.querySelector('#table_drag .el-table__body-wrapper tbody')
|
const el = document.querySelector('#table_drag .el-table__body-wrapper tbody')
|
||||||
|
|
@ -177,6 +184,7 @@ export default {
|
||||||
this.query.categoryId = ''
|
this.query.categoryId = ''
|
||||||
this.query.typeEnum = ''
|
this.query.typeEnum = ''
|
||||||
this.tableData.page = 0
|
this.tableData.page = 0
|
||||||
|
localStorage.setItem('shopIndexQuery', JSON.stringify(this.query))
|
||||||
this.getTableData()
|
this.getTableData()
|
||||||
},
|
},
|
||||||
// 分页回调
|
// 分页回调
|
||||||
|
|
@ -186,8 +194,13 @@ export default {
|
||||||
},
|
},
|
||||||
// 获取商品列表
|
// 获取商品列表
|
||||||
async getTableData() {
|
async getTableData() {
|
||||||
this.tableData.loading = true
|
|
||||||
try {
|
try {
|
||||||
|
let localQuery = JSON.parse(localStorage.getItem('shopIndexQuery'))
|
||||||
|
if (localQuery != null) {
|
||||||
|
this.query = localQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tableData.loading = true
|
||||||
const res = await tbProduct({
|
const res = await tbProduct({
|
||||||
page: this.tableData.page,
|
page: this.tableData.page,
|
||||||
size: this.tableData.size,
|
size: this.tableData.size,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue