代码暂存,

main
wangqiujuan0808 2024-03-23 14:37:08 +08:00
parent 2f1a032818
commit e906a05cd5
1 changed files with 127 additions and 112 deletions

View File

@ -4,16 +4,17 @@
<el-card>
<div>
<el-button type="primary" @click="router.push('home')"></el-button>
<el-button type="success">项目预览</el-button>
<el-button type="success" @click="saveProject"></el-button>
</div>
<div>
<el-button type="primary" class="add-btn" :icon="Plus" @click="addRoom"></el-button>
<el-button type="primary" class="add-btn" :icon="Plus" @click="add_room"></el-button>
</div>
<div class="room-list">
<div v-for="(item, index) in project.content" :key="index" class="room-span">
<div v-for="(item, index) in project.content" :key="index" class="room-span" @click="select_room(item)"
: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 />
<el-button type="danger" :icon="Delete" circle @click="delet_room(item)"/>
</div>
</div>
</el-card>
@ -23,15 +24,12 @@
<div class="flex-center bar">
<div class="div300">
<span>房型名称</span>
<el-select v-model="form.roomName" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-input v-model="currentRoom.room_name" placeholder="请输入房型名称" />
</div>
<div class="div300">
<span>房型数量</span>
<el-input-number v-model="form.num100" :min="1" :max="10" label="描述文字"></el-input-number>
<el-input-number v-model="currentRoom.room_count" :min="1" :max="10"
label="描述文字"></el-input-number>
</div>
</div>
</div>
@ -41,7 +39,7 @@
<div v-for="(item, i) in lightArr" :key="item.label">
<p>{{ item.label }}</p>
<p>
<el-input-number v-model="form.num100" :min="1" :max="100"></el-input-number>
<el-input-number v-model="currentRoom.lightInfo" :min="1" :max="100"></el-input-number>
</p>
</div>
</div>
@ -50,22 +48,22 @@
<span class="name name3">空调信息</span>
<div class="flex-center bar">
<div>盘管类型</div>
<el-radio-group v-model="form.type1">
<el-radio :label="item.value" :key="item.value"
v-for="(item, index) in radioGroup1">{{ item.label }}</el-radio>
<el-radio-group v-model="currentRoom.type1">
<el-radio :label="item.value" :key="item.value" v-for="(item, index) in radioGroup1">{{ item.label
}}</el-radio>
</el-radio-group>
<el-radio-group v-model="form.type2">
<el-radio :label="item.value" :key="item.value"
v-for="(item, index) in radioGroup2">{{ item.label }}</el-radio>
<el-radio-group v-model="currentRoom.type2">
<el-radio :label="item.value" :key="item.value" v-for="(item, index) in radioGroup2">{{ item.label
}}</el-radio>
</el-radio-group>
<el-radio-group v-model="form.type3">
<el-radio :label="item.value" :key="item.value"
v-for="(item, index) in radioGroup3">{{ item.label }}</el-radio>
<el-radio-group v-model="currentRoom.type3">
<el-radio :label="item.value" :key="item.value" v-for="(item, index) in radioGroup3">{{ item.label
}}</el-radio>
</el-radio-group>
<div>
<p>温控器数量</p>
<p>
<el-input-number v-model="form.num1" :min="1" :max="100"></el-input-number>
<el-input-number v-model="currentRoom.num1" :min="1" :max="100"></el-input-number>
</p>
</div>
</div>
@ -74,20 +72,20 @@
<span class="name name4">面板信息</span>
<div class="flex-center bar">
<div>面板类型</div>
<el-radio-group v-model="form.type4">
<el-radio :label="item.value" :key="item.value"
v-for="(item, index) in radioGroup4">{{ item.label }}</el-radio>
<el-radio-group v-model="currentRoom.type4">
<el-radio :label="item.value" :key="item.value" v-for="(item, index) in radioGroup4">{{ item.label
}}</el-radio>
</el-radio-group>
<div>
<p>面板数量</p>
<p>
<el-input-number v-model="form.mbnum" :min="1" :max="100"></el-input-number>
<el-input-number v-model="currentRoom.mbnum" :min="1" :max="100"></el-input-number>
</p>
</div>
<div>
<p>按钮数量</p>
<p>
<el-input-number v-model="form.btnnum" :min="1" :max="100"></el-input-number>
<el-input-number v-model="currentRoom.btnnum" :min="1" :max="100"></el-input-number>
</p>
</div>
</div>
@ -96,20 +94,20 @@
<span class="name name5">窗帘信息</span>
<div class="flex-center bar">
<div>窗帘类型</div>
<el-radio-group v-model="form.type5">
<el-radio :label="item.value" :key="item.value"
v-for="(item, index) in radioGroup5">{{ item.label }}</el-radio>
<el-radio-group v-model="currentRoom.type5">
<el-radio :label="item.value" :key="item.value" v-for="(item, index) in radioGroup5">{{ item.label
}}</el-radio>
</el-radio-group>
<div>
<p>窗帘数量</p>
<p>
<el-input-number v-model="form.chlnum" :min="1" :max="100"></el-input-number>
<el-input-number v-model="currentRoom.chlnum" :min="1" :max="100"></el-input-number>
</p>
</div>
<div>
<p>窗纱数量</p>
<p>
<el-input-number v-model="form.chshnum" :min="1" :max="100"></el-input-number>
<el-input-number v-model="currentRoom.chshnum" :min="1" :max="100"></el-input-number>
</p>
</div>
</div>
@ -121,12 +119,12 @@
<div v-for="(item, i) in otherArr" :key="item.label">
<p>{{ item.label }}</p>
<p>
<el-input-number v-model="form.num101" :min="1" :max="100"></el-input-number>
<el-input-number v-model="currentRoom['otherNum'+ item.value]" :min="1" :max="100"></el-input-number>
</p>
</div>
</div>
<el-checkbox-group v-model="form.checkone" class="rules-label">
<el-checkbox-group v-model="currentRoom.checkone" class="rules-label">
<el-checkbox v-for="(item, i) in checkList" :label="item.label" :key="item.value"
:value="item.value">
{{ item.label }}
@ -139,7 +137,7 @@
<span class="name name7">备注</span>
<div class="con-div100">
<div class="flex-center bar">
<el-input type="textarea" v-model="form.desc"></el-input>
<el-input type="textarea" v-model="currentRoom.desc"></el-input>
</div>
</div>
</div>
@ -162,6 +160,34 @@ const project = reactive({
description: "",
content: [],
});
const room_info = reactive({
room_name: '',
room_count: 1,
lightInfo: 1, //
type1: 0,//
type2: 0,
type3: 0,
num1: 1, //
type4: 0,//
type5: 0,//
mbnum: 0,//
btnnum: 0,//
chlnum: 0,//
chshnum: 0,//
checkone: [0,1],//
desc: '', // ,
otherNum0: 1,
otherNum1: 1,
otherNum2: 1,
otherNum3: 1,
otherNum4: 1
})
var currentRoom = reactive(room_info);
const get_project = async () => {
const param = {
action: 100,
@ -175,7 +201,10 @@ const get_project = async () => {
project.description = res.data.description;
if (Array.isArray(res.data.content)) {
project.content = res.data.content;
} else {
add_room();
}
select_room(project.content[0]);
} else {
ElMessage({
message: res.message,
@ -183,153 +212,134 @@ const get_project = async () => {
});
}
}
const delet_room = (item) => {
get_project();
}
onMounted(() => {
get_project();
if (project.content.length ===0) {
add_room();
}
});
const room_info = reactive({
room_name: '',
room_count: 1,
})
const select_room = (item) => {
currentRoom = item;
console.log(123, currentRoom);
}
const add_room = () => {
if (!Array.isArray(project.content)) {
project.content = []
}
room_info.room_name = "房型" + (project.content.length + 1);
room_info.room_count = 1;
project.content.push(room_info)
project.content.push(room_info);
console.log(1, project.content);
}
const saveProject = async () => {
const param = {
action: 102,
data: {
...project,
new_name: project.name
},
}
const res = await myApi.getProjects(param);
console.log(res);
if (res.code === 0) {
ElMessage({
message: "更新成功",
type: "success",
});
get_project();
} else {
ElMessage({
message: res.message + '[' + res.data + ']',
type: "warning",
});
}
}
const room_data = usrRoomStore();
const new_room = reactive({
name: '房型A',
number: 55,
})
const options = reactive([{
label: '房型A',
value: 1,
}, {
label: '房型B',
value: 2,
}])
const form = reactive({
roomName: options[0].value,
num1: 1,
num100: 1,
num101: 1,
type1: 0,
type2: 0,
type3: 0,
type4: 0,
type5: 0,
mbnum: 0,
btnnum: 0,
chlnum: 0,
chshnum: 0,
checkone: [],
desc: ''
})
const lightArr = reactive([{
label: '开关回路',
value: 1,
value: 0,
}, {
label: '0-10V调光',
value: 2,
value: 1,
}, {
label: '前沿调光',
value: 3,
value: 2,
}, {
label: '后沿调光',
value: 4,
value: 3,
}, {
label: 'DALI灯',
value: 5,
value: 4,
}])
const otherArr = reactive([{
label: '红外',
value: 1,
value: 0,
}, {
label: '双鉴红外',
value: 2,
value: 1,
}, {
label: '门磁',
value: 3,
value: 2,
}, {
label: '窗磁',
value: 4,
value: 3,
}, {
label: '门铃',
value: 5,
value: 4,
}])
const radioGroup1 = reactive([{
label: '普通三速风机',
value: 1,
value: 0,
}, {
label: '直流无刷风机',
value: 2,
value: 1,
}, {
label: '三方协议风机',
value: 3,
value: 2,
}])
const radioGroup2 = reactive([{
label: '两管制',
value: 4,
value: 0,
}, {
label: '四管制',
value: 5,
value: 1,
}])
const radioGroup3 = reactive([{
label: '两通阀',
value: 6,
value: 0,
}, {
label: '调节阀',
value: 7,
value: 1,
}])
const radioGroup4 = reactive([{
label: '普通面板(无背光)',
value: 8,
value: 0,
}, {
label: '普通面板(带背光)',
value: 9,
value: 1,
}, {
label: '协议面板',
value: 10,
}])
const radioGroup5 = reactive([{
label: '干接点电机',
value: 11,
value: 0,
}, {
label: '485电机',
value: 12,
value: 1,
}])
const checkList = reactive([{
label: 'DND',
value: 11,
value: 0,
}, {
label: 'MUR',
value: 12,
value: 1,
}, {
label: 'SOS',
value: 13,
value: 2,
}])
const addRoom = () => {
room_data.list.push({
name: new_room.name,
number: new_room.number,
});
}
const check = () => {
}
</script>
<style lang="scss" scoped>
.room-div {
@ -361,6 +371,7 @@ const check = () => {
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
>span {
width: 30%;
@ -500,5 +511,9 @@ const check = () => {
}
}
.selectDiv {
background: #409eff;
color: #fff;
}
</style>
}</style>