Commit d2185f56 by zhuzhequan

添加清除缓存功能

parent d9e2351d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "JomallProductionAssistant", "name": "JomallProductionAssistant",
"productName": "JomallProductionAssistant", "productName": "JomallProductionAssistant",
"description": "", "description": "",
"version": "1.0.1", "version": "1.0.2",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
......
...@@ -26,6 +26,7 @@ function endLoading() { ...@@ -26,6 +26,7 @@ function endLoading() {
// Add a request interceptor // Add a request interceptor
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
console.log(Vue.prototype.$dataStore);
const user = Vue.prototype.$dataStore.get("user"); const user = Vue.prototype.$dataStore.get("user");
const company = Vue.prototype.$dataStore.get("company"); const company = Vue.prototype.$dataStore.get("company");
if (user) { if (user) {
......
...@@ -6,8 +6,9 @@ import { grid } from "../data"; ...@@ -6,8 +6,9 @@ import { grid } from "../data";
import pkg from "../../../../package.json"; import pkg from "../../../../package.json";
import UpdateDialog from "@/views/design/updateDialog.vue"; import UpdateDialog from "@/views/design/updateDialog.vue";
export default { export default {
components: { PrintDialog,UpdateDialog }, components: { PrintDialog, UpdateDialog },
props: { props: {
user: { user: {
default: { default: {
...@@ -22,10 +23,34 @@ export default { ...@@ -22,10 +23,34 @@ export default {
}, },
data() { data() {
return { return {
checkList: [],
cacheList: [
{
label: "清除当前登录信息",
value: "token"
},
{
label: "登录记录",
value: "userList"
},{
label: "公司信息",
value: "company"
}, {
label: "打印预设",
value: "print-setting"
}, {
label: "系统授权信息",
value: "deviceId"
}, {
label: "系统设置",
value: "setting"
}
],
selectGridIndex: 0, selectGridIndex: 0,
pkg, pkg,
actionIndex: -1, actionIndex: -1,
isAutoFinish: false, isAutoFinish: false,
cacheVisible: false,
showPrintDialog: false, showPrintDialog: false,
productionNo: "", productionNo: "",
setting: { setting: {
...@@ -62,7 +87,7 @@ export default { ...@@ -62,7 +87,7 @@ export default {
avatar() { avatar() {
if (this.user && this.user.avatar && this.company.domain) { if (this.user && this.user.avatar && this.company.domain) {
console.log(this.user, 9); console.log(this.user, 9);
console.log(this.company,8); console.log(this.company, 8);
let host = this.company.domain; let host = this.company.domain;
if (host.includes("console")) { if (host.includes("console")) {
host = host.replace(".jomalls.com", ".joshine.cn"); host = host.replace(".jomalls.com", ".joshine.cn");
...@@ -107,8 +132,8 @@ export default { ...@@ -107,8 +132,8 @@ export default {
if (data) { if (data) {
// 有新版本更新 // 有新版本更新
this.$refs.updateDialog.open(data); this.$refs.updateDialog.open(data);
}else{ } else {
this.$message.warning('已是最新版本') this.$message.warning("已是最新版本");
} }
}); });
}, },
...@@ -141,19 +166,9 @@ export default { ...@@ -141,19 +166,9 @@ export default {
.catch(() => { .catch(() => {
}); });
break; break;
case "clear": case "cache":
// this.$confirm("是否清除缓存?", "提示", { this.checkList = [];
// confirmButtonText: "确定", this.cacheVisible = true;
// cancelButtonText: "取消",
// type: "warning"
// }).then(() => {
// for (let k in this.$dataStore.store) {
// this.$dataStore.delete(k);
// }
// location.reload();
// }).catch(() => {
//
// });
break; break;
} }
}, },
...@@ -175,6 +190,36 @@ export default { ...@@ -175,6 +190,36 @@ export default {
await this.setData(this.detail); await this.setData(this.detail);
}); });
}, },
clearCache() {
if (this.checkList.length === 0) {
return this.$message.warning("请选择要清除的数据");
}
this.$confirm("是否确定清除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
for (let k of this.checkList) {
if (k === "print-setting" || k === "deviceId") {
let list = Object.keys(this.$dataStore.store).filter(el => el.includes(k));
list.forEach(el => {
this.$dataStore.delete(el);
});
}else if (k === "token" ) {
this.$dataStore.delete('token');
this.$dataStore.delete('user');
} else {
if (this.$dataStore.get(k)) {
this.$dataStore.delete(k);
}
}
}
window.location.reload();
})
.catch(() => {
});
},
async downloadImage() { async downloadImage() {
if (!this.detail || Object.keys(this.detail).length === 0) if (!this.detail || Object.keys(this.detail).length === 0)
return this.$message.warning("请扫描生产单号"); return this.$message.warning("请扫描生产单号");
...@@ -522,12 +567,22 @@ export default { ...@@ -522,12 +567,22 @@ export default {
<!-- <el-dropdown-item command="clear">清除缓存</el-dropdown-item>--> <!-- <el-dropdown-item command="clear">清除缓存</el-dropdown-item>-->
<el-dropdown-item command="company">切换系统</el-dropdown-item> <el-dropdown-item command="company">切换系统</el-dropdown-item>
<el-dropdown-item command="logout">退出登录</el-dropdown-item> <el-dropdown-item command="logout">退出登录</el-dropdown-item>
<el-dropdown-item command="cache">清除缓存</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
</div> </div>
<update-dialog ref="updateDialog" /> <update-dialog ref="updateDialog" />
<el-dialog :visible.sync="cacheVisible" title="清除缓存" width="700px">
<el-checkbox-group style="display: flex;flex-direction: column" v-model="checkList">
<el-checkbox style="margin-bottom: 10px" :label="item.value" v-for="(item,i) in cacheList"
:key="i">{{item.label}}</el-checkbox>
</el-checkbox-group>
<template #footer>
<el-button @click="cacheVisible =false">取消</el-button>
<el-button @click="clearCache" type="primary">清除</el-button>
</template>
</el-dialog>
</div> </div>
</template> </template>
......
...@@ -4,7 +4,7 @@ export default { ...@@ -4,7 +4,7 @@ export default {
return { return {
rules: { rules: {
company: [ company: [
{ message: "请选择客户名称", required: true, trigger: "change" }, { validator:this.validatePass, message: "请检查客户名称", required: true, trigger: "blur" },
], ],
loginName: [ loginName: [
{ message: "请输入用户名", required: true, trigger: "blur" }, { message: "请输入用户名", required: true, trigger: "blur" },
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
this.company = this.$dataStore.get("company"); this.company = this.$dataStore.get("company");
this.userList = this.$dataStore.get("userList") || []; this.userList = this.$dataStore.get("userList") || [];
if (this.company) { if (this.company) {
this.form.company = this.company.domain; this.form.company = this.company.domain.replace('.jomalls.com','');
} }
// if (user) { // if (user) {
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
}, },
{ {
headers: { headers: {
company: this.form.company, company: this.form.company +'.jomalls.com',
}, },
} }
) )
...@@ -75,7 +75,7 @@ export default { ...@@ -75,7 +75,7 @@ export default {
this.authorityVisible = false; this.authorityVisible = false;
this.$message.success("申请提交成功"); this.$message.success("申请提交成功");
this.$dataStore.set( this.$dataStore.set(
this.form.company.replace('.jomalls.com','_') + "deviceId_" + this.form.loginName, this.form.company + "_deviceId_" + this.form.loginName,
res.data.id res.data.id
); );
} }
...@@ -109,10 +109,12 @@ export default { ...@@ -109,10 +109,12 @@ export default {
if (!f.deviceId) { if (!f.deviceId) {
f.deviceId = this.$dataStore.get( f.deviceId = this.$dataStore.get(
f.company.replace('.jomalls.com','_') + "deviceId_" + this.form.loginName f.company + "_deviceId_" + this.form.loginName
); );
} }
if(f.company){
f.company = f.company.includes('.jomalls.com')?f.company:f.company+'.jomalls.com'
}
if (!f.deviceId) delete f.deviceId; if (!f.deviceId) delete f.deviceId;
let { data, code, message } = await this.$api.post("/login", f); let { data, code, message } = await this.$api.post("/login", f);
if (code === 411) { if (code === 411) {
...@@ -132,7 +134,7 @@ export default { ...@@ -132,7 +134,7 @@ export default {
console.log(item, 111222); console.log(item, 111222);
this.$dataStore.set("user", data); this.$dataStore.set("user", data);
this.$dataStore.set("company", item); this.$dataStore.set("company", item);
console.log( this.$dataStore);
if (this.remember) { if (this.remember) {
let userList = this.$dataStore.get("userList"); let userList = this.$dataStore.get("userList");
...@@ -161,7 +163,7 @@ export default { ...@@ -161,7 +163,7 @@ export default {
return; return;
} }
console.log(this.userList, v); console.log(this.userList, v);
this.form.company = this.userList[v].company; this.form.company = this.userList[v].company.replace('.jomalls.com','');
this.form.loginName = this.userList[v].loginName; this.form.loginName = this.userList[v].loginName;
this.form.password = this.userList[v].password; this.form.password = this.userList[v].password;
this.form.deviceId = this.userList[v].deviceId; this.form.deviceId = this.userList[v].deviceId;
...@@ -177,7 +179,7 @@ export default { ...@@ -177,7 +179,7 @@ export default {
<template> <template>
<div class="login"> <div class="login">
<div class="form-content"> <div class="form-content">
<el-form v-if="" ref="formRef" :rules="rules" size="small" :model="form"> <el-form ref="formRef" :rules="rules" size="small" :model="form">
<el-form-item v-if="userList.length > 0"> <el-form-item v-if="userList.length > 0">
<el-select <el-select
@change="userChange" @change="userChange"
...@@ -199,30 +201,32 @@ export default { ...@@ -199,30 +201,32 @@ export default {
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-if="!company" prop="company"> <el-form-item v-if="!company" prop="company">
<!-- <el-select prefix-icon="el-icon-monitor" v-model="form.company">--> <!-- <el-select prefix-icon="el-icon-monitor" v-model="form.company">-->
<!-- <el-option v-for="(it,i) in companyList" :key="i" :label="it.companyName" :value="it.domain.replace('.jomalls.com','')"></el-option>--> <!-- <el-option v-for="(it,i) in companyList" :key="i" :label="it.companyName" :value="it.domain.replace('.jomalls.com','')"></el-option>-->
<!-- </el-select>--> <!-- </el-select>-->
<!--&lt;!&ndash; <el-input placeholder="客户(例如demo)" prefix-icon="el-icon-monitor" v-model="form.company"&ndash;&gt;--> <el-input placeholder="客户(例如demo)" prefix-icon="el-icon-monitor" v-model="form.company"
<!--&lt;!&ndash; clearable>&ndash;&gt;--> clearable>
<template #append>
<!--&lt;!&ndash; </el-input>&ndash;&gt;--> .jomalls.com
<el-select </template>
filterable </el-input>
style="width: 100%" <!-- <el-select-->
placeholder="系统" <!-- filterable-->
v-model="form.company" <!-- style="width: 100%"-->
clearable <!-- placeholder="系统"-->
> <!-- v-model="form.company"-->
<template slot="prefix"> <!-- clearable-->
<i class="el-icon-monitor"></i> <!-- >-->
</template> <!-- <template slot="prefix">-->
<el-option <!-- <i class="el-icon-monitor"></i>-->
v-for="(it, i) in companyList" <!-- </template>-->
:key="i" <!-- <el-option-->
:label="it.companyName" <!-- v-for="(it, i) in companyList"-->
:value="it.domain" <!-- :key="i"-->
></el-option> <!-- :label="it.companyName"-->
</el-select> <!-- :value="it.domain"-->
<!-- ></el-option>-->
<!-- </el-select>-->
</el-form-item> </el-form-item>
<el-form-item prop="loginName"> <el-form-item prop="loginName">
......
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