Commit becb0109 by 李伟康

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

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