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 @@
class="select"
@click.stop="showPop"
>
{{selectList[selectIndex].label}}
{{selectValue}}
<template v-if="!disabled">
<view class="sprite-icon icon-arrow-bottom"></view>
</template>
......@@ -39,6 +39,27 @@ export default {
disabled: {
type: Boolean,
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: '',
......@@ -125,8 +146,8 @@ export default {
}
}
}
.disabled{
.select{
.disabled {
.select {
padding: 0 toRpx(40);
}
}
......
......@@ -713,10 +713,6 @@ export default {
}[value]
this.orderObj[i.submitValue] = value
},
tabBarClick (e) {
if (this.tabIndex == e) return
this.tabIndex = e
},
filterTemplateList (item) {
let { hwOhterObjArray, defaultObjArray, orderObj: { templateType } } = this
if (item.firstBrandId == -1) {
......@@ -739,6 +735,8 @@ export default {
height: 100%;
.hide-box {
opacity: 0;
height: 100%;
overflow: hidden;
}
.common-title-btns {
margin: 0 toRpx(48) 0 auto;
......@@ -759,6 +757,9 @@ export default {
.repoet-view {
height: calc(100% - #{toRpx(248)});
position: relative;
.repoet-box {
height: 100%;
}
}
.full {
height: calc(100% - #{toRpx(120)});
......@@ -832,7 +833,7 @@ export default {
margin-left: toRpx(24);
text-align: right;
margin: toRpx(10) 0;
line-height: toRpx(28);
// line-height: toRpx(28);
font-size: toRpx(28);
}
}
......
......@@ -3,14 +3,18 @@
<view class="daily-report">
<view class="common-title flex">
填写日报
<view class="common-title-btns flex">
<select-component
:selectList="pickerTemplateList"
@chooseType="handleTemplagePickerChange"
styleV2
:disabled="filterDisabled(isEditReport) || isHmStore"
/>
</view>
<template v-if="orderObj.onBreak">
<view class="common-title-btns flex">
<select-component
:selectList="pickerTemplateList"
@chooseType="handleTemplagePickerChange"
styleV2
:disabled="filterDisabled(isEditReport) || isHmStore"
:defaultValue="orderObj.templateType"
ref="selectComponent"
/>
</view>
</template>
</view>
<scroll-view
:class="['repoet-view',{full:!orderObj.isDateWithin7Days}]"
......@@ -244,7 +248,7 @@
<template v-else>
<view
class="btn cancel-btn"
@click="isEditReport = false"
@click="cancel"
>取消</view>
<view
class="btn"
......@@ -385,6 +389,9 @@ export default {
infoObject () {
let { tabIndex, carBandList, orderObj: { templateType, totalOrderMoney } } = this,
{ brandType, firstBrandId } = carBandList[tabIndex],
/**模版为广联权益 */
TemplateType3 = templateType == 3,//
NotAitoAndTemplateType3 = brandType != 0 || TemplateType3, //非问界 或者 广联权益 时隐藏
infoArray = [
{
label: '个人成交总金额',
......@@ -395,47 +402,47 @@ export default {
{
label: `售前整车延保成交数·${brandType == 0 ? '问界' : '鸿蒙'}`,
key: 'extendedWarrantyCount',
hide: firstBrandId == -1 || templateType == 3
hide: firstBrandId == -1 || TemplateType3
},
{
label: `售后整车延保成交数·${brandType == 0 ? '问界' : '鸿蒙'}`,
key: 'afterSaleExtendedWarrantyCount',
hide: firstBrandId == -1 || templateType == 3
hide: firstBrandId == -1 || TemplateType3
},
{
label: '轮胎险成交数',
key: 'tireWarrantyCount',
hide: brandType != 0 || templateType == 3
hide: NotAitoAndTemplateType3
},
{
label: '安心包成交数',
key: 'axPackageCount',
hide: brandType != 0 || templateType == 3
hide: NotAitoAndTemplateType3
},
{
label: '安心包MAX成交数',
key: 'axPackageMaxCount',
hide: brandType != 0 || templateType == 3
hide: NotAitoAndTemplateType3
},
{
label: '安心包Pro成交数',
key: 'axPackageProCount',
hide: brandType != 0 || templateType == 3
hide: NotAitoAndTemplateType3
},
{
label: '电池延保成交数',
key: 'batteryExtendedWarrantyCount',
hide: brandType != 0 || templateType == 3
hide: NotAitoAndTemplateType3
},
{
label: '北汽无忧成交数',
key: 'bqWorryFreeCount',
hide: firstBrandId != -1 || templateType == 3
hide: firstBrandId != -1 || TemplateType3
},
{
label: '广爱无忧成交数',
key: 'gaWorryFreeCount',
hide: firstBrandId != -1 || templateType == 3
hide: firstBrandId != -1 || TemplateType3
},
{
label: '广联权益成交数',
......@@ -583,6 +590,7 @@ export default {
this.$emit('setCalendarSelected', selectedDay)
},
async getStaffDailyReportDetail () {
this.hideSelect()
this.isEditReport = false
this.loadComplete = false
let { currentDate,
......@@ -758,7 +766,7 @@ export default {
}
} catch (errorObj) {
uni.hideLoading()
if(errorObj.tabIndex != null) this.tabIndex = errorObj.tabIndex
if (errorObj.tabIndex != null) this.tabIndex = errorObj.tabIndex
if (errorObj.message) {
uni.showToast({
title: `${errorObj.message}不能为空`,
......@@ -785,14 +793,15 @@ export default {
}[value]
this.orderObj[i.submitValue] = value
},
tabBarClick (e) {
if (this.tabIndex == e) return
this.tabIndex = e
},
handleTemplagePickerChange ({ item }) {
console.log(item)
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 {
height: 100%;
.hide-box {
opacity: 0;
height: 100%;
overflow: hidden;
}
.common-title-btns {
margin: 0 toRpx(48) 0 auto;
......@@ -812,6 +823,9 @@ export default {
.repoet-view {
height: calc(100% - #{toRpx(248)});
position: relative;
.repoet-box {
height: 100%;
}
}
.full {
height: calc(100% - #{toRpx(120)});
......@@ -885,7 +899,7 @@ export default {
margin-left: toRpx(24);
text-align: right;
margin: toRpx(10) 0;
line-height: toRpx(28);
// line-height: 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!