增加房间
parent
186de06aad
commit
426393d7d7
|
@ -10,7 +10,6 @@
|
||||||
<el-card class="card-div" v-for="(item, index) in projects" :key="index">
|
<el-card class="card-div" v-for="(item, index) in projects" :key="index">
|
||||||
<p>{{ item.name }}</p>
|
<p>{{ item.name }}</p>
|
||||||
<p>{{ item.description }}</p>
|
<p>{{ item.description }}</p>
|
||||||
<p>{{ item.content }}</p>
|
|
||||||
<el-button type="primary" @click="router.push({ name: 'room', query: { project_name: item.name }})">管理</el-button>
|
<el-button type="primary" @click="router.push({ name: 'room', query: { project_name: item.name }})">管理</el-button>
|
||||||
<el-button type="success" @click="openUpdateDialog(item)">编辑</el-button>
|
<el-button type="success" @click="openUpdateDialog(item)">编辑</el-button>
|
||||||
<el-button type="danger" @click="openRemove(item)">删除</el-button>
|
<el-button type="danger" @click="openRemove(item)">删除</el-button>
|
||||||
|
@ -98,7 +97,6 @@ const add_project = async () => {
|
||||||
data: add_project_info,
|
data: add_project_info,
|
||||||
}
|
}
|
||||||
const res = await myApi.getProjects(param);
|
const res = await myApi.getProjects(param);
|
||||||
console.log(res);
|
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "新增成功",
|
message: "新增成功",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<div class="room-div">
|
<div class="room-div">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div>
|
<div>
|
||||||
<el-button type="primary" @click="router.push('home')">项目管理</el-button>
|
<el-button type="primary" @click="goHome">项目管理</el-button>
|
||||||
<el-button type="success" @click="saveProject">项目预览</el-button>
|
<el-button type="success" @click="save_room">项目预览</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<el-button type="primary" class="add-btn" :icon="Plus" @click="add_room">新建</el-button>
|
<el-button type="primary" class="add-btn" :icon="Plus" @click="add_room">新建</el-button>
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
:class="{ 'selectDiv': item.room_name === currentRoom.room_name }">
|
:class="{ 'selectDiv': item.room_name === currentRoom.room_name }">
|
||||||
<span>{{ item.room_name }}</span>
|
<span>{{ item.room_name }}</span>
|
||||||
<span>{{ item.room_count }}</span>
|
<span>{{ item.room_count }}</span>
|
||||||
<el-button type="danger" :icon="Delete" circle @click="delet_room(item)"/>
|
<el-button :icon="Delete" circle @click="delet_room(item)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
<div v-for="(item, i) in lightArr" :key="item.label">
|
<div v-for="(item, i) in lightArr" :key="item.label">
|
||||||
<p>{{ item.label }}</p>
|
<p>{{ item.label }}</p>
|
||||||
<p>
|
<p>
|
||||||
<el-input-number v-model="currentRoom.lightInfo" :min="1" :max="100"></el-input-number>
|
<el-input-number v-model="currentRoom['lightNum'+ item.value]" :min="1" :max="100"></el-input-number>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -164,7 +164,11 @@ const project = reactive({
|
||||||
const room_info = reactive({
|
const room_info = reactive({
|
||||||
room_name: '',
|
room_name: '',
|
||||||
room_count: 1,
|
room_count: 1,
|
||||||
lightInfo: 1, // 灯光信息
|
lightNum0: 1, // 开关回路
|
||||||
|
lightNum1: 1,//0-10V调光
|
||||||
|
lightNum2: 1,//前沿调光
|
||||||
|
lightNum3: 1,//后沿调光
|
||||||
|
lightNum4:1, //DALI灯
|
||||||
type1: 0,// 盘管类型
|
type1: 0,// 盘管类型
|
||||||
type2: 0,
|
type2: 0,
|
||||||
type3: 0,
|
type3: 0,
|
||||||
|
@ -196,10 +200,6 @@ const get_project = async () => {
|
||||||
}
|
}
|
||||||
const res = await myApi.getProjects(param);
|
const res = await myApi.getProjects(param);
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
ElMessage({
|
|
||||||
message: res.message,
|
|
||||||
type: "success",
|
|
||||||
});
|
|
||||||
project.name = res.data.name;
|
project.name = res.data.name;
|
||||||
project.description = res.data.description;
|
project.description = res.data.description;
|
||||||
if (Array.isArray(res.data.content)) {
|
if (Array.isArray(res.data.content)) {
|
||||||
|
@ -216,7 +216,15 @@ const get_project = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const delet_room = (item) => {
|
const delet_room = (item) => {
|
||||||
get_project();
|
if(project.content.length === 1) {
|
||||||
|
ElMessage.warning('至少保留一个。。')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
project.content = project.content.filter(ele => {
|
||||||
|
return ele.room_name !== item.room_name;
|
||||||
|
})
|
||||||
|
console.log(123,project);
|
||||||
|
save_room();
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
get_project();
|
get_project();
|
||||||
|
@ -224,24 +232,21 @@ onMounted(() => {
|
||||||
|
|
||||||
const select_room = (item) => {
|
const select_room = (item) => {
|
||||||
currentRoom.value = item;
|
currentRoom.value = item;
|
||||||
console.log(123, currentRoom);
|
|
||||||
}
|
}
|
||||||
const add_room = () => {
|
const add_room = () => {
|
||||||
if (!Array.isArray(project.content)) {
|
if (!Array.isArray(project.content)) {
|
||||||
project.content = []
|
project.content = []
|
||||||
}
|
}
|
||||||
room_info.room_name = "房型" + (project.content.length + 1);
|
let target=JSON.parse(JSON.stringify(room_info));
|
||||||
project.content.push(room_info);
|
target.room_name = "房型" + (project.content.length + 1);
|
||||||
|
project.content.push(target);
|
||||||
console.log(1, project.content);
|
console.log(1, project.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveProject = async () => {
|
const save_room = async () => {
|
||||||
const param = {
|
const param = {
|
||||||
action: 102,
|
action: 1021,
|
||||||
data: {
|
data: project
|
||||||
...project,
|
|
||||||
new_name: project.name
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
const res = await myApi.getProjects(param);
|
const res = await myApi.getProjects(param);
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
@ -259,6 +264,11 @@ const saveProject = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const goHome = () => {
|
||||||
|
save_room();
|
||||||
|
router.push('home');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const lightArr = reactive([{
|
const lightArr = reactive([{
|
||||||
label: '开关回路',
|
label: '开关回路',
|
||||||
|
|
Loading…
Reference in New Issue