Commit f2d4af5d by 李伟康

feat(orderEntry): 集成客户数据与选择组件

- 新增 API 方法获取客户列表,支持按门店筛选,分页大小固定100
- 在订单入口页面请求并转换客户列表数据,传递给子组件
- 工作单、合同单和销售单组件中客户选择项改用统一的 un-select 组件替代旧选择结构
- 优化部分表单字段交互样式以及占位提示信息
- 新增施工项目下拉选择示例数据
- RecentOrderEntry 组件中增加对订单日期格式化与展示支持
- 修正部分图标类型以提升界面一致性
- 调整样式文件,添加 un-select 组件所需的样式规则
1 parent 991563c4
import { request } from "@/api/modules/http/http.uts";
/**
*
* /api/customers
*查询客户列表,支持按门店、关键词分页筛选。pageSize 固定 100。
*/
export function getCustomersListApi(params: UTSJSONObject = {} as UTSJSONObject): Promise<any> {
return request("/customers", params, "GET");
}
......@@ -4,12 +4,15 @@
<view class="form-card">
<view class="form-item">
<text class="form-label">甲方(客户)</text>
<view class="form-select" >
<text class="form-select-text" :class="{ placeholder: contractForm.customer == '' }">
{{ contractForm.customer == "" ? "请选择" : contractForm.customer }}
</text>
<uni-icons type="down" size="12" color="#999999"></uni-icons>
</view>
<un-select
v-model="contractForm.customer"
:list="customersList"
placeholder="请选择客户"
class="form-select-custom"
borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view>
<view class="form-item">
......@@ -71,7 +74,14 @@
</template>
<script setup lang="uts">
import { ref, computed } from "vue";
import { ref, computed , defineProps} from "vue";
const props = defineProps({
customersList: {
type: Array,
default: () => []
}
});
type ContractForm = {
customer: string;
contractType: string;
......
......@@ -65,6 +65,46 @@ type RecentItem = {
day: string;
month: string;
};
function strVal(obj: UTSJSONObject, key: string): string {
const v = obj[key];
return v != null ? `${v}` : "";
}
function numVal(obj: UTSJSONObject, key: string): number {
const v = obj[key];
if (v == null) return 0;
const n = parseFloat(`${v}`);
return isNaN(n) ? 0 : n;
}
function toRecentItem(raw: any): RecentItem {
const obj = raw as UTSJSONObject;
const createdAt = strVal(obj, "createdAt");
const datePart = createdAt.split("T")[0];
const parts = datePart.split("-");
const day = parts.length >= 3 ? parts[2] : "";
const month = parts.length >= 2 ? parts[1] + "/" + day : "";
return {
id: strVal(obj, "id"),
orderNo: strVal(obj, "orderNo"),
storeId: numVal(obj, "storeId"),
customerId: numVal(obj, "customerId"),
customerName: strVal(obj, "customerName"),
customerPhone: strVal(obj, "customerPhone"),
staffId: strVal(obj, "staffId"),
sceneId: obj["sceneId"] != null ? numVal(obj, "sceneId") : null,
totalAmount: numVal(obj, "totalAmount"),
discountAmount: numVal(obj, "discountAmount"),
payAmount: numVal(obj, "payAmount"),
status: numVal(obj, "status"),
statusName: strVal(obj, "statusName"),
payType: obj["payType"] != null ? numVal(obj, "payType") : null,
payTime: obj["payTime"] != null ? strVal(obj, "payTime") : null,
remark: obj["remark"] != null ? strVal(obj, "remark") : null,
createdAt: createdAt,
items: [] as any[],
day: day,
month: month
} as RecentItem;
}
const recentList = ref<RecentItem[]>([]);
function goAll(): void {
uni.showToast({ title: "查看全部", icon: "none" });
......@@ -74,10 +114,12 @@ function onRecentClick(item: RecentItem): void {
}
const getRecentList = async (): Promise<void> => {
try {
const data = await getOrdersList() as RecentItem[];
for (let i = 0; i < data.length; i++) {
data[i].day = data[i].createdAt.split("T")[0].split("-")[2];
data[i].month = data[i].createdAt.split("T")[0].split("-")[1] + "/" + data[i].day;
const rawList = await getOrdersList({ storeId: 1 }) as any[];
console.log(rawList);
const data: RecentItem[] = [];
for (let i = 0; i < rawList.length; i++) {
if(data.length < 2) data.push(toRecentItem(rawList[i]));
else break;
}
recentList.value = data;
} catch (error) {
......
......@@ -4,17 +4,20 @@
<view class="form-card">
<view class="form-item">
<text class="form-label">客户</text>
<view class="form-select" >
<text class="form-select-text" :class="{ placeholder: salesForm.customer == '' }">
{{ salesForm.customer == "" ? "请选择" : salesForm.customer }}
</text>
<uni-icons type="down" size="12" color="#999999"></uni-icons>
</view>
<un-select
v-model="salesForm.customer"
:list="customersList"
placeholder="请选择客户"
class="form-select-custom"
borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view>
<view class="form-item">
<text class="form-label">选择商品</text>
<scroll-view class="sales-product-list" >
<scroll-view class="sales-product-list">
<view
v-for="product in productList"
:key="product.id"
......@@ -55,7 +58,13 @@
</template>
<script setup lang="uts">
import { ref, computed } from "vue";
import { ref, computed, defineProps } from "vue";
const props = defineProps({
customersList: {
type: Array,
default: () => []
}
});
type SalesForm = {
customer: string;
selectedProductIds: string[];
......
<template>
<view class="order-content">
<view class="order-box">
<view class="form-card">
<view class="form-item">
<text class="form-label">客户</text>
<view class="form-select">
<text class="form-select-text" :class="{ placeholder: form.customer == '' }">
{{ form.customer == "" ? "请选择" : form.customer }}
</text>
<uni-icons type="down" size="12" color="#999999"></uni-icons>
<view class="form-card">
<view class="form-item">
<text class="form-label">客户</text>
<un-select
v-model="form.customer"
:list="customersList"
placeholder="请选择客户"
class="form-select-custom"
borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view>
</view>
<view class="form-item">
<text class="form-label">施工项目</text>
<view class="form-select">
<text class="form-select-text" :class="{ placeholder: form.project == '' }">
{{ form.project == "" ? "请选择" : form.project }}
</text>
<uni-icons type="down" size="12" color="#999999"></uni-icons>
<view class="form-item">
<text class="form-label">施工项目</text>
<un-select
v-model="form.project"
:list="projectsList"
placeholder="请选择施工项目"
class="form-select-custom"
borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view>
</view>
<view class="form-item">
<text class="form-label">预约时间</text>
<view class="form-select" @click="openTimePicker">
<text class="form-select-text" :class="{ placeholder: form.appointmentTime == '' }">
{{ form.appointmentTime == "" ? "请选择预约时间" : form.appointmentTime }}
</text>
<uni-icons type="calendar" size="14" color="#999999"></uni-icons>
<view class="form-item">
<text class="form-label">预约时间</text>
<view class="form-select" @click="openTimePicker">
<text class="form-select-text" :class="{ placeholder: form.appointmentTime == '' }">
{{ form.appointmentTime == "" ? "请选择预约时间" : form.appointmentTime }}
</text>
<uni-icons type="calendar" size="14" color="#999999"></uni-icons>
</view>
</view>
</view>
<view class="form-item">
<text class="form-label">施工技师</text>
<input
v-model="form.technician"
class="form-input"
type="text"
placeholder="指派技师"
placeholder-class="form-placeholder"
/>
</view>
<view class="form-item">
<text class="form-label">施工技师</text>
<input
v-model="form.technician"
class="form-input"
type="text"
placeholder="请输入施工技师"
placeholder-class="form-placeholder"
/>
</view>
<view class="form-item form-item--last">
<text class="form-label">备注</text>
<textarea
v-model="form.remark"
class="form-textarea"
placeholder="施工备注..."
placeholder-class="form-placeholder"
/>
<view class="form-item form-item--last">
<text class="form-label">备注</text>
<textarea
v-model="form.remark"
class="form-textarea"
placeholder="请输入备注"
placeholder-class="form-placeholder"
/>
</view>
</view>
</view>
</view>
<view class="submit-wrap">
<view class="submit-btn" @click="submitOrder">
<text class="submit-btn-text">提交</text>
......@@ -74,7 +80,15 @@
</template>
<script setup lang="uts">
import { ref, computed } from "vue";
import { ref, computed , defineProps } from "vue";
import type { UnSelectOption } from '@/uni_modules/uview-unix'
const props = defineProps({
customersList: {
type: Array,
default: () => []
}
});
type OrderForm = {
customer: string;
project: string;
......@@ -89,6 +103,12 @@ const form = ref<OrderForm>({
technician: "",
remark: ""
});
const projectsList = ref<UnSelectOption[]>([
{ value: "1", text: "施工项目1" },
{ value: "2", text: "施工项目2" },
{ value: "3", text: "施工项目3" }
]);
const showTimePicker = ref<boolean>(false);
const appointmentTimeValue = ref<string | number>("");
function openTimePicker(): void {
......
......@@ -32,7 +32,7 @@
</view>
</view>
<scroll-view class="form-box">
<component :is="activeEntryComponent"></component>
<component :is="activeEntryComponent" :customers-list="customersList"></component>
<RecentOrderEntry />
</scroll-view>
</view>
......@@ -42,7 +42,7 @@
<script setup lang="uts">
import TabBarShell from "@/components/TabBar/TabBarShell.uvue";
import {getCustomersListApi} from "@/api/modules/customers.uts";
import pageVars from "./styles/index.vars";
import { ref, computed, getCurrentInstance, onMounted, nextTick, onResize } from "vue";
import { calcWindowTopInsetPx } from "@/utils/safe-area.uts";
......@@ -50,6 +50,7 @@ import WorkOrder from "./components/WorkOrder.uvue";
import ContractOrder from "./components/ContractOrder.uvue";
import SalesOrder from "./components/SalesOrder.uvue";
import RecentOrderEntry from "./components/RecentOrderEntry.uvue";
import type { UnSelectOption } from '@/uni_modules/uview-unix'
type TabItem = {
name: string;
iconType: string;
......@@ -66,6 +67,8 @@ const contentStyle = computed((): string => {
// return `height: ${windowHeight.value - navbarHeight.value - statusBarHeight.value}px`;
});
const customersList = ref<UnSelectOption[]>([]);
function measureNavbarHeight(): void {
uni
.createSelectorQuery()
......@@ -78,9 +81,25 @@ function measureNavbarHeight(): void {
}
});
}
const getCustomersList = async (): Promise<void> => {
try {
const rawList = await getCustomersListApi({ storeId: 1 }) as any[];
const data: UnSelectOption[] = [];
for (let i = 0; i < rawList.length; i++) {
const obj = rawList[i] as UTSJSONObject;
data.push({
text: obj["customerName"] != null ? `${obj["customerName"]}` : "",
value: obj["customerNo"] != null ? `${obj["customerNo"]}` : ""
} as UnSelectOption);
}
customersList.value = data;
} catch (error) {
console.error("获取客户列表失败:", error);
}
};
onMounted(() => {
nextTick(() => {
getCustomersList()
statusBarHeight.value = calcWindowTopInsetPx(uni.getWindowInfo());
measureNavbarHeight();
});
......@@ -96,7 +115,7 @@ onResize((_res: any): void => {
});
const tabs = ref<TabItem[]>([
{ name: "施工单", iconType: "warning-fill", componentName: WorkOrder },
{ name: "合同单", iconType: "lock-fill", componentName: ContractOrder },
{ name: "合同单", iconType: "file-text-fill", componentName: ContractOrder },
{ name: "销售单", iconType: "rmb-circle-fill", componentName: SalesOrder }
]);
function onTabChange(index: number): void {
......
......@@ -106,8 +106,13 @@
padding: 0 12px;
box-sizing: border-box;
background-color: #ffffff;
position: relative;
}
.form-select-custom{
width: 100%;
height: 44px;
box-sizing: border-box;
}
.form-select-text {
font-size: 14px;
font-weight: 400;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!