提交
This commit is contained in:
19
index.html
19
index.html
@@ -1,13 +1,14 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8"/>
|
||||||
<link rel="icon" href="/favicon.ico" />
|
<link rel="icon" href="/favicon.ico"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<title>Vite App</title>
|
<title>Vite App</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.js"></script>
|
<script type="module" src="/src/main.js"></script>
|
||||||
</body>
|
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"preview": "vite preview --port 4173"
|
"preview": "vite preview --port 4173"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^1.7.2",
|
||||||
"element-ui": "^2.15.14",
|
"element-ui": "^2.15.14",
|
||||||
"vue": "^2.7.7",
|
"vue": "^2.7.7",
|
||||||
"vue-router": "^3.5.4"
|
"vue-router": "^3.5.4"
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ import router from './router'
|
|||||||
import './assets/main.css'
|
import './assets/main.css'
|
||||||
import ElementUI from 'element-ui';
|
import ElementUI from 'element-ui';
|
||||||
import 'element-ui/lib/theme-chalk/index.css';
|
import 'element-ui/lib/theme-chalk/index.css';
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
Vue.use(ElementUI);
|
Vue.use(ElementUI);
|
||||||
|
|
||||||
|
window.axios = axios
|
||||||
|
window.$glob = {}
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
render: (h) => h(App)
|
render: (h) => h(App)
|
||||||
|
|||||||
41
src/utils/fetch.js
Normal file
41
src/utils/fetch.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
const {axios, $glob} = window
|
||||||
|
|
||||||
|
let getAuthing = false
|
||||||
|
const getToken = () => {
|
||||||
|
getAuthing = true
|
||||||
|
return axios.post("http://10.0.97.209/data-boot/na/sys/login", {
|
||||||
|
t: Date.now(),
|
||||||
|
userAcc: "kengee",
|
||||||
|
password: "kengee@123",
|
||||||
|
uuid: "",
|
||||||
|
captcha: ""
|
||||||
|
}).then(res => {
|
||||||
|
if (res?.data?.data) {
|
||||||
|
$glob.token = res.data.data.token
|
||||||
|
}
|
||||||
|
}).finally(() => getAuthing = false)
|
||||||
|
}
|
||||||
|
const http = axios.create({baseURL: '/'})
|
||||||
|
const addToken = (config) => {
|
||||||
|
config.headers['h-token'] = $glob.token
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
window.$wait = (t = 500) => new Promise(resolve => setTimeout(resolve, t))
|
||||||
|
http.interceptors.request.use(async config => {
|
||||||
|
while (getAuthing) {
|
||||||
|
await $wait()
|
||||||
|
}
|
||||||
|
if (!$glob.token && !getAuthing) {
|
||||||
|
await getToken()
|
||||||
|
}
|
||||||
|
return addToken(config)
|
||||||
|
})
|
||||||
|
http.interceptors.response.use(res => {
|
||||||
|
if (res?.data) {
|
||||||
|
return res.data
|
||||||
|
} else if (res?.code == 401) {
|
||||||
|
return getToken().then(() => http.request(res.config))
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
window.$http = http
|
||||||
@@ -39,6 +39,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
height: '600px',
|
height: '600px',
|
||||||
stores: [],
|
stores: [],
|
||||||
|
cameras: [],
|
||||||
|
storeKeyGoods: [],
|
||||||
|
categorySales: [],
|
||||||
columns: {
|
columns: {
|
||||||
品类销售情况: [
|
品类销售情况: [
|
||||||
{label: "品类", prop: "secondCategoryName"},
|
{label: "品类", prop: "secondCategoryName"},
|
||||||
@@ -60,6 +63,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
refs: v => v.$parent.getItemRefs(),
|
||||||
storeList: v => {
|
storeList: v => {
|
||||||
const list = []
|
const list = []
|
||||||
let group = []
|
let group = []
|
||||||
@@ -77,22 +81,48 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getData() {
|
getData() {
|
||||||
const refs = this.$parent.getItemRefs();
|
this.stores = this.stores.map(store => {
|
||||||
const cameras = refs['c82d439e-a316-4d0e-8792-d2513a950f11'].dataChart
|
const cameraStore = this.cameras.find(e => e.storeCode == store)
|
||||||
const storeKeyGoods = refs['6f6e3050-b084-4694-83c0-0d351346f426'].dataChart
|
|
||||||
const categorySales = refs['58fd4d5f-2ac3-444c-8a2c-361b8c8c3e6e'].dataChart
|
|
||||||
this.stores = JSON.parse(window.$glob.stores || "[]").map(store => {
|
|
||||||
const cameraStore = cameras.find(e => e.storeCode == store)
|
|
||||||
const {storeName = "仟吉门店", storeCameraVOList: camera = []} = cameraStore
|
const {storeName = "仟吉门店", storeCameraVOList: camera = []} = cameraStore
|
||||||
const keyGoods = storeKeyGoods.filter(e => e.storeCode == store)
|
const keyGoods = this.storeKeyGoods.filter(e => e.storeCode == store)
|
||||||
const categorySale = categorySales.filter(e => e.storeCode == store)
|
const categorySale = this.categorySales.filter(e => e.storeCode == store)
|
||||||
return {storeName, camera: camera.map(e => e.url), keyGoods, categorySale}
|
return {storeName, camera: camera.map(e => e.url), keyGoods, categorySale}
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
getCameras() {
|
||||||
|
return $http.post("/api/store/camera/list", {
|
||||||
|
storeCodes: this.stores
|
||||||
|
}).then(res => {
|
||||||
|
if (res?.data) {
|
||||||
|
this.cameras = res.data?.records || []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getStoreKeyGoods() {
|
||||||
|
return $http.post("/api/store/camera/list", {
|
||||||
|
storeCodes: this.stores
|
||||||
|
}).then(res => {
|
||||||
|
if (res?.data) {
|
||||||
|
this.storeKeyGoods = res.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getCategorySales() {
|
||||||
|
return $http.post("/api/store/camera/list", {
|
||||||
|
storeCodes: this.stores
|
||||||
|
}).then(res => {
|
||||||
|
if (res?.data) {
|
||||||
|
this.categorySales = res.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
this.height = `${this.$el.clientHeight}px`
|
this.height = `${this.$el.clientHeight}px`
|
||||||
this.getData()
|
this.stores = JSON.parse(window.$glob.stores || "[]")
|
||||||
|
while (!$http) await $wait()
|
||||||
|
Promise.all([this.getCameras(), this.getStoreKeyGoods(), this.getCategorySales()]).then(() => this.getData())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 9000
|
port: 9000,
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://10.0.97.209',
|
||||||
|
changeOrigin: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user