Commit f10973ab by 李伟康

feat(components): 优化 SelectComponent 组件功能与样式

新增 defaultValue 和 valueKey 属性支持默认值设置,
增加 selectValue 计算属性并完善 watch 监听逻辑。
同时修复组件禁用状态下的样式问题。

---

refactor(pages): 调整日报组件中模板选择器的显示逻辑

将 select-component 的渲染条件改为 v-if 控制,
确保仅在特定条件下展示,并传递 defaultValue 和 ref 引用。
移除冗余的 tabBarClick 方法,统一通过 handleTemplagePickerChange 处理选中逻辑。

---

style(pages): 统一代码缩进与注释格式

修正多个组件中的 CSS 缩进不一致问题,
调整部分样式规则顺序以提升可读性,
并对部分业务逻辑添加注释说明,增强维护性。
1 parent 78068593
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
class="select" class="select"
@click.stop="showPop" @click.stop="showPop"
> >
{{selectList[selectIndex].label}} {{selectValue}}
<template v-if="!disabled"> <template v-if="!disabled">
<view class="sprite-icon icon-arrow-bottom"></view> <view class="sprite-icon icon-arrow-bottom"></view>
</template> </template>
...@@ -39,6 +39,27 @@ export default { ...@@ -39,6 +39,27 @@ export default {
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false
},
defaultValue: [String, Number],
valueKey: {
type: String,
default: 'value'
}
},
computed: {
selectValue () {
let { selectList, selectIndex, labelKey } = this
return selectList[selectIndex][labelKey]
}
},
watch: {
defaultValue: {
immediate: true,
deep: true,
handler (n) {
let { selectList , valueKey} = this
this.selectIndex = selectList.findIndex(e => e[valueKey] == n)
}
} }
}, },
name: '', name: '',
...@@ -125,8 +146,8 @@ export default { ...@@ -125,8 +146,8 @@ export default {
} }
} }
} }
.disabled{ .disabled {
.select{ .select {
padding: 0 toRpx(40); padding: 0 toRpx(40);
} }
} }
......
...@@ -713,10 +713,6 @@ export default { ...@@ -713,10 +713,6 @@ export default {
}[value] }[value]
this.orderObj[i.submitValue] = value this.orderObj[i.submitValue] = value
}, },
tabBarClick (e) {
if (this.tabIndex == e) return
this.tabIndex = e
},
filterTemplateList (item) { filterTemplateList (item) {
let { hwOhterObjArray, defaultObjArray, orderObj: { templateType } } = this let { hwOhterObjArray, defaultObjArray, orderObj: { templateType } } = this
if (item.firstBrandId == -1) { if (item.firstBrandId == -1) {
...@@ -739,6 +735,8 @@ export default { ...@@ -739,6 +735,8 @@ export default {
height: 100%; height: 100%;
.hide-box { .hide-box {
opacity: 0; opacity: 0;
height: 100%;
overflow: hidden;
} }
.common-title-btns { .common-title-btns {
margin: 0 toRpx(48) 0 auto; margin: 0 toRpx(48) 0 auto;
...@@ -759,6 +757,9 @@ export default { ...@@ -759,6 +757,9 @@ export default {
.repoet-view { .repoet-view {
height: calc(100% - #{toRpx(248)}); height: calc(100% - #{toRpx(248)});
position: relative; position: relative;
.repoet-box {
height: 100%;
}
} }
.full { .full {
height: calc(100% - #{toRpx(120)}); height: calc(100% - #{toRpx(120)});
...@@ -832,7 +833,7 @@ export default { ...@@ -832,7 +833,7 @@ export default {
margin-left: toRpx(24); margin-left: toRpx(24);
text-align: right; text-align: right;
margin: toRpx(10) 0; margin: toRpx(10) 0;
line-height: toRpx(28); // line-height: toRpx(28);
font-size: toRpx(28); font-size: toRpx(28);
} }
} }
......
...@@ -3,14 +3,18 @@ ...@@ -3,14 +3,18 @@
<view class="daily-report"> <view class="daily-report">
<view class="common-title flex"> <view class="common-title flex">
填写日报 填写日报
<template v-if="orderObj.onBreak">
<view class="common-title-btns flex"> <view class="common-title-btns flex">
<select-component <select-component
:selectList="pickerTemplateList" :selectList="pickerTemplateList"
@chooseType="handleTemplagePickerChange" @chooseType="handleTemplagePickerChange"
styleV2 styleV2
:disabled="filterDisabled(isEditReport) || isHmStore" :disabled="filterDisabled(isEditReport) || isHmStore"
:defaultValue="orderObj.templateType"
ref="selectComponent"
/> />
</view> </view>
</template>
</view> </view>
<scroll-view <scroll-view
:class="['repoet-view',{full:!orderObj.isDateWithin7Days}]" :class="['repoet-view',{full:!orderObj.isDateWithin7Days}]"
...@@ -244,7 +248,7 @@ ...@@ -244,7 +248,7 @@
<template v-else> <template v-else>
<view <view
class="btn cancel-btn" class="btn cancel-btn"
@click="isEditReport = false" @click="cancel"
>取消</view> >取消</view>
<view <view
class="btn" class="btn"
...@@ -385,6 +389,9 @@ export default { ...@@ -385,6 +389,9 @@ export default {
infoObject () { infoObject () {
let { tabIndex, carBandList, orderObj: { templateType, totalOrderMoney } } = this, let { tabIndex, carBandList, orderObj: { templateType, totalOrderMoney } } = this,
{ brandType, firstBrandId } = carBandList[tabIndex], { brandType, firstBrandId } = carBandList[tabIndex],
/**模版为广联权益 */
TemplateType3 = templateType == 3,//
NotAitoAndTemplateType3 = brandType != 0 || TemplateType3, //非问界 或者 广联权益 时隐藏
infoArray = [ infoArray = [
{ {
label: '个人成交总金额', label: '个人成交总金额',
...@@ -395,47 +402,47 @@ export default { ...@@ -395,47 +402,47 @@ export default {
{ {
label: `售前整车延保成交数·${brandType == 0 ? '问界' : '鸿蒙'}`, label: `售前整车延保成交数·${brandType == 0 ? '问界' : '鸿蒙'}`,
key: 'extendedWarrantyCount', key: 'extendedWarrantyCount',
hide: firstBrandId == -1 || templateType == 3 hide: firstBrandId == -1 || TemplateType3
}, },
{ {
label: `售后整车延保成交数·${brandType == 0 ? '问界' : '鸿蒙'}`, label: `售后整车延保成交数·${brandType == 0 ? '问界' : '鸿蒙'}`,
key: 'afterSaleExtendedWarrantyCount', key: 'afterSaleExtendedWarrantyCount',
hide: firstBrandId == -1 || templateType == 3 hide: firstBrandId == -1 || TemplateType3
}, },
{ {
label: '轮胎险成交数', label: '轮胎险成交数',
key: 'tireWarrantyCount', key: 'tireWarrantyCount',
hide: brandType != 0 || templateType == 3 hide: NotAitoAndTemplateType3
}, },
{ {
label: '安心包成交数', label: '安心包成交数',
key: 'axPackageCount', key: 'axPackageCount',
hide: brandType != 0 || templateType == 3 hide: NotAitoAndTemplateType3
}, },
{ {
label: '安心包MAX成交数', label: '安心包MAX成交数',
key: 'axPackageMaxCount', key: 'axPackageMaxCount',
hide: brandType != 0 || templateType == 3 hide: NotAitoAndTemplateType3
}, },
{ {
label: '安心包Pro成交数', label: '安心包Pro成交数',
key: 'axPackageProCount', key: 'axPackageProCount',
hide: brandType != 0 || templateType == 3 hide: NotAitoAndTemplateType3
}, },
{ {
label: '电池延保成交数', label: '电池延保成交数',
key: 'batteryExtendedWarrantyCount', key: 'batteryExtendedWarrantyCount',
hide: brandType != 0 || templateType == 3 hide: NotAitoAndTemplateType3
}, },
{ {
label: '北汽无忧成交数', label: '北汽无忧成交数',
key: 'bqWorryFreeCount', key: 'bqWorryFreeCount',
hide: firstBrandId != -1 || templateType == 3 hide: firstBrandId != -1 || TemplateType3
}, },
{ {
label: '广爱无忧成交数', label: '广爱无忧成交数',
key: 'gaWorryFreeCount', key: 'gaWorryFreeCount',
hide: firstBrandId != -1 || templateType == 3 hide: firstBrandId != -1 || TemplateType3
}, },
{ {
label: '广联权益成交数', label: '广联权益成交数',
...@@ -583,6 +590,7 @@ export default { ...@@ -583,6 +590,7 @@ export default {
this.$emit('setCalendarSelected', selectedDay) this.$emit('setCalendarSelected', selectedDay)
}, },
async getStaffDailyReportDetail () { async getStaffDailyReportDetail () {
this.hideSelect()
this.isEditReport = false this.isEditReport = false
this.loadComplete = false this.loadComplete = false
let { currentDate, let { currentDate,
...@@ -758,7 +766,7 @@ export default { ...@@ -758,7 +766,7 @@ export default {
} }
} catch (errorObj) { } catch (errorObj) {
uni.hideLoading() uni.hideLoading()
if(errorObj.tabIndex != null) this.tabIndex = errorObj.tabIndex if (errorObj.tabIndex != null) this.tabIndex = errorObj.tabIndex
if (errorObj.message) { if (errorObj.message) {
uni.showToast({ uni.showToast({
title: `${errorObj.message}不能为空`, title: `${errorObj.message}不能为空`,
...@@ -785,14 +793,15 @@ export default { ...@@ -785,14 +793,15 @@ export default {
}[value] }[value]
this.orderObj[i.submitValue] = value this.orderObj[i.submitValue] = value
}, },
tabBarClick (e) {
if (this.tabIndex == e) return
this.tabIndex = e
},
handleTemplagePickerChange ({ item }) { handleTemplagePickerChange ({ item }) {
console.log(item)
this.orderObj.templateType = item.value this.orderObj.templateType = item.value
console.log(this.orderObj) },
cancel () {
this.isEditReport = false
this.hideSelect()
},
hideSelect () {
this.$refs?.selectComponent?.hideSelect()
} }
} }
} }
...@@ -803,6 +812,8 @@ export default { ...@@ -803,6 +812,8 @@ export default {
height: 100%; height: 100%;
.hide-box { .hide-box {
opacity: 0; opacity: 0;
height: 100%;
overflow: hidden;
} }
.common-title-btns { .common-title-btns {
margin: 0 toRpx(48) 0 auto; margin: 0 toRpx(48) 0 auto;
...@@ -812,6 +823,9 @@ export default { ...@@ -812,6 +823,9 @@ export default {
.repoet-view { .repoet-view {
height: calc(100% - #{toRpx(248)}); height: calc(100% - #{toRpx(248)});
position: relative; position: relative;
.repoet-box {
height: 100%;
}
} }
.full { .full {
height: calc(100% - #{toRpx(120)}); height: calc(100% - #{toRpx(120)});
...@@ -885,7 +899,7 @@ export default { ...@@ -885,7 +899,7 @@ export default {
margin-left: toRpx(24); margin-left: toRpx(24);
text-align: right; text-align: right;
margin: toRpx(10) 0; margin: toRpx(10) 0;
line-height: toRpx(28); // line-height: toRpx(28);
font-size: toRpx(28); font-size: toRpx(28);
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!