2023-09-20 21:33:11 +08:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
import app from './modules/app'
|
|
|
|
import settings from './modules/settings'
|
|
|
|
import user from './modules/user'
|
|
|
|
import api from '@/utils/api'
|
|
|
|
import { Message, MessageBox } from 'element-ui'
|
|
|
|
|
|
|
|
Vue.use(Vuex)
|
|
|
|
|
|
|
|
const store = new Vuex.Store({
|
|
|
|
state: {
|
2023-10-18 15:58:44 +08:00
|
|
|
shopList: [], // 商铺列表
|
2023-09-20 21:33:11 +08:00
|
|
|
adminList: [], // 管理员列表
|
|
|
|
airList: [], // 所有飞机列表
|
|
|
|
siteList: [], // 站点列表
|
|
|
|
routeList: [], // 航线列表
|
2023-10-18 15:58:44 +08:00
|
|
|
categoryList: [], // 分类列表(小程序)
|
2023-11-03 20:57:12 +08:00
|
|
|
spuList: [], // 商品spu列表
|
|
|
|
skuList: [], // 商品sku列表
|
2023-11-07 13:28:53 +08:00
|
|
|
orderList: [], // 订单列表
|
2023-09-20 21:33:11 +08:00
|
|
|
logList: [], // 操作日志列表
|
|
|
|
crosFrequency: null // 对频macadd
|
|
|
|
},
|
|
|
|
mutations: {
|
2023-10-18 15:58:44 +08:00
|
|
|
/**
|
|
|
|
* @description: 设置商铺列表
|
|
|
|
*/
|
|
|
|
setShopList (state, list) {
|
|
|
|
state.shopList = list
|
|
|
|
},
|
2023-09-20 21:33:11 +08:00
|
|
|
/**
|
|
|
|
* @description: 设置管理员列表
|
|
|
|
*/
|
|
|
|
setAdminList (state, list) {
|
|
|
|
state.adminList = list
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 设置飞机列表
|
|
|
|
*/
|
|
|
|
setAirList (state, list) {
|
|
|
|
state.airList = list
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 设置站点列表
|
|
|
|
*/
|
|
|
|
setSiteList (state, list) {
|
|
|
|
state.siteList = list
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 设置航线列表
|
|
|
|
*/
|
|
|
|
setRouteList (state, list) {
|
|
|
|
state.routeList = list
|
|
|
|
},
|
2023-10-18 15:58:44 +08:00
|
|
|
/**
|
|
|
|
* @description: 设置分类列表
|
|
|
|
*/
|
|
|
|
setCategoryList (state, list) {
|
|
|
|
state.categoryList = list
|
|
|
|
},
|
|
|
|
/**
|
2023-11-03 20:57:12 +08:00
|
|
|
* @description: 设置商品spu列表
|
2023-10-18 15:58:44 +08:00
|
|
|
*/
|
2023-11-03 20:57:12 +08:00
|
|
|
setSpuList (state, list) {
|
|
|
|
state.spuList = list
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 设置商品sku列表
|
|
|
|
*/
|
|
|
|
setSkuList (state, list) {
|
|
|
|
state.skuList = list
|
2023-10-18 15:58:44 +08:00
|
|
|
},
|
2023-09-20 21:33:11 +08:00
|
|
|
/**
|
|
|
|
* @description: 设置订单列表
|
|
|
|
*/
|
2023-11-07 13:28:53 +08:00
|
|
|
setOrderList (state, list) {
|
|
|
|
state.orderList = list
|
2023-09-20 21:33:11 +08:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 向操作日志列表最后插入新的信息
|
|
|
|
* @param {*} logData
|
|
|
|
*/
|
|
|
|
insertNewLog (state, logData) {
|
|
|
|
state.logList.push(logData)
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 登记对频信息
|
|
|
|
*/
|
|
|
|
setCrosFrequency (state, macAdd) {
|
|
|
|
state.crosFrequency = macAdd
|
|
|
|
}
|
|
|
|
},
|
|
|
|
actions: {
|
2023-10-18 15:58:44 +08:00
|
|
|
/**
|
|
|
|
* @description: 获取商铺列表
|
|
|
|
*/
|
|
|
|
async fetchShopList ({ commit }) {
|
|
|
|
const res = await api.get('getShopList', 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
commit('setShopList', res.data.shopList)
|
|
|
|
} else {
|
2023-11-06 18:01:40 +08:00
|
|
|
commit('setShopList', [])
|
2023-10-18 15:58:44 +08:00
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 添加商铺
|
|
|
|
* @param {*} 商铺信息表单
|
|
|
|
* @return {*} 服务器返回值
|
|
|
|
*/
|
|
|
|
async fetchAddShop ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('waiter', form.waiter)
|
|
|
|
params.append('service_wx', form.service_wx)
|
|
|
|
params.append('tel', form.tel)
|
|
|
|
params.append('email', form.email)
|
|
|
|
params.append('price_min', form.price_min)
|
|
|
|
params.append('weight_max', form.weight_max)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
params.append('opening_time', form.opening_time)
|
|
|
|
params.append('closeing_time', form.closeing_time)
|
|
|
|
const res = await api.post('addShop', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchShopList')// 刷新商铺列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 更新管商铺信息
|
|
|
|
* @param {*} 商铺信息表单
|
|
|
|
* @return {*} 服务器返回值
|
|
|
|
*/
|
|
|
|
async fetchSaveShop ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('waiter', form.waiter)
|
|
|
|
params.append('service_wx', form.service_wx)
|
|
|
|
params.append('tel', form.tel)
|
|
|
|
params.append('email', form.email)
|
|
|
|
params.append('price_min', form.price_min)
|
|
|
|
params.append('weight_max', form.weight_max)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
params.append('oldFile', form.oldFile)
|
|
|
|
params.append('opening_time', form.opening_time)
|
|
|
|
params.append('closeing_time', form.closeing_time)
|
|
|
|
const res = await api.post('saveShop', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchShopList')// 刷新商铺列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
2023-09-20 21:33:11 +08:00
|
|
|
/**
|
|
|
|
* @description: 获取管理员列表
|
|
|
|
*/
|
|
|
|
async fetchAdminList ({ commit }) {
|
2023-10-18 15:58:44 +08:00
|
|
|
const res = await api.get('getAdminList', 'Admin')
|
2023-09-20 21:33:11 +08:00
|
|
|
if (res.data.status === 1) {
|
2023-10-18 15:58:44 +08:00
|
|
|
res.data.adminList.forEach(item => { // 判断如果是当前登录用户 最后登录时间字段 从本地缓存中获取 PS:既登陆前缓存到本地的“最后登陆时间” 因为登录后 服务端会把当前登录的时间刷到lasttime字段
|
|
|
|
if (item.shop_id === store.state.user.shop_id) {
|
|
|
|
item.lasttime = store.state.user.lasttime
|
|
|
|
}
|
|
|
|
})
|
2023-09-20 21:33:11 +08:00
|
|
|
commit('setAdminList', res.data.adminList)
|
|
|
|
} else {
|
2023-11-06 18:01:40 +08:00
|
|
|
commit('setAdminList', [])
|
2023-09-20 21:33:11 +08:00
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
},
|
2023-10-18 15:58:44 +08:00
|
|
|
/**
|
|
|
|
* @description: 添加新的管理员
|
|
|
|
* @param {*} 管理员信息表单
|
|
|
|
* @return {*} 服务器返回值
|
|
|
|
*/
|
|
|
|
async fetchAddAdmin ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('uname', form.uname)
|
|
|
|
params.append('pwd', form.pwd)
|
|
|
|
params.append('shop_id', form.shop_id)
|
2023-11-03 20:57:12 +08:00
|
|
|
params.append('upFile', form.upFile)
|
2023-10-18 15:58:44 +08:00
|
|
|
const res = await api.post('addAdmin', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchAdminList')// 刷新用户列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 更新管理员账号信息
|
|
|
|
* @param {*} 管理员信息表单
|
|
|
|
* @return {*} 服务器返回值
|
|
|
|
*/
|
|
|
|
async fetchSaveAdmin ({ dispatch }, form) {
|
|
|
|
console.log(form)
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('uname', form.uname)
|
|
|
|
params.append('pwd', form.pwd)
|
2023-11-03 20:57:12 +08:00
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
params.append('oldFile', form.oldFile)
|
2023-10-18 15:58:44 +08:00
|
|
|
const res = await api.post('saveAdmin', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchAdminList')// 刷新用户列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 删除账号
|
|
|
|
* @param {*} 多选id组
|
|
|
|
*/
|
|
|
|
async fetchDelAdmin ({ dispatch }, idArr) {
|
|
|
|
if (idArr.length === 0) {
|
|
|
|
Message.error('未勾选记录')
|
|
|
|
} else {
|
|
|
|
MessageBox.confirm('请谨慎操作 确认删除?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('idArr', idArr)
|
|
|
|
api.post('deleteAdmin', params, 'Admin').then(res => {
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
dispatch('fetchAdminList')// 刷新管理员列表
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
Message.info('取消操作')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2023-09-20 21:33:11 +08:00
|
|
|
/**
|
|
|
|
* @description: 获取飞机列表
|
|
|
|
*/
|
|
|
|
async fetchAirList ({ commit, state }) {
|
|
|
|
const res = await api.get('getAirList')
|
|
|
|
res.data.airList.forEach(plane => {
|
|
|
|
plane.planeState = { // 飞机状态初始化字段
|
|
|
|
heartBeat: null, // 心跳
|
|
|
|
heartRandom: null, // 每次接收到心跳创建一个随机数 用于watch监听
|
|
|
|
voltagBattery: null, // 电压信息
|
|
|
|
currentBattery: null, // 电流信息
|
|
|
|
batteryRemaining: null, // 电池电量
|
|
|
|
positionAlt: null, // 高度信息
|
|
|
|
groundSpeed: null, // 对地速度
|
|
|
|
satCount: null, // 卫星数量
|
|
|
|
latitude: null, // 纬度
|
|
|
|
longitude: null, // 经度
|
|
|
|
fixType: null, // 定位状态
|
|
|
|
state: 1, // 飞机状态 默认初始状态为1
|
|
|
|
pingNet: null, // 网速测试
|
|
|
|
getPlaneMode: null, // 飞机模式
|
|
|
|
loadweight: null, // 重量
|
|
|
|
hookstatus: null, // 钩子状态
|
|
|
|
position: []// [[经度,维度,海拔高度]]累计数组
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
commit('setAirList', res.data.airList)
|
|
|
|
} else {
|
2023-11-06 18:01:40 +08:00
|
|
|
commit('setAirList', [])
|
2023-09-20 21:33:11 +08:00
|
|
|
Message.warning(res.data.msg)
|
|
|
|
}
|
|
|
|
return res.data.airList
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 创建新飞机
|
|
|
|
* @param {*} form 表单.飞机信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchAddAir ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('date', form.date)
|
2023-10-18 15:58:44 +08:00
|
|
|
if (form.onoff) {
|
|
|
|
params.append('onoff', '1')
|
2023-09-20 21:33:11 +08:00
|
|
|
} else {
|
2023-10-18 15:58:44 +08:00
|
|
|
params.append('onoff', '0')
|
2023-09-20 21:33:11 +08:00
|
|
|
}
|
2023-11-07 14:55:56 +08:00
|
|
|
params.append('weight_max', form.weight_max)
|
2023-09-20 21:33:11 +08:00
|
|
|
params.append('desc', form.desc)
|
|
|
|
const res = await api.post('addAir', params)
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchAirList')// 刷新飞机列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 更新新飞机数据
|
|
|
|
* @param {*} form 表单.飞机信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchSaveAir ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('date', form.date)
|
2023-10-18 15:58:44 +08:00
|
|
|
if (form.onoff) {
|
|
|
|
params.append('onoff', '1')
|
2023-09-20 21:33:11 +08:00
|
|
|
} else {
|
2023-10-18 15:58:44 +08:00
|
|
|
params.append('onoff', '0')
|
2023-09-20 21:33:11 +08:00
|
|
|
}
|
2023-11-07 14:55:56 +08:00
|
|
|
params.append('weight_max', form.weight_max)
|
2023-09-20 21:33:11 +08:00
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('id', form.id)
|
|
|
|
const res = await api.post('saveAir', params)
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchAirList')// 刷新飞机列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 删除指定序号飞机
|
|
|
|
* @param {*} idArray 飞机序号数组
|
|
|
|
*/
|
|
|
|
fetchDelAir ({ dispatch }, idArr) {
|
|
|
|
if (idArr.length === 0) {
|
|
|
|
Message.error('未勾选记录')
|
|
|
|
} else {
|
|
|
|
MessageBox.confirm('请谨慎操作 确认删除?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('idArr', idArr)
|
|
|
|
api.post('deleteAir', params).then(res => {
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
dispatch('fetchAirList')// 刷新飞机列表
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
Message.info('取消操作')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 获取站点列表
|
|
|
|
*/
|
|
|
|
async fetchSiteList ({ commit }) {
|
|
|
|
const res = await api.get('getSiteList')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
commit('setSiteList', res.data.siteList)
|
|
|
|
} else {
|
2023-11-06 18:01:40 +08:00
|
|
|
commit('setSiteList', [])
|
2023-09-20 21:33:11 +08:00
|
|
|
Message.warning(res.data.msg)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 锁定站点
|
|
|
|
* @param {*} form 表单.站点信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchLockSite ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('runing', form.runing)
|
|
|
|
const res = await api.post('lockSite', params)
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchSiteList')// 刷新站点列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 创建新站点
|
|
|
|
* @param {*} form 表单.站点信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchAddSite ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('sitename', form.sitename)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
params.append('size', form.size)
|
|
|
|
params.append('bindroute', form.bindroute)
|
|
|
|
const res = await api.post('addSite', params)
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchSiteList')// 刷新站点列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 创建新站点
|
|
|
|
* @param {*} form 表单.站点信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchSaveSite ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('sitename', form.sitename)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
params.append('size', form.size)
|
|
|
|
params.append('bindroute', form.bindroute)
|
|
|
|
const res = await api.post('saveSite', params)
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchSiteList')// 刷新站点列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 删除指定序号站点
|
|
|
|
* @param {*} idArray 站点序号数组
|
|
|
|
*/
|
|
|
|
fetchDelSite ({ dispatch }, idArr) {
|
|
|
|
if (idArr.length === 0) {
|
|
|
|
Message.error('未勾选记录')
|
|
|
|
} else {
|
|
|
|
MessageBox.confirm('请谨慎操作 确认删除?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('idArr', idArr)
|
|
|
|
api.post('deleteSite', params).then(res => {
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
dispatch('fetchSiteList')// 刷新站点列表
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
Message.info('取消操作')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 获取航线列表
|
|
|
|
*/
|
|
|
|
async fetchRouteList ({ commit }) {
|
|
|
|
const res = await api.get('getRouteList')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
commit('setRouteList', res.data.routeList)
|
|
|
|
} else {
|
2023-11-06 18:01:40 +08:00
|
|
|
commit('setRouteList', [])
|
2023-09-20 21:33:11 +08:00
|
|
|
Message.warning(res.data.msg)
|
|
|
|
}
|
|
|
|
return res.data.routeList
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 创建新航线
|
|
|
|
* @param {*} form 表单.航线信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchAddRoute ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
const res = await api.post('addRoute', params)
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchRouteList')// 刷新站点列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 更新航线
|
|
|
|
* @param {*} form 表单.航线信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchSaveRoute ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
const res = await api.post('saveRoute', params)
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchRouteList')// 刷新站点列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 删除指定序号航线
|
|
|
|
* @param {*} idArray 航线序号数组
|
|
|
|
*/
|
|
|
|
fetchDelRoute ({ dispatch }, idArr) {
|
|
|
|
if (idArr.length === 0) {
|
|
|
|
Message.error('未勾选记录')
|
|
|
|
} else {
|
|
|
|
MessageBox.confirm('请谨慎操作 确认删除?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('idArr', idArr)
|
|
|
|
api.post('deleteRoute', params).then(res => {
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
dispatch('fetchRouteList')// 刷新航线列表
|
|
|
|
dispatch('fetchSiteList')// 刷新站点列表
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
Message.info('取消操作')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2023-10-18 15:58:44 +08:00
|
|
|
/**
|
|
|
|
* @description: 获取分类列表
|
|
|
|
* @return {*} 列表
|
|
|
|
*/
|
|
|
|
async fetchCategoryList ({ commit }) {
|
|
|
|
const res = await api.get('getCategoryList', 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
commit('setCategoryList', res.data.categoryList)
|
2023-11-06 18:01:40 +08:00
|
|
|
} else {
|
|
|
|
commit('setCategoryList', [])
|
2023-10-18 15:58:44 +08:00
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 添加分类信息
|
|
|
|
* @param {*} 分类信息表单
|
|
|
|
* @return {*} 服务器返回值
|
|
|
|
*/
|
|
|
|
async fetchAddCategory ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('path', form.path)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('sort', form.sort)
|
|
|
|
params.append('show', form.show)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
const res = await api.post('addCategory', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchCategoryList')// 刷新商铺列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 更新分类信息
|
|
|
|
* @param {*} 分类信息表单
|
|
|
|
* @return {*} 服务器返回值
|
|
|
|
*/
|
|
|
|
async fetchSaveCategory ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('sort', form.sort)
|
|
|
|
params.append('show', form.show)
|
|
|
|
params.append('desc', form.desc)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
params.append('oldFile', form.oldFile)
|
|
|
|
const res = await api.post('saveCategory', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchCategoryList')// 刷新商铺列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
2023-11-05 06:54:40 +08:00
|
|
|
/**
|
|
|
|
* @description: 删除账号
|
|
|
|
* @param {*} 多选id组
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
async fetchDelCategory ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('delIdArr', form.delIdArr)
|
|
|
|
params.append('shop_id', form.shop_id)
|
2023-11-06 18:01:40 +08:00
|
|
|
api.post('deleteCategory', params, 'Admin').then(res => {
|
2023-11-05 06:54:40 +08:00
|
|
|
if (res.data.status === 1) {
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
dispatch('fetchCategoryList')// 刷新分类列表
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2023-10-18 15:58:44 +08:00
|
|
|
/**
|
2023-11-03 20:57:12 +08:00
|
|
|
* @description: 获取商品spu列表
|
2023-10-18 15:58:44 +08:00
|
|
|
* @return {*} 列表
|
|
|
|
*/
|
2023-11-03 20:57:12 +08:00
|
|
|
async fetchSpuList ({ commit }) {
|
|
|
|
const res = await api.get('getSpuList', 'Admin')
|
2023-10-18 15:58:44 +08:00
|
|
|
if (res.data.status === 1) {
|
2023-11-03 20:57:12 +08:00
|
|
|
commit('setSpuList', res.data.spuList)
|
2023-11-06 18:01:40 +08:00
|
|
|
} else {
|
|
|
|
commit('setSpuList', [])
|
2023-10-18 15:58:44 +08:00
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
2023-10-31 19:30:41 +08:00
|
|
|
/**
|
2023-11-03 20:57:12 +08:00
|
|
|
* @description: spu排序
|
|
|
|
* @param {*} spu信息
|
2023-10-31 19:30:41 +08:00
|
|
|
*/
|
2023-11-03 20:57:12 +08:00
|
|
|
async fetchOrderSpu ({ dispatch }, form) {
|
2023-10-31 19:30:41 +08:00
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('sort', form.sort)
|
2023-11-03 20:57:12 +08:00
|
|
|
const res = await api.post('orderSpu', params, 'Admin')
|
2023-10-31 19:30:41 +08:00
|
|
|
if (res.data.status === 1) {
|
2023-11-03 20:57:12 +08:00
|
|
|
await dispatch('fetchSpuList')// 刷新商品列表
|
2023-10-31 19:30:41 +08:00
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
2023-11-03 20:57:12 +08:00
|
|
|
* @description: 商品前端显示隐藏
|
|
|
|
* @param {*} 商品信息
|
2023-10-31 19:30:41 +08:00
|
|
|
*/
|
2023-11-03 20:57:12 +08:00
|
|
|
async fetchShowSpu ({ dispatch }, form) {
|
2023-10-31 19:30:41 +08:00
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('show', form.show)
|
2023-11-03 20:57:12 +08:00
|
|
|
const res = await api.post('showSpu', params, 'Admin')
|
2023-10-31 19:30:41 +08:00
|
|
|
if (res.data.status === 1) {
|
2023-11-03 20:57:12 +08:00
|
|
|
await dispatch('fetchSpuList')// 刷新商品列表
|
2023-10-31 19:30:41 +08:00
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
2023-11-03 20:57:12 +08:00
|
|
|
* @description: 商品前端推荐位
|
|
|
|
* @param {*} 商品信息
|
2023-10-31 19:30:41 +08:00
|
|
|
*/
|
2023-11-03 20:57:12 +08:00
|
|
|
async fetchRecommendSpu ({ dispatch }, form) {
|
2023-10-31 19:30:41 +08:00
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('recommend', form.recommend)
|
2023-11-03 20:57:12 +08:00
|
|
|
const res = await api.post('recommendSpu', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchSpuList')// 刷新商品列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 添加商品 spu
|
|
|
|
* @param {*} form 表单.商品信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchAddSpu ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('path', form.path)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('spu_number', form.spu_number)
|
|
|
|
params.append('sort', form.sort)
|
|
|
|
params.append('hot', form.hot)
|
2023-11-05 06:54:40 +08:00
|
|
|
params.append('pro_tag', JSON.stringify(form.pro_tag))
|
|
|
|
params.append('bind_sku', JSON.stringify(form.bind_sku))
|
2023-11-03 20:57:12 +08:00
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
if (form.recommend) {
|
|
|
|
params.append('recommend', '1')
|
|
|
|
} else {
|
|
|
|
params.append('recommend', '0')
|
|
|
|
}
|
|
|
|
if (form.show) {
|
|
|
|
params.append('show', '1')
|
|
|
|
} else {
|
|
|
|
params.append('show', '0')
|
|
|
|
}
|
|
|
|
const res = await api.post('addSpu', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchSpuList')// 刷新商品列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 更新商品 spu
|
|
|
|
* @param {*} form 表单.商品信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchSaveSpu ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('path', form.path)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('spu_number', form.spu_number)
|
|
|
|
params.append('sort', form.sort)
|
|
|
|
params.append('hot', form.hot)
|
2023-11-05 06:54:40 +08:00
|
|
|
params.append('pro_tag', JSON.stringify(form.pro_tag))
|
|
|
|
params.append('bind_sku', JSON.stringify(form.bind_sku))
|
2023-11-03 20:57:12 +08:00
|
|
|
params.append('oldFile', form.oldFile)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
if (form.recommend) {
|
|
|
|
params.append('recommend', '1')
|
|
|
|
} else {
|
|
|
|
params.append('recommend', '0')
|
|
|
|
}
|
|
|
|
if (form.show) {
|
|
|
|
params.append('show', '1')
|
|
|
|
} else {
|
|
|
|
params.append('show', '0')
|
|
|
|
}
|
|
|
|
const res = await api.post('saveSpu', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchSpuList')// 刷新商品列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
2023-11-06 18:01:40 +08:00
|
|
|
/**
|
|
|
|
* @description: 删除spu
|
|
|
|
* @param {*} 多选id组
|
|
|
|
*/
|
|
|
|
async fetchDelSpu ({ dispatch }, idArr) {
|
|
|
|
if (idArr.length === 0) {
|
|
|
|
Message.error('未勾选记录')
|
|
|
|
} else {
|
|
|
|
MessageBox.confirm('请谨慎操作 确认删除?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('idArr', idArr)
|
|
|
|
api.post('deleteSpu', params, 'Admin').then(res => {
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
dispatch('fetchSpuList')// 刷新列表
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
Message.info('取消操作')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2023-11-03 20:57:12 +08:00
|
|
|
/**
|
|
|
|
* @description: 获取商品sku列表
|
|
|
|
* @return {*} 列表
|
|
|
|
*/
|
|
|
|
async fetchSkuList ({ commit }) {
|
|
|
|
const res = await api.get('getSkuList', 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
commit('setSkuList', res.data.skuList)
|
2023-11-06 18:01:40 +08:00
|
|
|
} else {
|
|
|
|
commit('setSkuList', [])
|
2023-11-03 20:57:12 +08:00
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 添加商品 sku
|
|
|
|
* @param {*} form 表单.商品信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchAddSku ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('sku_number', form.sku_number)
|
|
|
|
params.append('price', form.price)
|
|
|
|
params.append('unit', form.unit)
|
2023-11-07 14:55:56 +08:00
|
|
|
params.append('weight', form.weight)
|
2023-11-03 20:57:12 +08:00
|
|
|
params.append('stock', form.stock)
|
|
|
|
params.append('purchase_channel', form.purchase_channel)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
const res = await api.post('addSku', params, 'Admin')
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
await dispatch('fetchSkuList')// 刷新商品列表
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 更新商品 sku
|
|
|
|
* @param {*} form 表单.商品信息
|
|
|
|
* @return {*} 服务器返回信息
|
|
|
|
*/
|
|
|
|
async fetchSaveSku ({ dispatch }, form) {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('id', form.id)
|
|
|
|
params.append('shop_id', form.shop_id)
|
|
|
|
params.append('name', form.name)
|
|
|
|
params.append('sku_number', form.sku_number)
|
|
|
|
params.append('price', form.price)
|
|
|
|
params.append('unit', form.unit)
|
2023-11-07 14:55:56 +08:00
|
|
|
params.append('weight', form.weight)
|
2023-11-03 20:57:12 +08:00
|
|
|
params.append('stock', form.stock)
|
|
|
|
params.append('purchase_channel', form.purchase_channel)
|
|
|
|
params.append('oldFile', form.oldFile)
|
|
|
|
params.append('upFile', form.upFile)
|
|
|
|
const res = await api.post('saveSku', params, 'Admin')
|
2023-10-31 19:30:41 +08:00
|
|
|
if (res.data.status === 1) {
|
2023-11-03 20:57:12 +08:00
|
|
|
await dispatch('fetchSkuList')// 刷新商品列表
|
2023-10-31 19:30:41 +08:00
|
|
|
Message.success(res.data.msg)
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
2023-11-06 18:01:40 +08:00
|
|
|
/**
|
|
|
|
* @description: 删除sku
|
|
|
|
* @param {*} 多选id组
|
|
|
|
*/
|
|
|
|
async fetchDelSku ({ dispatch }, idArr) {
|
|
|
|
if (idArr.length === 0) {
|
|
|
|
Message.error('未勾选记录')
|
|
|
|
} else {
|
|
|
|
MessageBox.confirm('请谨慎操作 确认删除?', '提示', {
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
const params = new URLSearchParams()
|
|
|
|
params.append('idArr', idArr)
|
|
|
|
api.post('deleteSku', params, 'Admin').then(res => {
|
|
|
|
if (res.data.status === 1) {
|
|
|
|
Message.success(res.data.msg)
|
|
|
|
dispatch('fetchSkuList')// 刷新列表
|
|
|
|
} else {
|
|
|
|
Message.error(res.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(() => {
|
|
|
|
Message.info('取消操作')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2023-09-20 21:33:11 +08:00
|
|
|
/**
|
|
|
|
* @description: 获取订单列表 ps:待发货及待收货 并且不是退款成功状态
|
|
|
|
* @return {*} 列表
|
|
|
|
*/
|
2023-11-07 13:28:53 +08:00
|
|
|
async fetchOrderList ({ commit }) {
|
|
|
|
const res = await api.get('getOrderList', 'Admin')
|
2023-09-20 21:33:11 +08:00
|
|
|
if (res.data.status === 1) {
|
2023-11-09 21:39:50 +08:00
|
|
|
const list = res.data.orderList
|
|
|
|
list.forEach((item, index) => { // 拿到订单列表数据 直接把订单列表数据反序列化
|
|
|
|
if (item.product_snapshot !== '') {
|
|
|
|
list[index].product_snapshot = JSON.parse(item.product_snapshot)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
commit('setOrderList', list)
|
2023-11-06 18:01:40 +08:00
|
|
|
} else {
|
2023-11-07 13:28:53 +08:00
|
|
|
commit('setOrderList', [])
|
2023-09-20 21:33:11 +08:00
|
|
|
}
|
|
|
|
return res
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 向操作日志插入信息 并在积攒多条之后 向服务器提交
|
|
|
|
* @param {logData} content 日志内容 logData.color 时间
|
|
|
|
* @param {logData} color 标点颜色 默认#409EFF
|
|
|
|
* @param {logData} timestamp 插入时间 默认当前时间
|
|
|
|
*/
|
|
|
|
fetchLog ({ commit }, logData) {
|
|
|
|
/* 插入日志 */
|
|
|
|
logData.color = typeof logData.color !== 'undefined' ? logData.color : '#409EFF'
|
|
|
|
logData.timestamp = typeof logData.timestamp !== 'undefined' ? logData.color : new Date().getTime()
|
|
|
|
commit('insertNewLog', logData)
|
|
|
|
/* 积攒 向服务器提交 日志 待续写... */
|
|
|
|
}
|
|
|
|
},
|
|
|
|
modules: {
|
|
|
|
app,
|
|
|
|
settings,
|
|
|
|
user
|
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export default store
|