|
@@ -1,21 +1,22 @@
|
|
|
import { useCollocation } from "@/modules/collocation";
|
|
|
import { css } from "@linaria/core";
|
|
|
+import { Image } from "@queenjs/ui";
|
|
|
import { Button, Space, Table } from "ant-design-vue";
|
|
|
+import { ColumnsType } from "ant-design-vue/lib/table/Table";
|
|
|
+import { queenApi } from "queenjs";
|
|
|
import { defineComponent, onMounted } from "vue";
|
|
|
-import { Image } from "@queenjs/ui";
|
|
|
import OperationModal from "./components/OperationModal";
|
|
|
-import { queenApi } from "queenjs";
|
|
|
|
|
|
export default defineComponent({
|
|
|
setup() {
|
|
|
const collocation = useCollocation();
|
|
|
|
|
|
- const columns = [
|
|
|
+ const columns: ColumnsType = [
|
|
|
{
|
|
|
title: "款式图片",
|
|
|
dataIndex: "thumbnail",
|
|
|
key: "thumbnail",
|
|
|
- customRender: ({ text }: any) => (
|
|
|
+ customRender: ({ text }) => (
|
|
|
<Image class="thumbnail" src={text?.url} size={120} />
|
|
|
),
|
|
|
},
|
|
@@ -39,13 +40,13 @@ export default defineComponent({
|
|
|
title: "价格(元)",
|
|
|
dataIndex: "price",
|
|
|
key: "price",
|
|
|
- customRender: ({ text }: any) => (text / 100 || 0).toFixed(2),
|
|
|
+ customRender: ({ text }) => (text / 100 || 0).toFixed(2),
|
|
|
},
|
|
|
{
|
|
|
title: "操作",
|
|
|
key: "action",
|
|
|
dataIndex: "action",
|
|
|
- customRender: ({ record }: any) => {
|
|
|
+ customRender: ({ record }) => {
|
|
|
return (
|
|
|
<Space>
|
|
|
<Button type="link" onClick={() => showEdit(record)}>
|
|
@@ -60,7 +61,11 @@ export default defineComponent({
|
|
|
>
|
|
|
定制内容
|
|
|
</Button>
|
|
|
- <Button type="text" danger onClick={() => delDesign(record)}>
|
|
|
+ <Button
|
|
|
+ type="text"
|
|
|
+ danger
|
|
|
+ onClick={() => collocation.actions.delDesign(record)}
|
|
|
+ >
|
|
|
删除
|
|
|
</Button>
|
|
|
</Space>
|
|
@@ -70,41 +75,39 @@ export default defineComponent({
|
|
|
];
|
|
|
|
|
|
onMounted(() => {
|
|
|
- // ctx.design.DesignList.loadPage(1, 20);
|
|
|
- // ctx.design.SizeList.loadPage(1, 1000);
|
|
|
+ collocation.controls.listCtrl.loadPage(1, 20);
|
|
|
});
|
|
|
|
|
|
const showAddDesign = async () => {
|
|
|
- const values: any = await collocation.showModal(<OperationModal />, {
|
|
|
+ const values: IStyle = await collocation.showModal(<OperationModal />, {
|
|
|
title: "添加可定制款式",
|
|
|
width: "500px",
|
|
|
});
|
|
|
if (!values) return;
|
|
|
- values.thumbnail = values.scenePack.thumbnail;
|
|
|
- // values.price = parseInt(values.price * 100 + "");
|
|
|
- // let res = await ctx.design.actions.addDesign(values);
|
|
|
- };
|
|
|
|
|
|
- const showEdit = async (record: any) => {
|
|
|
- // let item = await ctx.design.actions.getDesignDTL(record._id);
|
|
|
- // if (!item) return false;
|
|
|
- // item.price = (item.price / 100).toFixed(2);
|
|
|
- const values: any = await collocation.showModal(<OperationModal />, {
|
|
|
- title: "编辑可定制款式",
|
|
|
- width: "500px",
|
|
|
- });
|
|
|
- // if (!values) return;
|
|
|
- // values.thumbnail = values.scenePack.thumbnail;
|
|
|
- // values.price = parseInt(values.price * 100 + "");
|
|
|
- // let res = await ctx.design.actions.updateDesign(values);
|
|
|
+ values.thumbnail = values.scenePack?.thumbnail;
|
|
|
+ await collocation.https.createStyle(values);
|
|
|
};
|
|
|
|
|
|
- const delDesign = (item: any) => {
|
|
|
- collocation.actions.delDesign(item);
|
|
|
+ const showEdit = async (record: IStyle) => {
|
|
|
+ const item: IStyle = await collocation.https.getStyleDetail(record._id);
|
|
|
+ if (!item) return false;
|
|
|
+
|
|
|
+ const values: IStyle = await collocation.showModal(
|
|
|
+ <OperationModal data={record} />,
|
|
|
+ {
|
|
|
+ title: "编辑可定制款式",
|
|
|
+ width: "500px",
|
|
|
+ }
|
|
|
+ );
|
|
|
+ if (!values) return;
|
|
|
+
|
|
|
+ values.thumbnail = values.scenePack.thumbnail;
|
|
|
+ await collocation.https.updateStyle(values);
|
|
|
};
|
|
|
|
|
|
return () => {
|
|
|
- const dataSource: any = [{ name: "456", _id: "122" }];
|
|
|
+ const listCtrl = collocation.controls.listCtrl;
|
|
|
return (
|
|
|
<div class={DesignStyle}>
|
|
|
<div class="mb-20px table_header">
|
|
@@ -116,14 +119,13 @@ export default defineComponent({
|
|
|
<Table
|
|
|
size="small"
|
|
|
columns={columns}
|
|
|
- dataSource={dataSource}
|
|
|
rowKey={(record) => record._id}
|
|
|
+ dataSource={listCtrl.state.list}
|
|
|
pagination={{
|
|
|
- size: "default",
|
|
|
- // pageSize: ctx.design.DesignList.state.size,
|
|
|
- // current: ctx.design.DesignList.state.page,
|
|
|
- // total: ctx.design.DesignList.state.total,
|
|
|
- // onChange: (p) => ctx.design.DesignList.loadPage(p),
|
|
|
+ pageSize: listCtrl.state.size,
|
|
|
+ current: listCtrl.state.page,
|
|
|
+ total: listCtrl.state.total,
|
|
|
+ onChange: (p) => listCtrl.loadPage(p),
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|