Commit bbc0cddc by liimin

refactor(components): 重构汽车品牌和员工选择组件样式及结构

- 调整 CarBrands 组件模板结构和属性命名格式
- 优化 CarBrands 组件导入顺序和代码布局
- 更新 Employee 组件模板结构和属性命名格式
- 调整 FinishStep 组件弹窗结构和按钮组件
- 优化选择项样式为居中对齐的弹性布局
- 统一组件属性绑定的命名规范
- 调整 FinishStep 组件表单输入和选择控件样式
1 parent 6267daab
<template> <template>
<MessageBox <MessageBox ref="employeeBoxVisible"
ref="employeeBoxVisible" :is-footer="false"
:max-height="1000"
position="bottom" position="bottom"
:isFooter="false"
:title="`请选择${title}`" :title="`请选择${title}`"
:maxHeight="1000" @close="handleClose">
@close="handleClose"
>
<view class="select-box"> <view class="select-box">
<template v-for="(item, index) in employeeList" :key="index" > <template v-for="(item, index) in employeeList" :key="index">
<view <view class="select-item"
:class="['select-item',{ checked: (salesUuid as string) == (item as UTSJSONObject).uuid }]" :class="[{ checked: (salesUuid as string) == (item as UTSJSONObject).uuid }]"
@click="handleSelect(item)" @click="handleSelect(item)">
>
{{ (item as UTSJSONObject).staffName }} {{ (item as UTSJSONObject).staffName }}
</view> </view>
</template> </template>
...@@ -21,96 +18,97 @@ ...@@ -21,96 +18,97 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, computed, watch } from 'vue' import { ComponentPublicInstance, computed, ref, watch } from "vue";
import MessageBox from './MessageBox.uvue'
import { state, dispatch } from '@/store/index.uts' import { getEmployeeListApi } from "@/api/common-api.uts";
import { storage } from '@/utils/storage.uts' import { dispatch, state } from "@/store/index.uts";
import { getEmployeeListApi } from '@/api/common-api.uts' import { storage } from "@/utils/storage.uts";
import { ComponentPublicInstance } from 'vue'
import MessageBox from "./MessageBox.uvue";
type Props = { type Props = {
title?: string
salesPropsUuid?: string salesPropsUuid?: string
title?: string
} }
type UserInfo = UTSJSONObject type UserInfo = UTSJSONObject
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
title: '销售', title: "销售",
salesPropsUuid: '' salesPropsUuid: ""
}) });
const emit = defineEmits(['close', 'select']) const emit = defineEmits(["close", "select"]);
const employeeBoxVisible = ref(null) const employeeBoxVisible = ref(null);
const watchStatus = computed(() => { const watchStatus = computed(() => {
const status = state.user?.historyStatus const status = state.user?.historyStatus;
if (status == null) { if (status == null) {
return false return false;
} else if (status == 1) { } else if (status == 1) {
return true return true;
} else { } else {
return false return false;
} }
}) });
const updateView = ref<number>(Date.now()) const updateView = ref<number>(Date.now());
const salesUuid = computed(() => { const salesUuid = computed(() => {
const val1 = state.user.customerInfo.salesUuid const val1 = state.user.customerInfo.salesUuid;
const val2 = props.salesPropsUuid const val2 = props.salesPropsUuid;
return val1 !== null && val1 !== '' ? val1 : val2 return val1 !== null && val1 !== "" ? val1 : val2;
}) });
// const employeeList = computed(() => { // const employeeList = computed(() => {
// return state.user.employeeList // return state.user.employeeList
// }) // })
const employeeList = ref<Array<any>>([]) const employeeList = ref<Array<any>>([]);
watch(updateView.value,()=>{ watch(updateView.value, ()=>{
const list = storage.get("employeeList") as UTSArray<Any> const list = storage.get("employeeList") as UTSArray<Any>;
employeeList.value = list != null ? list : [] employeeList.value = list != null ? list : [];
}, { immediate: true, deep: true }) }, { immediate: true, deep: true });
function close(): void { function close(): void {
if (employeeBoxVisible.value != null) { if (employeeBoxVisible.value != null) {
(employeeBoxVisible.value as ComponentPublicInstance).$callMethod('close') (employeeBoxVisible.value as ComponentPublicInstance).$callMethod("close");
}
} }
}
watch(watchStatus.value, () => { watch(watchStatus.value, () => {
close() close();
}, { immediate: true }) }, { immediate: true });
function handleClose(): void { function handleClose(): void {
emit('close') emit("close");
} }
function open(): void { function open(): void {
if (employeeBoxVisible.value != null) { if (employeeBoxVisible.value != null) {
(employeeBoxVisible.value as ComponentPublicInstance).$callMethod('open') (employeeBoxVisible.value as ComponentPublicInstance).$callMethod("open");
} }
const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null const userInfo: null | UserInfo = storage.get("userInfo") as null | UTSJSONObject;
if (userInfo == null) return if (userInfo == null) return;
const shopMerchantId = userInfo.shopMerchantId const shopMerchantId = userInfo.shopMerchantId;
// 获取销售人员列表 // 获取销售人员列表
getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => { getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => {
const employeeList = res as Array<any> const employeeList = res as Array<any>;
dispatch('setEmployeeList', employeeList) dispatch("setEmployeeList", employeeList);
const listToStore = employeeList != null ? employeeList : [] const listToStore = employeeList != null ? employeeList : [];
storage.set('employeeList', listToStore, 0) storage.set("employeeList", listToStore, 0);
updateView.value = Date.now() updateView.value = Date.now();
}) });
} }
function handleSelect(item: any): void { function handleSelect(item: any): void {
close() close();
emit('select', item) emit("select", item);
} }
defineExpose({ open, close }) defineExpose({ open, close });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -127,14 +125,20 @@ ...@@ -127,14 +125,20 @@
/* width: 23.5%; */ /* width: 23.5%; */
margin-right: 2%; margin-right: 2%;
margin-bottom: 16px; margin-bottom: 16px;
text-align: center;
height: 34px; height: 34px;
line-height: 22px;
opacity: 1; opacity: 1;
border: 1px solid #dce0e6; border: 1px solid #dce0e6;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
text {
text-align: center;
color: #333; color: #333;
font-size: 16px; font-size: 16px;
border-radius: 4px; line-height: 22px;
}
&:nth-child(4n) { &:nth-child(4n) {
margin-right: 0; margin-right: 0;
......
<template> <template>
<un-popup :show="visible" @close="onClose" @open="open" :mode="position"> <un-popup :mode="position"
<view :show="visible">
:class="['tips-wrapper',{'radius': position === 'center'}]" <view class="tips-wrapper"
:style="popupStyle" :class="[{'radius': position === 'center'}]"
> :style="popupStyle">
<view class="tips-content"> <view class="tips-content">
<view <view class="icon-close-box flex"
class="icon-close-box flex" @click="hide">
@click="hide" <uni-icons class="icon-close"
>
<uni-icons
class="icon-close"
type="closeempty"
:size="18"
color="#1A1A1A" color="#1A1A1A"
> :size="18"
type="closeempty">
</uni-icons> </uni-icons>
</view> </view>
<view class="tips-title"> <view class="tips-title">
<template v-if="back"> <template v-if="back">
<view <view class="sprite-icon icon-back"
class="sprite-icon icon-back" @click="hide">
@click="hide"
>
</view> </view>
</template> </template>
{{ title }} {{ title }}
</view> </view>
<text <text v-if="content"
class="tips-text" class="tips-text">
v-if="content" {{ content }}
>{{ content }}</text> </text>
<slot> <slot>
</slot> </slot>
</view> </view>
<view <view v-if="isFooter"
class="tips-footer" class="tips-footer">
v-if="isFooter" <view v-if="showCancelBtn"
>
<view
v-if="showCancelBtn"
class="tips-btn close" class="tips-btn close"
@click="cancel" @click="cancel">
>{{ {{
cancelBtnText cancelBtnText
}}</view> }}
<view </view>
class="tips-btn preview" <view class="tips-btn preview"
@click="confirm" @click="confirm">
>{{ {{
confirmBtnText confirmBtnText
}}</view> }}
</view>
</view> </view>
<template v-else> <template v-else>
<slot name="footer"> <slot name="footer">
</slot> </slot>
</template> </template>
</view> </view>
</un-popup> </un-popup>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ComponentPublicInstance } from 'vue' import { ComponentPublicInstance } from "vue";
const props = defineProps({ const props = defineProps({
isAutoClose: { isAutoClose: {
type: Boolean, type: Boolean,
default: true default: true
...@@ -103,57 +95,57 @@ ...@@ -103,57 +95,57 @@
type: Boolean, type: Boolean,
default: true default: true
} }
}) });
const emit = defineEmits(['close', const emit = defineEmits(["close",
'cancel', "cancel",
'confirm']) "confirm"]);
const visible = ref<boolean>(false) const visible = ref<boolean>(false);
const popupRef= ref(null) const popupRef= ref(null);
const popupStyle = computed(() => { const popupStyle = computed(() => {
return { return {
width: props.popupW != null && props.popupW > 0 ? (props.popupW ?? 0) + 'px' : '100%', width: props.popupW != null && props.popupW > 0 ? `${props.popupW ?? 0 }px` : "100%",
minHeight: props.popupH != null && props.popupH > 0 ? (props.popupH ?? 0) + 'px' : '100%', minHeight: props.popupH != null && props.popupH > 0 ? `${props.popupH ?? 0 }px` : "100%",
maxHeight: props.maxHeight != null && props.maxHeight > 0 ? (props.maxHeight ?? 0) + 'px' : '100%' maxHeight: props.maxHeight != null && props.maxHeight > 0 ? `${props.maxHeight ?? 0 }px` : "100%"
} };
}) });
function onClose(): void { function onClose(): void {
emit('close') emit("close");
} }
function close(): void { function close(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false;
} else { } else {
if (popupRef.value != null) { if (popupRef.value != null) {
(popupRef.value as ComponentPublicInstance).$callMethod('close') (popupRef.value as ComponentPublicInstance).$callMethod("close");
}
}
emit('close')
} }
function hide(): void {
visible.value = false
}
function open(): void {
visible.value = true
} }
emit("close");
}
function hide(): void {
visible.value = false;
}
function open(): void {
visible.value = true;
}
function cancel(): void { function cancel(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false;
}
emit('cancel')
} }
emit("cancel");
}
function confirm(): void { function confirm(): void {
if (props.isAutoClose) { if (props.isAutoClose) {
visible.value = false visible.value = false;
}
emit('confirm')
} }
emit("confirm");
}
defineExpose({ open, close ,hide }) defineExpose({ open, close, hide });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -184,10 +176,16 @@ ...@@ -184,10 +176,16 @@
.tips-title { .tips-title {
position: relative; position: relative;
width: 100%; width: 100%;
display: flex;
align-items: center;
justify-content: center;
text {
font-weight: 500; font-weight: 500;
font-size: 18px; font-size: 18px;
color: #292d33; color: #292d33;
text-align: center; text-align: center;
}
.icon-back { .icon-back {
position: absolute; position: absolute;
...@@ -200,12 +198,16 @@ ...@@ -200,12 +198,16 @@
.tips-text { .tips-text {
display: block; display: block;
text-align: center;
margin-top: 24px;
text {
font-size: 15px; font-size: 15px;
color: #5a5e66; color: #5a5e66;
letter-spacing: 0.5px; letter-spacing: 0.5px;
text-align: center;
line-height: 20px; line-height: 20px;
margin-top: 24px; text-align: center;
}
} }
.tips-footer { .tips-footer {
...@@ -215,23 +217,32 @@ ...@@ -215,23 +217,32 @@
height: 50px; height: 50px;
border-top: 1px solid #e8e8e8; border-top: 1px solid #e8e8e8;
flex-direction: row; flex-direction: row;
.close { .close {
text {
color: #6c6c70; color: #6c6c70;
} }
}
.preview { .preview {
text {
color: #2c66f7; color: #2c66f7;
} }
} }
}
.tips-btn { .tips-btn {
width: 50%; width: 50%;
display: flex;
align-items: center;
justify-content: center;
text {
text-align: center; text-align: center;
font-size: 16px; font-size: 16px;
text-align: center;
line-height: 22px; line-height: 22px;
font-weight: 500; font-weight: 500;
justify-content: center; }
} }
} }
.radius{ .radius{
......
...@@ -196,9 +196,6 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -196,9 +196,6 @@ const chooseMerchant = (userInfo: any): void => {
width: 100%; width: 100%;
height: 100%; height: 100%;
padding-top: 72px; padding-top: 72px;
font-size: 14px;
color: #333;
letter-spacing: 0;
box-sizing: border-box; box-sizing: border-box;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
...@@ -310,9 +307,7 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -310,9 +307,7 @@ const chooseMerchant = (userInfo: any): void => {
border: 1.5px solid #a8c1ff; border: 1.5px solid #a8c1ff;
border-radius: 8px; border-radius: 8px;
box-sizing: border-box; box-sizing: border-box;
color: #333;
padding: 0 6px; padding: 0 6px;
font-size: 14px;
position: relative; position: relative;
.input { .input {
...@@ -320,9 +315,11 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -320,9 +315,11 @@ const chooseMerchant = (userInfo: any): void => {
align-items: center; align-items: center;
height: 100%; height: 100%;
width: 100%; width: 100%;
justify-content: center;
text-align: center; text {
font-size: 14px; font-size: 14px;
text-align: center;
}
} }
.icon-search { .icon-search {
...@@ -330,8 +327,11 @@ const chooseMerchant = (userInfo: any): void => { ...@@ -330,8 +327,11 @@ const chooseMerchant = (userInfo: any): void => {
} }
.placeholder { .placeholder {
text {
font-size: 14px; font-size: 14px;
color: #999999; color: #999999;
text-align: center;
}
} }
} }
......
<template> <template>
<view v-if="loading" class="skeleton-wrap"> <view v-if="loading" class="skeleton-wrap">
<un-skeleton :loading="true" :animate="true" title avatar rows="3"></un-skeleton> <un-skeleton :animate="true"
avatar
:loading="true"
rows="3"
title>
</un-skeleton>
</view> </view>
<view v-else class="box"> <view v-else class="box">
<view v-for="(item, index) in sceneList" <view v-for="(item, index) in sceneList"
...@@ -83,7 +88,7 @@ function jump(info: UTSJSONObject, data: any | null): void { ...@@ -83,7 +88,7 @@ function jump(info: UTSJSONObject, data: any | null): void {
} else { } else {
info.channelType = 1; info.channelType = 1;
} }
info.staffUuid = info.uuid info.staffUuid = info.uuid;
storage.set("userInfo", info, 0); storage.set("userInfo", info, 0);
const sceneType = info.sceneType as null | number; const sceneType = info.sceneType as null | number;
...@@ -229,6 +234,7 @@ defineExpose({ ...@@ -229,6 +234,7 @@ defineExpose({
<style scoped lang="scss"> <style scoped lang="scss">
.skeleton-wrap { .skeleton-wrap {
padding: 24px; padding: 24px;
width: 100%;
} }
.box { .box {
......
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
<view v-if="code != ''" <view v-if="code != ''"
class="icon" class="icon"
@click="clearCode"> @click="clearCode">
<icon color="#000" <uni-icons color="#000"
size="16" size="16"
type="clear"> type="clear">
</icon> </uni-icons>
</view> </view>
<view class="code-btn" <view class="code-btn"
:class="[count > 0 ? 'code-disabled' : '']" :class="[count > 0 ? 'code-disabled' : '']"
......
...@@ -65,10 +65,13 @@ ...@@ -65,10 +65,13 @@
.code-btn { .code-btn {
flex-shrink: 0; flex-shrink: 0;
margin-right: 20px; margin-right: 20px;
border: none;
text {
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
color: #2c66f7; color: #2c66f7;
border: none; }
} }
.code-disabled { .code-disabled {
...@@ -122,10 +125,13 @@ ...@@ -122,10 +125,13 @@
position: fixed; position: fixed;
bottom: 10px; bottom: 10px;
left: 50%; left: 50%;
transform: translate(-50%);
text {
font-size: 12px; font-size: 12px;
line-height: 20px; line-height: 20px;
color: #999; color: #999;
transform: translate(-50%); }
.icon-clone { .icon-clone {
width: 12px; width: 12px;
......
...@@ -54,7 +54,7 @@ function setViewInfo(data: any): void { ...@@ -54,7 +54,7 @@ function setViewInfo(data: any): void {
moduleList.value = dataObj.moduleList as Array<any>; moduleList.value = dataObj.moduleList as Array<any>;
toolList.value = dataObj.toolList as Array<any>; toolList.value = dataObj.toolList as Array<any>;
const idValue = dataObj.id; const idValue = dataObj.id;
mediaId.value = typeof idValue === 'number' ? idValue.toString() : (idValue as string) ?? ''; mediaId.value = typeof idValue === "number" ? idValue.toString() : (idValue as string) ?? "";
loadComplete.value = true; loadComplete.value = true;
// 直接将数据属性设置到 state.user 上 // 直接将数据属性设置到 state.user 上
...@@ -87,15 +87,15 @@ async function getSoure(brandIdList: number[], subBrandIdList: number[]): Promis ...@@ -87,15 +87,15 @@ async function getSoure(brandIdList: number[], subBrandIdList: number[]): Promis
const storageKey = `source_${sceneType}_${shopMerchantId}`; const storageKey = `source_${sceneType}_${shopMerchantId}`;
const cachedData = uni.getStorageSync(storageKey); const cachedData = uni.getStorageSync(storageKey);
let data: UTSJSONObject | null = null; let data: null | UTSJSONObject = null;
if (cachedData != null && cachedData !== '') { if (cachedData != null && cachedData !== "") {
try { try {
data = JSON.parse(cachedData as string) as UTSJSONObject; data = JSON.parse(cachedData as string) as UTSJSONObject;
} catch (e) { } catch (error) {
console.error('解析缓存数据失败:', e); console.error("解析缓存数据失败:", error);
} }
} }
console.log(data) console.log(data);
if (data != null) { if (data != null) {
setViewInfo(data); setViewInfo(data);
} }
......
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
*/ */
import { Logger } from "./logger/LoggerCore"; import { Logger } from "./logger/LoggerCore";
import { DBRecord } from "./recorder/DBRecord.uts"; import DBRecord from "./recorder/DBRecord.uts";
import { RecordSave } from "./recorder/RecordSave.uts";
import { RecordService } from "./recorder/RecordService.uts"; import { RecordService } from "./recorder/RecordService.uts";
import { TimeoutService } from "./recorder/TimeoutService.uts"; import { TimeoutService } from "./recorder/TimeoutService.uts";
import { FileUploadService } from "./uploader/FileUploadService.uts"; import { FileUploadService } from "./uploader/FileUploadService.uts";
...@@ -85,21 +84,6 @@ class Services { ...@@ -85,21 +84,6 @@ class Services {
return this._loggerInstance as Logger; return this._loggerInstance as Logger;
} }
/** /**
* 获取记录保存服务
*
* 使用方式:
* ```typescript
* const recordSave = services.recordSave;
* await recordSave.save(record);
* ```
*/
get recordSave(): RecordSave {
if (this._recordSaveInstance === null) {
this._recordSaveInstance = RecordSave.getInstance();
}
return this._recordSaveInstance as RecordSave;
}
/**
* 获取录音服务(已是单例,直接返回) * 获取录音服务(已是单例,直接返回)
* *
* 使用方式: * 使用方式:
...@@ -137,7 +121,6 @@ class Services { ...@@ -137,7 +121,6 @@ class Services {
private _dbRecordInstance: DBRecord | null = null; private _dbRecordInstance: DBRecord | null = null;
private _fileUploadInstance: FileUploadService | null = null; private _fileUploadInstance: FileUploadService | null = null;
private _loggerInstance: Logger | null = null; private _loggerInstance: Logger | null = null;
private _recordSaveInstance: null | RecordSave = null;
private _recordServiceInstance: null | RecordService = null; private _recordServiceInstance: null | RecordService = null;
private _timeoutServiceInstance: null | TimeoutService = null; private _timeoutServiceInstance: null | TimeoutService = null;
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
......
...@@ -29,7 +29,7 @@ export async function consumeAll(recordId: string, cacheConfig: string[]): Promi ...@@ -29,7 +29,7 @@ export async function consumeAll(recordId: string, cacheConfig: string[]): Promi
uni.removeStorage({ uni.removeStorage({
key: storageKey, key: storageKey,
fail: (res) => { fail: (res) => {
services.logger?.warn(`RecordCacheManager: Remove ${storageKey} failed: ${res.errMsg}`, "RecordCache"); services.logger.warn(`RecordCacheManager: Remove ${storageKey} failed: ${res.errMsg}`, "RecordCache");
} }
}); });
} }
......
...@@ -82,12 +82,10 @@ $uni-font-size-paragraph: 15px; ...@@ -82,12 +82,10 @@ $uni-font-size-paragraph: 15px;
} }
.text-two-line { .text-two-line {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
/* 定义文本的行数 */
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-flex;
max-height: 48px; /* 根据 font-size * line-height * 2 计算 */
} }
.select-box { .select-box {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!