Commit 495695bd by zhuzhequan

转为工厂端

parent a7b73f94
{
"apiApiHost":"https://factory.jomalls.com/api",
"fileApiUrl":"https://factory.jomalls.com/upload/factory",
"visionUrl":"https://console.jomalls.com"
}
......@@ -77,8 +77,9 @@ async function createWindow() {
});
win.on("closed", () => {
win.removeAllListeners();
win && win.removeAllListeners();
win = null;
newWindow && newWindow.close()
newWindow = null;
});
......
import { downloadImage, toSend, writeProfileXml } from "@/server/utils";
import axios from "axios";
import { returnLogFilePath } from "../utils/log";
var request = require("request");
const compressing = require("compressing");
const uuid = require("uuid");
const path = require("path");
const fs = require("fs");
const os = require("os");
import axios from "axios";
import { returnLogFilePath } from "../utils/log";
const { app } = require("electron");
let fileEnv, env, visionUrl;
axios.defaults.timeout = 12600000;
const multiparty = require("multiparty");
function readEnv() {
let exePath,configPath
if(process.env.NODE_ENV === "development") {
configPath = path.join(__dirname, "../config/env.json");
}else{
exePath = path.dirname(app.getPath("exe")).replace(/\\/g, "/");
configPath = `${exePath}/config/env.json`;
}
console.log(configPath,__dirname);
fs.readFile(configPath, "utf-8", (err, data) => {
if (err) {
console.error("读取配置文件失败:", err);
return;
}
const config = JSON.parse(data);
fileEnv = config.fileApiUrl;
env = config.apiApiHost;
visionUrl = config.visionUrl;
});
}
readEnv()
export default {
writePrintLog: async (req, res) => {
try {
......@@ -33,32 +56,24 @@ export default {
res.json({ code: 500, msg: e });
}
},
getPodProductionInfo: async (req, res) => {
downloadBySubOrderNumber: async (req, res) => {
const token = req.headers["jwt-token"];
const company = req.headers["company"];
const productionNo = req.body.productionNo;
try {
let { data } = await axios.post(
`https://${company}/api/podDesignCenter/getPodImageByProduction`,
{ productionNo },
{ headers: { "jwt-token": token } }
let {
data
} = await axios.get(
`${env}/factory/podJomallOrder/downloadBySubOrderNumber`,
{ params: req.body, headers: { "jwt-token": token } }
);
console.log(data);
if (data.code === 200 && data.data && data.data.length > 0) {
let f = data.data.find(el => !el.productionFile);
if (f) {
return res.json({ code: 500, msg: "存在地址错误的素材图" });
}
data.data.forEach(el => {
if (!el.productionFile.includes("http")) {
el.productionFile = el.productionFile.replace(
"/data/upload/erp/",
""
);
el.productionFile = `https://${company}/upload/erp${el.productionFile}`;
}
let files = [];
if (data.code === 200 && data.message) {
files = [data.message];
files = files.map(el => {
return { url: `${fileEnv}${el}` };
});
downloadImage(data.data)
console.log(files);
downloadImage(files)
.then(data => {
res.json({ code: 200, data });
})
......@@ -75,11 +90,10 @@ export default {
},
findByPodProductionNo: async (req, res) => {
const token = req.headers["jwt-token"];
const company = req.headers["company"];
const q = req.body;
try {
let { data } = await axios.get(
`https://${company}/api/pod/podProductionInfo/findByPodProductionNo`,
`${env}/factory/podJomallOrderProduct/getSubOrderBySubOrderNumber`,
{
params: q,
headers: { "jwt-token": token }
......@@ -101,34 +115,20 @@ export default {
res.json({ code: 500, msg: err });
}
},
commitApply: async (req, res) => {
const company = req.headers["company"];
const q = req.body;
try {
let { data } = await axios.post(
`https://${company}/api/sysDeviceInfo/commitApply`,
q
);
res.send(data);
} catch (err) {
console.log(err);
res.json({ code: 500, msg: err });
}
},
commitApply: async (req, res) => {},
completeDelivery: async (req, res) => {
const token = req.headers["jwt-token"];
const company = req.headers["company"];
const q = req.body;
try {
let { data } = await axios.post(
`https://${company}/api/pod/podProductionInfo/completeDelivery`,
q,
{
headers: { "jwt-token": token }
}
let {
data
} = await axios.post(
`${env}/factory/podJomallOrderProduct/completeDelivery`,
req.body,
{ headers: { "jwt-token": token } }
);
res.json(data);
res.send(data);
} catch (err) {
console.log(err);
res.json({ code: 500, msg: err });
}
},
......@@ -232,14 +232,9 @@ export default {
}
},
login: async (req, res) => {
const { loginName, company, password, deviceId } = req.body;
try {
let { data } = await axios.post(`https://${company}/api/sysLogin/login`, {
loginName,
password,
deviceId
});
console.log(`${env}/factory/login`);
let { data } = await axios.post(`${env}/factory/login`, req.body);
res.send(data);
} catch (err) {
console.log(err);
......@@ -282,8 +277,7 @@ export default {
let from = path.join(process.cwd(), "./resources/app/css.zip");
let dirName = path.join(process.cwd(), "./resources/app/");
let stream = fs.createWriteStream(from);
const company = req.headers["company"];
req.body.url = "https://" + company + req.body.url;
req.body.url = visionUrl + req.body.url;
console.log(req.body.url, "下载zip地址");
request(req.body.url)
.pipe(stream)
......
......@@ -23,7 +23,7 @@ router.post("/commitApply", fn.commitApply);
// 下载素材到本地
router.post("/downloadByDesignId", fn.downloadByDesignId);
// 获取 生产单号返回素材地址
router.post("/getPodProductionInfo", fn.getPodProductionInfo);
router.post("/downloadBySubOrderNumber", fn.downloadBySubOrderNumber);
// 提交生产完成
router.post("/completeDelivery", fn.completeDelivery);
// 根据生产单号查询详情
......
......@@ -27,6 +27,7 @@ function zip(from, to) {
fs.renameSync(file_path, path.join(to, fileName));
arr.push({
fileName: fileName,
designId: data[i].split(".")[0],
productionFile: path.join(to, fileName)
});
}
......@@ -53,7 +54,7 @@ export const downloadImage = list => {
}
let count = 0;
for (let i = 0; i < list.length; i++) {
if (list[i].productionFile && list[i].productionFile.includes("http")) {
if (list[i].url && list[i].url.includes("http")) {
let fileName = "";
let type = 2;
let flag =
......@@ -66,30 +67,24 @@ export const downloadImage = list => {
".7z",
".gz",
".bz2"
].filter(el => list[i].productionFile.toLowerCase().includes(el))
].filter(el => list[i].url.toLowerCase().includes(el))
.length > 0;
if (flag) {
fileName = list[i].productionFile.split("/")[
list[i].productionFile.split("/").length - 1
fileName = list[i].url.split("/")[
list[i].url.split("/").length - 1
];
type = 1;
} else {
fileName = uuid.v4() + ".png";
type = 2;
}
list[i].fileName = fileName;
list[i].type = type;
let p = path.join(process.cwd(), "./print/Input/" + fileName);
let stream = fs.createWriteStream(p);
request(list[i].productionFile)
request(list[i].url)
.pipe(stream)
.on("close", async function() {
if (type === 1) {
let res_data = await zip(p, dirPath);
res_data.forEach(item => {
item.designId = list[i].designId;
});
list[i].list = res_data;
list[i].list = await zip(p, dirPath);
if (count === list.length - 1) {
resolve(list);
}
......
......@@ -43,7 +43,6 @@ const addFormatLog = function(req, res, data) {
const resTime = now - req._startTime;
const token = req.headers["jwt-token"];
const company = req.headers["company"];
const {
ip,
headers,
......@@ -60,7 +59,6 @@ const addFormatLog = function(req, res, data) {
method,
url,
token,
company,
body,
httpVersion,
statusCode,
......@@ -70,21 +68,16 @@ const addFormatLog = function(req, res, data) {
};
// ${JSON.stringify(logInfo)}
logger("log").info(`
时间:${moment(new Date()).format("YYYY-MM-DD HH:mm:ss")}
ip : ${logInfo.ip}
host : ${logInfo.host}
响应时间 : ${logInfo.resTime / 1000} s
method :${logInfo.method}
url :${logInfo.url}
客户 :${logInfo.company || ""}
token :${logInfo.token || ""}
body :${JSON.stringify(logInfo.body)}
状态码 :${logInfo.statusCode}
data :${JSON.stringify(logInfo.data)}
`
);
......
......@@ -28,10 +28,8 @@ service.interceptors.request.use(
config => {
console.log(Vue.prototype.$dataStore);
const user = Vue.prototype.$dataStore.get("user");
const company = Vue.prototype.$dataStore.get("company");
if (user) {
config.headers["jwt-token"] = user.token;
config.headers["company"] = company.domain;
}
startLoading();
return config;
......
......@@ -12,13 +12,10 @@ export default {
props: {
user: {
default: {
avatar: ""
avatar: "",
factory: {}
},
type: Object
},
company: {
default: {},
type: Object
}
},
data() {
......@@ -32,16 +29,12 @@ export default {
{
label: "登录记录",
value: "userList"
},{
label: "公司信息",
value: "company"
}, {
},
{
label: "打印预设",
value: "print-setting"
}, {
label: "系统授权信息",
value: "deviceId"
}, {
},
{
label: "系统设置",
value: "setting"
}
......@@ -84,22 +77,6 @@ export default {
};
},
computed: {
avatar() {
if (this.user && this.user.avatar && this.company.domain) {
console.log(this.user, 9);
console.log(this.company, 8);
let host = this.company.domain;
if (host.includes("console")) {
host = host.replace(".jomalls.com", ".joshine.cn");
}
let avatar = this.user.avatar.includes("http")
? this.user.avatar
: `https://${host}/erpimg/${this.user.avatar}`;
console.log(avatar);
return avatar;
}
return "";
},
actionList() {
return this.$store.getters.getActionList;
}
......@@ -149,23 +126,9 @@ export default {
this.$dataStore.delete("user");
this.$router.push("/");
})
.catch(() => {
});
break;
case "company":
this.$confirm("是否切换系统?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.$dataStore.delete("company");
this.$dataStore.delete("user");
this.$router.push("/");
})
.catch(() => {
});
.catch(() => {});
break;
case "cache":
this.checkList = [];
this.cacheVisible = true;
......@@ -174,9 +137,8 @@ export default {
},
async setData(data) {
if (!data) return this.$message.warning("请扫描生产单号");
await this.$api.post("/completeDelivery", { id: data.id }).then(() => {
});
this.$message.success("成功生产完成");
await this.$api.post("/completeDelivery", { id: data.id }).then(() => {});
this.$message.success("操作成功");
},
async sureData() {
if (!this.detail || Object.keys(this.detail).length <= 1) {
......@@ -202,13 +164,15 @@ export default {
.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));
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 (k === "token") {
this.$dataStore.delete("token");
this.$dataStore.delete("user");
} else {
if (this.$dataStore.get(k)) {
this.$dataStore.delete(k);
......@@ -217,14 +181,13 @@ export default {
}
window.location.reload();
})
.catch(() => {
});
.catch(() => {});
},
async downloadImage() {
if (!this.detail || Object.keys(this.detail).length === 0)
return this.$message.warning("请扫描生产单号");
let params = {
productionNo: this.detail.podProductionNo,
productionNo: this.detail.factorySubOrderNumber,
imgList: this.imgList
};
......@@ -246,30 +209,28 @@ export default {
const findByPodProductionNo = await this.$api.post(
"/findByPodProductionNo",
{
podProductionNo: this.productionNo,
status: "IN_PRODUCTION"
factorySubOrderNumber: this.productionNo
}
);
this.detail = findByPodProductionNo.data;
console.log(findByPodProductionNo.data, "findByPodProductionNo.data");
ipcRenderer.send("win-subScreen", findByPodProductionNo.data);
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let res = await this.$api.post("/getPodProductionInfo", {
productionNo: this.productionNo
let res = await this.$api.post("/downloadBySubOrderNumber", {
subOrderNumber: this.productionNo
});
this.imgList = [];
res.data.forEach(el => {
this.imgList = this.imgList.concat(el.list || []);
});
this.$dataStore.set('production_no',this.productionNo)
this.$dataStore.set("production_no", this.productionNo);
if (res.data.length === 0)
return this.$message.warning("未找到素材图!");
let arr = [];
res.data.forEach(el => {
arr.push(el);
if (el.list) {
el.list.forEach(it => {
arr.push({
...it,
...{
designId: el.designId
}
});
arr.push(it);
});
}
});
......@@ -367,9 +328,8 @@ export default {
<!-- </el-tooltip>-->
<el-dropdown trigger="click" @command="command" :hide-on-click="false">
<el-button style="height: 100%;margin-right: 0px" size="small">{{
grid[selectGridIndex].label
}}
<el-button style="height: 100%;margin-right: 0px" size="small"
>{{ grid[selectGridIndex].label }}
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="i" v-for="(it, i) in grid" :key="i">
......@@ -492,7 +452,12 @@ export default {
</el-form-item>
<el-form-item prop="language" label="版本号">
<b>{{ pkg.version || "" }}</b>
<el-button @click="checkUpdate" style="margin-left: 15px" type="text">检查更新</el-button>
<el-button
@click="checkUpdate"
style="margin-left: 15px"
type="text"
>检查更新</el-button
>
</el-form-item>
<!-- <el-form-item label="自动打印模式">-->
......@@ -510,7 +475,7 @@ export default {
<el-tooltip slot="reference" content="设置">
<el-button style="margin-right: 8px" size="small">
<img
style="width: 15px;height: 15px"
style="width: 18px;height: 18px"
src="@/static/icon/shezhi.png"
alt=""
/>
......@@ -539,8 +504,7 @@ export default {
style="margin-left: 10px"
type="primary"
>查询
</el-button
>
</el-button>
<div class="sure-btn">
<el-button
@click="sureData"
......@@ -562,13 +526,14 @@ export default {
</el-button>
</div>
<div class="right-user">
<p>{{ company.companyName }}</p>
<el-avatar :src="avatar"></el-avatar>
<p v-if="user && user.factory">{{ user.factory.title }}</p>
<el-dropdown @command="dropdownCommand">
<b style="cursor:pointer;">{{ user.employeeName }}</b>
<div style="margin-right: 20px">
<b style="cursor:pointer;">{{ user.account }}</b>
<i class="el-icon-arrow-down"></i>
</div>
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item command="clear">清除缓存</el-dropdown-item>-->
<el-dropdown-item command="company">切换系统</el-dropdown-item>
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
<el-dropdown-item command="cache">清除缓存</el-dropdown-item>
</el-dropdown-menu>
......@@ -577,12 +542,20 @@ export default {
</div>
<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
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="cacheVisible = false">取消</el-button>
<el-button @click="clearCache" type="primary">清除</el-button>
</template>
</el-dialog>
......@@ -595,7 +568,7 @@ export default {
align-items: center;
b {
margin: 0 10px;
margin: 0 3px;
display: inline-block;
color: black;
font-size: 15px;
......@@ -675,4 +648,12 @@ export default {
z-index: 2;
color: white;
}
::v-deep .el-color-picker__trigger{
background: white;
width: 41px;
}
::v-deep .el-color-picker__color{
border: none !important;
}
</style>
......@@ -903,7 +903,7 @@ export default {
<el-button
@click="getPrintCmd"
type="primary"
style="width: 100%;height: 50px"
style="width: 98%;height: 50px"
>打印
</el-button>
</div>
......@@ -929,10 +929,10 @@ export default {
}
.el-form {
height: 84%;
height: 87%;
display: flex;
flex-direction: column;
padding-top: 15px;
padding-top: 0;
border-top: 1px solid #ececec;
}
......@@ -952,8 +952,7 @@ export default {
font-size: 20px;
color: #409eff;
position: relative;
margin-bottom: 30px;
margin-top: 30px;
margin :15px 0;
display: inline-block;
left: -15px;
}
......@@ -969,6 +968,7 @@ export default {
.setting-left {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 15px 30px;
background-color: white;
......@@ -981,8 +981,8 @@ export default {
}
.bottom-info {
padding: 15px 0;
margin-top: 20px;
padding: 5px 0;
margin-top: 10px;
font-size: 14px;
justify-content: space-between;
border-top: 1px solid #ececec;
......@@ -1080,6 +1080,9 @@ export default {
justify-content: center;
}
}
::v-deep .el-form-item{
margin-bottom: 9px;
}
</style>
<style>
.my-popper {
......
......@@ -9,12 +9,10 @@ export default {
data() {
return {
user: {},
company: {}
};
},
mounted() {
this.user = this.$dataStore.get("user");
this.company = this.$dataStore.get("company");
this.$refs.updateDialog.checkUpdate().then(data => {
if (data) {
// 有新版本更新
......@@ -27,7 +25,7 @@ export default {
<template>
<div class="page">
<p-head :company="company" :user="user" />
<p-head :user="user" />
<p-main />
<update-dialog ref="updateDialog" />
</div>
......
......@@ -41,7 +41,6 @@ export default {
item: {
handler() {
if (this.item) {
let setting = this.$dataStore.get("setting");
this.item.y = (this.item.y - this.item.h / 2);
this.item.x = (this.item.x - this.item.w / 2);
......@@ -139,7 +138,7 @@ export default {
</script>
<template>
<div class="drawer" :style="{animation:`ltr-drawer-in .3s 1ms`}" v-show="visible">
<div class="drawer" :style="{animation:`ltr-drawer-in .3s 1ms`}">
<div class="title">
图片编辑
</div>
......@@ -246,6 +245,7 @@ export default {
</el-row>
</el-form>
</div>
<slot></slot>
</div>
</template>
......@@ -299,6 +299,8 @@ export default {
position: fixed;
border-right: 1px solid #ececec;
height: calc(100vh - 50px);
display: flex;
flex-direction: column;
//animation: ltr-drawer-in .3s 1ms;
.title {
padding-bottom: 10px;
......
......@@ -82,7 +82,7 @@ export default {
selectImgList: [],
bus: 0,
grid,
showImgSetting: false,
showImgSetting: true,
printDialogShow: true,
parentHeight: 0,
width: 0,
......@@ -259,6 +259,8 @@ export default {
},
selectImg(it, i) {
// this.selectImgIndexList.push(i)
let item = this.imgList.find(img=>img.fileName===it.fileName)
if(item) return
// this.selectImgIndexList = Array.from(new Set(this.selectImgIndexList))
this.getBackFile([it], file => {
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
......@@ -635,17 +637,6 @@ export default {
<div class="page-main">
<div @click="outsideClick" class="main-bg">
<div class="container">
<div class="select-img" v-if="selectImgList.length > 1">
<div
@click="selectImg(it, i)"
v-for="(it, i) in selectImgList"
:key="i"
class="img-item"
>
<img style="width: 100px;height: auto;" :src="it.productionFile" />
<span>{{ it.designId }}</span>
</div>
</div>
<div :style="{ height: imgHeight }" id="img">
<div id="line">
<div
......@@ -738,8 +729,19 @@ export default {
@change="formChange"
:item="returnItem"
@close="close"
:visible="showImgSetting"
>
<div class="select-img" v-if="selectImgList.length">
<div
@click="selectImg(it, i)"
v-for="(it, i) in selectImgList"
:key="i"
class="img-item"
>
<img style="width: 140px;height: auto;" :src="it.productionFile" />
<span>{{ it.designId }}</span>
</div>
</div>
</img-setting>
</div>
</template>
......@@ -870,18 +872,12 @@ export default {
}
.select-img {
border-color: #409eff;
width: 120px;
z-index: 5;
border: 1px solid #ececec;
width: 100%;
overflow: auto;
background-color: gray;
height: calc(100% - 72px);
height: calc(100% - 251px);
padding: 10px;
position: fixed;
box-sizing: border-box;
left: 0;
bottom: 0;
border-right: 1px solid #ececec;
}
img {
......@@ -910,8 +906,9 @@ img {
justify-content: center;
span {
font-size: 14px;
margin: 5px 0;
color: white;
color: black;
}
}
......
......@@ -91,7 +91,7 @@ export default {
console.log("开始下载");
if (this.item.fullUpdate) {
// 全量更新
const domain = "https://" + this.$dataStore.get("company").domain;
const domain = "https://console.jomalls.com";
this.item.url =
domain + this.item.fileList[0].versionPath.replace("/data", "");
console.log(this.item.url);
......
......@@ -3,43 +3,26 @@ export default {
data() {
return {
rules: {
company: [
{ validator:this.validatePass, message: "请检查客户名称", required: true, trigger: "blur" },
factoryCode: [
{ message: "请输入工厂编码", required: true, trigger: "blur" }
],
loginName: [
{ message: "请输入用户名", required: true, trigger: "blur" },
],
password: [{ message: "请输入密码", required: true, trigger: "blur" }],
account: [{ message: "请输入账号", required: true, trigger: "blur" }],
password: [{ message: "请输入密码", required: true, trigger: "blur" }]
},
companyList: [],
userList: [],
company: null,
authorityVisible: false,
remember: true,
authorityForm: {},
form: {
loginName: "",
user: "",
company: "",
password: "",
},
factoryCode: "",
account: "",
password: ""
}
};
},
created() {
// this.len = Object.keys(this.$dataStore.store).length
console.log(this.$dataStore, "this.$dataStore");
// this.$dataStore.set('console_deviceId_Zhe Wang','920d79c4748c2a3c4111fb878ffe44a2')
this.company = this.$dataStore.get("company");
this.userList = this.$dataStore.get("userList") || [];
if (this.company) {
this.form.company = this.company.domain.replace('.jomalls.com','');
}
// if (user) {
// return this.$router.push('/design')
// }
this.getCompanyList();
this.userList = this.$dataStore.get('userList') || []
},
mounted() {
document.addEventListener("keyup", this.keyUp);
......@@ -49,100 +32,26 @@ export default {
},
methods: {
keyUp(e) {
console.log(e);
if (e.keyCode === 13) {
this.login();
}
},
submitAuthority() {
this.$refs.authorityForm.validate((v) => {
if (v) {
this.$api
.post(
"/commitApply",
{
...this.authorityForm,
...this.form,
},
{
headers: {
company: this.form.company +'.jomalls.com',
},
}
)
.then((res) => {
if (res.code === 200) {
this.authorityVisible = false;
this.$message.success("申请提交成功");
this.$dataStore.set(
this.form.company + "_deviceId_" + this.form.loginName,
res.data.id
);
}
});
}
});
},
validatePass(rule, value, callback) {
if (!value || value === "") {
return callback(new Error("请输入客户(例如demo)"));
}
let item = this.companyList.find(
(item) => item.domain.replace(".jomalls.com", "") === value
);
if (item) {
return callback();
} else {
return callback(new Error("未查找到该客户"));
}
},
async login() {
// if (this.form.auth) {
// this.$dataStore.set(this.form.auth.split(",")[0], this.form.auth.split(",")[1]);
// console.log("存储成功");
// console.log(this.$dataStore.store);
//
// }
this.$refs.formRef.validate(async (valid) => {
this.$refs.formRef.validate(async valid => {
if (valid) {
let f = JSON.parse(JSON.stringify(this.form));
if (!f.deviceId) {
f.deviceId = this.$dataStore.get(
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;
let { data, code, message } = await this.$api.post("/login", f);
if (code === 411) {
this.authorityVisible = true;
this.authorityForm = {};
return this.$message.error(message);
}
data = {
...data.sysUser,
...{
token: data.token,
},
};
delete data.sysMenus;
delete data.sysUser;
let item = this.companyList.find((item) => item.domain === f.company);
console.log(item, 111222);
this.$dataStore.set("user", data);
this.$dataStore.set("company", item);
console.log( this.$dataStore);
let { data } = await this.$api.post("/login", f);
this.$dataStore.set("user", { ...data.sysUser,...{token:data.token} });
console.log(this.$dataStore);
if (this.remember) {
let userList = this.$dataStore.get("userList");
if (userList) {
if (
!userList.find(
(el) =>
el.loginName === f.loginName && el.company === f.company
el =>
el.account === f.account && el.factoryCode === f.factoryCode
)
) {
userList.push(f);
......@@ -158,21 +67,11 @@ export default {
});
},
userChange(v) {
if (v === "") {
this.form.deviceId = "";
return;
}
console.log(this.userList, v);
this.form.company = this.userList[v].company.replace('.jomalls.com','');
this.form.loginName = this.userList[v].loginName;
this.form.account = this.userList[v].account;
this.form.factoryCode = this.userList[v].factoryCode;
this.form.password = this.userList[v].password;
this.form.deviceId = this.userList[v].deviceId;
},
async getCompanyList() {
let { data } = await this.$api.get("/getCompanyList");
this.companyList = data.records;
},
},
}
}
};
</script>
......@@ -195,45 +94,24 @@ export default {
<el-option
v-for="(it, i) in userList"
:key="i"
:label="`${it.loginName}(${it.company.split('.')[0]})`"
:label="`${it.account}(${it.factoryCode})`"
:value="i"
></el-option>
</el-select>
</el-form-item>
<el-form-item v-if="!company" prop="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-select>-->
<el-input placeholder="客户(例如demo)" prefix-icon="el-icon-monitor" v-model="form.company"
clearable>
<template #append>
.jomalls.com
</template>
</el-input>
<!-- <el-select-->
<!-- filterable-->
<!-- style="width: 100%"-->
<!-- placeholder="系统"-->
<!-- v-model="form.company"-->
<!-- clearable-->
<!-- >-->
<!-- <template slot="prefix">-->
<!-- <i class="el-icon-monitor"></i>-->
<!-- </template>-->
<!-- <el-option-->
<!-- v-for="(it, i) in companyList"-->
<!-- :key="i"-->
<!-- :label="it.companyName"-->
<!-- :value="it.domain"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<el-form-item prop="factoryCode">
<el-input
placeholder="工厂编码"
prefix-icon="el-icon-s-shop"
v-model="form.factoryCode"
clearable
></el-input>
</el-form-item>
<el-form-item prop="loginName">
<el-form-item prop="account">
<el-input
placeholder="用户名"
placeholder="账号"
prefix-icon="el-icon-user"
v-model="form.loginName"
v-model="form.account"
clearable
></el-input>
</el-form-item>
......@@ -247,10 +125,6 @@ export default {
clearable
></el-input>
</el-form-item>
<!-- <el-form-item v-if="len===0" prop="授权信息">-->
<!-- <el-input placeholder="授权信息" prefix-icon="el-icon-lock" v-model="form.auth"-->
<!-- clearable></el-input>-->
<!-- </el-form-item>-->
<div class="check">
<el-checkbox v-model="remember">记住账号</el-checkbox>
</div>
......@@ -267,41 +141,6 @@ export default {
</el-form-item>
</el-form>
</div>
<el-dialog
:close-on-click-modal="false"
title="权限申请"
:visible.sync="authorityVisible"
top="15%"
width="400px"
>
<el-form
:model="authorityForm"
size="mini"
ref="authorityForm"
label-width="80px"
>
<el-form-item label="设备名称" prop="deviceName" required>
<el-input v-model="authorityForm.deviceName"></el-input>
</el-form-item>
<el-form-item label="授权类型" prop="authType" required>
<el-radio v-model="authorityForm.authType" label="1">
一次授权
</el-radio>
<el-radio v-model="authorityForm.authType" label="2">
永久授权
</el-radio>
</el-form-item>
</el-form>
<span slot="footer">
<el-button size="mini" @click="authorityVisible = false">
取 消
</el-button>
<el-button size="mini" type="primary" @click="submitAuthority">
提交
</el-button>
</span>
</el-dialog>
</div>
</template>
......
......@@ -106,6 +106,10 @@ module.exports = {
{
from: "./logs/",
to: "../logs"
},
{
from: "./config/",
to: "../config"
}
]
}
......
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