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 @@ ...@@ -4,12 +4,15 @@
<view class="form-card"> <view class="form-card">
<view class="form-item"> <view class="form-item">
<text class="form-label">甲方(客户)</text> <text class="form-label">甲方(客户)</text>
<view class="form-select" > <un-select
<text class="form-select-text" :class="{ placeholder: contractForm.customer == '' }"> v-model="contractForm.customer"
{{ contractForm.customer == "" ? "请选择" : contractForm.customer }} :list="customersList"
</text> placeholder="请选择客户"
<uni-icons type="down" size="12" color="#999999"></uni-icons> class="form-select-custom"
</view> borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view> </view>
<view class="form-item"> <view class="form-item">
...@@ -71,7 +74,14 @@ ...@@ -71,7 +74,14 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, computed } from "vue"; import { ref, computed , defineProps} from "vue";
const props = defineProps({
customersList: {
type: Array,
default: () => []
}
});
type ContractForm = { type ContractForm = {
customer: string; customer: string;
contractType: string; contractType: string;
......
...@@ -65,6 +65,46 @@ type RecentItem = { ...@@ -65,6 +65,46 @@ type RecentItem = {
day: string; day: string;
month: 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[]>([]); const recentList = ref<RecentItem[]>([]);
function goAll(): void { function goAll(): void {
uni.showToast({ title: "查看全部", icon: "none" }); uni.showToast({ title: "查看全部", icon: "none" });
...@@ -74,10 +114,12 @@ function onRecentClick(item: RecentItem): void { ...@@ -74,10 +114,12 @@ function onRecentClick(item: RecentItem): void {
} }
const getRecentList = async (): Promise<void> => { const getRecentList = async (): Promise<void> => {
try { try {
const data = await getOrdersList() as RecentItem[]; const rawList = await getOrdersList({ storeId: 1 }) as any[];
for (let i = 0; i < data.length; i++) { console.log(rawList);
data[i].day = data[i].createdAt.split("T")[0].split("-")[2]; const data: RecentItem[] = [];
data[i].month = data[i].createdAt.split("T")[0].split("-")[1] + "/" + data[i].day; for (let i = 0; i < rawList.length; i++) {
if(data.length < 2) data.push(toRecentItem(rawList[i]));
else break;
} }
recentList.value = data; recentList.value = data;
} catch (error) { } catch (error) {
......
...@@ -4,17 +4,20 @@ ...@@ -4,17 +4,20 @@
<view class="form-card"> <view class="form-card">
<view class="form-item"> <view class="form-item">
<text class="form-label">客户</text> <text class="form-label">客户</text>
<view class="form-select" > <un-select
<text class="form-select-text" :class="{ placeholder: salesForm.customer == '' }"> v-model="salesForm.customer"
{{ salesForm.customer == "" ? "请选择" : salesForm.customer }} :list="customersList"
</text> placeholder="请选择客户"
<uni-icons type="down" size="12" color="#999999"></uni-icons> class="form-select-custom"
</view> borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="form-label">选择商品</text> <text class="form-label">选择商品</text>
<scroll-view class="sales-product-list" > <scroll-view class="sales-product-list">
<view <view
v-for="product in productList" v-for="product in productList"
:key="product.id" :key="product.id"
...@@ -55,7 +58,13 @@ ...@@ -55,7 +58,13 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, computed } from "vue"; import { ref, computed, defineProps } from "vue";
const props = defineProps({
customersList: {
type: Array,
default: () => []
}
});
type SalesForm = { type SalesForm = {
customer: string; customer: string;
selectedProductIds: string[]; selectedProductIds: string[];
......
...@@ -4,22 +4,28 @@ ...@@ -4,22 +4,28 @@
<view class="form-card"> <view class="form-card">
<view class="form-item"> <view class="form-item">
<text class="form-label">客户</text> <text class="form-label">客户</text>
<view class="form-select"> <un-select
<text class="form-select-text" :class="{ placeholder: form.customer == '' }"> v-model="form.customer"
{{ form.customer == "" ? "请选择" : form.customer }} :list="customersList"
</text> placeholder="请选择客户"
<uni-icons type="down" size="12" color="#999999"></uni-icons> class="form-select-custom"
</view> borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="form-label">施工项目</text> <text class="form-label">施工项目</text>
<view class="form-select"> <un-select
<text class="form-select-text" :class="{ placeholder: form.project == '' }"> v-model="form.project"
{{ form.project == "" ? "请选择" : form.project }} :list="projectsList"
</text> placeholder="请选择施工项目"
<uni-icons type="down" size="12" color="#999999"></uni-icons> class="form-select-custom"
</view> borderColor="#e5e6eb"
round="8px"
inputStyle="height:44px;padding: 0 12px;"
></un-select>
</view> </view>
<view class="form-item"> <view class="form-item">
...@@ -38,7 +44,7 @@ ...@@ -38,7 +44,7 @@
v-model="form.technician" v-model="form.technician"
class="form-input" class="form-input"
type="text" type="text"
placeholder="指派技师" placeholder="请输入施工技师"
placeholder-class="form-placeholder" placeholder-class="form-placeholder"
/> />
</view> </view>
...@@ -48,7 +54,7 @@ ...@@ -48,7 +54,7 @@
<textarea <textarea
v-model="form.remark" v-model="form.remark"
class="form-textarea" class="form-textarea"
placeholder="施工备注..." placeholder="请输入备注"
placeholder-class="form-placeholder" placeholder-class="form-placeholder"
/> />
</view> </view>
...@@ -74,7 +80,15 @@ ...@@ -74,7 +80,15 @@
</template> </template>
<script setup lang="uts"> <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 = { type OrderForm = {
customer: string; customer: string;
project: string; project: string;
...@@ -89,6 +103,12 @@ const form = ref<OrderForm>({ ...@@ -89,6 +103,12 @@ const form = ref<OrderForm>({
technician: "", technician: "",
remark: "" remark: ""
}); });
const projectsList = ref<UnSelectOption[]>([
{ value: "1", text: "施工项目1" },
{ value: "2", text: "施工项目2" },
{ value: "3", text: "施工项目3" }
]);
const showTimePicker = ref<boolean>(false); const showTimePicker = ref<boolean>(false);
const appointmentTimeValue = ref<string | number>(""); const appointmentTimeValue = ref<string | number>("");
function openTimePicker(): void { function openTimePicker(): void {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</view> </view>
</view> </view>
<scroll-view class="form-box"> <scroll-view class="form-box">
<component :is="activeEntryComponent"></component> <component :is="activeEntryComponent" :customers-list="customersList"></component>
<RecentOrderEntry /> <RecentOrderEntry />
</scroll-view> </scroll-view>
</view> </view>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<script setup lang="uts"> <script setup lang="uts">
import TabBarShell from "@/components/TabBar/TabBarShell.uvue"; import TabBarShell from "@/components/TabBar/TabBarShell.uvue";
import {getCustomersListApi} from "@/api/modules/customers.uts";
import pageVars from "./styles/index.vars"; import pageVars from "./styles/index.vars";
import { ref, computed, getCurrentInstance, onMounted, nextTick, onResize } from "vue"; import { ref, computed, getCurrentInstance, onMounted, nextTick, onResize } from "vue";
import { calcWindowTopInsetPx } from "@/utils/safe-area.uts"; import { calcWindowTopInsetPx } from "@/utils/safe-area.uts";
...@@ -50,6 +50,7 @@ import WorkOrder from "./components/WorkOrder.uvue"; ...@@ -50,6 +50,7 @@ import WorkOrder from "./components/WorkOrder.uvue";
import ContractOrder from "./components/ContractOrder.uvue"; import ContractOrder from "./components/ContractOrder.uvue";
import SalesOrder from "./components/SalesOrder.uvue"; import SalesOrder from "./components/SalesOrder.uvue";
import RecentOrderEntry from "./components/RecentOrderEntry.uvue"; import RecentOrderEntry from "./components/RecentOrderEntry.uvue";
import type { UnSelectOption } from '@/uni_modules/uview-unix'
type TabItem = { type TabItem = {
name: string; name: string;
iconType: string; iconType: string;
...@@ -66,6 +67,8 @@ const contentStyle = computed((): string => { ...@@ -66,6 +67,8 @@ const contentStyle = computed((): string => {
// return `height: ${windowHeight.value - navbarHeight.value - statusBarHeight.value}px`; // return `height: ${windowHeight.value - navbarHeight.value - statusBarHeight.value}px`;
}); });
const customersList = ref<UnSelectOption[]>([]);
function measureNavbarHeight(): void { function measureNavbarHeight(): void {
uni uni
.createSelectorQuery() .createSelectorQuery()
...@@ -78,9 +81,25 @@ function measureNavbarHeight(): void { ...@@ -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(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
getCustomersList()
statusBarHeight.value = calcWindowTopInsetPx(uni.getWindowInfo()); statusBarHeight.value = calcWindowTopInsetPx(uni.getWindowInfo());
measureNavbarHeight(); measureNavbarHeight();
}); });
...@@ -96,7 +115,7 @@ onResize((_res: any): void => { ...@@ -96,7 +115,7 @@ onResize((_res: any): void => {
}); });
const tabs = ref<TabItem[]>([ const tabs = ref<TabItem[]>([
{ name: "施工单", iconType: "warning-fill", componentName: WorkOrder }, { 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 } { name: "销售单", iconType: "rmb-circle-fill", componentName: SalesOrder }
]); ]);
function onTabChange(index: number): void { function onTabChange(index: number): void {
......
...@@ -106,8 +106,13 @@ ...@@ -106,8 +106,13 @@
padding: 0 12px; padding: 0 12px;
box-sizing: border-box; box-sizing: border-box;
background-color: #ffffff; background-color: #ffffff;
position: relative;
}
.form-select-custom{
width: 100%;
height: 44px;
box-sizing: border-box;
} }
.form-select-text { .form-select-text {
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!