fix: membership create & update
This commit is contained in:
parent
d41681c217
commit
ac13d366c8
|
@ -68,6 +68,11 @@ export const SubcategoryComponent = observer((props) => {
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
key: "name",
|
key: "name",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Category",
|
||||||
|
dataIndex: "categoryName",
|
||||||
|
key: "categoryName",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Action",
|
title: "Action",
|
||||||
key: "action",
|
key: "action",
|
||||||
|
|
|
@ -212,7 +212,6 @@ export const Membership = observer(() => {
|
||||||
setInitialData({});
|
setInitialData({});
|
||||||
setConfirmLoading(true);
|
setConfirmLoading(true);
|
||||||
try {
|
try {
|
||||||
console.log(data);
|
|
||||||
await store.membership.update(initialData.id, data);
|
await store.membership.update(initialData.id, data);
|
||||||
message.success(
|
message.success(
|
||||||
initialData.isChangePassword
|
initialData.isChangePassword
|
||||||
|
|
|
@ -35,6 +35,7 @@ export const MembershipModal = ({
|
||||||
.validateFields()
|
.validateFields()
|
||||||
.then((values) => {
|
.then((values) => {
|
||||||
let input = values;
|
let input = values;
|
||||||
|
if (initialData.id)
|
||||||
input.username = initialData.username;
|
input.username = initialData.username;
|
||||||
|
|
||||||
onCreate(input);
|
onCreate(input);
|
||||||
|
@ -51,7 +52,8 @@ export const MembershipModal = ({
|
||||||
name="form_in_modal"
|
name="form_in_modal"
|
||||||
initialValues={initialData}
|
initialValues={initialData}
|
||||||
>
|
>
|
||||||
{((initialData.id && !initialData.isChangePassword) || !initialData.id) && (
|
{((initialData.id && !initialData.isChangePassword) ||
|
||||||
|
!initialData.id) && (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="name"
|
||||||
label="Name"
|
label="Name"
|
||||||
|
@ -69,7 +71,8 @@ export const MembershipModal = ({
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
{((initialData.id && initialData.isChangePassword) || !initialData.id) && (
|
{((initialData.id && initialData.isChangePassword) ||
|
||||||
|
!initialData.id) && (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="password"
|
name="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
|
@ -78,7 +81,18 @@ export const MembershipModal = ({
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
{((initialData.id && !initialData.isChangePassword) || !initialData.id) && (
|
{((initialData.id && !initialData.isChangePassword) ||
|
||||||
|
!initialData.id) && (
|
||||||
|
<Form.Item
|
||||||
|
name="phone_number"
|
||||||
|
label="Phone Number"
|
||||||
|
rules={[{ required: true, message: "Please input Phone Number!" }]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
{((initialData.id && !initialData.isChangePassword) ||
|
||||||
|
!initialData.id) && (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="roleId"
|
name="roleId"
|
||||||
label="Role"
|
label="Role"
|
||||||
|
|
|
@ -26,21 +26,32 @@ export class Category {
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
const response = await http.get(`/product/categories?page=${this.page}&pageSize=${this.pageSize}`);
|
const response = await http.get(`/product/categories?page=${this.page}&pageSize=${this.pageSize}`);
|
||||||
console.log(response)
|
this.data = response.body.data.map((item, idx) => {
|
||||||
this.data = response.body.data ?? []
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
|
|
||||||
this.total_data = response.body.total_data ?? 0
|
this.total_data = response.body.total_data ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDataSubCategories() {
|
async getDataSubCategories() {
|
||||||
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
||||||
this.dataSubCategories = response.body.data ?? []
|
this.dataSubCategories = response.body.data.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
|
|
||||||
this.total_dataSubCategories = response.body.count ?? 0
|
this.total_dataSubCategories = response.body.count ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDataCategories() {
|
async getDataCategories() {
|
||||||
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
|
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
|
||||||
|
|
||||||
this.dataCategories = response.body.data ?? []
|
this.dataCategories = response.body.data.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
|
|
||||||
this.total_dataCategories = response.body.total_data ?? 0
|
this.total_dataCategories = response.body.total_data ?? 0
|
||||||
if (this.dataCategories.length > 0) {
|
if (this.dataCategories.length > 0) {
|
||||||
this.filterCategory = this.dataCategories[0].id
|
this.filterCategory = this.dataCategories[0].id
|
||||||
|
|
|
@ -18,6 +18,7 @@ export class Membership {
|
||||||
this.data = response.body.data.map((item, idx) => {
|
this.data = response.body.data.map((item, idx) => {
|
||||||
item.key = idx;
|
item.key = idx;
|
||||||
item.name = item?.user_detail?.name;
|
item.name = item?.user_detail?.name;
|
||||||
|
item.phone_number = item?.user_detail?.phone_number;
|
||||||
item.roleId = item?.roles.id;
|
item.roleId = item?.roles.id;
|
||||||
item.roleName = item?.roles.name;
|
item.roleName = item?.roles.name;
|
||||||
return item
|
return item
|
||||||
|
@ -33,6 +34,7 @@ export class Membership {
|
||||||
this.data = response.body.data.map((item, idx) => {
|
this.data = response.body.data.map((item, idx) => {
|
||||||
item.key = idx;
|
item.key = idx;
|
||||||
item.name = item?.user_detail?.name;
|
item.name = item?.user_detail?.name;
|
||||||
|
item.phone_number = item?.user_detail?.phone_number;
|
||||||
item.roleId = item?.roles.id;
|
item.roleId = item?.roles.id;
|
||||||
item.roleName = item?.roles?.name;
|
item.roleName = item?.roles?.name;
|
||||||
return item
|
return item
|
||||||
|
|
|
@ -26,13 +26,22 @@ export class Subcategory {
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
const response = await http.get(`/product/sub-categories?page=${this.page}&pageSize=${this.pageSize}`);
|
const response = await http.get(`/product/sub-categories?page=${this.page}&pageSize=${this.pageSize}`);
|
||||||
this.data = response.body.data ?? []
|
this.data = response.body.data.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
item.categoryName = item.category.name;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
|
|
||||||
this.total_data = response.body.total_data ?? 0
|
this.total_data = response.body.total_data ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDataSubCategories() {
|
async getDataSubCategories() {
|
||||||
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
||||||
this.dataSubCategories = response.body.data ?? []
|
this.dataSubCategories = response.body.data.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
|
|
||||||
this.total_dataSubCategories = response.body.count ?? 0
|
this.total_dataSubCategories = response.body.count ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user