物机管理配置页面开发

dev_xd
lj7788@126.com 2025-07-11 12:13:06 +08:00
parent b668ef41c6
commit f4cfbec7df
3 changed files with 182 additions and 2 deletions

View File

@ -0,0 +1,43 @@
//物机配置
import request from '@/utils/request'
export function addCfg(data){
return request({
url: '/manage/api/project/machmater/addCfg',
method: 'post',
data: {
vo:data
}
})
}
export function updateCfg(data){
return request({
url: '/manage/api/project/machmater/updateCfg',
method: 'post',
data: {
vo:data
}
})
}
export function deleteCfg(id){
return request({
url: '/manage/api/project/machmater/deleteCfg',
method: 'get',
params: {
id: id
}
})
}
export function listCfg(projectId,cfgType){
return request({
url: '/manage/api/project/machmater/listCfg',
method: 'get',
params: {
projectId: projectId,
cfgType: cfgType
}
})
}

View File

@ -5,7 +5,7 @@
<nav-top-att-worker-count :attInfo="attInfo" :key="elKey" />
<nav-top-att-online-count :attInfo="attInfo" :key="elKey" />
<nav-top-att-mgr-count :attInfo="attInfo" :key="elKey" />
<nav-top-att-real-count v-if="vendorsCode == 'uni'" :attInfo="attInfo" :key="elKey" />
<nav-top-att-real-count :attInfo="attInfo" :key="elKey" />
</el-card>
<el-card class="nav-body" style="margin-top: 20px">
@ -22,7 +22,7 @@
<el-col :span="8">
<nav-att-laborer-trend />
</el-col>
<el-col :span="8" v-if="vendorsCode == 'uni'">
<el-col :span="8">
<nav-att-woker-prop :attInfo="attInfo" :key="elKey" />
</el-col>
<el-col :span="8">

View File

@ -0,0 +1,137 @@
<template>
<div class="mach-config-index app-container">
<el-card :header="title" style="width: 30%; min-width: 500px">
<el-form :model="form" :rules="rules" label-width="120px" ref="form">
<el-form-item label="用户ID" prop="userId">
<span v-if="mode == 'show'">{{ form.userId }}</span>
<el-input v-else v-model="form.userId" placeholder="请输入用户ID"></el-input>
</el-form-item>
<el-form-item label="配置key" prop="chinaKey">
<span v-if="mode == 'show'">{{ form.chinaKey }}</span>
<el-input v-else v-model="form.chinaKey" placeholder="请输入配置key"></el-input>
</el-form-item>
<el-form-item label="项目ID" prop="prjId">
<span v-if="mode == 'show'">{{ form.prjId }}</span>
<el-input v-else v-model="form.prjId" placeholder="请输入项目ID"></el-input>
</el-form-item>
</el-form>
<template #footer>
<div v-hasPermi="['machmange:config:edit']">
<div v-if="mode == 'show'">
<el-button type="primary" @click="doEdit"></el-button>
</div>
<div v-else>
<el-button type="primary" @click="doSave"></el-button>
<el-button @click="doCancel()"></el-button>
</div>
</div>
</template>
</el-card>
</div>
</template>
<script>
import { listCfg, deleteCfg, updateCfg, addCfg } from "@/api/manage/machConfig";
import useUserStore from "@/store/modules/user";
export default {
data() {
return {
userStore: null,
currentPrjId: null,
currentComId: null,
type: "",
cfgInfo: null,
title: "",
mode: "show",
form: {
userId: "",
chinaKey: "",
prjId: "",
},
rules: {
userId: {
required: true,
message: "请输入用户ID",
trigger: "blur",
},
chinaKey: {
required: true,
message: "请输入配置key",
trigger: "blur",
},
prjId: {
required: true,
message: "请输入项目ID",
trigger: "blur",
},
},
};
},
mounted() {
this.type = this.$route.query.type || "mach";
this.userStore = useUserStore();
this.currentPrjId = this.userStore.currentPrjId;
this.currentComId = this.userStore.currentComId;
this.title = this.type == "mach" ? "机械管理配置" : "材料管理配置";
this.doCancel(() => {
if (!this.cfgInfo) {
this.doEdit();
}
});
},
methods: {
doEdit() {
this.mode = "edit";
this.form.userId = this.cfgInfo?.userId || "";
this.form.chinaKey = this.cfgInfo?.chinaKey || "";
this.form.prjId = this.cfgInfo?.prjId || "";
},
doSave() {
this.$refs.form.validate().then((valid) => {
if (valid) {
let data = {
comId: this.currentComId,
projectId: this.currentPrjId,
cfgType: this.type,
userId: this.form.userId,
chinaKey: this.form.chinaKey,
prjId: this.form.prjId,
remark: "",
state: 0,
};
if (this.cfgInfo && this.cfgInfo.id) {
data.id = this.cfgInfo.id;
updateCfg(data).then((d) => {
this.$message({
message: "修改成功",
type: "success",
});
this.doCancel();
});
} else {
addCfg(data).then((d) => {
this.$message({
message: "新增成功",
type: "success",
});
this.doCancel();
});
}
}
});
},
doCancel(cb) {
this.mode = "show";
listCfg(this.currentPrjId, this.type).then((d) => {
this.cfgInfo = d.data.length > 0 ? d.data[0] : null;
this.form.userId = this.cfgInfo?.userId || "未配置";
this.form.chinaKey = this.cfgInfo?.chinaKey || "未配置";
this.form.prjId = this.cfgInfo?.prjId || "未配置";
cb && cb();
});
},
},
};
</script>
<style lang="mach-config-index"></style>