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 OperationModal from "./components/OperationModal";
export default defineComponent({
setup() {
const collocation = useCollocation();
const columns: ColumnsType = [
{
title: "款式图片",
dataIndex: "thumbnail",
key: "thumbnail",
customRender: ({ text }) => (
),
},
{
title: "款式名称",
dataIndex: "name",
key: "name",
width: 200,
},
{
title: "款式编号",
dataIndex: "code",
key: "code",
},
{
title: "款式类别",
dataIndex: "category",
key: "category",
},
{
title: "价格(元)",
dataIndex: "price",
key: "price",
customRender: ({ text }) => (text / 100 || 0).toFixed(2),
},
{
title: "操作",
key: "action",
dataIndex: "action",
customRender: ({ record }) => {
return (
);
},
},
];
onMounted(() => {
collocation.controls.listCtrl.loadPage(1, 20);
});
const showAddDesign = async () => {
const values: IStyle = await collocation.showModal(, {
title: "添加可定制款式",
width: "500px",
});
if (!values) return;
values.thumbnail = values.scenePack?.thumbnail;
await collocation.https.createStyle(values);
};
const showEdit = async (record: IStyle) => {
const item: IStyle = await collocation.https.getStyleDetail(record._id);
if (!item) return false;
const values: IStyle = await collocation.showModal(
,
{
title: "编辑可定制款式",
width: "500px",
}
);
if (!values) return;
values.thumbnail = values.scenePack.thumbnail;
await collocation.https.updateStyle(values);
};
return () => {
const listCtrl = collocation.controls.listCtrl;
return (
record._id}
dataSource={listCtrl.state.list}
pagination={{
pageSize: listCtrl.state.size,
current: listCtrl.state.page,
total: listCtrl.state.total,
onChange: (p) => listCtrl.loadPage(p),
}}
/>
);
};
},
});
const DesignStyle = css`
padding: 20px;
.table_header {
display: flex;
align-items: center;
justify-content: space-between;
}
.ant-table-thead > tr > th,
.ant-table-tbody > tr > td {
text-align: center;
}
.thumbnail {
width: 120px;
object-fit: contain;
}
`;