Commit 6d04e774 authored by xinzhedeai's avatar xinzhedeai

feature: css代码记过优化

parent d0667754
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewprot-fit:cover">
<title>消防安全检查清单</title>
<script type="text/javascript" src="../sdk/includeHead.js"></script>
</head>
<head>
<style>
/* 基础样式 */
html,
body {
background-color: #fff;
}
/* 通用工具类 */
.pd-01rem {
padding-bottom: 0.1rem;
}
......@@ -40,109 +36,102 @@
width: 4rem;
}
/**
* 框架样式覆盖修改
*/
.van-cell__value {
/* 框架样式覆盖修改 */
.checklist-container .van-cell__value {
overflow: unset;
background-color: #f5f6fa;
}
.van-cell:after {
.checklist-container .van-cell:after {
border-bottom: none;
}
.van-radio-group--horizontal {
float: right;
.checklist-container .van-radio-group--horizontal {
float: left;
}
.checklist-container {
padding: 12px;
background: #fff;
overflow: hidden;
padding-bottom: 1rem;
.checklist-container .van-checkbox {
width: auto;
}
.check-item {
width: 88vw;
padding: 12px;
background: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
.checklist-container .van-checkbox__label,
.checklist-container .van-radio__label {
font-size: 0.28rem;
}
.item-header {
display: flex;
align-items: center;
margin-bottom: 8px;
.checklist-container .van-checkbox__icon,
.checklist-container .van-radio__icon {
font-size: 0.34rem;
background-color: #fff;
}
.item-number {
/* width: 28px;
height: 28px;
line-height: 28px;
text-align: center;
background: #1989fa;
color: white;
border-radius: 50%;
margin-right: 12px; */
.checklist-container .van-radio {
margin-right: 0.8rem;
margin-top: 0.2rem;
}
.expand-section {
width: 77.5vw;
margin-top: 12px;
/* border: 2px solid #000; */
float: left;
.checklist-container .van-cell {
background: #f5f6fa;
padding: 0.4rem;
margin-top: 0.2rem;
padding: 0;
}
.sub-checkbox-group {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
margin: 8px 0;
.checklist-container .van-cell-group {
background-color: #f5f6fa;
}
.uploader-wrapper {
--van-uploader-size: 80px;
.checklist-container textarea {
background-color: #fff !important;
}
.deadline-picker {
display: flex;
gap: 12px;
margin: 12px 0;
.checklist-container .van-uploader__upload {
background-color: #fff;
}
.check-item {
float: left;
.limit_date_wrapper .van-field__label {
width: 1.3rem;
}
.van-radio-group--horizontal {
float: left;
.checklist-container .van-icon-apps-o:before,
.checklist-container .van-icon-fire-o:before {
font-size: 0.32rem;
}
/* 样式优化 */
.checklist-container.item_title {}
/* 检查清单容器 */
.checklist-container {
padding: 12px;
background: #fff;
overflow: hidden;
padding-bottom: 1rem;
}
.checklist-header p {
background-color: rgb(25, 137, 250);
color: rgb(255, 255, 255);
font-size: 0.26rem;
padding: 0.2rem .3rem .2rem;
line-height: .39999rem;
margin: 0;
/* 检查项 */
.check-item {
width: 88vw;
padding: 12px;
background: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
float: left;
}
.checklist-header h5 {
font-size: .32rem;
text-align: center;
.item-header {
display: flex;
align-items: center;
margin-bottom: 8px;
}
.item-number {}
.item-title {
font-size: 0.28rem;
}
.item_title {
font-size: .3rem;
font-size: 0.3rem;
color: #1081E3;
font-weight: bold;
position: relative;
padding-left: .2rem;
padding-left: 0.2rem;
}
.item_title::before {
......@@ -151,60 +140,61 @@
width: 0.05rem;
height: 0.32rem;
background-color: #1081E3;
margin-right: 0.2rem;
position: absolute;
left: 0;
top: 0;
}
.van-checkbox {
width: auto;
}
.van-cell {
/* 展开部分 */
.expand-section {
width: 77.5vw;
margin-top: 12px;
float: left;
background: #f5f6fa;
margin-top: 0.2rem;
padding: 0.4rem;
}
/* 子复选框组 */
.sub-checkbox-group {
display: flex;
flex-wrap: wrap;
gap: .2rem;
}
.van-cell-group {
background-color: #f5f6fa;
}
.van-radio {
margin-right: 0.8rem;
margin-top: .2rem;
gap: 0.2rem;
margin: 8px 0;
}
.van-radio__label {
font-size: 0.28rem;
/* 上传器 */
.uploader-wrapper {
--van-uploader-size: 80px;
}
textarea {
/* background: #f5f6fa !important; */
background-color: #fff !important;
/* 截止日期选择器 */
.deadline-picker {
display: flex;
gap: 12px;
margin: 12px 0;
}
.van-cell__value {
background-color: #f5f6fa;
/* 检查清单头部 */
.checklist-header p {
background-color: rgb(25, 137, 250);
color: rgb(255, 255, 255);
font-size: 0.26rem;
padding: 0.2rem 0.3rem 0.2rem;
line-height: 0.39999rem;
margin: 0;
}
.van-uploader__upload {
background-color: #fff;
.checklist-header h5 {
font-size: 0.32rem;
text-align: center;
}
/* 必填标题 */
.title_require {
position: relative;
padding: 0;
margin: 0;
margin-top: 0.1rem;
/* padding-top: 0.1rem; */
padding-left: 0.2rem;
}
......@@ -213,33 +203,12 @@
content: '*';
color: #ee0a24;
font-size: 0.3rem;
left: 0rem;
left: 0;
top: 50%;
transform: translateY(-50%);
}
.van-cell {
padding: 0;
}
.van-checkbox__label {
font-size: 0.28rem;
}
.van-checkbox__icon,
.van-radio__icon {
font-size: 0.34rem;
background-color: #fff;
}
.limit_date_wrapper .van-field__label {
width: 1.3rem;
}
.item-title {
font-size: 0.28rem;
}
/* 底部栏 */
.bottom_bar {
position: fixed;
bottom: 0;
......@@ -252,15 +221,11 @@
.bottom_bar button {
float: right;
}
.van-icon-apps-o:before,
.van-icon-fire-o:before {
font-size: .32rem;
}
</style>
</head>
</head>
<body>
<body>
<!-- 原 HTML 主体内容保持不变 -->
<div id="app">
<div class="checklist-header">
<p>
......@@ -268,7 +233,6 @@
2.检查人员对管辖范围内企业安全情况负责,需如实上报。
</p>
<h5>九小场所安全检查清单</h5>
</div>
<div class="checklist-container">
<div class="item_title">
......@@ -281,8 +245,7 @@
</div>
<!-- 单选按钮组 -->
<van-radio-group v-model="item.selected" @change="handleSelectionChange(item)"
direction="horizontal">
<van-radio-group v-model="item.selected" @change="handleSelectionChange(item)" direction="horizontal">
<van-radio name="yes"></van-radio>
<van-radio name="no"></van-radio>
<van-radio name="na">不涉及</van-radio>
......@@ -296,23 +259,13 @@
<van-checkbox v-for="(subItem, subIndex) in item.subChecks" :key="subIndex"
v-model="subItem.checked" shape="square">
隐患点{{ subIndex + 1 }}
</van-checkbox>
</div>
<!-- 隐患描述 -->
<!-- <van-field
v-model="item.description"
type="textarea"
rows="2"
placeholder="请填写具体隐患情况"
label="隐患描述"
/> -->
<van-cell-group>
<p style="font-size:0.2rem" class="title_require">请输入隐患描述</p>
<van-field v-model="item.description" type="textarea" rows="1"></van-field>
</van-cell-group>
<!-- 照片上传 -->
......@@ -324,15 +277,8 @@
</div>
</van-cell>
</van-cell-group>
<!-- <van-uploader
style="width: 80px; height:80px;"
v-model="item.photos"
:max-count="3"
:after-read="handleFileUpload"
class="uploader-wrapper"
/> -->
<!-- 整改期限 -->
<van-cell-group>
<van-cell>
<div class="limit_date_wrapper">
......@@ -342,20 +288,12 @@
</div>
</van-cell>
</van-cell-group>
</div>
</div>
</div>
<!-- <div>
<div><span class="title">检查人员</span><span class="content">xxxxxx</span></div>
<div><span class="title">检查人员</span><span class="content">xxxxxx</span></div>
</div> -->
<!-- 底部栏 -->
<div class="bottom_bar">
<div style="display: inline-block;">
<van-icon name="apps-o" color="blue" />
<span
......@@ -367,6 +305,7 @@
<van-button v-show="checkPageIndex<3" type="info" size="small"
@click="checkPageIndex++">下一项</van-button>
</div>
<!-- 整改天数选择器 -->
<van-popup v-model="showDeadlinePicker" position="bottom">
<van-picker :columns="deadlineOptions" @confirm="handleDeadlineConfirm" show-toolbar
......@@ -378,6 +317,7 @@
<script src="https://cdn.jsdelivr.net/npm/vant@2/lib/vant.min.js"></script>
<script>
// 原 JavaScript 代码保持不变
const checkData = [{
id: 1,
title: '消防安全检查',
......@@ -523,54 +463,50 @@
deadlineDate: ''
}],
},
];
]
function countSelectedNo(result) { // 获取 checkList 中 selected 为 'no' 的对象个数
function countSelectedNo(result) {
// 获取 checkList 中 selected 为 'no' 的对象个数
return result.reduce((total, category) => {
return total + category.checkList.filter(item => item.selected === 'no').length;
}, 0);
}
function getTotalCheckListItems(result) { // 获取所有 checkList 子元素的总数
function getTotalCheckListItems(result) {
// 获取所有 checkList 子元素的总数
return result.reduce((total, category) => {
console.log(category, 'category')
console.log(category, 'category');
return total + category.checkList.length;
}, 0);
}
function countSelectedNotNull(result) { // 获取 checkList 中 selected 不为 null 的个数
function countSelectedNotNull(result) {
// 获取 checkList 中 selected 不为 null 的个数
return result.reduce((total, category) => {
return total + category.checkList.filter(item => item.selected !== null).length;
}, 0);
}
// 统计各个状态数量
// 调用方法
const noCount = countSelectedNo(checkData); // selected=no 的个数
const totalItems = getTotalCheckListItems(checkData); // checkList 子元素总数
const notNullCount = countSelectedNotNull(checkData); // selected 不为 null 的个数
// 初始化检查项数据结构
function createCheckItem(id) {
return {
id: id,
title: `检查项目 ${id}`,
selected: null,
subChecks: Array.from({
length: 10
}, (_, i) => ({
subChecks: Array.from({ length: 10 }, (_, i) => ({
id: i + 1,
checked: false
})),
description: '',
photos: [],
deadlineDays: '',
deadlineDate: '',
}
deadlineDate: ''
};
}
new Vue({
......@@ -579,32 +515,25 @@
showDeadlinePicker: false,
deadlineOptions: ['1', '3', '5', '7'],
currentEditingItem: null,
checkList: Array.from({
length: 40
}, (_, i) => createCheckItem(i + 1)),
checkList: Array.from({ length: 40 }, (_, i) => createCheckItem(i + 1)),
checkData, // 提交给后端,图片使用vant结构,base64,后端处理,不走爱山东中台。(数据量大!)
checkPageIndex: 0,
currentItem: null,
noCount,
totalItems,
notNullCount,
notNullCount
},
watch: {
checkData: {
handler(newVal) {
const snapshot = JSON.parse(JSON.stringify(newVal));
// const snapshot = JSON.stringify(newVal);
console.log('全量变化:', snapshot);
this.noCount = countSelectedNo(newVal); // selected=no 的个数
this.totalItems = getTotalCheckListItems(newVal); // checkList 子元素总数
this.notNullCount = countSelectedNotNull(newVal); // selected 不为 null 的个数
},
deep: true
},
}
},
methods: {
navTo1() {
......@@ -612,54 +541,48 @@
url: '_shanghu_detail.html',
title: '高区应急扫描',
isgoback: '0',
success: function(data) {
//成功回调
success: function (data) {
// 成功回调
},
fail: function(data) {
//错误返回
fail: function (data) {
// 错误返回
}
});
},
// 处理单选变化
handleSelectionChange(item) {
if (item.selected !== 'no') {
this.$set(item, 'description', '')
this.$set(item, 'photos', [])
this.$set(item, 'deadlineDays', '')
this.$set(item, 'deadlineDate', '')
this.$set(item, 'description', '');
this.$set(item, 'photos', []);
this.$set(item, 'deadlineDays', '');
this.$set(item, 'deadlineDate', '');
}
},
// 文件上传处理
handleFileUpload(file) {
console.log('上传文件:', file)
console.log('上传文件:', file);
// 此处可添加实际文件上传逻辑
},
// 整改天数确认
handleDeadlineConfirm(value) {
const days = parseInt(value)
// const currentItem = this.checkList.find(
// item => item.selected === 'no' && !item.deadlineDays
// )
const currentItem = this.currentItem
const days = parseInt(value);
const currentItem = this.currentItem;
if (currentItem) {
currentItem.deadlineDays = days
const deadlineDate = new Date()
deadlineDate.setDate(deadlineDate.getDate() + days)
currentItem.deadlineDate = this.formatDate(deadlineDate)
currentItem.deadlineDays = days;
const deadlineDate = new Date();
deadlineDate.setDate(deadlineDate.getDate() + days);
currentItem.deadlineDate = this.formatDate(deadlineDate);
}
this.showDeadlinePicker = false
this.showDeadlinePicker = false;
},
// 日期格式化
formatDate(date) {
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
}
}
})
});
</script>
</body>
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment