Commit bbc0cddc by liimin

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

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