feat: 更新依赖包版本,添加编辑发行期功能,优化时间验证逻辑
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
"@better-scroll/core": "2.5.1",
|
||||
"@elysiajs/eden": "^1.4.5",
|
||||
"@iconify/vue": "5.0.0",
|
||||
"@riwa/api-types": "http://192.168.1.27:9527/api/riwa-api-types-0.0.47.tgz",
|
||||
"@riwa/api-types": "http://192.168.1.27:9527/api/riwa-api-types-0.0.56.tgz",
|
||||
"@sa/axios": "workspace:*",
|
||||
"@sa/color": "workspace:*",
|
||||
"@sa/hooks": "workspace:*",
|
||||
|
||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -18,8 +18,8 @@ importers:
|
||||
specifier: 5.0.0
|
||||
version: 5.0.0(vue@3.5.25(typescript@5.9.3))
|
||||
'@riwa/api-types':
|
||||
specifier: http://192.168.1.27:9527/api/riwa-api-types-0.0.47.tgz
|
||||
version: http://192.168.1.27:9527/api/riwa-api-types-0.0.47.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))
|
||||
specifier: http://192.168.1.27:9527/api/riwa-api-types-0.0.56.tgz
|
||||
version: http://192.168.1.27:9527/api/riwa-api-types-0.0.56.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))
|
||||
'@sa/axios':
|
||||
specifier: workspace:*
|
||||
version: link:packages/axios
|
||||
@@ -1068,9 +1068,9 @@ packages:
|
||||
'@quansync/fs@0.1.6':
|
||||
resolution: {integrity: sha512-zoA8SqQO11qH9H8FCBR7NIbowYARIPmBz3nKjgAaOUDi/xPAAu1uAgebtV7KXHTc6CDZJVRZ1u4wIGvY5CWYaw==}
|
||||
|
||||
'@riwa/api-types@http://192.168.1.27:9527/api/riwa-api-types-0.0.47.tgz':
|
||||
resolution: {tarball: http://192.168.1.27:9527/api/riwa-api-types-0.0.47.tgz}
|
||||
version: 0.0.47
|
||||
'@riwa/api-types@http://192.168.1.27:9527/api/riwa-api-types-0.0.56.tgz':
|
||||
resolution: {tarball: http://192.168.1.27:9527/api/riwa-api-types-0.0.56.tgz}
|
||||
version: 0.0.56
|
||||
peerDependencies:
|
||||
'@elysiajs/eden': ^1.4.5
|
||||
|
||||
@@ -5057,7 +5057,7 @@ snapshots:
|
||||
dependencies:
|
||||
quansync: 0.3.0
|
||||
|
||||
'@riwa/api-types@http://192.168.1.27:9527/api/riwa-api-types-0.0.47.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))':
|
||||
'@riwa/api-types@http://192.168.1.27:9527/api/riwa-api-types-0.0.56.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))':
|
||||
dependencies:
|
||||
'@elysiajs/eden': 1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3))
|
||||
|
||||
|
||||
@@ -91,15 +91,14 @@ function handleCreateDraftAndSubmit() {
|
||||
window.$message?.error(timeError);
|
||||
return;
|
||||
}
|
||||
// await safeClient(
|
||||
// client.api.admin.rwa.issuance.editions.post({
|
||||
// ...form.value,
|
||||
// launchDate: form.value.launchDate ? new Date(form.value.launchDate) : undefined,
|
||||
// subscriptionStartDate: form.value.subscriptionStartDate ? new Date(form.value.subscriptionStartDate) : undefined,
|
||||
// subscriptionEndDate: form.value.subscriptionEndDate ? new Date(form.value.subscriptionEndDate) : undefined,
|
||||
// submitForReview: true
|
||||
// })
|
||||
// );
|
||||
await safeClient(
|
||||
client.api.admin.rwa.issuance.editions.post({
|
||||
...form.value,
|
||||
launchDate: new Date(form.value.launchDate!),
|
||||
subscriptionStartDate: new Date(form.value.subscriptionStartDate!),
|
||||
subscriptionEndDate: new Date(form.value.subscriptionEndDate!)
|
||||
} as Body)
|
||||
);
|
||||
emit('close');
|
||||
}
|
||||
});
|
||||
@@ -185,8 +184,8 @@ function handleCreateDraftAndSubmit() {
|
||||
</NFormItem>
|
||||
|
||||
<NSpace justify="end" class="mt-5">
|
||||
<NButton type="primary" ghost @click="handleCreateDraftAndSubmit">创建草稿并发布</NButton>
|
||||
<NButton type="primary" @click="handleCreateDraft">创建草稿</NButton>
|
||||
<NButton type="primary" ghost @click="handleCreateDraftAndSubmit">创建并发布</NButton>
|
||||
<NButton type="primary" @click="handleCreateDraft">创建</NButton>
|
||||
</NSpace>
|
||||
</NForm>
|
||||
</div>
|
||||
|
||||
177
src/views/rwa/product/components/edit-edition.vue
Normal file
177
src/views/rwa/product/components/edit-edition.vue
Normal file
@@ -0,0 +1,177 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref, useTemplateRef } from 'vue';
|
||||
import type { FormInst, FormRules } from 'naive-ui';
|
||||
import dayjs from 'dayjs';
|
||||
import { client, safeClient } from '@/service/api';
|
||||
|
||||
type Body = CommonType.TreatyBody<typeof client.api.admin.rwa.issuance.editions.post>;
|
||||
|
||||
defineOptions({ name: 'RwaEditionAdd' });
|
||||
const emit = defineEmits<{
|
||||
(e: 'close'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
data: Body;
|
||||
}>();
|
||||
|
||||
const formInst = useTemplateRef<FormInst>('formInst');
|
||||
const form = ref<Body>({
|
||||
productId: props.data.productId,
|
||||
editionName: props.data.editionName,
|
||||
perUserLimit: props.data.perUserLimit,
|
||||
totalSupply: props.data.totalSupply,
|
||||
unitPrice: props.data.unitPrice,
|
||||
dividendRate: props.data.dividendRate,
|
||||
launchDate: dayjs(props.data.launchDate).toDate(),
|
||||
subscriptionStartDate: props.data.subscriptionStartDate ? dayjs(props.data.subscriptionStartDate).toDate() : null,
|
||||
subscriptionEndDate: props.data.subscriptionEndDate ? dayjs(props.data.subscriptionEndDate).toDate() : null
|
||||
});
|
||||
|
||||
const rules: FormRules = {
|
||||
editionName: [{ required: true, message: '请输入发行期名称', trigger: ['blur', 'input'] }],
|
||||
perUserLimit: [{ required: true, message: '请输入个人申购上限', trigger: ['blur', 'input'] }],
|
||||
totalSupply: [{ required: true, message: '请输入发行总量', trigger: ['blur', 'input'] }],
|
||||
unitPrice: [{ required: true, message: '请输入单价', trigger: ['blur', 'input'] }],
|
||||
dividendRate: [{ required: true, message: '请输入分红率', trigger: ['blur', 'input'] }],
|
||||
launchDate: [{ required: true, type: 'number', message: '请选择预热时间', trigger: ['blur', 'change'] }],
|
||||
subscriptionStartDate: [
|
||||
{ required: true, type: 'number', message: '请选择申购开始时间', trigger: ['blur', 'change'] }
|
||||
],
|
||||
subscriptionEndDate: [{ required: true, type: 'number', message: '请选择申购结束时间', trigger: ['blur', 'change'] }]
|
||||
};
|
||||
|
||||
// 手动验证时间逻辑
|
||||
function validateTimes() {
|
||||
const now = dayjs();
|
||||
|
||||
if (form.value.launchDate && dayjs(form.value.launchDate).isBefore(now)) {
|
||||
return '预热时间必须在当前时间之后';
|
||||
}
|
||||
|
||||
if (form.value.subscriptionStartDate && form.value.launchDate) {
|
||||
if (dayjs(form.value.subscriptionStartDate).isBefore(dayjs(form.value.launchDate))) {
|
||||
return '申购开始时间必须在预热时间之后';
|
||||
}
|
||||
}
|
||||
|
||||
if (form.value.subscriptionEndDate && form.value.subscriptionStartDate) {
|
||||
if (dayjs(form.value.subscriptionEndDate).isBefore(dayjs(form.value.subscriptionStartDate))) {
|
||||
return '申购结束时间必须在开始时间之后';
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
formInst.value?.validate(async errors => {
|
||||
if (!errors) {
|
||||
const timeError = validateTimes();
|
||||
if (timeError) {
|
||||
window.$message?.error(timeError);
|
||||
return;
|
||||
}
|
||||
await safeClient(
|
||||
client.api.admin.rwa.issuance.editions.post({
|
||||
...form.value,
|
||||
launchDate: new Date(form.value.launchDate!),
|
||||
subscriptionStartDate: new Date(form.value.subscriptionStartDate!),
|
||||
subscriptionEndDate: new Date(form.value.subscriptionEndDate!)
|
||||
} as Body)
|
||||
);
|
||||
emit('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-10">
|
||||
<NForm
|
||||
ref="formInst"
|
||||
:model="form"
|
||||
label-width="150"
|
||||
label-placement="left"
|
||||
label-align="left"
|
||||
:rules="rules"
|
||||
require-mark-placement="left"
|
||||
>
|
||||
<NFormItem path="editionName" label="发行期名称">
|
||||
<NInput v-model:value="form.editionName" />
|
||||
</NFormItem>
|
||||
<NFormItem path="perUserLimit" label="个人申购上限(份)">
|
||||
<NInputNumber
|
||||
:min="1"
|
||||
:step="10"
|
||||
:value="Number(form.perUserLimit)"
|
||||
@update:value="val => (form.perUserLimit = String(val))"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem path="totalSupply" label="发行总量(份)">
|
||||
<NInputNumber
|
||||
:min="1"
|
||||
:step="100"
|
||||
:value="Number(form.totalSupply)"
|
||||
@update:value="val => (form.totalSupply = String(val))"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem path="unitPrice" label="单价($)">
|
||||
<NInputNumber :min="0" :value="Number(form.unitPrice)" @update:value="val => (form.unitPrice = String(val))" />
|
||||
</NFormItem>
|
||||
<NFormItem path="dividendRate" label="分红率(0.01 = 1%)">
|
||||
<NInputNumber
|
||||
:max="1"
|
||||
:min="0"
|
||||
:step="0.01"
|
||||
:value="Number(form.dividendRate)"
|
||||
@update:value="val => (form.dividendRate = String(val))"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem path="launchDate" label="预热时间">
|
||||
<NDatePicker
|
||||
:value="dayjs(form.launchDate).valueOf()"
|
||||
type="datetime"
|
||||
format="yyyy-MM-dd HH:mm"
|
||||
:is-date-disabled="(ts: number) => ts < Date.now()"
|
||||
value-format="x"
|
||||
@update:value="val => (form.launchDate = new Date(val))"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem>
|
||||
<NSpace vertical class="w-full">
|
||||
<NFormItem path="subscriptionStartDate" label="申购开始时间" label-width="150">
|
||||
<NDatePicker
|
||||
:value="dayjs(form.subscriptionStartDate).valueOf()"
|
||||
type="datetime"
|
||||
format="yyyy-MM-dd HH:mm"
|
||||
:is-date-disabled="(ts: number) => (form.launchDate ? ts < Number(form.launchDate) : false)"
|
||||
value-format="x"
|
||||
class="w-full"
|
||||
@update:value="val => (form.subscriptionStartDate = new Date(val))"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem path="subscriptionEndDate" label="申购结束时间" label-width="150">
|
||||
<NDatePicker
|
||||
:value="dayjs(form.subscriptionEndDate).valueOf()"
|
||||
type="datetime"
|
||||
format="yyyy-MM-dd HH:mm"
|
||||
:is-date-disabled="
|
||||
(ts: number) => (form.subscriptionStartDate ? ts < Number(form.subscriptionStartDate) : false)
|
||||
"
|
||||
value-format="x"
|
||||
class="w-full"
|
||||
@update:value="val => (form.subscriptionEndDate = new Date(val))"
|
||||
/>
|
||||
</NFormItem>
|
||||
</NSpace>
|
||||
</NFormItem>
|
||||
|
||||
<NSpace justify="end" class="mt-5">
|
||||
<NButton type="primary" @click="handleSubmit">修 改</NButton>
|
||||
</NSpace>
|
||||
</NForm>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="css" scoped></style>
|
||||
@@ -7,6 +7,7 @@ import { client, safeClient } from '@/service/api';
|
||||
import type { TableBaseColumns, TableFetchData, TableInst } from '@/components/table';
|
||||
import { RwaEditionStatusEnum } from '@/enum';
|
||||
import AddEdition from './add-edition.vue';
|
||||
import EditEdition from './edit-edition.vue';
|
||||
|
||||
defineOptions({ name: 'RwaProductEditions' });
|
||||
|
||||
@@ -98,19 +99,37 @@ const columns: TableBaseColumns = [
|
||||
type: 'primary',
|
||||
ghost: true,
|
||||
size: 'small',
|
||||
visible: row.status === 'draft',
|
||||
onClick: () => {
|
||||
console.log(row);
|
||||
visible: row.status === 'draft' || row.status === 'cancelled',
|
||||
onClick: async () => {
|
||||
dialog.create({
|
||||
title: '确认发布该发行期吗?',
|
||||
content: '发布后该发行期将对投资者可见,且不可修改。',
|
||||
positiveText: '确认',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
await safeClient(client.api.admin.rwa.issuance.editions({ id: row.id }).publish.post());
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
contentText: '取消',
|
||||
contentText: '取消发布',
|
||||
type: 'primary',
|
||||
ghost: true,
|
||||
size: 'small',
|
||||
visible: row.status === 'draft',
|
||||
onClick: () => {
|
||||
console.log(row);
|
||||
visible: row.status === 'scheduled',
|
||||
onClick: async () => {
|
||||
dialog.create({
|
||||
title: '确认取消发布该发行期吗?',
|
||||
content: '取消发布后该发行期将对投资者不可见,且不可修改。',
|
||||
positiveText: '确认',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
await safeClient(client.api.admin.rwa.issuance.editions({ id: row.id }).cancel.post());
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -119,15 +138,14 @@ const columns: TableBaseColumns = [
|
||||
ghost: true,
|
||||
size: 'small',
|
||||
visible: row.status === 'draft',
|
||||
onClick: () => {
|
||||
console.log(row);
|
||||
}
|
||||
onClick: () => handleEdit(row)
|
||||
},
|
||||
{
|
||||
contentText: '删除',
|
||||
type: 'error',
|
||||
ghost: true,
|
||||
size: 'small',
|
||||
visible: row.status === 'draft',
|
||||
onClick: () => {
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
@@ -138,8 +156,33 @@ const columns: TableBaseColumns = [
|
||||
|
||||
function handleAdd() {
|
||||
const dialogInstance = dialog.create({
|
||||
title: '发行期列表',
|
||||
content: () => h(AddEdition, { productId: props.data.id }),
|
||||
title: '添加发行期',
|
||||
content: () =>
|
||||
h(AddEdition, {
|
||||
productId: props.data.id,
|
||||
onClose: () => {
|
||||
dialogInstance.destroy();
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
}),
|
||||
style: { width: '600px' },
|
||||
showIcon: false,
|
||||
onPositiveClick: () => {
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
function handleEdit(row: any) {
|
||||
const dialogInstance = dialog.create({
|
||||
title: '编辑发行期',
|
||||
content: () =>
|
||||
h(EditEdition, {
|
||||
data: row,
|
||||
onClose: () => {
|
||||
dialogInstance.destroy();
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
}),
|
||||
style: { width: '600px' },
|
||||
showIcon: false,
|
||||
onPositiveClick: () => {
|
||||
|
||||
Reference in New Issue
Block a user