瀏覽代碼

update shop editor

dev
powersir 1 年之前
父節點
當前提交
942f5bcc94
共有 11 個文件被更改,包括 108 次插入88 次删除
  1. +1
    -1
      src/models/platform.data.ts
  2. +1
    -1
      src/pages/custom/product/sample/components/attr-editor.tsx
  3. +1
    -1
      src/pages/custom/template/dict/dict-detail-editor.tsx
  4. +1
    -1
      src/pages/custom/template/dict/dict-editor.tsx
  5. +1
    -1
      src/pages/system/dept/create-department.tsx
  6. +1
    -1
      src/pages/system/post/create-position.tsx
  7. +2
    -2
      src/pages/system/shop/manage/index.tsx
  8. +97
    -77
      src/pages/system/shop/manage/shop-editor.tsx
  9. +1
    -1
      src/pages/system/tenant/list/tenant-editor.tsx
  10. +1
    -1
      src/pages/system/tenant/package/tenant-pkg-editor.tsx
  11. +1
    -1
      src/request/service/platform-shop.ts

+ 1
- 1
src/models/platform.data.ts 查看文件

@@ -5,7 +5,7 @@ export interface PlatformShop {
/**
* 授权过期时间
*/
expiresTime?: Date;
expiresTime?: number;
/**
* 调用参数_动态_空值
*/


+ 1
- 1
src/pages/custom/product/sample/components/attr-editor.tsx 查看文件

@@ -206,7 +206,7 @@ const SampleAttrEditor: React.FC<CreateSampleAttrProps> = (props) => {
<>
<Drawer
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onClose={() => { onCancel() }}
extra={


+ 1
- 1
src/pages/custom/template/dict/dict-detail-editor.tsx 查看文件

@@ -58,7 +58,7 @@ export default (props: {
<>
<Modal
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onOk={save}
onCancel={() => onCancel()}


+ 1
- 1
src/pages/custom/template/dict/dict-editor.tsx 查看文件

@@ -58,7 +58,7 @@ export default (props: {
<>
<Modal
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onOk={save}
onCancel={() => onCancel()}


+ 1
- 1
src/pages/system/dept/create-department.tsx 查看文件

@@ -61,7 +61,7 @@ const DepartmentEditor: React.FC<EditorProps> = (props) => {
<>
<Modal
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onOk={save}
onCancel={() => onCancel()}


+ 1
- 1
src/pages/system/post/create-position.tsx 查看文件

@@ -61,7 +61,7 @@ const PositionEditor: React.FC<EditorProps> = (props) => {
<>
<Modal
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onOk={save}
onCancel={() => onCancel()}


+ 2
- 2
src/pages/system/shop/manage/index.tsx 查看文件

@@ -217,14 +217,14 @@ export default () => {
pagination={false} />
</Card>
</div>
{/* <ShopEditor
<ShopEditor
onSave={() => {
load();
seEditorVisable(false);
}}
onCancel={() => { seEditorVisable(false) }}
visible={editorVisable}
data={editData} /> */}
data={editData} />
</>
);
};


+ 97
- 77
src/pages/system/shop/manage/shop-editor.tsx 查看文件

@@ -1,9 +1,8 @@
import React, { useEffect, useState } from 'react'
import { Form, Input, InputNumber, Radio, Modal, Select, DatePicker } from 'antd';
import tenantService from '@/request/service/tenant';
import tenantPkgService from '@/request/service/tenant-package';
import React, { useEffect, useState } from 'react';
import { Form, Input, InputNumber, Radio, Modal, Steps, DatePicker, Button } from 'antd';
import platformShopService from '@/request/service/platform-shop';
import { useRequest } from '@/hooks/use-request';
import type { TenantVO } from '@/models'
import type { PlatformShop } from '@/models'
import { antdUtils } from '@/utils/antd';
import customParseFormat from 'dayjs/plugin/customParseFormat';

@@ -19,45 +18,56 @@ const layout = {
interface EditorProps {
visible: boolean;
onCancel: (flag?: boolean) => void;
onSave: (role: TenantVO) => void;
data?: TenantVO | null;
onSave: (role: PlatformShop) => void;
data?: PlatformShop | null;
}


const TenantEditor: React.FC<EditorProps> = (props) => {

const { visible, onCancel, onSave, data } = props;

const { runAsync: updateApi } = useRequest(tenantService.updateTenantApi, { manual: true });
const { runAsync: createApi } = useRequest(tenantService.createTenantApi, { manual: true });
const { data: tenanPackages, run: getTenantPackageList } = useRequest(tenantPkgService.getTenantPackageList, { manual: true });
const { runAsync: updateApi } = useRequest(platformShopService.updatePlatformShop, { manual: true });
const { runAsync: createApi } = useRequest(platformShopService.createPlatformShop, { manual: true });

const isEdit = !!data;

const [current, setCurrent] = useState(0);

const next = async () => {
const isValidate = await form.validateFields();
console.log(isValidate)
setCurrent(current + 1);
};

const prev = () => {
setCurrent(current - 1);
};
const [saveLoading, setSaveLoading] = useState(false);
const [form] = Form.useForm();
const [shopForm] = Form.useForm();

useEffect(() => {
if (visible) {
if (data) {
form.setFieldsValue(data);
form.setFieldValue('expireTime', dayjs(data.expireTime))
form.setFieldValue('expiresTime', dayjs(data.expiresTime));
shopForm.setFieldsValue(data.shopConfig);
} else {
form.setFieldValue("shopStatus", 0);
}
} else {
form.resetFields();
shopForm.resetFields();
}
}, [visible]);

useEffect(() => {
getTenantPackageList()
}, [getTenantPackageList])

const save = async () => {
await shopForm.validateFields();
setSaveLoading(true);
const fieldValues = form.getFieldsValue();
const expireTime = dayjs(form.getFieldValue('expireTime')).toDate().getTime()
const newValue = isEdit ? { ...data, ...fieldValues, expireTime } : {...fieldValues, expireTime};
const expireTime = dayjs(form.getFieldValue('expiresTime')).toDate().getTime();
const shopFieldValues = shopForm.getFieldsValue();
const newValue = isEdit ? { ...data, ...fieldValues, expireTime, shopConfig: { ...shopFieldValues } } : { ...fieldValues, expireTime, shopConfig: { ...shopFieldValues } };
const [error, { msg, code }] = isEdit ? await updateApi(newValue) : await createApi(newValue);
if (!error && code === 0) {
onSave(newValue);
@@ -74,85 +84,63 @@ const TenantEditor: React.FC<EditorProps> = (props) => {
<>
<Modal
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onOk={save}
onCancel={() => onCancel()}
confirmLoading= {saveLoading}
footer={null}
confirmLoading={saveLoading}
destroyOnClose
>
<Steps className="my-5" current={current} items={[
{
title: '商户设置'
},
{
title: '平台店铺配置',
}
]} />

<Form
form={form}
{...layout}
onFinish={save}
labelCol={{ flex: '0 0 100px' }}
wrapperCol={{ span: 16 }}
>
<Form.Item name="name" label="租户名称"
rules={[
{
required: true,
message: '请输入租户名称',
},
]}
>
<Input />
</Form.Item>

<Form.Item name="packageId" label="租户套餐"
rules={[
{
required: true,
message: '请选择租户套餐',
},
]}
>
<Select placeholder="请选择租户套餐" options={tenanPackages?.data.map(item => {
return {
label: item.name,
value: item.id,
}
})}>
</Select>
</Form.Item>
hidden={current === 1}

<Form.Item name="contactName" label="联系人"
>
<Form.Item name="shopName" label="店铺名称"
rules={[
{
required: true,
message: '请输入联系人',
message: '请输入店铺名称',
},
]}
>
<Input />
</Form.Item>


<Form.Item name="contactMobile" label="联系电话"
<Form.Item name="platformId" label="平台"
rules={[
{
required: true,
message: '请输入电话号码',
message: '请选择',
},
]}
>
<Input />
</Form.Item>

<Form.Item name="username" label="用户名称">
<Form.Item name="userName" label="账号">
<Input />
</Form.Item>

<Form.Item name="password" label="用户密码">
<Form.Item name="password" label="密码">
<Input />
</Form.Item>

<Form.Item name="accountCount" label="账号额度" >
<InputNumber min={0} />
</Form.Item>

<Form.Item name="expireTime" label="过期时间"
<Form.Item name="expiresTime" label="过期时间"
rules={[
{
required: true,
@@ -162,30 +150,62 @@ const TenantEditor: React.FC<EditorProps> = (props) => {
<DatePicker showTime format="YYYY-MM-DD HH:mm:ss" />
</Form.Item>

<Form.Item name="domain" label="绑定域名"
rules={[
{
required: true,
message: '请输入绑定域名',
},
]}
>
<Input />
<Form.Item name="shopStatus" label="状态" rules={[{
required: true,
message: '请设置状态',
},]}>
<Radio.Group options={[
{ value: 0, label: "开启" },
{ value: 1, label: "关闭" }
]} optionType="default">
</Radio.Group>
</Form.Item>
</Form>

<Form.Item name="status" label="租户状态" rules={[
<Form
form={shopForm}
{...layout}
onFinish={save}
labelCol={{ flex: '0 0 100px' }}
wrapperCol={{ span: 16 }}
hidden={current === 0}
>
<Form.Item name="shopId" label="店铺"
rules={[
{
required: true,
message: '请选择租户状态',
message: '请设置店铺',
},
]}>
<Radio.Group options={[
{ value: 0, label: "开启" },
{ value: 1, label: "关闭" }
]} optionType="default">
</Radio.Group>
<Input />
</Form.Item>
<Form.Item name="iossNo" label="欧盟税号">
<Input />
</Form.Item>
<Form.Item name="vat" label="vat税号">
<Input />
</Form.Item>
<Form.Item name="language" label="语言">
<Input />
</Form.Item>
<Form.Item name="dayMaxPublishNumber" label="最大刊登量">
<InputNumber min={0} />
</Form.Item>
</Form>

<div className='flex justify-end'>
{
(current === 0 ?
(<Button type='primary' size='large' onClick={next}> 下一步 </Button>) :
(
<>
<Button size='large' onClick={prev} disabled={saveLoading}> 上一步 </Button>
<Button type='primary' size='large' className='ml-2' onClick={save}> 提交 </Button>
</>
)
)
}
</div>
</Modal>
</>
)


+ 1
- 1
src/pages/system/tenant/list/tenant-editor.tsx 查看文件

@@ -74,7 +74,7 @@ const TenantEditor: React.FC<EditorProps> = (props) => {
<>
<Modal
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onOk={save}
onCancel={() => onCancel()}


+ 1
- 1
src/pages/system/tenant/package/tenant-pkg-editor.tsx 查看文件

@@ -89,7 +89,7 @@ const TenantPackageEditor: React.FC<EditorProps> = (props) => {
<>
<Modal
open={visible}
title="新建"
title={isEdit ? "编辑" : "新建"}
width={640}
onOk={save}
confirmLoading={saveLoading}


+ 1
- 1
src/request/service/platform-shop.ts 查看文件

@@ -16,7 +16,7 @@ export default {

// 修改平台店铺
updatePlatformShop: (data: PlatformShop) => {
return request.put(`${BASE_URL}/update`, data);
return request.post(`${BASE_URL}/update`, data);
},

// 删除平台店铺


Loading…
取消
儲存