Commit becb0109 by 李伟康

style(dailyNewspaper): 格式化代码以符合团队样式指南

- 统一缩进格式并标准化代码对齐方式
- 简化模板中的属性绑定语法
- 优化长行拆分以提高可读性
- 标准化函数声明语法并移除多余空行
- 优化数组和对象的格式化布局
- 调整CSS样式规则的组织结构
- 规范组件和方法的代码格式
- 统一引号使用和括号位置
- 清理多余的空白字符和空行
- 优化条件语句和循环语句的格式化
- 调整组件属性的换行和对齐方式
1 parent 757affd1
<template> <template>
<view class="detail-box"> <view class="detail-box">
<view class="nav-bar"> <view class="nav-bar">
<view <view class="back" @click="back">
class="back" <uni-icons type="left" :size="20" color="#000"></uni-icons>
@click="back"
>
<uni-icons
type="left"
:size="20"
color="#000"
></uni-icons>
</view> </view>
<view class="title">展业工具</view> <view class="title">展业工具</view>
</view> </view>
<view class="detail-content"> <view class="detail-content">
<view class="detail-left"> <view class="detail-left">
<view class="common-title"> <view class="common-title">
<div :class="['sprite-icon',`icon-${assignIcon || titleIcon}-mini`]"></div> <div :class="['sprite-icon', `icon-${assignIcon || titleIcon}-mini`]"></div>
{{assignTitle || title }} {{ assignTitle || title }}
</view> </view>
<view class="content"> <view class="content">
<image <image class="banner" src="https://img02.glsx.com.cn/weapp/resource/app-tape/common/daily-banner.webp"
class="banner" mode="scaleToFill" />
src="https://img02.glsx.com.cn/weapp/resource/app-tape/common/daily-banner.webp"
mode="scaleToFill"
/>
<view class="calendar"> <view class="calendar">
<uni-calendar <uni-calendar ref="calendar" :clearDate="false" :endDate="endDate" :showMonth="false"
ref="calendar" @monthSwitch="changeMonth" backgroundColor="transparent" :selected="selectedDays" :date="currentDate"
:clearDate="false" :calendarItemStyle="{ width: '84rpx', height: '90rpx' }" openBeforeChange @beforeChange="changeDate" />
:endDate="endDate"
:showMonth="false"
@monthSwitch="changeMonth"
backgroundColor="transparent"
:selected="selectedDays"
:date="currentDate"
:calendarItemStyle="{width:'84rpx',height:'90rpx'}"
openBeforeChange
@beforeChange="changeDate"
/>
</view> </view>
</view> </view>
</view> </view>
<view class="detail-right"> <view class="detail-right">
<component <component :ref="`ref-${componentName}`" :is="componentName" :templateData="templateData"
:ref="`ref-${componentName}`" :currentDate="currentDate" @changeComponent="changeComponent" @submitReport="submitReport"
:is="componentName" @saveReportStatus="saveReportStatus" />
:templateData="templateData"
:currentDate="currentDate"
@changeComponent="changeComponent"
@submitReport="submitReport"
@saveReportStatus="saveReportStatus"
/>
</view> </view>
</view> </view>
<NoticePopup <NoticePopup ref="notice" :title="noticeObj.title" :text="noticeObj.text" :type="noticeObj.type || 'success'"
ref="notice" :buttons="noticeObj.buttons"></NoticePopup>
:title="noticeObj.title"
:text="noticeObj.text"
:type="noticeObj.type || 'success'"
:buttons="noticeObj.buttons"
></NoticePopup>
</view> </view>
</template> </template>
...@@ -81,16 +50,16 @@ export default { ...@@ -81,16 +50,16 @@ export default {
NegotiationDetail, NegotiationDetail,
EditNegotiationDetail EditNegotiationDetail
}, },
provide () { provide() {
return { return {
sceneType: this.SCENE_TYPE, sceneType: this.SCENE_TYPE,
userInfo: this.userInfo, userInfo: this.userInfo,
templateType: () => this.templateType, templateType: () => this.templateType,
dailyReportRecordId: () => this.dailyReportRecordId, dailyReportRecordId: () => this.dailyReportRecordId,
reportStatus: () => this.reportStatus, reportStatus: () => this.reportStatus
} }
}, },
data () { data() {
return { return {
noticeObj: {}, noticeObj: {},
options: {}, options: {},
...@@ -105,10 +74,10 @@ export default { ...@@ -105,10 +74,10 @@ export default {
assignTitle: '', assignTitle: '',
assignIcon: '', assignIcon: '',
dailyReportRecordId: '', dailyReportRecordId: '',
reportStatus: '', reportStatus: ''
} }
}, },
onBackPress (options) { onBackPress(options) {
if (options.from === 'backbutton') { if (options.from === 'backbutton') {
// 物理返回按钮触发 // 物理返回按钮触发
// 阻止默认行为,即不执行页面返回 // 阻止默认行为,即不执行页面返回
...@@ -119,50 +88,50 @@ export default { ...@@ -119,50 +88,50 @@ export default {
return false return false
}, },
computed: { computed: {
userInfo () { userInfo() {
return uni.$storage.get("userInfo") return uni.$storage.get('userInfo')
}, },
SCENE_TYPE () { SCENE_TYPE() {
const { sceneType } = uni.$storage.get('userInfo') const { sceneType } = uni.$storage.get('userInfo')
return Number(sceneType) return Number(sceneType)
}, },
CAR_BRAND_ID () { CAR_BRAND_ID() {
const carBrandList = uni.$storage.get('carBrandList'), const carBrandList = uni.$storage.get('carBrandList'),
carBrandId = carBrandList.map(item => item.id) carBrandId = carBrandList.map(item => item.id)
return carBrandId return carBrandId
}, },
BASE_SCENE_CODE () { BASE_SCENE_CODE() {
const baseSceneCode = uni.$storage.get('baseSceneCode') const baseSceneCode = uni.$storage.get('baseSceneCode')
return baseSceneCode return baseSceneCode
}, },
title () { title() {
return { return {
staffdailyreport: '驻店日报', staffdailyreport: '驻店日报',
storedailyreport: '门店日报', storedailyreport: '门店日报',
negotiationdetail: '洽谈明细' negotiationdetail: '洽谈明细'
}[this.componentName.toLowerCase()] }[this.componentName.toLowerCase()]
}, },
titleIcon () { titleIcon() {
return { return {
staffdailyreport: 'daily-report', staffdailyreport: 'daily-report',
storedailyreport: 'store-daily-report', storedailyreport: 'store-daily-report',
negotiationdetail: 'negotiation-detail' negotiationdetail: 'negotiation-detail'
}[this.componentName.toLowerCase()] }[this.componentName.toLowerCase()]
}, },
componentName () { componentName() {
let { options } = this, let { options } = this,
componentName = options.componentName || '' componentName = options.componentName || ''
return componentName return componentName
}, },
templateType () { templateType() {
return { return {
staffdailyreport: 1, staffdailyreport: 1,
storedailyreport: 2, storedailyreport: 2,
negotiationdetail: 3, negotiationdetail: 3
}[this.componentName.toLowerCase()] }[this.componentName.toLowerCase()]
}, },
dayList () { dayList() {
let currentMonth = dayjs(this.currentMonth).format('YYYY-MM'), let currentMonth = dayjs(this.currentMonth).format('YYYY-MM'),
mouthNumber = dayjs(currentMonth).daysInMonth(), mouthNumber = dayjs(currentMonth).daysInMonth(),
nowYear = dayjs(currentMonth).format('YYYY'), nowYear = dayjs(currentMonth).format('YYYY'),
...@@ -176,30 +145,33 @@ export default { ...@@ -176,30 +145,33 @@ export default {
dayList.push(date) dayList.push(date)
} }
return dayList return dayList
}, }
}, },
onLoad (options) { onLoad(options) {
this.options = options this.options = options
if (options.currentDate) this.setCurrentDate(options.currentDate) if (options.currentDate) this.setCurrentDate(options.currentDate)
this.getReportList() this.getReportList()
this.getReportDetail() this.getReportDetail()
}, },
onUnload () { onUnload() { },
},
methods: { methods: {
exitInterception (callBack) { exitInterception(callBack) {
this.openNotice({ this.openNotice(
text: '内容尚未保存,是否退出编辑?', {
buttons: { text: '内容尚未保存,是否退出编辑?',
cancelText: '继续编辑', buttons: {
confirmText: '确定退出' cancelText: '继续编辑',
confirmText: '确定退出'
}
},
false,
_ => {
if (callBack) callBack()
else this.backPage()
} }
}, false, _ => { )
if (callBack) callBack()
else this.backPage()
})
}, },
back () { back() {
let now = dayjs().format('YYYY-MM-DD') let now = dayjs().format('YYYY-MM-DD')
if (this.currentDate == now) { if (this.currentDate == now) {
if (this.templateType == 2) { if (this.templateType == 2) {
...@@ -210,7 +182,7 @@ export default { ...@@ -210,7 +182,7 @@ export default {
} }
} else this.backPage() } else this.backPage()
}, },
async getReportList () { async getReportList() {
const { uuid, shopMerchantId } = this.userInfo, const { uuid, shopMerchantId } = this.userInfo,
{ templateType, dayList } = this { templateType, dayList } = this
const data = await uni.$api.dailyTemplateApi.getReportList({ const data = await uni.$api.dailyTemplateApi.getReportList({
...@@ -222,20 +194,21 @@ export default { ...@@ -222,20 +194,21 @@ export default {
}) })
let selectedDay = [] let selectedDay = []
dayList.map(e => { dayList.map(e => {
if (!data.includes(e)) selectedDay.push({ if (!data.includes(e))
date: e selectedDay.push({
}) date: e
})
}) })
this.selectedDays = selectedDay this.selectedDays = selectedDay
}, },
async getDailyTemplate () { async getDailyTemplate() {
const hasCommonElement = (arrA, arrB) => { const hasCommonElement = (arrA, arrB) => {
return arrA.some(item => arrB.includes(item)) return arrA.some(item => arrB.includes(item))
} }
const isSubset = (arrA, arrB) => { const isSubset = (arrA, arrB) => {
// 检查arrB的每个元素是否都在arrA中 // 检查arrB的每个元素是否都在arrA中
const setA = new Set(arrA); const setA = new Set(arrA)
return arrB.every(item => setA.has(item)); return arrB.every(item => setA.has(item))
} }
const { templateType, CAR_BRAND_ID, BASE_SCENE_CODE } = this, const { templateType, CAR_BRAND_ID, BASE_SCENE_CODE } = this,
data = await uni.$api.dailyTemplateApi.getDailyTemplate(templateType) data = await uni.$api.dailyTemplateApi.getDailyTemplate(templateType)
...@@ -254,17 +227,19 @@ export default { ...@@ -254,17 +227,19 @@ export default {
}) })
.filter(item => { .filter(item => {
if (item.type == 'group' && item.children.length) { if (item.type == 'group' && item.children.length) {
item.children = item.children.filter(child => { item.children = item.children
// 品牌过滤 .filter(child => {
if (child.filterBrandId && child.filterBrandId.length) { // 品牌过滤
return !isSubset(child.filterBrandId, CAR_BRAND_ID) if (child.filterBrandId && child.filterBrandId.length) {
} else { return !isSubset(child.filterBrandId, CAR_BRAND_ID)
return child.brandId?.length ? hasCommonElement(child.brandId, CAR_BRAND_ID) : true } else {
} return child.brandId?.length ? hasCommonElement(child.brandId, CAR_BRAND_ID) : true
}).filter(child => { }
// 基础场景代码过滤 })
return child.baseSceneCode.length ? hasCommonElement(child.baseSceneCode, BASE_SCENE_CODE) : true .filter(child => {
}) // 基础场景代码过滤
return child.baseSceneCode.length ? hasCommonElement(child.baseSceneCode, BASE_SCENE_CODE) : true
})
} }
// 基础场景代码过滤 // 基础场景代码过滤
if (item.type == 'divider') { if (item.type == 'divider') {
...@@ -278,8 +253,7 @@ export default { ...@@ -278,8 +253,7 @@ export default {
} else { } else {
return hasCommonElement(item.qgCode, BASE_SCENE_CODE) return hasCommonElement(item.qgCode, BASE_SCENE_CODE)
} }
} } else return item.baseSceneCode?.length ? hasCommonElement(item.baseSceneCode, BASE_SCENE_CODE) : true
else return item.baseSceneCode?.length ? hasCommonElement(item.baseSceneCode, BASE_SCENE_CODE) : true
}) })
templateData.map(e => { templateData.map(e => {
if (e.children && e.type == 'subform') e.origin_children = e.children[0] if (e.children && e.type == 'subform') e.origin_children = e.children[0]
...@@ -287,27 +261,28 @@ export default { ...@@ -287,27 +261,28 @@ export default {
uni.hideLoading() uni.hideLoading()
this.templateData = templateData this.templateData = templateData
}, },
setCurrentDate (currentDate) { setCurrentDate(currentDate) {
this.currentDate = currentDate this.currentDate = currentDate
this.currentMonth = dayjs(currentDate).format('YYYY-MM') this.currentMonth = dayjs(currentDate).format('YYYY-MM')
}, },
changeCurrentDate (e) { changeCurrentDate(e) {
this.templateData = [] this.templateData = []
this.currentDate = e.fullDate this.currentDate = e.fullDate
this.getReportDetail() this.getReportDetail()
}, },
async checkReport () { async checkReport() {
let { templateType, reportStatus } = this, currentComponent = this.$refs[`ref-${this.componentName}`] let { templateType, reportStatus } = this,
currentComponent = this.$refs[`ref-${this.componentName}`]
if (currentComponent.isToday) { if (currentComponent.isToday) {
if (templateType == 2) { if (templateType == 2) {
return reportStatus != 1 return reportStatus != 1
} else { } else {
return true return true
} }
} return false }
return false
}, },
async changeDate (e) { async changeDate(e) {
if (e.fullDate == this.currentDate) return if (e.fullDate == this.currentDate) return
const openNotice = await this.checkReport() const openNotice = await this.checkReport()
if (!openNotice) { if (!openNotice) {
...@@ -320,12 +295,7 @@ export default { ...@@ -320,12 +295,7 @@ export default {
this.changeCurrentDate(e) this.changeCurrentDate(e)
}) })
}, },
openNotice ({ openNotice({ title, text, type, buttons }, back = true, callBack) {
title,
text,
type,
buttons
}, back = true, callBack) {
this.noticeObj = { this.noticeObj = {
title: title || '重要提示', title: title || '重要提示',
text: text || '确认提交后将不可再编辑,确认继续?', text: text || '确认提交后将不可再编辑,确认继续?',
...@@ -351,7 +321,7 @@ export default { ...@@ -351,7 +321,7 @@ export default {
} }
this.$refs.notice.open() this.$refs.notice.open()
}, },
async getReportDetail () { async getReportDetail() {
uni.showLoading({ title: '加载中...', mask: true }) uni.showLoading({ title: '加载中...', mask: true })
try { try {
const { uuid, shopMerchantId } = this.userInfo, const { uuid, shopMerchantId } = this.userInfo,
...@@ -394,35 +364,33 @@ export default { ...@@ -394,35 +364,33 @@ export default {
}) })
this.templateData = templateData this.templateData = templateData
console.log(templateData) console.log(templateData)
} } else {
else {
if (nowDate == currentDate) this.getDailyTemplate() if (nowDate == currentDate) this.getDailyTemplate()
else uni.hideLoading() else uni.hideLoading()
} }
} catch (error) { } catch (error) {
uni.showToast({ title: error, icon: 'none', mask: true }) uni.showToast({ title: error, icon: 'none', mask: true })
} }
}, },
changeMonth (e) { changeMonth(e) {
this.currentMonth = `${e.year}-${e.month}` this.currentMonth = `${e.year}-${e.month}`
this.getReportList() this.getReportList()
}, },
backPage () { backPage() {
uni.navigateBack() uni.navigateBack()
}, },
// name:跳转组件名,val:跳转参数 // name:跳转组件名,val:跳转参数
jump (name, val) { jump(name, val) {
this.componentName = name this.componentName = name
if (val) { if (val) {
this.transmissionOfData = val this.transmissionOfData = val
} }
}, },
changeComponent (val) { changeComponent(val) {
this.assignTitle = val.title this.assignTitle = val.title
this.assignIcon = val.icon this.assignIcon = val.icon
}, },
async submitReport (reportParams, skip) { async submitReport(reportParams, skip) {
if (this.templateType == 2 && !skip) { if (this.templateType == 2 && !skip) {
uni.hideLoading() uni.hideLoading()
this.noticeObj = { this.noticeObj = {
...@@ -456,15 +424,14 @@ export default { ...@@ -456,15 +424,14 @@ export default {
if (data) { if (data) {
uni.showToast({ title: '操作成功', icon: 'success', mask: true }) uni.showToast({ title: '操作成功', icon: 'success', mask: true })
this.saveReportStatus(data) this.saveReportStatus(data)
} } else uni.showToast({ title: '操作失败', icon: 'none', mask: true })
else uni.showToast({ title: '操作失败', icon: 'none', mask: true })
}, },
saveReportStatus (data) { saveReportStatus(data) {
if (data) setTimeout(() => { if (data)
this.getReportList() setTimeout(() => {
this.getReportDetail() this.getReportList()
}, 1.5e3) this.getReportDetail()
}, 1.5e3)
} }
} }
} }
...@@ -473,6 +440,7 @@ export default { ...@@ -473,6 +440,7 @@ export default {
.nav-bar { .nav-bar {
z-index: 1; z-index: 1;
} }
.detail-content { .detail-content {
display: flex; display: flex;
height: calc(100vh - #{toRpx(212)}); height: calc(100vh - #{toRpx(212)});
...@@ -486,13 +454,16 @@ export default { ...@@ -486,13 +454,16 @@ export default {
margin-right: toRpx(32); margin-right: toRpx(32);
z-index: 1; z-index: 1;
overflow: hidden; overflow: hidden;
.content { .content {
padding: 0 toRpx(32); padding: 0 toRpx(32);
height: calc(100% - #{toRpx(144)}); height: calc(100% - #{toRpx(144)});
.banner { .banner {
width: 100%; width: 100%;
height: toRpx(256); height: toRpx(256);
} }
.calendar { .calendar {
height: calc(100% - #{toRpx(304)}); height: calc(100% - #{toRpx(304)});
background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.5) 100%); background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.5) 100%);
...@@ -504,6 +475,7 @@ export default { ...@@ -504,6 +475,7 @@ export default {
} }
} }
} }
.detail-right { .detail-right {
width: calc(100% - #{toRpx(684)}); width: calc(100% - #{toRpx(684)});
height: 100%; height: 100%;
...@@ -513,6 +485,7 @@ export default { ...@@ -513,6 +485,7 @@ export default {
z-index: 1; z-index: 1;
overflow: hidden; overflow: hidden;
} }
.common-title { .common-title {
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -521,21 +494,25 @@ export default { ...@@ -521,21 +494,25 @@ export default {
height: toRpx(144); height: toRpx(144);
justify-content: start; justify-content: start;
padding-left: toRpx(32); padding-left: toRpx(32);
.sprite-icon { .sprite-icon {
margin-right: toRpx(24); margin-right: toRpx(24);
} }
&::before, &::before,
&::after { &::after {
display: none; display: none;
} }
} }
} }
.error-order-title { .error-order-title {
text-align: center; text-align: center;
color: #333333; color: #333333;
font-size: toRpx(40); font-size: toRpx(40);
font-weight: 500; font-weight: 500;
} }
.error-order-content { .error-order-content {
text-align: center; text-align: center;
color: #666666; color: #666666;
...@@ -543,10 +520,12 @@ export default { ...@@ -543,10 +520,12 @@ export default {
font-weight: 400; font-weight: 400;
margin-top: toRpx(16); margin-top: toRpx(16);
} }
.error-order-footer { .error-order-footer {
margin-top: toRpx(64); margin-top: toRpx(64);
margin-bottom: toRpx(48); margin-bottom: toRpx(48);
width: 100%; width: 100%;
.cancel { .cancel {
height: toRpx(88); height: toRpx(88);
border-radius: toRpx(64); border-radius: toRpx(64);
...@@ -559,6 +538,7 @@ export default { ...@@ -559,6 +538,7 @@ export default {
font-size: toRpx(32); font-size: toRpx(32);
font-weight: 400; font-weight: 400;
} }
.sure { .sure {
height: toRpx(88); height: toRpx(88);
border-radius: toRpx(64); border-radius: toRpx(64);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!