Commit 89880107 by chenwq

功能(任务页面): 新增通用自定义表单组件并重构日报报告页面

创建自定义表单的类型定义文件与通用表单组件,支持多种表单字段类型
提取日报表单配置项至单独的常量模块
重构日报报告页面,使用通用表单组件替换原有硬编码的表单结构
移除旧的日报表单样式代码
简化任务页面的活动入口组件映射逻辑
1 parent 731d15e0
export type CustomFormFieldType = "input" | "picker" | "textarea" | "radio" | "checkbox";
export type CustomFormOption = {
label: string
value: string
}
export type CustomFormItem = {
key: string
label: string
type: CustomFormFieldType
inputType?: string
placeholder?: string
required?: boolean
message?: string
full?: boolean
options?: CustomFormOption[]
}
......@@ -18,31 +18,11 @@
<text class="daily-form__title">{{ activeScopeTitle }}</text>
</view>
<view class="daily-form__grid">
<view v-for="(item, index) in dailyFields"
:key="index"
class="daily-field">
<text class="daily-field__label">{{ item.label }}</text>
<input class="daily-field__input"
type="number"
:value="item.value"
placeholder="0" />
</view>
</view>
<view class="daily-field daily-field--full">
<text class="daily-field__label">备注</text>
<textarea class="daily-field__textarea"
:auto-height="false"
maxlength="200" />
</view>
<button class="daily-submit-btn">
<image class="daily-submit-btn__icon"
mode="aspectFit"
src="/static/images/tabbar/record-active.png" />
<text class="daily-submit-btn__text">提交日报</text>
</button>
<CustomForm
:items="dailyReportFormItems"
submit-text="提交日报"
@submit="onSubmitDailyReport">
</CustomForm>
</view>
</view>
</template>
......@@ -50,26 +30,24 @@
<script setup lang="uts">
import { computed, ref } from "vue";
type DailyField = {
label: string
value: string
}
import CustomForm from "@/components/CustomForm.uvue";
import { DAILY_REPORT_FORM_ITEMS } from "../constants/dailyReportForm.uts";
const reportScopes = ["个人", "门店", "品牌"];
const activeScopeIndex = ref<number>(0);
const dailyFields: DailyField[] = [
{ label: "交车数", value: "0" },
{ label: "触客数", value: "0" },
{ label: "意向客户", value: "0" },
{ label: "成交额", value: "0" }
];
const dailyReportFormItems = DAILY_REPORT_FORM_ITEMS;
const activeScopeTitle = computed((): string => {
if (activeScopeIndex.value == 1) return "门店日报";
if (activeScopeIndex.value == 2) return "品牌日报";
return "个人日报";
});
function onSubmitDailyReport(data: UTSJSONObject): void {
console.log("[DailyReport] submit", data);
uni.showToast({ title: "提交成功", icon: "success" });
}
</script>
<style scoped lang="scss">
......
import type { CustomFormItem } from "@/components/CustomFormTypes.uts";
export const DAILY_REPORT_FORM_ITEMS: CustomFormItem[] = [
{
key: "deliveryCount",
label: "交车数",
type: "input",
inputType: "number",
placeholder: "0",
required: true,
message: "请输入交车数"
},
{
key: "customerTouchCount",
label: "触客数",
type: "input",
inputType: "number",
placeholder: "0",
required: true,
message: "请输入触客数"
},
// {
// key: "customerLevel",
// label: "客户级别",
// type: "picker",
// placeholder: "请选择客户级别",
// required: true,
// message: "请选择客户级别",
// options: [
// { label: "A级", value: "A" },
// { label: "B级", value: "B" },
// { label: "C级", value: "C" }
// ]
// },
// {
// key: "dealResult",
// label: "成交状态",
// type: "radio",
// required: true,
// message: "请选择成交状态",
// options: [
// { label: "未成交", value: "pending" },
// { label: "已成交", value: "done" }
// ]
// },
// {
// key: "followActions",
// label: "跟进动作",
// type: "checkbox",
// required: true,
// message: "请选择跟进动作",
// options: [
// { label: "电话回访", value: "phone" },
// { label: "到店邀约", value: "invite" },
// { label: "资料发送", value: "material" }
// ]
// },
{
key: "remark",
label: "备注",
type: "textarea",
placeholder: "请输入备注",
full: true
}
];
......@@ -114,80 +114,6 @@
color: var(--tasks-text-primary, #111827);
}
.daily-form__grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.daily-field {
width: var(--tasks-daily-field-width, 48%);
display: flex;
flex-direction: column;
margin-bottom: 12px;
}
.daily-field--full {
width: 100%;
}
.daily-field__label {
font-size: 13px;
font-weight: 600;
color: var(--tasks-text-primary, #202939);
margin-bottom: 6px;
}
.daily-field__input,
.daily-field__textarea {
width: 100%;
background-color: #fbfcfe;
border: 1px solid var(--tasks-input-border, #e2e8f0);
border-radius: 7px;
box-sizing: border-box;
font-size: 15px;
color: var(--tasks-text-primary, #111827);
}
.daily-field__input {
height: 40px;
padding: 0 12px;
}
.daily-field__textarea {
height: var(--tasks-daily-textarea-height, 60px);
padding: 10px 12px;
}
.daily-submit-btn {
width: 100%;
height: var(--tasks-submit-height, 50px);
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
border-radius: 9px;
background-color: #21a84f;
margin-top: 2px;
}
.daily-submit-btn::after {
border: none;
}
.daily-submit-btn__icon {
width: 18px;
height: 18px;
margin-right: 6px;
}
.daily-submit-btn__text {
font-size: 17px;
font-weight: 700;
color: #ffffff;
}
.study-module {
flex: 1;
min-height: 0;
......
......@@ -37,15 +37,11 @@ const shellRef = ref(null);
const taskEntryConfigs = TASK_ENTRY_CONFIGS;
const activeEntryKey = ref<TaskEntryKey>("daily");
const entryComponentMap = {
daily: DailyReport,
study: StudyPanel,
strategy: StrategyPanel,
review: ReviewPanel
};
const activeEntryComponent = computed((): any => {
return entryComponentMap[activeEntryKey.value];
if (activeEntryKey.value == "study") return StudyPanel;
if (activeEntryKey.value == "strategy") return StrategyPanel;
if (activeEntryKey.value == "review") return ReviewPanel;
return DailyReport;
});
function onEntryChange(key: string): void {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!