update BATCH

Esse commit está contido em:
lb 2023-04-27 16:03:26 +08:00
commit fb29bb7b3d

Ver arquivo

@ -1,6 +1,18 @@
<template>
<InputsArea class="batch-view" title="Batch">
batch view
<el-form ref="form" :model="dataForm" label-width="100px">
<el-form-item v-for="(conf, key) in dataForm" :key="conf.key" :label="label[key]">
<el-input v-if="key !== 'description'" v-model="dataForm[key]" clearable :placeholder="label[key]"></el-input>
<el-select v-else v-model="dataForm[key]">
<el-option v-for="opt in descriptions" :key="opt.label" :label="opt.label" :value="opt.value"></el-option>
</el-select>
</el-form-item>
</el-form>
<div style="float: right">
<el-button type="primary" class="" @click="handleSave" :loading="btnLoading.save">保存设置</el-button>
<el-button type="" class="" @click="handleInit" :loading="btnLoading.init">初始化</el-button>
<el-button type="warning" @click="handleLogin" :loading="btnLoading.login">登录</el-button>
</div>
</InputsArea>
</template>
@ -12,12 +24,196 @@ export default {
components: { InputsArea },
props: {},
data() {
return {};
return {
dataForm: {
ip: "",
upWeight: "",
downWeight: "",
user: "",
password: "",
projecthdl: "",
pcellhdl: "",
description: "",
},
descriptions: [
{ label: "batch主服务器", value: "batch主服务器" },
{ label: "batch备用服务器", value: "batch备用服务器" },
],
label: {
ip: "IP",
upWeight: "混料上限",
downWeight: "混料下限",
user: "用户",
password: "密码",
projecthdl: "projecthdl",
pcellhdl: "pcellhdl",
description: "描述",
},
btnLoading: {
save: false,
init: false,
login: false,
},
initData: [],
activeIndex: 0,
};
},
watch: {
btnLoading: {
handler: (val) => {
if (val) {
document.body.style.cursor = "progress";
} else {
document.body.style.cursor = "unset";
}
},
deep: true,
},
"dataForm.description": function (val) {
console.log("here", val);
if (val === "batch备用服务器") {
this.loadData(0);
} else {
this.loadData(1);
}
},
},
mounted() {
this.loadInit();
},
methods: {
loadData(enabledValue) {
this.activeIndex = this.initData.findIndex((item) => item.enabled === enabledValue);
try {
Object.keys(this.dataForm).forEach((key) => {
this.$set(this.dataForm, key, this.initData[this.activeIndex][key]);
});
} catch (err) {
this.$message({
message: "出错",
type: "error",
duration: 1500,
});
}
},
loadInit() {
this.$http
.get("/pms/batchConstant/page", {
params: {
limit: 20,
page: 1,
},
})
.then(({ data: res }) => {
if (res.code === 0) {
this.initData = res.data.list;
this.loadData(1);
}
});
},
handleInit() {
this.btnLoading.init = true;
const url = "/pms/trans/batchInit";
this.$http.post(url).then(({ data: res }) => {
this.btnLoading.init = false;
if (res.code !== 0) {
this.$message({
message: res.msg,
type: "error",
duration: 1500,
});
return;
}
this.$message({
message: res.msg,
type: "success",
duration: 1500,
});
this.loadInit();
});
},
handleSave() {
this.btnLoading.save = true;
const url = "/pms/batchConstant/saveconfig";
this.$http
.post(
url,
{ ...this.dataForm, id: this.initData[this.activeIndex].id }
// {
// headers: {
// token: "",
// },
// }
)
.then(({ data: res }) => {
this.btnLoading.save = false;
if (res.code !== 0) {
this.$message({
message: res.msg,
type: "error",
duration: 1500,
});
return;
}
this.$message({
message: res.msg,
type: "success",
duration: 1500,
});
this.loadInit();
});
},
handleLogin() {
this.btnLoading.login = true;
const url = "/pms/trans/batchLogin";
this.$http.post(url).then(({ data: res }) => {
this.btnLoading.login = false;
if (res.code !== 0) {
this.$message({
message: res.msg,
type: "error",
duration: 1500,
});
return;
}
this.$message({
message: res.data,
type: "success",
duration: 1500,
});
this.loadInit();
});
},
handleConnectOpc() {
this.btnLoading = true;
const url = "/opcua/addThisPlc";
this.$http
.post(
url,
{ ...this.dataForm },
{
headers: {
token: "",
},
}
)
.then(({ data: res }) => {
this.btnLoading = false;
if (res.code !== 0) {
this.$message({
message: res.msg,
type: "error",
duration: 1500,
});
}
});
},
},
created() {},
mounted() {},
methods: {},
};
</script>
<style scoped></style>
<style scoped>
.batch-view >>> .el-select {
width: 100%;
}
</style>