feat: 优化咨询表单配置体验
This commit is contained in:
1 parent
37e898a4b9
commit
2bc2193b44
4 files changed
+62
-14
No files matched your search
@@ -85,6 +85,19 @@ export function WorkspacePage() {
|
||||
const [previewVisual, setPreviewVisual] = useState("linjing-editorial");
|
||||
const [form] = Form.useForm<Record<string, unknown>>();
|
||||
const [inquiryForm] = Form.useForm<Record<string, unknown>>();
|
||||
const openNewInquiryForm = () => {
|
||||
setEditingForm(null);
|
||||
inquiryForm.setFieldsValue({
|
||||
name: "合作咨询",
|
||||
purpose: "inquiry",
|
||||
fieldsSnapshot: [
|
||||
{ key: "name", label: "您的称呼", type: "text", required: true },
|
||||
{ key: "phone", label: "联系电话", type: "phone", required: true },
|
||||
{ key: "remark", label: "想咨询什么", type: "textarea", required: false },
|
||||
],
|
||||
});
|
||||
setFormOpen(true);
|
||||
};
|
||||
const query = useQuery({
|
||||
queryKey: ["admin-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
@@ -496,14 +509,7 @@ export function WorkspacePage() {
|
||||
<Card
|
||||
title="动态咨询表单"
|
||||
extra={
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setEditingForm(null);
|
||||
inquiryForm.resetFields();
|
||||
setFormOpen(true);
|
||||
}}
|
||||
>
|
||||
<Button type="primary" onClick={openNewInquiryForm}>
|
||||
新增表单
|
||||
</Button>
|
||||
}
|
||||
@@ -512,6 +518,7 @@ export function WorkspacePage() {
|
||||
rowKey="id"
|
||||
loading={forms.isLoading}
|
||||
dataSource={forms.data ?? []}
|
||||
locale={{ emptyText: "还没有咨询入口,点击右上角即可从默认表单开始。" }}
|
||||
columns={[
|
||||
{ title: "名称", dataIndex: "name" },
|
||||
{ title: "版本", dataIndex: "version", render: (value) => <Tag>v{value}</Tag> },
|
||||
@@ -529,6 +536,7 @@ export function WorkspacePage() {
|
||||
size="small"
|
||||
onClick={() => {
|
||||
setEditingForm(item);
|
||||
inquiryForm.resetFields();
|
||||
inquiryForm.setFieldsValue({
|
||||
name: item.name,
|
||||
purpose: item.purpose,
|
||||
@@ -684,7 +692,11 @@ export function WorkspacePage() {
|
||||
}}
|
||||
onOk={() => inquiryForm.submit()}
|
||||
confirmLoading={createForm.isPending || updateForm.isPending}
|
||||
width={760}
|
||||
>
|
||||
<Typography.Paragraph type="secondary">
|
||||
先确定客户要提交的事情,再设置你希望客户填写的问题。保存后还需要在“配置与发布”中检查并发布,才会在小程序生效。
|
||||
</Typography.Paragraph>
|
||||
<Form
|
||||
form={inquiryForm}
|
||||
layout="vertical"
|
||||
@@ -721,11 +733,21 @@ export function WorkspacePage() {
|
||||
})()
|
||||
}
|
||||
>
|
||||
<Form.Item name="name" label="表单名称" rules={[{ required: true }]}>
|
||||
<Input placeholder="例如:合作咨询" />
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="这份表单叫什么"
|
||||
help="客户会在小程序看到这个名称。"
|
||||
rules={[{ required: true, message: "请填写表单名称" }]}
|
||||
>
|
||||
<Input placeholder="例如:预约上门测量、家庭聚餐预订" />
|
||||
</Form.Item>
|
||||
<Space style={{ display: "flex" }} align="start">
|
||||
<Form.Item name="purpose" label="用途" initialValue="inquiry">
|
||||
<Form.Item
|
||||
name="purpose"
|
||||
label="客户要做什么"
|
||||
help="决定提交按钮和后续处理方式。"
|
||||
initialValue="inquiry"
|
||||
>
|
||||
<Select
|
||||
style={{ width: 160 }}
|
||||
options={[
|
||||
@@ -735,7 +757,7 @@ export function WorkspacePage() {
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="offeringId" label="关联业务">
|
||||
<Form.Item name="offeringId" label="关联哪项业务" help="不选择表示这是品牌通用入口。">
|
||||
<Select
|
||||
allowClear
|
||||
style={{ width: 220 }}
|
||||
@@ -750,7 +772,10 @@ export function WorkspacePage() {
|
||||
<Form.List name="fieldsSnapshot">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
<Form.Item label="表单字段">
|
||||
<Form.Item
|
||||
label="客户需要填写什么"
|
||||
help="建议保留称呼和联系电话,再添加与你的业务有关的问题。"
|
||||
>
|
||||
<Button
|
||||
onClick={() =>
|
||||
add({
|
||||
@@ -779,7 +804,7 @@ export function WorkspacePage() {
|
||||
<Input placeholder="例如:联系电话、预计预算、项目地址" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "type"]} label="回答方式">
|
||||
<Select style={{ width: 130 }} options={inquiryFieldTypes} />
|
||||
<Select style={{ width: 150 }} options={inquiryFieldTypes} />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "required"]} label="必填">
|
||||
<Select
|
||||
|
||||
Reference in new issue
Block a user