提交 faa48184 authored 作者: 袁伟伟's avatar 袁伟伟

fix: 商品分类

上级 562f9b12
......@@ -13,7 +13,7 @@ VITE_PUBLIC_PATH=/
VITE_DROP_CONSOLE=false
# Basic interface address SPA
VITE_GLOB_API_URL=http://192.168.100.225:8088
VITE_GLOB_API_URL=http://192.168.101.69:8087
# File upload address, optional
VITE_GLOB_UPLOAD_URL=/upload
......
......@@ -19,20 +19,17 @@ const baseApi = '/v1/product/goods-category';
/**
* 新增
*/
export const add = (entity: GoodsCategory) =>
defHttp.post<GoodsCategory>({ url: `${baseApi}/`, data: entity });
export const add = (entity: GoodsCategory) => defHttp.post<GoodsCategory>({ url: `${baseApi}/`, data: entity });
/**
* 更新
*/
export const update = (entity: GoodsCategory) =>
defHttp.put<GoodsCategory>({ url: `${baseApi}/`, data: entity });
export const update = (entity: GoodsCategory) => defHttp.put<GoodsCategory>({ url: `${baseApi}/`, data: entity });
/**
* 删除
*/
export const remove = (id: any) =>
defHttp.delete<Number>({ url: `${baseApi}/${id}` });
export const remove = (id: any) => defHttp.delete<Number>({ url: `${baseApi}/${id}` });
/**
* 分页查询
......@@ -49,14 +46,12 @@ export const all = (params?: GoodsCategoryParams) =>
/**
* 通过主键查询
*/
export const getById = (id: any) =>
defHttp.get<GoodsCategory>({ url: `${baseApi}/${id}` });
export const getById = (id: any) => defHttp.get<GoodsCategory>({ url: `${baseApi}/${id}` });
/**
* 单个查询
*/
export const getOne = (params?: GoodsCategoryParams) =>
defHttp.get<GoodsCategory>({ url: `${baseApi}/one`, params });
export const getOne = (params?: GoodsCategoryParams) => defHttp.get<GoodsCategory>({ url: `${baseApi}/one`, params });
/**
* 批量删除
......@@ -79,7 +74,12 @@ export const batchUpdate = (entityList: Array<GoodsCategory>) =>
/**
* 查询数量
*/
export const count = (params?: GoodsCategoryParams) =>
defHttp.get<Number>({ url: `${baseApi}/count`, params });
export const count = (params?: GoodsCategoryParams) => defHttp.get<Number>({ url: `${baseApi}/count`, params });
/**
* 查询商品分类树
*/
export const tree = () =>
defHttp.get<Number>({
url: `${baseApi}/tree`,
});
......@@ -108,6 +108,12 @@
}
}
.myModal {
.ant-modal-body {
padding: 24px;
}
}
.ant-modal-confirm .ant-modal-body {
padding: 24px !important;
}
......
.container {
padding: 16px;
}
.container .queryWrap {
background: #fff;
padding: 12px 10px 6px;
margin-bottom: 16px;
}
.container .queryWrap .ant-form-item {
width: 30%;
margin-bottom: 8px;
}
.container .queryWrap .ant-form-item .ant-btn {
margin-right: 15px;
}
.container .queryWrap .checkBoxWrap {
width: 50%;
margin-left: 4%;
}
.container .tableWrap {
padding: 6px;
background-color: #fff;
border-radius: 2px;
}
.container .tableWrap .titleWrap {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
}
.container .tableWrap .titleWrap .title {
position: relative;
display: flex;
padding-left: 7px;
font-size: 16px;
font-weight: 500;
line-height: 32px;
color: rgba(0, 0, 0, 0.85);
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.container {
padding: 16px;
.queryWrap {
background: #fff;
padding: 12px 10px 6px;
margin-bottom: 16px;
.ant-form-item {
width: 30%;
margin-bottom: 8px;
.ant-btn {
margin-right: 15px;
}
}
.checkBoxWrap {
width: 50%;
margin-left: 4%;
}
}
.tableWrap {
padding: 6px;
background-color: #fff;
border-radius: 2px;
.titleWrap {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
.title {
position: relative;
display: flex;
padding-left: 7px;
font-size: 16px;
font-weight: 500;
line-height: 32px;
color: rgba(0, 0, 0, 0.85);
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
}
}
}
<template>
<Card :bordered="false">
<Descriptions bordered :column="3">
<Descriptions.Item
v-for="p in displayProps"
:key="p.title"
:label="p.title"
:span="['avatar'].includes(p.name) ? 3 : 1"
>
<span v-if="p.key === 'avatar'">
<img :src="p.value" style="width: 120px; height: 120px" />
</span>
<template v-else>
{{ p.value }}
</template>
</Descriptions.Item>
</Descriptions>
</Card>
</template>
<script lang="ts" setup name="DeviceDetail">
import { onMounted, computed, ref, reactive } from 'vue';
import { useRoute } from 'vue-router';
import { ComputedRef } from '@vue/reactivity';
import { Descriptions, Card } from 'ant-design-vue';
import { descriptionColumns } from './schema';
import * as GoodsCategoryApi from '/@/api/product/goodsCategoryApi';
import { Device } from '/@/api/model/device';
const route = useRoute();
const id = ref(route.params?.id);
let data = reactive({
detail: {},
isOver: false,
});
const getDetail = () => {
GoodsCategoryApi.getById(id.value).then((res: Device) => {
data.isOver = true;
data.detail = res;
});
};
onMounted(() => {
getDetail();
});
const displayProps: ComputedRef<Array<any>> = computed(() => {
if (!data.isOver) return {};
const display: any = descriptionColumns.map(({ title, dataIndex = '', customRender }) => ({
key: dataIndex,
title,
value: customRender ? customRender(data.detail[dataIndex], data.detail) : data.detail[dataIndex],
}));
return display;
});
</script>
<style scoped></style>
<template>
<BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="600px" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicDrawer>
</template>
<script lang="ts" setup name="GoodsCategoryDrawer">
import { defineEmits, ref, computed, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './schema';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import * as GoodsCategoryApi from '/@/api/product/goodsCategoryApi';
const emit = defineEmits(['success', 'register']);
const isUpdate = ref(true);
const entityId = ref(0);
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
await resetFields();
setDrawerProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
entityId.value = data?.record?.id;
if (unref(isUpdate)) {
await setFieldsValue({
...data.record,
});
}
});
const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
async function handleSubmit() {
try {
const values = await validate();
setDrawerProps({ confirmLoading: true });
const {
...rest
} = values;
const action = !unref(isUpdate) ? GoodsCategoryApi.add : GoodsCategoryApi.update;
const data = !unref(isUpdate)
? {
...rest,
}
: Object.assign({},
{
...rest,
id: unref(entityId),
},
);
await action(data);
closeDrawer();
emit('success');
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>
<template>
<div>
<BasicTable @register="registerTable">
<template #headerTop>
<a-alert type="info" show-icon>
<template #message>
<template v-if="checkedKeys.length > 0">
<span>已选中{{ checkedKeys.length }}条记录</span>
<a-button type="link" @click="checkedKeys = []" size="small">清空</a-button>
<a-popconfirm
class="ml-4"
title="确定要全部删除吗?"
ok-text="是"
cancel-text="否"
@confirm="handleBatchDelete"
>
<a href="#" class="text-red-500">删除</a>
</a-popconfirm>
</template>
<template v-else>
<span>未选中任何项目</span>
</template>
<div class="container">
<div class="tableWrap">
<div class="titleWrap">
<span class="title"></span>
<a-button type="primary" @click="handleAdd">新增</a-button>
</div>
<a-table :columns="columns" :data-source="data" :pagination="false">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-button type="link">编辑</a-button>
<a-button type="link">禁用</a-button>
<a-button type="link">添加商品</a-button>
<a-button type="link">添加节点</a-button>
<a-button type="link">删除</a-button>
</template>
</a-alert>
</template>
<template #toolbar>
<a-button v-auth="'AUTH_PRODUCT_GOODS_CATEGORY:ADD'" type="primary" @click="handleCreate"> 新增</a-button>
</template>
<template #bodyCell="{ column, record, text }">
<template v-if="column.dataIndex === 'id'">
<a @click="handleView(record)"> {{ record.id }} </a>
</template>
<template v-if="[].includes(column.dataIndex)">
<img :src="text" class="photo" alt="图片" v-if="!!text" />
</template>
<template v-if="column.dataIndex === 'action'">
<TableAction
:actions="[
{
tooltip: '编辑',
icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record),
ifShow: hasPermission('AUTH_PRODUCT_GOODS_CATEGORY:EDIT'),
},
{
tooltip: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
},
ifShow: hasPermission('AUTH_PRODUCT_GOODS_CATEGORY:DELETE'),
},
]"
/>
</template>
</template>
</BasicTable>
<GoodsCategoryDrawer @register="registerDrawer" @success="handleSuccess" />
</a-table>
</div>
<Modal ref="modalRef"></Modal>
</div>
</template>
<script lang="ts" setup name="DeviceIndex">
<script lang="ts" setup>
import { ref } from 'vue';
import { useGo } from '/@/hooks/web/usePage';
import { usePermission } from '/@/hooks/web/usePermission';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { isObject } from '/@/utils/is';
import moment from 'moment';
import Modal from './modal.vue';
import * as GoodsCategoryApi from '/@/api/product/goodsCategoryApi';
import { useDrawer } from '/@/components/Drawer';
import componentSetting from '/@/settings/componentSetting';
import GoodsCategoryDrawer from './drawer.vue';
import { columns, searchFormSchema } from './schema';
const { hasPermission } = usePermission();
const go = useGo();
const { formConfig, showTableSetting, bordered, showIndexColumn } = componentSetting.table;
const checkedKeys = ref<Array<string | number>>([]);
const onSelectChange = (selectedRowKeys: (string | number)[]) => {
checkedKeys.value = selectedRowKeys;
};
const [registerDrawer, { openDrawer }] = useDrawer();
const [registerTable, { reload }] = useTable({
title: '商品分类',
api: (params) => GoodsCategoryApi.search(handleParams(params)),
columns,
formConfig: {
labelWidth: formConfig.labelWidth,
schemas: searchFormSchema,
showAdvancedButton: false,
const modalRef = ref();
const columns = [
{
title: '分类名称',
dataIndex: 'name',
key: 'name',
},
rowSelection: {
type: 'checkbox',
selectedRowKeys: checkedKeys,
onChange: onSelectChange,
{
title: '排序',
dataIndex: 'age',
key: 'age',
},
useSearchForm: true,
showTableSetting,
bordered,
showIndexColumn,
canResize: false,
rowKey: (record: any) => record.id,
actionColumn: {
width: 80,
{
title: '层级',
dataIndex: 'address',
key: 'address',
},
{
title: '状态',
dataIndex: 'state',
key: 'state',
},
{
title: '操作',
dataIndex: 'action',
fixed: 'right',
key: 'action',
},
});
const handleParams = (params) => {
const { pageNum, pageSize } = params;
const handledParams: any = { pageNum, pageSize };
Object.keys(params).forEach((key) => {
const schema = searchFormSchema.find((item) => item.field === key);
const value = params[key];
if (schema && value !== undefined && value !== '') {
if (schema.component === 'Input') {
handledParams[key] = `%${value.trim()}%`;
} else if (['Select', 'ApiSelect'].includes(schema.component)) {
handledParams[key] = isObject(value) ? value.value : value;
} else if (schema.component === 'RangePicker') {
handledParams[`${key}From`] = moment(value[0]).startOf('d').format('YYYY-MM-DD HH:mm:ss');
handledParams[`${key}To`] = moment(value[1]).endOf('d').format('YYYY-MM-DD HH:mm:ss');
} else if (schema.component === 'DatePicker') {
handledParams[key] = moment(value).format((schema.componentProps as any).format || 'YYYY-MM-DD');
} else {
handledParams[key] = value;
}
}
});
return handledParams;
};
];
const handleCreate = () => {
openDrawer(true, {
isUpdate: false,
});
};
const handleEdit = (record: Recordable) => {
openDrawer(true, {
record,
isUpdate: true,
});
};
interface DataItem {
key: number;
name: string;
age: number;
address: string;
children?: DataItem[];
}
const handleDelete = (record: Recordable) => {
GoodsCategoryApi.remove(record.id).then((_) => {
reload();
});
};
const data = ref<DataItem[]>([
{
key: 1,
name: 'John Brown sr.',
age: 60,
address: 'New York No. 1 Lake Park',
children: [
{
key: 11,
name: 'John Brown',
age: 42,
address: 'New York No. 2 Lake Park',
},
],
},
]);
const handleBatchDelete = () => {
GoodsCategoryApi.batchRemove(checkedKeys.value).then((_) => {
reload();
const getData = () => {
GoodsCategoryApi.tree().then((res) => {
console.log(res);
});
};
const handleSuccess = () => {
reload();
};
const handleView = (record) => {
go('/product/goods-category/' + record.id);
const handleAdd = () => {
modalRef.value.visible = true;
};
</script>
<style lang="less" scoped>
@import url('/@/style/index.less');
</style>
<template>
<a-modal v-model:visible="visible" title="新增商品分类" @ok="handleOk" class="myModal">
<a-form :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }">
<a-form-item label="分类类型" v-bind="validateInfos.parentId">
<a-select ref="select" v-model:value="formData.parentId">
<a-select-option :value="item.id" v-for="item in classifyOption">{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="产品线" v-bind="validateInfos.thirdProductId" v-if="formData.parentId === 0">
<a-select ref="select" v-model:value="formData.thirdProductId">
<a-select-option :value="item.id" v-for="item in thirdProductOption">{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="分类名称" v-bind="validateInfos.name">
<a-input v-model:value="formData.name" />
</a-form-item>
<a-form-item label="排序" v-bind="validateInfos.sort">
<a-input v-model:value="formData.sort" />
</a-form-item>
<a-form-item label="状态" v-bind="validateInfos.status">
<a-input v-model:value="formData.status" />
</a-form-item>
<a-form-item label="页面关键词" v-bind="validateInfos.name">
<a-input v-model:value="formData.name" />
</a-form-item>
<a-form-item label="页面描述" v-bind="validateInfos.remark">
<a-input v-model:value="formData.remark" />
</a-form-item>
</a-form>
</a-modal>
</template>
<script lang="ts" setup>
import { defineExpose, ref, reactive } from 'vue';
import { Form } from 'ant-design-vue';
import * as GoodsCategoryApi from '/@/api/product/goodsCategoryApi';
const visible = ref<boolean>(false);
const useForm = Form.useForm;
const formData = reactive({
name: '',
remark: '',
status: 'NO',
sort: 0,
thirdProductId: 1,
parentId: 0,
});
const rulesRef = reactive({
name: [
{
required: true,
message: 'Please input name',
},
],
});
const classifyOption = ref([
{
name: '顶级分类',
id: 0,
},
]);
const thirdProductOption = ref([{ name: '产品线1', id: 1 }]);
const { resetFields, validate, validateInfos } = useForm(formData, rulesRef);
const handleOk = () => {
validate().then(() => {
console.log(111);
});
// visible.value = false;
};
defineExpose({ visible });
</script>
<style lang="less" scoped>
::v-deep .ant-modal .ant-modal-body {
padding: 24px !important;
}
</style>
<template>
<div>
<BasicTable @register="registerTable">
<template #headerTop>
<a-alert type="info" show-icon>
<template #message>
<template v-if="checkedKeys.length > 0">
<span>已选中{{ checkedKeys.length }}条记录</span>
<a-button type="link" @click="checkedKeys = []" size="small">清空</a-button>
<a-popconfirm
class="ml-4"
title="确定要全部删除吗?"
ok-text="是"
cancel-text="否"
@confirm="handleBatchDelete"
>
<a href="#" class="text-red-500">删除</a>
</a-popconfirm>
</template>
<template v-else>
<span>未选中任何项目</span>
</template>
<div class="container">
<div class="queryWrap">
<a-form
:model="formState"
name="basic"
ref="formRef"
layout="inline"
:label-col="{ span: 8 }"
:wrapper-col="{ span: 16 }"
autocomplete="off"
@finish="onFinish"
@finishFailed="onFinishFailed"
class="ant-row"
>
<a-form-item label="商品名称" name="goodsName">
<a-input v-model:value="formState.goodsName" />
</a-form-item>
<a-form-item label="分类" name="classify">
<a-input v-model:value="formState.classify" />
</a-form-item>
<a-form-item label="产品线" name="productLine">
<a-input v-model:value="formState.productLine" />
</a-form-item>
<a-form-item label="产品编码" name="productCode">
<a-input v-model:value="formState.productCode" />
</a-form-item>
<a-form-item label="是否为促销" name="promotion">
<a-input v-model:value="formState.promotion" />
</a-form-item>
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
<a-button @click="handleReset">重置</a-button>
<a-button type="primary" html-type="submit">查询</a-button>
</a-form-item>
<a-form-item class="checkBoxWrap">
<a-checkbox-group v-model:value="stateChange" name="checkboxgroup" :options="stateOption" />
</a-form-item>
</a-form>
</div>
<div class="tableWrap">
<div class="titleWrap">
<span class="title">商品分类</span>
<a-button type="primary" @click="handleAdd">新增</a-button>
</div>
<a-table :dataSource="dataSource" :columns="columns" :pagination="pagination">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-button type="link">编辑</a-button>
<a-button type="link">删除</a-button>
</template>
</a-alert>
</template>
<template #toolbar>
<a-button v-auth="'AUTH_PRODUCT_GOODS:ADD'" type="primary" @click="handleCreate"> 新增</a-button>
</template>
<template #bodyCell="{ column, record, text }">
<template v-if="column.dataIndex === 'id'">
<a @click="handleView(record)"> {{ record.id }} </a>
</template>
<template v-if="[].includes(column.dataIndex)">
<img :src="text" class="photo" alt="图片" v-if="!!text" />
</template>
<template v-if="column.dataIndex === 'action'">
<TableAction
:actions="[
{
tooltip: '编辑',
icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record),
ifShow: hasPermission('AUTH_PRODUCT_GOODS:EDIT'),
},
{
tooltip: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
},
ifShow: hasPermission('AUTH_PRODUCT_GOODS:DELETE'),
},
]"
/>
</template>
</template>
</BasicTable>
<GoodsDrawer @register="registerDrawer" @success="handleSuccess" />
</a-table>
</div>
</div>
</template>
<script lang="ts" setup name="DeviceIndex">
import { ref } from 'vue';
import { ref, reactive } from 'vue';
import { useGo } from '/@/hooks/web/usePage';
import { usePermission } from '/@/hooks/web/usePermission';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { isObject } from '/@/utils/is';
import moment from 'moment';
import * as GoodsApi from '/@/api/product/goodsApi';
import { useDrawer } from '/@/components/Drawer';
import componentSetting from '/@/settings/componentSetting';
import GoodsDrawer from './drawer.vue';
import { columns, searchFormSchema } from './schema';
interface FormState {
goodsName: string;
classify: string;
productLine: string;
productCode: string;
promotion: boolean | null;
}
const { hasPermission } = usePermission();
const go = useGo();
const { formConfig, showTableSetting, bordered, showIndexColumn } = componentSetting.table;
const checkedKeys = ref<Array<string | number>>([]);
const onSelectChange = (selectedRowKeys: (string | number)[]) => {
checkedKeys.value = selectedRowKeys;
};
const formRef = ref();
const formState = reactive<FormState>({
goodsName: '',
classify: '',
productLine: '',
productCode: '',
promotion: null,
});
const [registerDrawer, { openDrawer }] = useDrawer();
const [registerTable, { reload }] = useTable({
title: '商品表',
api: (params) => GoodsApi.search(handleParams(params)),
columns,
formConfig: {
labelWidth: formConfig.labelWidth,
schemas: searchFormSchema,
showAdvancedButton: false,
const stateChange = ref([]);
const dataSource = [
{
index: '1',
name: '胡彦斌',
classify: '分类1',
line: '产品线1',
grounding: 1,
emphasis: 1,
new: 1,
unconventionality: 1,
},
];
const columns = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
},
{
title: '商品名称',
dataIndex: 'name',
key: 'name',
},
{
title: '分类',
dataIndex: 'classify',
key: 'classify',
},
rowSelection: {
type: 'checkbox',
selectedRowKeys: checkedKeys,
onChange: onSelectChange,
{
title: '产品线',
dataIndex: 'line',
key: 'line',
},
useSearchForm: true,
showTableSetting,
bordered,
showIndexColumn,
canResize: false,
rowKey: (record: any) => record.id,
actionColumn: {
width: 80,
{
title: '上架',
dataIndex: 'grounding',
key: 'grounding',
},
{
title: '重点',
dataIndex: 'emphasis',
key: 'emphasis',
},
{
title: '新品',
dataIndex: 'new',
key: 'new',
},
{
title: '非常规',
dataIndex: 'unconventionality',
key: 'unconventionality',
},
{
title: '操作',
dataIndex: 'action',
fixed: 'right',
key: 'action',
},
});
];
const handleParams = (params) => {
const { pageNum, pageSize } = params;
const handledParams: any = { pageNum, pageSize };
Object.keys(params).forEach((key) => {
const schema = searchFormSchema.find((item) => item.field === key);
const value = params[key];
if (schema && value !== undefined && value !== '') {
if (schema.component === 'Input') {
handledParams[key] = `%${value.trim()}%`;
} else if (['Select', 'ApiSelect'].includes(schema.component)) {
handledParams[key] = isObject(value) ? value.value : value;
} else if (schema.component === 'RangePicker') {
handledParams[`${key}From`] = moment(value[0]).startOf('d').format('YYYY-MM-DD HH:mm:ss');
handledParams[`${key}To`] = moment(value[1]).endOf('d').format('YYYY-MM-DD HH:mm:ss');
} else if (schema.component === 'DatePicker') {
handledParams[key] = moment(value).format((schema.componentProps as any).format || 'YYYY-MM-DD');
} else {
handledParams[key] = value;
}
}
});
return handledParams;
};
const stateOption = ['上架', '重点', '非常规', '新品'];
const handleCreate = () => {
openDrawer(true, {
isUpdate: false,
});
const pagination = {
current: 1,
pageSize: 10,
total: 85,
showTotal: (total) => `共 ${total} 条数据`,
onChange: (page, pageSize) => {
console.log(page, pageSize);
},
size: 'small',
};
const handleEdit = (record: Recordable) => {
openDrawer(true, {
record,
isUpdate: true,
});
const onFinish = (values: any) => {
console.log('Success:', values);
};
const handleDelete = (record: Recordable) => {
GoodsApi.remove(record.id).then((_) => {
reload();
});
const onFinishFailed = (errorInfo: any) => {
console.log('Failed:', errorInfo);
};
const handleBatchDelete = () => {
GoodsApi.batchRemove(checkedKeys.value).then((_) => {
reload();
});
const handleReset = () => {
formRef.value.resetFields();
};
const handleSuccess = () => {
reload();
};
const handleAdd = () => {};
const handleView = (record) => {
go('/product/goods/' + record.id);
};
</script>
<style lang="less" scoped>
@import url('/@/style/index.less');
</style>
......@@ -54,8 +54,7 @@ export const schema = {
component: 'InputNumber',
rules: [{ required: true, message: '请输入ID系统自动生成!' }],
},
table: {
},
table: {},
},
{
field: 'distributorId',
......@@ -70,8 +69,7 @@ export const schema = {
component: 'InputNumber',
rules: [{ required: true, message: '请输入经销商id!' }],
},
table: {
},
table: {},
},
{
field: 'discountPrice',
......@@ -86,8 +84,7 @@ export const schema = {
component: 'InputNumber',
rules: [{ required: true, message: '请输入折扣价!' }],
},
table: {
},
table: {},
},
{
field: 'remark',
......@@ -101,8 +98,7 @@ export const schema = {
colProps,
component: 'Input',
},
table: {
},
table: {},
},
{
field: 'status',
......@@ -120,7 +116,7 @@ export const schema = {
},
table: {
customRender: ({ text }) => {
const option = YesNoEnumOptions.find((item) => item.value === text)
const option = YesNoEnumOptions.find((item) => item.value === text);
return option ? option.label : text;
},
},
......@@ -141,7 +137,7 @@ export const schema = {
},
table: {
customRender: ({ text }) => {
const option = GoodsTypeEnumOptions.find((item) => item.value === text)
const option = GoodsTypeEnumOptions.find((item) => item.value === text);
return option ? option.label : text;
},
},
......@@ -162,7 +158,7 @@ export const schema = {
},
table: {
customRender: ({ text }) => {
const option = YesNoEnumOptions.find((item) => item.value === text)
const option = YesNoEnumOptions.find((item) => item.value === text);
return option ? option.label : text;
},
},
......@@ -180,8 +176,7 @@ export const schema = {
component: 'InputNumber',
rules: [{ required: true, message: '请输入操作人ID!' }],
},
table: {
},
table: {},
},
{
field: 'editorName',
......@@ -196,8 +191,7 @@ export const schema = {
component: 'Input',
rules: [{ required: true, message: '请输入操作人!' }],
},
table: {
},
table: {},
},
{
field: 'createTime',
......@@ -214,8 +208,7 @@ export const schema = {
component: 'RangePicker',
rules: [{ required: true, message: '请输入CreateTime!' }],
},
table: {
},
table: {},
},
{
field: 'updateTime',
......@@ -232,18 +225,42 @@ export const schema = {
component: 'RangePicker',
rules: [{ required: true, message: '请输入UpdateTime!' }],
},
table: {
},
table: {},
},
],
};
const queryFields = ['id','distributorId','discountPrice','remark','status','goodsType','deleteStatus','editorId','editorName','createTime','updateTime'];
const editFields = ['distributorId','discountPrice','remark','status','goodsType','deleteStatus'];
const tableFields = ['id','distributorId','discountPrice','remark','status','goodsType','deleteStatus','editorId','editorName','createTime','updateTime'];
const descriptionFields = ['id','distributorId','discountPrice','remark','status','goodsType','deleteStatus','editorId','editorName','createTime','updateTime'];
const queryFields = ['status', 'goodsType', 'deleteStatus', 'editorId', 'editorName', 'createTime', 'updateTime'];
const editFields = ['distributorId', 'discountPrice', 'remark', 'status', 'goodsType', 'deleteStatus'];
const tableFields = [
'id',
'distributorId',
'discountPrice',
'remark',
'status',
'goodsType',
'deleteStatus',
'editorId',
'editorName',
'createTime',
'updateTime',
];
const descriptionFields = [
'id',
'distributorId',
'discountPrice',
'remark',
'status',
'goodsType',
'deleteStatus',
'editorId',
'editorName',
'createTime',
'updateTime',
];
export const searchFormSchema: FormSchema[] = schema.properties.filter(item => queryFields.includes(item.field))
export const searchFormSchema: FormSchema[] = schema.properties
.filter((item) => queryFields.includes(item.field))
.map(
({ field, label, form: { rules = [], ...formProps } }) =>
({
......@@ -255,7 +272,8 @@ export const searchFormSchema: FormSchema[] = schema.properties.filter(item => q
} as FormSchema),
);
export const formSchema: FormSchema[] = schema.properties.filter(item => editFields.includes(item.field))
export const formSchema: FormSchema[] = schema.properties
.filter((item) => editFields.includes(item.field))
.map(
({ field, label, defaultValue, form }) =>
({
......@@ -267,17 +285,19 @@ export const formSchema: FormSchema[] = schema.properties.filter(item => editFie
} as FormSchema),
);
export const columns: BasicColumn[] = schema.properties.filter(item => tableFields.includes(item.field))
export const columns: BasicColumn[] = schema.properties
.filter((item) => tableFields.includes(item.field))
.map(
({ field, label, table }) =>
({
dataIndex: field,
title: label,
...table,
} as BasicColumn)
} as BasicColumn),
);
export const descriptionColumns: BasicColumn[] = schema.properties.filter(item => descriptionFields.includes(item.field))
export const descriptionColumns: BasicColumn[] = schema.properties
.filter((item) => descriptionFields.includes(item.field))
.map(
({ field, label, table }) =>
({
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论