Commit 536cb79c by 李伟康

feat(dailyNewspaper): 实现日报详情页面功能

- 添加员工日报详情页面的完整UI组件和数据展示逻辑
- 实现门店日报详情页面的表格展示和动态数据渲染功能
- 集成Table和Nothing组件用于数据展示和空状态处理
- 添加数据格式化和分组显示功能,支持不同类型的字段展示
- 实现滚动容器和响应式布局样式
- 添加数据监听和条件渲染逻辑,优化用户体验
1 parent 22df53af
<template> <template>
<div> <view class="daily-report">
详情 <view class="common-title">
</div> 基础信息
</view>
<view class="content">
<template v-if="loadComplete">
<template v-if="list.length">
<template v-for="(item, index) in list">
<template v-if="item.type == 'group'">
<view
class="group-box"
:key="`group-${index}`"
>
<view class="group-title">{{ item.label }}</view>
<view class="group-list">
<template v-for="(child, childIndex) in item.children">
<view class="item" :key="`child-${childIndex}`">
<view class="label">{{ child.label }}</view>
<view class="value">{{ formatValue(child.value) }}</view>
</view>
</template>
</view>
</view>
</template>
<template v-else>
<view
:class="['item',{ 'before-divider': isFollowedByGroup(index)},{'frist': index === 0}]"
:key="`item-${index}`"
>
<view class="label">{{ item.label }}</view>
<view class="value">{{ formatValue(item.value) }}</view>
</view>
</template>
</template>
</template>
<nothing v-else />
</template>
</view>
</view>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
export default { import Table from '../components/Table'
name: '', import Nothing from '../components/Nothing'
export default {
components: { Table, Nothing },
name: 'detail',
props: {
templateData: {
type: Array,
default: () => []
}
},
data () { data () {
return { return {
loadComplete: false,
list: []
} }
}, },
watch: {
templateData: {
handler (newVal) {
if (newVal.length) this.formatData(newVal)
else {
this.list = []
this.loadComplete = true
}
},
immediate: true,
deep: true
}
},
computed: {
},
mounted () { mounted () {
}, },
methods: { methods: {
isFollowedByGroup(index) {
const prevItem = this.list[index + 1];
return prevItem && prevItem.type === 'group';
},
formatValue (value) {
return value != null ? value : '-'
},
formatData (list) {
console.log(list)
// list.map(item => {
// let columns = [],
// dataList = [],
// values = {}
// if (item.children && item.children.length) {
// item.children.map((child, index) => {
// child.map(k => {
// if (!values[k.key]) values[k.key] = []
// values[k.key].push(k.value)
// })
// columns.push({ title: `数据${index + 1}` })
// })
// let rowData = item.children[0] || []
// rowData.map(row => {
// dataList.push({
// rowHeader: row.label,
// data: values[row.key]
// })
// })
// }
// item.columns = columns
// item.dataList = dataList
// })
this.list = list
this.loadComplete = true
} }
} }
}
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.daily-report {
height: 100%;
position: relative;
.content {
height: calc(100% - #{toRpx(120)});
overflow-y: auto;
padding: 0 48rpx 32rpx;
box-sizing: border-box;
}
.divider {
color: #333333;
font-size: 32rpx;
font-weight: 500;
line-height: 48rpx;
margin-bottom: 24rpx;
padding-top: 16rpx;
}
.item {
display: flex;
align-items: flex-start;
gap: 32rpx;
background-color: #fff;
box-sizing: border-box;
padding: 0 32rpx 16rpx;
font-size: 28rpx;
font-weight: 400;
color: #333333;
.label,
.value {
width: calc(50% - #{toRpx(16)});
}
.label {
color: #999999;
}
}
.item.before-divider {
padding-bottom: 28rpx;
border-radius: 0 0 16rpx 16rpx;
}
.frist{
padding-top: 28rpx;
border-radius: 16rpx 16rpx 0 0;
}
.group-box {
width: 100%;
margin-top: 16rpx;
.group-title {
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
padding: 16rpx 0 24rpx;
}
.group-list{
display: flex;
flex-direction: column;
gap: 12rpx;
border-radius: 16rpx;
background: #fff;
padding: 28rpx 32rpx;
.item{
padding: 0;
}
}
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div> <view class="daily-report">
门店详情 <view class="common-title">
</div> 基础信息
</view>
<view class="content">
<template v-if="loadComplete">
<template v-if="list.length">
<template v-for="(item, index) in list">
<template v-if="item.type == 'subform'">
<view
class="list-box"
:key="`subform-${index}`"
>
<view class="list-title">{{ item.label }}</view>
<Table
:columns="item.columns"
:data="item.dataList"
tableStyle="padding-right:32rpx"
cornerText="门店日报内容项"
/>
</view>
</template>
<template v-else-if="item.type == 'divider'">
<view
class="divider"
:key="`divider-${index}`"
>{{ item.label }}</view>
</template>
<template v-else>
<view
:class="['item',{ 'before-divider': isFollowedByDivider(index) || isFollowedBySubform(index)},{'frist': index === 0}]"
:key="`item-${index}`"
>
<view class="label">{{ item.label }}</view>
<view class="value">{{ formatValue(item.value) }}</view>
</view>
</template>
</template>
</template>
<nothing v-else />
</template>
</view>
</view>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
export default { import Table from '../components/Table'
name: '', import Nothing from '../components/Nothing'
export default {
components: { Table, Nothing },
name: 'detail',
props: {
templateData: {
type: Array,
default: () => []
}
},
data () { data () {
return { return {
loadComplete: false,
list: []
} }
}, },
watch: {
templateData: {
handler (newVal) {
if (newVal.length) this.formatData(newVal)
else {
this.list = []
this.loadComplete = true
}
},
immediate: true,
deep: true
}
},
computed: {
},
mounted () { mounted () {
}, },
methods: { methods: {
isFollowedByDivider(index) {
const nextItem = this.list[index + 1];
return nextItem && nextItem.type === 'divider';
},
isFollowedBySubform(index) {
const prevItem = this.list[index + 1];
return prevItem && prevItem.type === 'subform';
},
formatValue (value) {
return value != null ? value : '-'
},
formatData (list) {
console.log(list)
list.map(item => {
let columns = [],
dataList = [],
values = {}
if (item.children && item.children.length) {
item.children.map((child, index) => {
child.map(k => {
if (!values[k.key]) values[k.key] = []
values[k.key].push(k.value)
})
columns.push({ title: `数据${index + 1}` })
})
let rowData = item.children[0] || []
rowData.map(row => {
dataList.push({
rowHeader: row.label,
data: values[row.key]
})
})
}
item.columns = columns
item.dataList = dataList
})
this.list = list
this.loadComplete = true
} }
} }
}
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.daily-report {
height: 100%;
position: relative;
.content {
height: calc(100% - #{toRpx(120)});
overflow-y: auto;
padding: 0 48rpx 32rpx;
box-sizing: border-box;
}
.divider {
color: #333333;
font-size: 32rpx;
font-weight: 500;
line-height: 48rpx;
margin-bottom: 24rpx;
padding-top: 16rpx;
}
.item {
display: flex;
align-items: flex-start;
gap: 32rpx;
background-color: #fff;
box-sizing: border-box;
padding: 0 32rpx 16rpx;
font-size: 28rpx;
font-weight: 400;
color: #333333;
.label,
.value {
width: calc(50% - #{toRpx(16)});
}
.label {
color: #999999;
}
}
.item.before-divider {
padding-bottom: 28rpx;
border-radius: 0 0 16rpx 16rpx;
}
.divider + .item ,.frist{
padding-top: 28rpx;
border-radius: 16rpx 16rpx 0 0;
}
.list-box {
// position: absolute;
width: 100%;
border-radius: 16rpx;
background: #fff;
padding: 0 0 32rpx 32rpx;
overflow-x: auto;
margin-top: 16rpx;
.list-title {
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
padding: 32rpx 0 24rpx;
}
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!