Merge branch 'dwb' of https://e.coding.net/g-cphe0354/yinshoukeguanliduan/management into wwz
This commit is contained in:
commit
9c98052782
|
|
@ -4,8 +4,8 @@ ENV = 'development'
|
|||
# VUE_APP_BASE_API = 'http://192.168.2.17:8000'
|
||||
# VUE_APP_BASE_API = 'http://192.168.2.42:8000'
|
||||
# VUE_APP_BASE_API = 'http://192.168.2.133:8000'
|
||||
VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn'
|
||||
# VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn'
|
||||
# VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn'
|
||||
VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn'
|
||||
# VUE_APP_BASE_API = 'http://192.168.2.96:8000'
|
||||
VUE_APP_WS_API = 'ws://192.168.2.128:8000'
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ ENV = 'production'
|
|||
|
||||
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置
|
||||
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
|
||||
# VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn'
|
||||
VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn'
|
||||
VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn'
|
||||
# VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn'
|
||||
# VUE_APP_BASE_API = 'http://192.168.2.98:8000'
|
||||
# 如果接口是 http 形式, wss 需要改为 ws
|
||||
VUE_APP_WS_API = 'wss://123.56.110.252
|
||||
|
|
|
|||
|
|
@ -11,6 +11,13 @@ export function tbProductGet(params) {
|
|||
params
|
||||
});
|
||||
}
|
||||
export function tbProductlist(params) {
|
||||
return request({
|
||||
url: "/api/tbProduct/list",
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 进销存类型字典
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import request from "@/utils/request";
|
|||
*/
|
||||
export function tbProduct(params) {
|
||||
return request({
|
||||
url: "/api/tbProduct/list",
|
||||
url: "/api/tbProduct",
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
|
|
|
|||
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 Editor from "@/components/Editor"
|
||||
import dict from "./components/Dict";
|
||||
import Editor from "@/components/Editor";
|
||||
|
||||
// 权限指令
|
||||
import checkPer from '@/utils/permission'
|
||||
import permission from './components/Permission'
|
||||
import './assets/styles/element-variables.scss'
|
||||
import checkPer from "@/utils/permission";
|
||||
import permission from "./components/Permission";
|
||||
import "./assets/styles/element-variables.scss";
|
||||
|
||||
// global css
|
||||
import './assets/styles/index.scss'
|
||||
import "./assets/styles/index.scss";
|
||||
|
||||
import App from './App'
|
||||
import store from './store'
|
||||
import router from './router/routers'
|
||||
import App from "./App";
|
||||
import store from "./store";
|
||||
import router from "./router/routers";
|
||||
|
||||
import './assets/icons' // icon
|
||||
import './router/index' // permission control
|
||||
import "./assets/icons"; // icon
|
||||
import "./router/index"; // permission control
|
||||
|
||||
// 全局引入
|
||||
import EleUploadImage from 'vue-ele-upload-image'
|
||||
import VueAMap from 'vue-amap';
|
||||
import EleUploadImage from "vue-ele-upload-image";
|
||||
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('Editor', Editor)
|
||||
Vue.component(EleUploadImage.name, EleUploadImage);
|
||||
Vue.component("Editor", Editor);
|
||||
|
||||
Vue.use(checkPer)
|
||||
Vue.use(permission)
|
||||
Vue.use(dict)
|
||||
Vue.use(checkPer);
|
||||
Vue.use(permission);
|
||||
Vue.use(dict);
|
||||
Vue.use(Element, {
|
||||
size: Cookies.get('size') || 'small' // set element-ui default size
|
||||
})
|
||||
Vue.use(VueAMap)
|
||||
Vue.use(VueClipboard)
|
||||
size: Cookies.get("size") || "small" // set element-ui default size
|
||||
});
|
||||
Vue.use(VueAMap);
|
||||
Vue.use(VueClipboard);
|
||||
|
||||
Vue.prototype.isPcBowser = isPcBowser();
|
||||
|
||||
VueAMap.initAMapApiLoader({
|
||||
key: '6033c97e67bf2e9ceac306e1a3fa35f8',
|
||||
key: "6033c97e67bf2e9ceac306e1a3fa35f8",
|
||||
// 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({
|
||||
el: '#app',
|
||||
el: "#app",
|
||||
router,
|
||||
store,
|
||||
render: h => h(App)
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,22 +10,22 @@
|
|||
*/
|
||||
export function parseTime(time, cFormat) {
|
||||
if (arguments.length === 0) {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
|
||||
let date
|
||||
if (typeof time === 'undefined' || time === null || time === 'null') {
|
||||
return ''
|
||||
} else if (typeof time === 'object') {
|
||||
date = time
|
||||
const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
|
||||
let date;
|
||||
if (typeof time === "undefined" || time === null || time === "null") {
|
||||
return "";
|
||||
} else if (typeof time === "object") {
|
||||
date = time;
|
||||
} else {
|
||||
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
|
||||
time = parseInt(time)
|
||||
if (typeof time === "string" && /^[0-9]+$/.test(time)) {
|
||||
time = parseInt(time);
|
||||
}
|
||||
if ((typeof time === 'number') && (time.toString().length === 10)) {
|
||||
time = time * 1000
|
||||
if (typeof time === "number" && time.toString().length === 10) {
|
||||
time = time * 1000;
|
||||
}
|
||||
date = new Date(time)
|
||||
date = new Date(time);
|
||||
}
|
||||
const formatObj = {
|
||||
y: date.getFullYear(),
|
||||
|
|
@ -35,17 +35,19 @@ export function parseTime(time, cFormat) {
|
|||
i: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
a: date.getDay()
|
||||
}
|
||||
};
|
||||
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
|
||||
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = '0' + value
|
||||
if (key === "a") {
|
||||
return ["日", "一", "二", "三", "四", "五", "六"][value];
|
||||
}
|
||||
return value || 0
|
||||
})
|
||||
return time_str
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = "0" + value;
|
||||
}
|
||||
return value || 0;
|
||||
});
|
||||
return time_str;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,40 +56,40 @@ export function parseTime(time, cFormat) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function formatTime(time, option) {
|
||||
if (('' + time).length === 10) {
|
||||
time = parseInt(time) * 1000
|
||||
if (("" + time).length === 10) {
|
||||
time = parseInt(time) * 1000;
|
||||
} else {
|
||||
time = +time
|
||||
time = +time;
|
||||
}
|
||||
const d = new Date(time)
|
||||
const now = Date.now()
|
||||
const d = new Date(time);
|
||||
const now = Date.now();
|
||||
|
||||
const diff = (now - d) / 1000
|
||||
const diff = (now - d) / 1000;
|
||||
|
||||
if (diff < 30) {
|
||||
return '刚刚'
|
||||
return "刚刚";
|
||||
} else if (diff < 3600) {
|
||||
// less 1 hour
|
||||
return Math.ceil(diff / 60) + '分钟前'
|
||||
return Math.ceil(diff / 60) + "分钟前";
|
||||
} else if (diff < 3600 * 24) {
|
||||
return Math.ceil(diff / 3600) + '小时前'
|
||||
return Math.ceil(diff / 3600) + "小时前";
|
||||
} else if (diff < 3600 * 24 * 2) {
|
||||
return '1天前'
|
||||
return "1天前";
|
||||
}
|
||||
if (option) {
|
||||
return parseTime(time, option)
|
||||
return parseTime(time, option);
|
||||
} else {
|
||||
return (
|
||||
d.getMonth() +
|
||||
1 +
|
||||
'月' +
|
||||
"月" +
|
||||
d.getDate() +
|
||||
'日' +
|
||||
"日" +
|
||||
d.getHours() +
|
||||
'时' +
|
||||
"时" +
|
||||
d.getMinutes() +
|
||||
'分'
|
||||
)
|
||||
"分"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,18 +98,18 @@ export function formatTime(time, option) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function getQueryObject(url) {
|
||||
url = url == null ? window.location.href : url
|
||||
const search = url.substring(url.lastIndexOf('?') + 1)
|
||||
const obj = {}
|
||||
const reg = /([^?&=]+)=([^?&=]*)/g
|
||||
url = url == null ? window.location.href : url;
|
||||
const search = url.substring(url.lastIndexOf("?") + 1);
|
||||
const obj = {};
|
||||
const reg = /([^?&=]+)=([^?&=]*)/g;
|
||||
search.replace(reg, (rs, $1, $2) => {
|
||||
const name = decodeURIComponent($1)
|
||||
let val = decodeURIComponent($2)
|
||||
val = String(val)
|
||||
obj[name] = val
|
||||
return rs
|
||||
})
|
||||
return obj
|
||||
const name = decodeURIComponent($1);
|
||||
let val = decodeURIComponent($2);
|
||||
val = String(val);
|
||||
obj[name] = val;
|
||||
return rs;
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,14 +118,14 @@ export function getQueryObject(url) {
|
|||
*/
|
||||
export function byteLength(str) {
|
||||
// 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--) {
|
||||
const code = str.charCodeAt(i)
|
||||
if (code > 0x7f && code <= 0x7ff) s++
|
||||
else if (code > 0x7ff && code <= 0xffff) s += 2
|
||||
if (code >= 0xDC00 && code <= 0xDFFF) i--
|
||||
const code = str.charCodeAt(i);
|
||||
if (code > 0x7f && code <= 0x7ff) s++;
|
||||
else if (code > 0x7ff && code <= 0xffff) s += 2;
|
||||
if (code >= 0xdc00 && code <= 0xdfff) i--;
|
||||
}
|
||||
return s
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -131,13 +133,13 @@ export function byteLength(str) {
|
|||
* @returns {Array}
|
||||
*/
|
||||
export function cleanArray(actual) {
|
||||
const newArray = []
|
||||
const newArray = [];
|
||||
for (let i = 0; i < actual.length; 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}
|
||||
*/
|
||||
export function param(json) {
|
||||
if (!json) return ''
|
||||
if (!json) return "";
|
||||
return cleanArray(
|
||||
Object.keys(json).map(key => {
|
||||
if (json[key] === undefined) return ''
|
||||
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
|
||||
if (json[key] === undefined) return "";
|
||||
return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
|
||||
})
|
||||
).join('&')
|
||||
).join("&");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -159,19 +161,19 @@ export function param(json) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function param2Obj(url) {
|
||||
const search = url.split('?')[1]
|
||||
const search = url.split("?")[1];
|
||||
if (!search) {
|
||||
return {}
|
||||
return {};
|
||||
}
|
||||
return JSON.parse(
|
||||
'{"' +
|
||||
decodeURIComponent(search)
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/&/g, '","')
|
||||
.replace(/=/g, '":"')
|
||||
.replace(/\+/g, ' ') +
|
||||
'"}'
|
||||
)
|
||||
decodeURIComponent(search)
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/&/g, '","')
|
||||
.replace(/=/g, '":"')
|
||||
.replace(/\+/g, " ") +
|
||||
'"}'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -179,9 +181,9 @@ export function param2Obj(url) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function html2Text(val) {
|
||||
const div = document.createElement('div')
|
||||
div.innerHTML = val
|
||||
return div.textContent || div.innerText
|
||||
const div = document.createElement("div");
|
||||
div.innerHTML = val;
|
||||
return div.textContent || div.innerText;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -191,21 +193,21 @@ export function html2Text(val) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function objectMerge(target, source) {
|
||||
if (typeof target !== 'object') {
|
||||
target = {}
|
||||
if (typeof target !== "object") {
|
||||
target = {};
|
||||
}
|
||||
if (Array.isArray(source)) {
|
||||
return source.slice()
|
||||
return source.slice();
|
||||
}
|
||||
Object.keys(source).forEach(property => {
|
||||
const sourceProperty = source[property]
|
||||
if (typeof sourceProperty === 'object') {
|
||||
target[property] = objectMerge(target[property], sourceProperty)
|
||||
const sourceProperty = source[property];
|
||||
if (typeof sourceProperty === "object") {
|
||||
target[property] = objectMerge(target[property], sourceProperty);
|
||||
} 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) {
|
||||
if (!element || !className) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
let classString = element.className
|
||||
const nameIndex = classString.indexOf(className)
|
||||
let classString = element.className;
|
||||
const nameIndex = classString.indexOf(className);
|
||||
if (nameIndex === -1) {
|
||||
classString += '' + className
|
||||
classString += "" + className;
|
||||
} else {
|
||||
classString =
|
||||
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}
|
||||
*/
|
||||
export function getTime(type) {
|
||||
if (type === 'start') {
|
||||
return new Date().getTime() - 3600 * 1000 * 24 * 90
|
||||
if (type === "start") {
|
||||
return new Date().getTime() - 3600 * 1000 * 24 * 90;
|
||||
} else {
|
||||
return new Date(new Date().toDateString())
|
||||
return new Date(new Date().toDateString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,38 +249,38 @@ export function getTime(type) {
|
|||
* @return {*}
|
||||
*/
|
||||
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
|
||||
if (last < wait && last > 0) {
|
||||
timeout = setTimeout(later, wait - last)
|
||||
timeout = setTimeout(later, wait - last);
|
||||
} else {
|
||||
timeout = null
|
||||
timeout = null;
|
||||
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
||||
if (!immediate) {
|
||||
result = func.apply(context, args)
|
||||
if (!timeout) context = args = null
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return function (...args) {
|
||||
context = this
|
||||
timestamp = +new Date()
|
||||
const callNow = immediate && !timeout
|
||||
return function(...args) {
|
||||
context = this;
|
||||
timestamp = +new Date();
|
||||
const callNow = immediate && !timeout;
|
||||
// 如果延时不存在,重新设定延时
|
||||
if (!timeout) timeout = setTimeout(later, wait)
|
||||
if (!timeout) timeout = setTimeout(later, wait);
|
||||
if (callNow) {
|
||||
result = func.apply(context, args)
|
||||
context = args = null
|
||||
result = func.apply(context, args);
|
||||
context = args = null;
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -289,18 +291,18 @@ export function debounce(func, wait, immediate) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function deepClone(source) {
|
||||
if (!source && typeof source !== 'object') {
|
||||
throw new Error('error arguments', 'deepClone')
|
||||
if (!source && typeof source !== "object") {
|
||||
throw new Error("error arguments", "deepClone");
|
||||
}
|
||||
const targetObj = source.constructor === Array ? [] : {}
|
||||
const targetObj = source.constructor === Array ? [] : {};
|
||||
Object.keys(source).forEach(keys => {
|
||||
if (source[keys] && typeof source[keys] === 'object') {
|
||||
targetObj[keys] = deepClone(source[keys])
|
||||
if (source[keys] && typeof source[keys] === "object") {
|
||||
targetObj[keys] = deepClone(source[keys]);
|
||||
} else {
|
||||
targetObj[keys] = source[keys]
|
||||
targetObj[keys] = source[keys];
|
||||
}
|
||||
})
|
||||
return targetObj
|
||||
});
|
||||
return targetObj;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -308,16 +310,16 @@ export function deepClone(source) {
|
|||
* @returns {Array}
|
||||
*/
|
||||
export function uniqueArr(arr) {
|
||||
return Array.from(new Set(arr))
|
||||
return Array.from(new Set(arr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function createUniqueString() {
|
||||
const timestamp = +new Date() + ''
|
||||
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
||||
return (+(randomNum + timestamp)).toString(32)
|
||||
const timestamp = +new Date() + "";
|
||||
const randomNum = parseInt((1 + Math.random()) * 65536) + "";
|
||||
return (+(randomNum + timestamp)).toString(32);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -327,7 +329,7 @@ export function createUniqueString() {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
if (hasClass(ele, cls)) {
|
||||
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
|
||||
ele.className = ele.className.replace(reg, ' ')
|
||||
const reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
||||
ele.className = ele.className.replace(reg, " ");
|
||||
}
|
||||
}
|
||||
|
||||
// 替换邮箱字符
|
||||
export function regEmail(email) {
|
||||
if (String(email).indexOf('@') > 0) {
|
||||
const str = email.split('@')
|
||||
let _s = ''
|
||||
if (String(email).indexOf("@") > 0) {
|
||||
const str = email.split("@");
|
||||
let _s = "";
|
||||
if (str[0].length > 3) {
|
||||
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) {
|
||||
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) {
|
||||
const url = window.URL.createObjectURL(new Blob([obj]))
|
||||
const link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = url
|
||||
const fileName = parseTime(new Date()) + '-' + name + '.' + suffix
|
||||
link.setAttribute('download', fileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
const url = window.URL.createObjectURL(new Blob([obj]));
|
||||
const link = document.createElement("a");
|
||||
link.style.display = "none";
|
||||
link.href = url;
|
||||
const fileName = parseTime(new Date()) + "-" + name + "." + suffix;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -398,3 +400,19 @@ export function RandomNumBoth(Max, Min = 0) {
|
|||
var num = Min + Math.round(Rand * Range); //四舍五入
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,194 @@
|
|||
<template>
|
||||
<el-dialog title="选择商品" :visible.sync="dialogVisible" @open="resetHandle()">
|
||||
<el-form :model="searhForm" inline>
|
||||
<el-form-item>
|
||||
<el-input v-model="searhForm.name" placeholder="商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-select v-model="searhForm.category" placeholder="商品分类">
|
||||
<el-option :label="item.name" :value="item.id" v-for="item in categoryList"
|
||||
:key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getTableData">查询</el-button>
|
||||
<el-button @click="resetHandle">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="head-container">
|
||||
<el-table ref="table" :data="tableData.list" v-loading="tableData.loading">
|
||||
<el-table-column type="selection" width="55" align="center"></el-table-column>
|
||||
<el-table-column label="商品信息">
|
||||
<template v-slot="scope">
|
||||
<div class="shop_info">
|
||||
<el-image :src="scope.row.coverImg" style="width: 30px;height: 30px;">
|
||||
<div class="img_error" slot="error">
|
||||
<i class="icon el-icon-document-delete"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
<span>{{ scope.row.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="规格">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.typeEnum }}
|
||||
</template>
|
||||
</el-table-column> <el-table-column label="是否售罄">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.isPauseSale == 1?'是':'否' }}
|
||||
</template>
|
||||
</el-table-column> <el-table-column label="是否分销">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.isDistribute == 1?'是':'否' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="售价">
|
||||
<template v-slot="scope">
|
||||
¥{{ scope.row.lowPrice }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="销量/库存">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.realSalesNumber }}/{{ scope.row.stockNumber }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分类名称" prop="categoryName"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
|
||||
@current-change="paginationChange" @size-change="sizeChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="confirmHandle">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tbShopCategoryGet, tbProductlist } from "@/api/invoicing";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
searhForm: {
|
||||
name: '',
|
||||
category: ''
|
||||
},
|
||||
categoryList: [],
|
||||
tableData: {
|
||||
page: 0,
|
||||
size: 10,
|
||||
total: 0,
|
||||
loading: false,
|
||||
list: []
|
||||
},
|
||||
goods: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 确定选商品
|
||||
confirmHandle() {
|
||||
let res = this.$refs.table.selection
|
||||
this.$emit('success', res)
|
||||
this.close()
|
||||
},
|
||||
// 重置查询
|
||||
resetHandle() {
|
||||
this.searhForm.name = ''
|
||||
this.searhForm.category = ''
|
||||
this.tableData.page = 0
|
||||
this.tableData.size = 10
|
||||
this.tableData.list = []
|
||||
this.getTableData()
|
||||
},
|
||||
// 分页大小改变
|
||||
sizeChange(e) {
|
||||
this.tableData.size = e
|
||||
this.getTableData()
|
||||
},
|
||||
// 分页回调
|
||||
paginationChange(e) {
|
||||
this.tableData.page = e - 1
|
||||
this.getTableData()
|
||||
},
|
||||
// 商品列表
|
||||
async getTableData() {
|
||||
this.tableData.loading = true
|
||||
try {
|
||||
const res = await tbProductlist({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
name: this.searhForm.name,
|
||||
categoryId: this.searhForm.category,
|
||||
shopId: localStorage.getItem('shopId'),
|
||||
sort: 'id',
|
||||
})
|
||||
this.tableData.list = res.content
|
||||
this.tableData.total = res.totalElements
|
||||
|
||||
if (this.goods.length) {
|
||||
this.$nextTick(() => {
|
||||
this.selection()
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.tableData.loading = false
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
// 商品分类
|
||||
async tbShopCategoryGet() {
|
||||
try {
|
||||
const res = await tbShopCategoryGet({
|
||||
page: 0,
|
||||
size: 100,
|
||||
sort: 'id',
|
||||
shopId: localStorage.getItem('shopId')
|
||||
})
|
||||
this.categoryList = res.content
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
show(goods) {
|
||||
this.dialogVisible = true
|
||||
if (goods && goods.length) {
|
||||
this.goods = goods
|
||||
} else {
|
||||
this.goods = []
|
||||
}
|
||||
this.resetHandle()
|
||||
this.tbShopCategoryGet()
|
||||
this.getTableData()
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false
|
||||
},
|
||||
selection() {
|
||||
this.goods.forEach(row => {
|
||||
this.tableData.list.forEach((item, index) => {
|
||||
if (row.id == item.id) {
|
||||
this.$refs.table.toggleRowSelection(this.tableData.list[index]);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.shop_info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
span {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -140,7 +140,7 @@
|
|||
|
||||
<script>
|
||||
import dayjs from 'dayjs'
|
||||
import shopList from '@/components/shopList'
|
||||
import shopList from './components/shopList'
|
||||
import { tbShopPurveyorGet, tbProductStockOperateOutAndOn } from '@/api/invoicing'
|
||||
export default {
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@
|
|||
|
||||
<script>
|
||||
import dayjs from 'dayjs'
|
||||
import shopList from '@/components/shopList'
|
||||
import shopList from './components/shopList'
|
||||
import { tbShopPurveyorGet, tbProductStockOperateOutAndOn } from '@/api/invoicing'
|
||||
export default {
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="操作" width="240">
|
||||
<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)"
|
||||
style="margin-left: 20px !important;">编辑</el-button>
|
||||
<el-popconfirm title="确定删除吗?" @confirm="delHandle([scope.row.id])">
|
||||
|
|
@ -56,9 +56,11 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
this.getTableData()
|
||||
this.$nextTick(() => {
|
||||
this.tableDrag()
|
||||
})
|
||||
if (this.isPcBowser) {
|
||||
this.$nextTick(() => {
|
||||
this.tableDrag()
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//表格拖拽
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
</el-select>
|
||||
</el-col>
|
||||
<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-col>
|
||||
</el-row>
|
||||
|
|
@ -80,7 +80,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="操作" width="200">
|
||||
<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 } }"
|
||||
style="margin-left: 20px !important;">
|
||||
<el-button type="text" icon="el-icon-edit">编辑</el-button>
|
||||
|
|
@ -125,14 +125,21 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getTableData()
|
||||
this.tbShopCategoryGet()
|
||||
this.$nextTick(() => {
|
||||
this.tableDrag()
|
||||
})
|
||||
async mounted() {
|
||||
await this.tbShopCategoryGet()
|
||||
await this.getTableData()
|
||||
if (this.isPcBowser) {
|
||||
this.$nextTick(() => {
|
||||
this.tableDrag()
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 选择分类
|
||||
queryHandle() {
|
||||
localStorage.setItem('shopIndexQuery', JSON.stringify(this.query))
|
||||
this.getTableData()
|
||||
},
|
||||
//表格拖拽
|
||||
tableDrag() {
|
||||
const el = document.querySelector('#table_drag .el-table__body-wrapper tbody')
|
||||
|
|
@ -177,6 +184,7 @@ export default {
|
|||
this.query.categoryId = ''
|
||||
this.query.typeEnum = ''
|
||||
this.tableData.page = 0
|
||||
localStorage.setItem('shopIndexQuery', JSON.stringify(this.query))
|
||||
this.getTableData()
|
||||
},
|
||||
// 分页回调
|
||||
|
|
@ -186,8 +194,13 @@ export default {
|
|||
},
|
||||
// 获取商品列表
|
||||
async getTableData() {
|
||||
this.tableData.loading = true
|
||||
try {
|
||||
let localQuery = JSON.parse(localStorage.getItem('shopIndexQuery'))
|
||||
if (localQuery != null) {
|
||||
this.query = localQuery
|
||||
}
|
||||
|
||||
this.tableData.loading = true
|
||||
const res = await tbProduct({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
|
|
|
|||
Loading…
Reference in New Issue