Commit 445d37bd by qinjianhui

fix: 删除多余代码

parent a72043b7
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
</div> </div>
</template> </template>
<script> <script>
// import Head from './components/head.vue'
export default { export default {
data() { data() {
return {} return {}
}, },
// components: { Head },
} }
</script> </script>
<style> <style>
......
[
{
"title": "待派单",
"icon": "Home-Logistics-exception-order.png",
"value": "0",
"show": true,
"top": false,
"key": "wait_send_order_count",
"route": "order_pending"
},
{
"title": "SKU异常订单",
"icon": "Home-SKU-abnormal-order.png",
"value": "0",
"show": true,
"top": false,
"key": "sku_exception_Count",
"route": "order_pending"
},
{
"title": "缺货订单",
"icon": "Home-Out-of-stock-order.png",
"value": "0",
"show": true,
"top": false,
"key": "out_of_stock_count",
"route": "order_pending"
},
{
"title": "物流异常订单",
"icon": "Home-Logistics-exception-order.png",
"value": "0",
"show": true,
"top": false,
"key": "logistics_exception_count",
"route": ""
},
{
"title": "待包装订单",
"icon": "Home-Pending-order.png",
"value": "0",
"show": true,
"top": false,
"key": "wait_package_count",
"route": "order_nopack"
},
{
"title": "待发货订单",
"icon": "Home-Shipping-Pending-orders.png",
"value": "0",
"show": true,
"top": false,
"key": "wait_ship_count",
"route": "order_nodelivery"
},
{
"title": "报销待审批",
"icon": "Home-Reimbursement-pending-approval.png",
"value": "0",
"show": true,
"top": false,
"key": "fee_count",
"route": "financial_declareCost"
},
{
"title": "请假待审批",
"icon": "Home-Leave-pending.png",
"value": "0",
"show": true,
"top": false,
"key": "leave_count",
"route": "/personalCenter/leave/1"
},
{
"title": "采购待审批",
"icon": "Home-Purchase-pending.png",
"value": "0",
"show": true,
"top": false,
"key": "purchase_wait_audit_count",
"route": "purchase_order"
},
{
"title": "采购待付款",
"icon": "Home-Purchase-pending-payment.png",
"value": "0",
"show": true,
"top": false,
"key": "purchase_wait_pay_count",
"route": "purchase_order"
},
{
"title": "采购未完全入库",
"icon": "Home-Procurement-is-not-fully-warehoused.png",
"value": "0",
"show": true,
"top": false,
"key": "purchase_uncompleted_stored_count",
"route": "purchase_order"
},
{
"title": "采购入库待审核",
"icon": "Home-Purchase-and-storage-pending-review.png",
"value": "0",
"show": true,
"top": false,
"key": "stored_wait_audit_count",
"route": "purchase_warehousing"
},
{
"title": "采购退回待审核",
"icon": "Home-Purchase-returned-pending-review.png",
"value": "0",
"show": true,
"top": false,
"key": "purchase_retreat_count",
"route": "purchase_returned"
},
{
"title": "派给我的任务",
"icon": "Home-Purchase-returned-pending-review.png",
"value": "0",
"show": true,
"top": false,
"key": "assign_count",
"route": ""
},
{
"title": "待验收的任务",
"icon": "Home-Purchase-returned-pending-review.png",
"value": "0",
"show": true,
"top": false,
"key": "acceptance_count",
"route": ""
},
{
"title": "抄送给我的任务",
"icon": "Home-Purchase-returned-pending-review.png",
"value": "0",
"show": true,
"top": false,
"key": "correlation_count",
"route": ""
}
]
[{
"name": "Shopify",
"type": "SHOPIFY",
"icon": "./images/icon/logo-1.png",
"cycle": "today",
"route": "/statistics/storeProfits"
},
{
"name": "AliExpress",
"type": "AE",
"icon": "./images/icon/logo-3.png",
"cycle": "today",
"route": "/statistics/storeProfits/aliexpress"
},
{
"name": "Amazon",
"type": "AMAZON",
"icon": "./images/icon/logo-2.png",
"cycle": "yesterday",
"route": "/statistics/storeProfits/amazon"
},
{
"name": "Magento",
"type": "MAGENTO",
"icon": "./images/icon/logo-6.png",
"cycle": "today",
"route": "/statistics/storeProfits/magento"
},
{
"name": "SHOPLINE",
"type": "SHOPLINE",
"cycle": "today",
"icon": "./images/icon/logo-4.png",
"route": "/statistics/storeProfits/shopline"
},
{
"name": "Shoplazza",
"type": "SHOPLAZZA",
"cycle": "today",
"icon": "./images/icon/logo-5.png",
"route": "/statistics/storeProfits/shoplazza"
},
{
"name": "Alibaba",
"type": "ALIBABA",
"cycle": "today",
"icon": "./images/icon/alibaba.png",
"route": "/statistics/storeProfits/alibaba"
},
{
"name": "walmart",
"type": "WALMART",
"cycle": "today",
"icon": "./images/icon/walmart.png",
"route": "/statistics/storeProfits/walmart"
},
{
"name": "Customize",
"type": "CUSTOMIZE",
"cycle": "today",
"icon": "./images/icon/customize.png",
"route": "/statistics/storeProfits/customize"
}
]
\ No newline at end of file
/*
* @Description: 描述
* @Author: chd
* @Date: 2021-02-04 10:02:43
* @LastEditors: chd
* @LastEditTime: 2021-02-04 10:02:58
*/
export default {
Seconds: {
name: '秒',
every: '每一秒钟',
interval: ['每隔', '秒执行 从', '秒开始'],
specific: '具体秒数(可多选)',
cycle: ['周期从', '到', '秒'],
},
Minutes: {
name: '分',
every: '每一分钟',
interval: ['每隔', '分执行 从', '分开始'],
specific: '具体分钟数(可多选)',
cycle: ['周期从', '到', '分'],
},
Hours: {
name: '时',
every: '每一小时',
interval: ['每隔', '小时执行 从', '小时开始'],
specific: '具体小时数(可多选)',
cycle: ['周期从', '到', '小时'],
},
Day: {
name: '天',
every: '每一天',
intervalWeek: ['每隔', '周执行 从', '开始'],
intervalDay: ['每隔', '天执行 从', '天开始'],
specificWeek: '具体星期几(可多选)',
specificDay: '具体天数(可多选)',
lastDay: '在这个月的最后一天',
lastWeekday: '在这个月的最后一个工作日',
lastWeek: ['在这个月的最后一个'],
beforeEndMonth: ['在本月底前', '天'],
nearestWeekday: ['最近的工作日(周一至周五)至本月', '日'],
someWeekday: ['在这个月的第', '个'],
},
Week: ['天', '一', '二', '三', '四', '五', '六'].map((val) => '星期' + val),
Month: {
name: '月',
every: '每一月',
interval: ['每隔', '月执行 从', '月开始'],
specific: '具体月数(可多选)',
cycle: ['从', '到', '月之间的每个月'],
},
Year: {
name: '年',
every: '每一年',
interval: ['每隔', '年执行 从', '年开始'],
specific: '具体年份(可多选)',
cycle: ['从', '到', '年之间的每一年'],
},
Save: '保存',
Close: '关闭',
}
/*
* @Description: 描述
* @Author: chd
* @Date: 2021-02-04 10:04:17
* @LastEditors: chd
* @LastEditTime: 2021-02-04 10:04:17
*/
export default {
Seconds: {
name: 'Seconds',
every: 'Every second',
interval: ['Every', 'second(s) starting at second'],
specific: 'Specific second (choose one or many)',
cycle: ['Every second between second', 'and second'],
},
Minutes: {
name: 'Minutes',
every: 'Every minute',
interval: ['Every', 'minute(s) starting at minute'],
specific: 'Specific minute (choose one or many)',
cycle: ['Every minute between minute', 'and minute'],
},
Hours: {
name: 'Hours',
every: 'Every hour',
interval: ['Every', 'hour(s) starting at hour'],
specific: 'Specific hour (choose one or many)',
cycle: ['Every hour between hour', 'and hour'],
},
Day: {
name: 'Day',
every: 'Every day',
intervalWeek: ['Every', 'day(s) starting on'],
intervalDay: ['Every', 'day(s) starting at the', 'of the month'],
specificWeek: 'Specific day of week (choose one or many)',
specificDay: 'Specific day of month (choose one or many)',
lastDay: 'On the last day of the month',
lastWeekday: 'On the last weekday of the month',
lastWeek: ['On the last', ' of the month'],
beforeEndMonth: ['day(s) before the end of the month'],
nearestWeekday: [
'Nearest weekday (Monday to Friday) to the',
'of the month',
],
someWeekday: ['On the', 'of the month'],
},
Week: [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
],
Month: {
name: 'Month',
every: 'Every month',
interval: ['Every', 'month(s) starting in'],
specific: 'Specific month (choose one or many)',
cycle: ['Every month between', 'and'],
},
Year: {
name: 'Year',
every: 'Any year',
interval: ['Every', 'year(s) starting in'],
specific: 'Specific year (choose one or many)',
cycle: ['Every year between', 'and'],
},
Save: 'Save',
Close: 'Close',
}
/*
* @Description: 描述
* @Author: chd
* @Date: 2021-02-04 10:03:33
* @LastEditors: chd
* @LastEditTime: 2021-02-04 10:04:59
*/
import en from './en'
import cn from './cn'
export default {
en,
cn,
}
...@@ -18,102 +18,7 @@ import './assets/css/root.css' ...@@ -18,102 +18,7 @@ import './assets/css/root.css'
import './assets/css/common.css' import './assets/css/common.css'
import './assets/css/index.css' import './assets/css/index.css'
import './styles/index.scss' import './styles/index.scss'
import moment from 'moment'
import { filePath, zImgPath } from './utils/axios'
import './mork'
import _ from 'lodash'
Vue.config.performance = true
Vue.config.productionTip = process.env.NODE_ENV !== 'production'
const isMobile = () => window.innerWidth <= 1100
Vue.util.defineReactive(Vue.prototype, '$isMobile', isMobile())
window.addEventListener('resize', () => {
Vue.prototype.$isMobile = isMobile()
})
// 待优化
Vue.prototype.$moment = moment
// 待优化
// 日期格式化 待优化
Vue.filter('dateformat', function (dataStr, pattern = 'YYYY-MM-DD') {
if (dataStr) {
return moment(dataStr).format(pattern)
} else {
return dataStr
}
})
// 待优化
// 权限校验
Vue.prototype.roleShow = (name) => {
let roles = store.state.reqMenu.buttons
if (!roles) return false
if (Array.isArray(name)) {
return name.some((key) => roles.includes(key))
} else {
return roles ? roles.includes(name) : false
}
}
/**
* 图片下载地址
* w=width&h=height&g=isgray&x=position_x&y=position_y&r=rotate&q=quality&f=format
* @param {*} url
* @param {Object} options
* @param {Number} options.w -width
* @param {Number} options.w -height
* @param {0 | 1} options.g -isgray 灰色
* @param {Number} options.x -position_x
* @param {Number} options.y -position_y
* @param {Number} options.r -rotate 旋转
* @param {Number} options.q -quality 质量
* @param {'jpeg' | 'png' | 'gif' | 'jeg'} options.f -format
* @returns String
*/
const clientWidth = document.body.clientWidth
const dpi = _.add(_.ceil(_.divide(clientWidth / 1920)) + 0.5)
console.log('dpi', dpi)
Vue.prototype.setimgUrl = (url, options = {}) => {
const { w, h, ...others } = options
let query = ''
if (w) {
query += query ? '&w=' : 'w=' + _.floor(_.multiply(dpi * w))
}
if (h) {
query += query ? '&h=' : 'h=' + _.floor(_.multiply(dpi * h))
}
for (const key in others) {
query += `${query ? '&' : ''}${key}=${options[key]}`
}
if (!url) return ''
if (/(http|https):\/\/([^/]+)/i.test(url)) {
return url
} else if (url.indexOf('/') === -1) {
return zImgPath + url + (query ? '?' : '') + query
} else {
return filePath + url
}
}
/**
* 大数字转换
* @param {*} num
* @returns
*/
Vue.prototype.amountConversion = (num, cb) => {
if (!num) return ['0', '']
let text = ''
if (num > 99999999) {
text = [Math.floor(num / 10000000) / 10, '亿']
} else if (num > 9999) {
text = [Math.floor(num / 1000) / 10, '万']
} else {
text = [num, '']
}
if (cb) {
return cb(num)
}
return text
}
new Vue({ new Vue({
store, store,
......
/*
* @Description: 描述
* @Author: chd
* @Date: 2021-01-27 17:22:04
* @LastEditors: chd
* @LastEditTime: 2021-01-27 17:24:04
*/
export default {
data() {
return {
paginationOptions: {
pageSize: 100,
currentPage: 1,
total: 0,
},
}
},
methods: {
setpaginationOptions(opt) {
for (const key in opt) {
this.paginationOptions[key] = opt[key]
}
this.getlist()
},
},
}
import Mock from 'mockjs'
Mock.mock(/baseCategoryInfo\/saveDef/, 'post', () => ({
message: '操作成功',
code: 200,
}))
Mock.mock(/local\/stockNumber/, 'get', () => ({
message: '操作成功',
data: [
{
warehouseSku: '22019081_BLK_2',
quantity: 1,
},
{
warehouseSku: '22019081_BLK_4',
quantity: 2,
},
],
code: 200,
}))
Mock.mock(/baseCategoryInfo\/supplierList/, 'get', (params) => {
console.log(params)
const data = []
for (let i = 0; i < 10; i++) {
data.push({
address: '杠三十公分',
bankAccount: '545766867',
belongTo: '224',
buyer: '43',
categoryName: '男装',
code: '185',
contact: '阿凡达',
createTime: '2020-04-29 23:25:10',
deliveryMethod: '127',
email: '111@514.com',
enable: true,
id: i,
limitDay: 181,
name: '测试供应商182',
payment: '124',
phone: '12876544567',
remark: '阿凡达的发',
url: 'www.vvv.cc',
wangwang: '345435_43406',
})
}
return {
message: '操作成功',
data: data,
code: 200,
}
})
export default Mock
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
Vue.use(Vuex) Vue.use(Vuex)
import Order from './modules/order'
import im from './modules/im'
import roleAuth from './modules/roleAuth'
import supply from './modules/supply'
import { delChildren } from '../utils/commonUtil'
export default new Vuex.Store({ export default new Vuex.Store({
// strict: process.env.NODE_ENV !== 'production',
modules: { modules: {
Order,
im,
roleAuth,
supply,
}, },
state: { state: {
country: [], //国家列表
currency: [], //币种列表
warehouse: [], //仓库列表
customTag: [], //自定义标签列表
logistics: [], //物流公司列表
logisticsMode: [], //物流方式列表
employee: [], //员工列表
purchaseChannels: [], //采购渠道
productCategory: [], //产品类别
supplierList: [], //供应商
printOptions: [], //打印模板
storeList: [],
canlogistics: [],
keyCode: null,
showChat: false,
//页面默认选项
reqMenu: {
buttons: [],
},
//导航标签
tags: [
{
title: '首页',
name: 'home',
route: '/home',
},
],
tagsIndex: 0, //导航下标
permissions: [],
historyList: [],
costomThemeVisible: false,
navList: [], //快捷导航
sysColumns: {},
platformOptions: [],
}, },
mutations: { mutations: {
setState(state, options) {
for (const key in options) {
if (Object.prototype.hasOwnProperty.call(state, key)) {
if (key === 'productCategory') {
// 去除空的children
try {
state[key] = delChildren(options[key])
} catch (error) {
state[key] = options[key]
}
} else {
state[key] = options[key]
}
}
}
},
resetState(state) {
const arr = ['Order', 'im', 'roleAuth', 'supply']
for (const key in state) {
if (arr.includes(key)) continue //跳过 modules
if (key === 'reqMenu') continue //待优化
if (Array.isArray(state[key])) {
state[key] = []
} else if (typeof state[key] === 'string') {
state[key] = ''
} else if (typeof state[key] === 'number') {
state[key] = 0
} else if (typeof state[key] === 'boolean') {
state[key] = false
} else if (typeof state[key] === 'object') {
state[key] = {}
} else {
state[key] = ''
}
state.tagsIndex = 0
state.tags = [{ title: '首页', name: 'home', route: '/home' }]
}
},
loginout(state) {
state.tags = [{ title: '首页', name: 'home', route: '/home' }]
state.tagsIndex = 0
state.permissions = []
},
set_route_premissions(state, msg) {
state.permissions.push(msg)
},
modify_home_tabs(state, msg) {
if (msg.length > 0) {
state.tags = msg
} else {
state.tags = [{ title: '首页', name: 'home', route: '/home' }]
}
},
modify_activeIndex(state, msg) {
state.tagsIndex = msg
},
modify_reqMenu(state, msg) {
state.reqMenu = msg
},
setSysColumns(state, options) {
for (const key in options) {
state.sysColumns[key] = options[key]
}
},
setKeyCode(state, msg) {
state.keyCode = msg
},
}, },
actions: { actions: {
resetState({ commit }) {
commit('resetState')
},
setState({ commit }, options) {
commit('setState', options)
},
loginout({ commit }) {
commit('loginout')
},
loginIn({ commit }, { msg }) {
commit('loginIn', msg)
},
setSysColumns({ commit }, options) {
commit('setSysColumns', options)
},
setKeyCode({ commit }, msg) {
commit('setKeyCode', msg)
},
setMenuList({ commit }, list) {
commit('modify_menulist', list)
},
}, },
}) })
const state = {
users: [], //用户
sessionList: [],
activeIndex: 0,
uid: '',
groups: [],
}
const mutations = {
setUsersStatus(state, list) {
let users = state.users
for (const iterator of list) {
for (const iterato of users) {
if (iterato.uid === iterator.uid) {
iterato.status = iterator.status
break
}
}
}
},
setUsers(state, list) {
state.users = list
},
addSession(state, data) {
let list = state.sessionList
let index = list.findIndex((h) => h.uid === data.uid)
if (index !== -1) {
state.activeIndex = index
// let item = list[index];
// list.splice(index, 1);
// list.unshift(item);
} else {
list.unshift(data)
state.activeIndex = 0
}
},
setUnread(state, { uid, unread }) {
let list = state.sessionList
let index = list.findIndex((h) => h.uid === uid)
let item
// 取消未读
if (state.activeIndex === index && unread) {
list[index].unread = false
return
}
// 来消息置顶
if (index !== -1) {
item = list[index]
list.splice(index, 1)
if (state.activeIndex < index) {
state.activeIndex = index + 1
item.unread = !!unread
} else if (state.activeIndex === index) {
state.activeIndex = 0
} else {
item.unread = !!unread
}
} else {
item = state.users.find((item) => item.uid === uid)
state.activeIndex += 1
}
list.unshift(item)
// for (const iterator of state.sessionList) {
// if(iterator.uid === uid){
// iterator.unread = !iterator.unread;
// break
// }
// }
},
setActiveIndex(state, index) {
state.activeIndex = index
state.sessionList
},
setGroups(state, list) {
state.groups = list
},
setUid(state, uid) {
state.uid = uid
},
}
const actions = {
// 在线状态
setUsersStatus({ commit }, list) {
commit('setUsersStatus', list)
},
// 用户
setUsers({ commit }, list) {
commit('setUsers', list)
},
// 历史聊天
addSession({ commit }, data) {
commit('addSession', data)
},
// 未读
setUnread({ commit }, uid) {
commit('setUnread', uid)
},
setActiveIndex({ commit }, index) {
commit('setActiveIndex', index)
},
setUid({ commit }, uid) {
commit('setUid', uid)
},
setGroups({ commit }, list) {
commit('setGroups', list)
},
}
export default { state, mutations, actions }
/*
* @Description: 描述
* @Author: chd
* @Date: 2020-05-20 17:52:12
* @LastEditors: chd
* @LastEditTime: 2021-01-21 14:01:35
*/
import { get } from '../../utils/axios'
import Vue from 'vue'
const state = {
orderItem: {},
tableKey: 0,
oldSelection: [],
}
const mutations = {
setOrderItem(state, data) {
state.orderItem = data
},
setTableKey(state, num) {
state.tableKey = num
},
saveSelection(state, list) {
state.oldSelection = list
},
}
const actions = {
setOrderItem({ commit }, { id }) {
get('orderDetails/get', { id }).then((res) => {
if (res.code == 200) {
commit('setOrderItem', res.data)
} else {
Vue.prototype.$alert(res.message, '错误提示', {
dangerouslyUseHTMLString: true,
})
}
})
},
setTableKey({ commit }) {
let num = Math.floor(Math.random() * (1 - 100) + 100)
commit('setTableKey', num)
},
saveSelection({ commit }, list) {
commit('saveSelection', list)
},
}
export default { state, mutations, actions }
/*
* @Description: 描述
* @Author: chd
* @Date: 2020-10-17 09:42:30
* @LastEditors: chd
* @LastEditTime: 2021-04-28 16:07:58
*/
import { get } from '../../utils/axios'
const state = {
menusTree: [],
dataAccess: [],
roleAuth: {},
warehouselist: [],
supplierlist: [],
}
const mutations = {
setMenuTree(state, list) {
state.menusTree = list
},
setRoleAuth(state, obj) {
for (const key in obj) {
state.roleAuth[key] = obj[key]
}
},
setDataList(state, list) {
state.dataAccess = list
},
setWarehouselist(state, list) {
state.warehouselist = list
},
setSupplierList(state, list) {
state.supplierlist = list
},
}
const actions = {
setMenuTree({ commit }, list) {
commit('setMenuTree', list)
},
setRoleAuth({ commit }, obj) {
commit('setRoleAuth', obj)
},
getWarehouselist({ commit }) {
get('warehouseInfo/allList').then((res) => {
commit('setWarehouselist', res.data)
})
},
getSupplierList({ commit }) {
get('supplySupplier/getCategorySupplyTree').then((res) => {
commit('setSupplierList', res.data)
})
},
getDataList({ commit, state }) {
return new Promise((resolve) => {
if (state.dataAccess.length === 0) {
/* function getName(key) {
let text = '';
switch (key) {
case 'order':
text = '订单';
break;
case 'product':
text = '产品';
break;
case 'supplier':
text = '供应商';
break;
case 'customer':
text = '客户';
break;
}
return text;
} */
get('dataAuthority/authorityList').then((res) => {
if (res.code === 200) {
let obj = {}
for (const iterator of res.data) {
if (!obj[iterator.type]) {
obj[iterator.type] = {
name: iterator.typeName,
children: [],
dataCheckAll: false,
dataIndeter: false,
dataChecklist: [],
group: [],
}
}
const current = obj[iterator.type]
if (iterator.propGroup) {
const item = current.group.find(
(item) => item.label === iterator.propGroup
)
if (item) {
item.list.push(iterator)
} else {
current.group.push({
label: iterator.propGroup,
list: [iterator],
checked: '',
})
}
} else {
current.children.push(iterator)
}
}
let arr = []
for (const key in obj) {
arr.push(obj[key])
}
commit('setDataList', arr)
resolve({ dataAccess: arr, roleAuth: state.roleAuth })
}
})
} else {
resolve({ dataAccess: state.dataAccess, roleAuth: state.roleAuth })
}
})
},
}
const getters = {}
export default { state, mutations, actions, getters }
const state = {
componentId: 'CardMode',
CardComponentId: 'BasicCard',
}
const mutations = {
setComponent(state, id) {
state.componentId = id
},
setCardComponent(state, id) {
state.CardComponentId = id
},
}
const actions = {
setComponent({ commit }, id) {
commit('setComponent', id)
},
setCardComponent({ commit }, id) {
commit('setCardComponent', id)
},
}
export default { state, mutations, actions }
//==本JS是加载Lodop插件或Web打印服务CLodop/Lodop7的综合示例,可直接使用,建议理解后融入自己程序==
import Vue from 'vue'
var CreatedOKLodopObject, CLodopIsLocal, CLodopJsState
//==判断是否需要CLodop(那些不支持插件的浏览器):==
function needCLodop() {
try {
var ua = navigator.userAgent
if (ua.match(/Windows\sPhone/i)) return true
if (ua.match(/iPhone|iPod|iPad/i)) return true
if (ua.match(/Android/i)) return true
if (ua.match(/Edge\D?\d+/i)) return true
var verTrident = ua.match(/Trident\D?\d+/i)
var verIE = ua.match(/MSIE\D?\d+/i)
var verOPR = ua.match(/OPR\D?\d+/i)
var verFF = ua.match(/Firefox\D?\d+/i)
var x64 = ua.match(/x64/i)
if (!verTrident && !verIE && x64) return true
else if (verFF) {
verFF = verFF[0].match(/\d+/)
if (verFF[0] >= 41 || x64) return true
} else if (verOPR) {
verOPR = verOPR[0].match(/\d+/)
if (verOPR[0] >= 32) return true
} else if (!verTrident && !verIE) {
var verChrome = ua.match(/Chrome\D?\d+/i)
if (verChrome) {
verChrome = verChrome[0].match(/\d+/)
if (verChrome[0] >= 41) return true
}
}
return false
} catch (err) {
return true
}
}
//加载CLodop时用双端口(http是8000/18000,而https是8443/8444)以防其中某端口被占,
//主JS文件名“CLodopfuncs.js”是固定名称,其内容是动态的,与其链接的打印环境有关:
function loadCLodop() {
if (CLodopJsState == 'loading' || CLodopJsState == 'complete') return
CLodopJsState = 'loading'
var head =
document.head ||
document.getElementsByTagName('head')[0] ||
document.documentElement
var JS1 = document.createElement('script')
var JS2 = document.createElement('script')
if (window.location.protocol == 'https:') {
JS1.src = 'https://localhost.lodop.net:8443/CLodopfuncs.js'
JS2.src = 'https://localhost.lodop.net:8444/CLodopfuncs.js'
} else {
JS1.src = 'http://localhost:8000/CLodopfuncs.js'
JS2.src = 'http://localhost:18000/CLodopfuncs.js'
}
JS1.onload = JS2.onload = function () {
CLodopJsState = 'complete'
}
JS1.onerror = JS2.onerror = function () {
CLodopJsState = 'complete'
}
head.insertBefore(JS1, head.firstChild)
head.insertBefore(JS2, head.firstChild)
CLodopIsLocal = !!(JS1.src + JS2.src).match(/\/\/localho|\/\/127.0.0./i)
}
if (needCLodop()) {
loadCLodop()
} //开始加载
function showMsg(text) {
Vue.prototype.$msgbox({
title: '提示',
message: text,
showCancelButton: false,
showConfirmButton: false,
dangerouslyUseHTMLString: true,
closeOnClickModal: false,
center: true,
})
}
//==获取LODOP对象主过程,判断是否安装、需否升级:==
export function getLodop(oOBJECT, oEMBED) {
var strFontTag = "<font '>打印控件"
var strLodopInstall =
strFontTag +
"未安装!点击这里<a href='http://www.lodop.net/download/Lodop6.226Clodop4.161.zip' target='_self'>执行安装</a>"
var strLodopUpdate =
strFontTag +
"需要升级!点击这里<a href='install_lodop32.exe' target='_self'>执行升级</a>"
var strLodop64Install =
strFontTag +
"未安装!点击这里<a href='install_lodop64.exe' target='_self'>执行安装</a>"
var strLodop64Update =
strFontTag +
"需要升级!点击这里<a href='install_lodop64.exe' target='_self'>执行升级</a>"
var strCLodopInstallA =
"<font >Web打印服务CLodop未安装启动,点击下列按钮执行安装<br><a href='http://www.lodop.net/download/Lodop6.226Clodop4.161.zip' target='_self'>安装32位</a> <a href='http://www.lodop.net/download/CLodop_Setup_for_Win64NT_4.161EN.zip' target='_self'>安装64位</a><br>"
var strCLodopInstallB =
"(若此前已安装过,可点这里直接<a href='CLodop.protocol:setup' target='_self'>再次启动</a>)"
var strCLodopUpdate =
"<font >Web打印服务CLodop需升级!点击这里<a href='CLodop_Setup_for_Win32NT.exe' target='_self'>执行升级</a>"
var strLodop7FontTag = '<font >Web打印服务Lodop7'
var strLodop7HrefX86 =
"点击这里<a href='http://www.lodop.net/download/Lodop7.043_Linux_X86_64_CN.tar.gz' target='_self'>下载安装</a>(下载后解压,点击lodop文件开始执行)"
var strLodop7HrefARM =
"点击这里<a href='http://www.lodop.net/download/Lodop7.043_Linux_ARM64_CN.tar.gz' target='_self'>下载安装</a>(下载后解压,点击lodop文件开始执行)"
var strLodop7Install_X86 =
strLodop7FontTag + '未安装启动,' + strLodop7HrefX86
var strLodop7Install_ARM =
strLodop7FontTag + '未安装启动,' + strLodop7HrefARM
var strLodop7Update_X86 = strLodop7FontTag + '需升级,' + strLodop7HrefX86
var strLodop7Update_ARM = strLodop7FontTag + '需升级,' + strLodop7HrefARM
var strInstallOK = ',成功后请刷新本页面或重启浏览器。</font>'
var LODOP
try {
var isWinIE =
/MSIE/i.test(navigator.userAgent) || /Trident/i.test(navigator.userAgent)
var isWinIE64 = isWinIE && /x64/i.test(navigator.userAgent)
var isLinuxX86 =
/Linux/i.test(navigator.platform) && /x86/i.test(navigator.platform)
var isLinuxARM =
/Linux/i.test(navigator.platform) && /aarch/i.test(navigator.platform)
if (needCLodop() || isLinuxX86 || isLinuxARM) {
try {
LODOP = window.getCLodop()
} catch (err) {
console.log(err);
}
if (!LODOP && CLodopJsState !== 'complete') {
if (CLodopJsState == 'loading')
alert('网页还没下载完毕,请稍等一下再操作.')
else alert('未曾加载Lodop主JS文件,请先调用loadCLodop过程.')
return
}
var strAlertMessage
if (!LODOP) {
if (isLinuxX86) strAlertMessage = strLodop7Install_X86
else if (isLinuxARM) strAlertMessage = strLodop7Install_ARM
else
strAlertMessage =
strCLodopInstallA + (CLodopIsLocal ? strCLodopInstallB : '')
showMsg(strAlertMessage + strInstallOK)
// document.body.innerHTML =
// strAlertMessage + strInstallOK + document.body.innerHTML
return
} else {
if (isLinuxX86 && LODOP.CVERSION < '7.0.4.3')
strAlertMessage = strLodop7Update_X86
else if (isLinuxARM && LODOP.CVERSION < '7.0.4.3')
strAlertMessage = strLodop7Update_ARM
else if (window.CLODOP.CVERSION < '4.1.6.1') strAlertMessage = strCLodopUpdate
if (strAlertMessage) showMsg(strAlertMessage + strInstallOK)
// document.body.innerHTML =
// strAlertMessage + strInstallOK + document.body.innerHTML
}
} else {
//==如果页面有Lodop插件就直接使用,否则新建:==
if (oOBJECT || oEMBED) {
if (isWinIE) LODOP = oOBJECT
else LODOP = oEMBED
} else if (!CreatedOKLodopObject) {
LODOP = document.createElement('object')
LODOP.setAttribute('width', 0)
LODOP.setAttribute('height', 0)
LODOP.setAttribute(
'style',
'position:absolute;left:0px;top:-100px;width:0px;height:0px;'
)
if (isWinIE)
LODOP.setAttribute(
'classid',
'clsid:2105C259-1E0C-4534-8141-A753534CB4CA'
)
else LODOP.setAttribute('type', 'application/x-print-lodop')
document.documentElement.appendChild(LODOP)
CreatedOKLodopObject = LODOP
} else LODOP = CreatedOKLodopObject
//==Lodop插件未安装时提示下载地址:==
if (!LODOP || !LODOP.VERSION) {
showMsg(
(isWinIE64 ? strLodop64Install : strLodopInstall) + strInstallOK
)
// document.body.innerHTML =
// (isWinIE64 ? strLodop64Install : strLodopInstall) +
// strInstallOK +
// document.body.innerHTML
return LODOP
}
if (LODOP.VERSION < '6.2.2.6') {
showMsg((isWinIE64 ? strLodop64Update : strLodopUpdate) + strInstallOK)
// document.body.innerHTML =
// (isWinIE64 ? strLodop64Update : strLodopUpdate) +
// strInstallOK +
// document.body.innerHTML
}
}
//===如下空白位置适合调用统一功能(如注册语句、语言选择等):=======================
LODOP.SET_LICENSES('', 'A9F23BF819622E36A8775E717685989E9FC', '', '')
//===============================================================================
return LODOP
} catch (err) {
alert('getLodop出错:' + err)
}
}
/*
* @Description: 描述
* @Author: chd
* @Date: 2021-01-18 13:49:02
* @LastEditors: chd
* @LastEditTime: 2021-04-27 21:40:51
*/
import { get, post } from './axios'
/**
* 品牌
* @param {Object} options
* @param {String} options.brandName
* @param {Number} options.categoryId
* @param {Number} options.styleId
* @returns Promise
*/
export const getBrandList = (options = {}) => post('brandWebsite/list', options)
/**
* 公告
* @returns Promise
*/
export const getBulletin = () => get('home/announcements')
/**
* 字典
* @param {String} code
* @returns Promise
*/
export const getDictionary = (code) =>
get('baseDictData/findDictByCode/' + code)
/**
* 字典
* @param {String} cateCode
* @returns Promise
*/
export const getDictByCateCode = (cateCode) =>
get('baseDictData/findDictByCateCode/' + cateCode)
/**
* 表格展示项
* @param {String} name
* @returns Promise
*/
export const getColumn = (name) =>
get('sysLogin/getColumn', {
reqMenu: name,
})
/**
* 保存表格展示项
* @param {String} path
* @param {Object} data
* @returns Promise
*/
export const saveColumns = (path, data) =>
post('sysUserDisplayOption/save', {
displayOption: JSON.stringify(data),
pageName: path,
})
/**
* 删除表格展示项
* @param {String} path
* @returns Promise
*/
export const removeColumns = (path) =>
post('sysUserDisplayOption/delete', {
pageName: path,
})
/**
* 有权限的表格展示项
* @param {String} type
* @returns Promise
*/
export const getSysColumn = (type) => get('sysDataRole/findRoleColumns/' + type)
/**
* 获取平台
* @returns Promise
*/
export const getplatform = () => get('global/platform')
/**
* 获取包装规格
* @returns Promise
*/
export const getPackingSpecification = () => get('basePackingSpec/all_list')
//
/**
* 员工列表
* @returns Promise
*/
export const employeeList = () =>
new Promise((resolve, reject) => {
get('employee/userInServiceOption')
.then((res) => {
let data = res.data
for (const iterator of data) {
let name = iterator.name
iterator.name = iterator.enName
iterator.enName = name
}
resolve({ data })
})
.catch(reject)
})
/**
* 获取部门职员
* @returns Promise
*/
export const getDepartmentStaff = () =>
new Promise((resolve, reject) => {
get('dept/allDeptAndEmp')
.then((res) => {
let arr = []
for (const iterator of res.data) {
let item = arr.find(
(val) => val.value === 'deptId_' + iterator.deptId
)
if (item) {
item.children.push({
label: iterator.empName,
value: iterator.empId,
qyvxId: iterator.qyvxId,
avatar: iterator.avatar,
mobile: iterator.mobile,
})
} else {
arr.push({
value: 'deptId_' + iterator.deptId,
label: iterator.deptName,
children: [
{
label: iterator.empName,
value: iterator.empId,
qyvxId: iterator.qyvxId,
avatar: iterator.avatar,
mobile: iterator.mobile,
},
],
})
}
}
resolve({ data: arr })
})
.catch(reject)
})
// 国家列表
const countryList = () => get('baseCountryCode/all_list')
// 币种列表
const currencyList = () => get('baseExchangeRateCur/getCurAll')
// 仓库列表
const warehouseList = () => get('warehouseInfo/can_use')
// 物流公司列表
const logisticsList = () => get('logisticsCompany/all_options')
// 可用物流公司列表
export const canlogisticsList = (companyCode) =>
get('logisticsCompany/can_use', { companyCode })
// 物流方式列表
const logisticsModeList = () => get('logisticsWay/usableAllList')
// 站点列表
export const notRoleShopifyStores = () => get('shopifyShopInfo/shop_list')
// 加权站点列表
const storeListList = () => get('shopifyShopInfo/shop_options')
/**
* 平台筛选站点列表
* @param {Object} params
* @param params.platform {string} - 平台
* @param params.adChannels {string} - 投放渠道
* @returns Promise
*/
export const getPlatformStore = (params) => {
params = params || {}
if (typeof params !== 'object') {
params = { platform: params }
}
return get('shopifyShopInfo/role_shop_list', params)
}
/**
* 站点负责人
* @param {String} platform 平台
* @returns Promise
*/
export const siteOwner = (platform) =>
get('shopifyShopInfo/shops_leader', { platform })
/**
* 采购渠道
* @returns Promise
*/
const purchaseChannelsList = () =>
get('baseDictData/findDictByCode/supply_channel')
/**
* 商品分类
* @returns Promise
*/
const categories = () => get('baseCategoryInfo/tree_list_option')
//
/**
* 商品风格
* @param {Number} cateId 分类ID
* @returns Promise
*/
export const getStyleList = (cateId) =>
get('baseStyleInfo/listByCateId', {
cateId,
})
/**
* 获取供应商
* @returns Promise
*/
const supplierList = () => get('supplySupplier/getSupplierByPermission')
/**
* 打印模板
* @param {*} types 模板类型
* @returns Promise
*/
export const printTemplate = (types) =>
new Promise((resolve, reject) => {
post('printTemplate/list_page', {
currentPage: 1,
pageSize: 100,
typeList: types ? types.split(',') : [],
})
.then((res) => resolve({ ...res, data: res.data.records }))
.catch(reject)
})
/**
* 自定义标签
* @param {*} type 标签类型
* @returns Promise
*/
export const customTagList = (type) =>
get(`baseCustomTag/findListByType/${type}`)
export function get_options(name) {
if (name === 'country') {
return countryList()
}
if (name === 'currency') {
return currencyList()
}
if (name === 'warehouse') {
return warehouseList()
}
if (name === 'logistics') {
return logisticsList()
}
if (name === 'logisticsMode') {
return logisticsModeList()
}
if (name === 'employee') {
return employeeList()
}
if (name === 'canlogistics') {
return canlogisticsList()
}
if (name === 'storeList') {
return storeListList()
}
if (name === 'purchaseChannels') {
return purchaseChannelsList()
}
if (name === 'productCategory') {
return categories()
}
if (name === 'supplierList') {
return supplierList()
}
if (name === 'printOptions') {
return printTemplate()
}
}
/**
* 上传图片
* @param {*} params
* @param {String} params.filePath - 文件存储文件夹
* @param {object} ...other
* @returns Promise
*/
export function upload_img(file, params = {}) {
let from = new FormData()
from.append('file', file)
for (const key in params) {
from.append(key, params[key])
}
return post(`upload/fileUpload/images`, from, {
headers: { 'content-type': 'multipart/form-data' },
})
}
export function upload_other_file(params) {
const { url, name, file, ...other } = params
let from = new FormData()
for (const key in other) {
from.append(key, other[key])
}
from.append(name, file)
return post(url, from, {
headers: { 'content-type': 'multipart/form-data' },
})
}
import Vue from 'vue' import Vue from 'vue'
import axios from 'axios' import axios from 'axios'
//import QS from 'qs';
import router from '../router' import router from '../router'
import CancelToken from './cancelToken' import CancelToken from './cancelToken'
function getApi() { function getApi() {
......
/* eslint-disable */
/* Blob.js
* A Blob implementation.
* 2014-05-27
*
* By Eli Grey, http://eligrey.com
* By Devin Samarin, https://github.com/eboyjr
* License: X11/MIT
* See LICENSE.md
*/
/*global self, unescape */
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
plusplus: true */
/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
const blob = function (view) {
'use strict'
view.URL = view.URL || view.webkitURL
if (view.Blob && view.URL) {
try {
new Blob()
return
} catch (e) {}
}
// Internally we use a BlobBuilder implementation to base Blob off of
// in order to support older browsers that only have BlobBuilder
var BlobBuilder =
view.BlobBuilder ||
view.WebKitBlobBuilder ||
view.MozBlobBuilder ||
(function (view) {
var get_class = function (object) {
return Object.prototype.toString
.call(object)
.match(/^\[object\s(.*)\]$/)[1]
},
FakeBlobBuilder = function BlobBuilder() {
this.data = []
},
FakeBlob = function Blob(data, type, encoding) {
this.data = data
this.size = data.length
this.type = type
this.encoding = encoding
},
FBB_proto = FakeBlobBuilder.prototype,
FB_proto = FakeBlob.prototype,
FileReaderSync = view.FileReaderSync,
FileException = function (type) {
this.code = this[(this.name = type)]
},
file_ex_codes = (
'NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR ' +
'NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR'
).split(' '),
file_ex_code = file_ex_codes.length,
real_URL = view.URL || view.webkitURL || view,
real_create_object_URL = real_URL.createObjectURL,
real_revoke_object_URL = real_URL.revokeObjectURL,
URL = real_URL,
btoa = view.btoa,
atob = view.atob,
ArrayBuffer = view.ArrayBuffer,
Uint8Array = view.Uint8Array
FakeBlob.fake = FB_proto.fake = true
while (file_ex_code--) {
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1
}
if (!real_URL.createObjectURL) {
URL = view.URL = {}
}
URL.createObjectURL = function (blob) {
var type = blob.type,
data_URI_header
if (type === null) {
type = 'application/octet-stream'
}
if (blob instanceof FakeBlob) {
data_URI_header = 'data:' + type
if (blob.encoding === 'base64') {
return data_URI_header + ';base64,' + blob.data
} else if (blob.encoding === 'URI') {
return data_URI_header + ',' + decodeURIComponent(blob.data)
}
if (btoa) {
return data_URI_header + ';base64,' + btoa(blob.data)
} else {
return data_URI_header + ',' + encodeURIComponent(blob.data)
}
} else if (real_create_object_URL) {
return real_create_object_URL.call(real_URL, blob)
}
}
URL.revokeObjectURL = function (object_URL) {
if (object_URL.substring(0, 5) !== 'data:' && real_revoke_object_URL) {
real_revoke_object_URL.call(real_URL, object_URL)
}
}
FBB_proto.append = function (data /*, endings*/) {
var bb = this.data
// decode data to a binary string
if (
Uint8Array &&
(data instanceof ArrayBuffer || data instanceof Uint8Array)
) {
var str = '',
buf = new Uint8Array(data),
i = 0,
buf_len = buf.length
for (; i < buf_len; i++) {
str += String.fromCharCode(buf[i])
}
bb.push(str)
} else if (get_class(data) === 'Blob' || get_class(data) === 'File') {
if (FileReaderSync) {
var fr = new FileReaderSync()
bb.push(fr.readAsBinaryString(data))
} else {
// async FileReader won't work as BlobBuilder is sync
throw new FileException('NOT_READABLE_ERR')
}
} else if (data instanceof FakeBlob) {
if (data.encoding === 'base64' && atob) {
bb.push(atob(data.data))
} else if (data.encoding === 'URI') {
bb.push(decodeURIComponent(data.data))
} else if (data.encoding === 'raw') {
bb.push(data.data)
}
} else {
if (typeof data !== 'string') {
data += '' // convert unsupported types to strings
}
// decode UTF-16 to binary string
bb.push(unescape(encodeURIComponent(data)))
}
}
FBB_proto.getBlob = function (type) {
if (!arguments.length) {
type = null
}
return new FakeBlob(this.data.join(''), type, 'raw')
}
FBB_proto.toString = function () {
return '[object BlobBuilder]'
}
FB_proto.slice = function (start, end, type) {
var args = arguments.length
if (args < 3) {
type = null
}
return new FakeBlob(
this.data.slice(start, args > 1 ? end : this.data.length),
type,
this.encoding
)
}
FB_proto.toString = function () {
return '[object Blob]'
}
FB_proto.close = function () {
this.size = this.data.length = 0
}
return FakeBlobBuilder
})(view)
view.Blob = function Blob(blobParts, options) {
var type = options ? options.type || '' : ''
var builder = new BlobBuilder()
if (blobParts) {
for (var i = 0, len = blobParts.length; i < len; i++) {
builder.append(blobParts[i])
}
}
return builder.getBlob(type)
}
}
exports.blob = blob
/* eslint-disable */
import 'file-saver'
// require('script-loader!./Blob');
// import Blob from './blob'
import * as XLSX from 'xlsx'
function generateArray(table) {
var out = []
var rows = table.querySelectorAll('tr')
var ranges = []
for (var R = 0; R < rows.length; ++R) {
var outRow = []
var row = rows[R]
var columns = row.querySelectorAll('td')
for (var C = 0; C < columns.length; ++C) {
var cell = columns[C]
var colspan = cell.getAttribute('colspan')
var rowspan = cell.getAttribute('rowspan')
var cellValue = cell.innerText
if (cellValue !== '' && cellValue == +cellValue) cellValue = +cellValue
//Skip ranges
ranges.forEach(function (range) {
if (
R >= range.s.r &&
R <= range.e.r &&
outRow.length >= range.s.c &&
outRow.length <= range.e.c
) {
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null)
}
})
//Handle Row Span
if (rowspan || colspan) {
rowspan = rowspan || 1
colspan = colspan || 1
ranges.push({
s: { r: R, c: outRow.length },
e: { r: R + rowspan - 1, c: outRow.length + colspan - 1 },
})
}
//Handle Value
outRow.push(cellValue !== '' ? cellValue : null)
//Handle Colspan
if (colspan) for (var k = 0; k < colspan - 1; ++k) outRow.push(null)
}
out.push(outRow)
}
return [out, ranges]
}
function datenum(v, date1904) {
if (date1904) v += 1462
var epoch = Date.parse(v)
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000)
}
function sheet_from_array_of_arrays(data, opts) {
var ws = {}
var range = { s: { c: 10000000, r: 10000000 }, e: { c: 0, r: 0 } }
for (var R = 0; R != data.length; ++R) {
for (var C = 0; C != data[R].length; ++C) {
if (range.s.r > R) range.s.r = R
if (range.s.c > C) range.s.c = C
if (range.e.r < R) range.e.r = R
if (range.e.c < C) range.e.c = C
var cell = { v: data[R][C] }
if (cell.v == null) continue
var cell_ref = XLSX.utils.encode_cell({ c: C, r: R })
if (typeof cell.v === 'number') cell.t = 'n'
else if (typeof cell.v === 'boolean') cell.t = 'b'
else if (cell.v instanceof Date) {
cell.t = 'n'
cell.z = XLSX.SSF._table[14]
cell.v = datenum(cell.v)
} else cell.t = 's'
ws[cell_ref] = cell
}
}
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range)
return ws
}
function Workbook() {
if (!(this instanceof Workbook)) return new Workbook()
this.SheetNames = []
this.Sheets = {}
}
function s2ab(s) {
var buf = new ArrayBuffer(s.length)
var view = new Uint8Array(buf)
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xff
return buf
}
export function export_table_to_excel(id) {
var theTable = document.getElementById(id)
console.log('a')
var oo = generateArray(theTable)
var ranges = oo[1]
/* original data */
var data = oo[0]
var ws_name = 'SheetJS'
var wb = new Workbook(),
ws = sheet_from_array_of_arrays(data)
/* add ranges to worksheet */
// ws['!cols'] = ['apple', 'banan'];
ws['!merges'] = ranges
/* add worksheet to workbook */
wb.SheetNames.push(ws_name)
wb.Sheets[ws_name] = ws
var wbout = XLSX.write(wb, {
bookType: 'xlsx',
bookSST: false,
type: 'binary',
})
saveAs(
new Blob([s2ab(wbout)], { type: 'application/octet-stream' }),
'test.xlsx'
)
}
function formatJson(jsonData) {
console.log(jsonData)
}
export function export_json_to_excel(th, jsonData, defaultTitle) {
/* original data */
var data = jsonData
data.unshift(th)
var ws_name = 'SheetJS'
var wb = new Workbook(),
ws = sheet_from_array_of_arrays(data)
/* add worksheet to workbook */
wb.SheetNames.push(ws_name)
wb.Sheets[ws_name] = ws
var wbout = XLSX.write(wb, {
bookType: 'xlsx',
bookSST: false,
type: 'binary',
})
var title = defaultTitle || '列表'
saveAs(
new Blob([s2ab(wbout)], { type: 'application/octet-stream' }),
title + '.xlsx'
)
}
export function read_excel(callback, options) {
let obj = {
raw: false,
defval: '',
}
for (const key in options) {
obj[key] = options[key]
}
let input = document.createElement('input')
input.style.display = 'none'
input.type = 'file'
input.onchange = function () {
let files = this.files[0]
console.log(files)
let fileReader = new FileReader()
fileReader.onload = function (ev) {
console.log(ev, 'ev')
let workbook,
persons = {} // 存储获取到的数据
try {
let data = ev.target.result
workbook = XLSX.read(data, {
type: 'binary',
// dateNF:'14**'
cellDates: true,
}) // 以二进制流方式读取得到整份excel表格对象
} catch (e) {
console.log('文件类型不正确')
return
}
// 表格的表格范围,可用于判断表头是否数量是否正确
var fromTo = ''
// 遍历每张表读取
for (var sheet in workbook.Sheets) {
if (workbook.Sheets.hasOwnProperty(sheet)) {
fromTo = workbook.Sheets[sheet]['!ref']
console.log(fromTo)
if (obj.range) {
obj.range = fromTo.replace('A1', 'A' + obj.range)
}
console.log(obj)
persons[sheet] = XLSX.utils.sheet_to_json(workbook.Sheets[sheet], obj)
// break; // 如果只取第一张表,就取消注释这行
}
}
console.log(persons)
callback && callback(persons)
}
// 以二进制方式打开文件
fileReader.readAsBinaryString(files)
}
input.click()
}
/*
* @Description: 描述
* @Author: chd
* @Date: 2021-04-27 20:55:41
* @LastEditors: chd
* @LastEditTime: 2021-06-10 18:14:18
*/
import axios from 'axios'
import Vue from 'vue'
import router from '../router'
const baseURL = window.apiHostSetting.VUE_APP_API_URL
let httpNum = 0
const instance = axios.create({
baseURL: baseURL + 'api/',
timeout: 5 * 60 * 1000,
// headers: {
// "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
// },
validateStatus: (status) => status >= 200 && status < 500, // 默认的
})
instance.interceptors.request.use(
(config) => {
httpNum++
let usertoken = localStorage.getItem('token')
if (usertoken) {
config.headers['jwt-token'] = usertoken
}
return config
},
(error) => {
return Promise.reject(error)
}
)
// 响应拦截器
instance.interceptors.response.use(
(res) => {
httpNum--
if (res.status === 200) {
if (res.data.code === 401) {
// token过期
if (httpNum === 0) {
Vue.prototype.$message({
type: 'error',
message: res.data.message,
})
sessionStorage.setItem('active', 'true')
router
.replace({
name: 'login',
})
.catch((err) => {
console.log(err)
})
}
return Promise.reject(res.data)
} else if (res.data.code === 402) {
Vue.prototype.$message({ message: res.data.message, type: 'warning' })
return Promise.reject(res.data)
} else if (res.data.code === 500) {
Vue.prototype.$alert(
'<div style="max-height:500px;overflow:auto">' +
res.data.message +
'</div>',
'错误提示',
{
dangerouslyUseHTMLString: true,
}
)
return Promise.reject(res.data)
} else {
return Promise.resolve(res)
}
} else {
switch (res.status) {
case 400:
Vue.prototype.$alert('请求参数有误', '提示', {
confirmButtonText: '确定',
callback: () => {},
})
break
case 404:
Vue.prototype.$alert('请求不存在', '提示', {
confirmButtonText: '确定',
callback: () => {},
})
break
default:
break
}
return Promise.reject(res)
}
},
// 服务器状态码不是200的情况
(error) => {
httpNum--
if (httpNum == 0) {
Vue.prototype.$alert(error.message, {
confirmButtonText: '确定',
callback: () => {},
})
}
return Promise.reject(error)
}
)
export function get(url, params) {
return new Promise((resolve, reject) => {
instance
.get(url, { params })
.then((res) => {
if (res.status === 200 && res.data) {
resolve(res.data)
} else {
resolve(res)
}
})
.catch((err) => {
reject(err)
})
})
}
export function post(url, params, headers) {
return new Promise((resolve, reject) => {
instance
.post(url, params, headers)
.then((res) => {
if (res.status === 200 && res.data) {
resolve(res.data)
} else {
resolve(res)
}
})
.catch((err) => {
reject(err)
})
})
}
export default { get, post }
import store from '../store'
const defaultFunc = () => {}
const Im = {
socket: null,
init(msgfunc = defaultFunc, openfunc = defaultFunc, options) {
// let vm = this;
if (window.WebSocket) {
let url = options?.url || 'ws://192.168.1.114:8001'
this.socket = new WebSocket(url)
let socket = this.socket
socket.onopen = () => {
console.log('服务器连接成功')
openfunc && openfunc()
}
socket.onclose = () => {
console.log('服务器关闭')
this.socket = null
}
socket.onerror = () => {
console.log('连接出错')
this.socket = null
}
// 接收服务器的消息
socket.onmessage = (res) => {
if (typeof res.data === 'string') {
msgfunc && msgfunc(res.data)
} else {
let message = JSON.parse(res.data)
if (message.users) {
store.dispatch('setUsersStatus', message.users)
return
}
if (message.groups) {
// this.groups = message.groups;
store.dispatch('setGroups', message.groups)
}
// 判断当前聊天对话框是否是消息所对应的用户 添加消息提示
if (message.bridge) {
let { uid, sessionList, activeIndex } = store.state.im
let otheruid = message.bridge.find((v) => v !== uid)
if (otheruid && sessionList[activeIndex].uid !== otheruid) {
store.dispatch('setUnread', { otheruid, unread: true })
}
}
msgfunc && msgfunc(message)
}
}
}
},
send(options) {
if (this.socket) {
this.socket.send(JSON.stringify(options))
}
},
}
export default Im
export default class Lock {
constructor() {
this.isLock = false
}
lock() {
this.isLock = true
}
unlock() {
this.isLock = false
}
}
\ No newline at end of file
/**
* 语音播报
*/
import { get } from './axios'
const synth = window.speechSynthesis
const speech = new SpeechSynthesisUtterance()
let isLocalServe
setTimeout(() => {
let voices = speechSynthesis.getVoices()
console.log(voices)
isLocalServe = voices.some(
(item) => item.lang == 'zh-CN' && item.localService
)
if (isLocalServe) {
speech.pitch = 2 // 获取并设置话语的音调(值越大越尖锐,越低越低沉)
speech.rate = 3 // 获取并设置说话的速度(值越大语速越快,越小语速越慢)
// speech.voice = 10 // 获取并设置说话的声音
speech.volume = 1 // 获取并设置说话的音量
speech.lang = 'zh-CN' // 设置播放语言,测试没效果
}
}, 0)
let token = ''
let expireTime = sessionStorage.getItem('aliYunTokenExpireTime')
if (
expireTime &&
new Date().getTime() < new Date(Number(expireTime)).getTime()
) {
token = sessionStorage.getItem('aliYunToken')
} else {
get('home/getAliYunToken', {}).then((res) => {
console.log(res)
if (res.message) {
token = res.data.token
let expireTime = res.data.expireTime
sessionStorage.setItem('aliYunTokenExpireTime', expireTime * 1000)
sessionStorage.setItem('aliYunToken', token)
}
})
}
export function speak(text) {
if (isLocalServe) {
console.log('isLocalServe')
speech.text = text
synth.speak(speech)
} else {
console.log('Audio')
try {
new Audio(
`https://nls-gateway-cn-shanghai.aliyuncs.com/stream/v1/tts?speech_rate=300&appkey=B4PZmmipkz4wPqnT&token=${token}&text=${text}&format=mp3&sample_rate=16000`
).play()
} catch (error) {
console.log(error)
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* 可自定义表格展示项字段变更 添加变更页面 route.name
*
*/
export default ['']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment