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