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

feat

上级 71c4a018
......@@ -142,6 +142,7 @@ export interface Goods {
goodsCategoryList: Array<{ id: number }> | number[];
name: string;
pic?: string;
}
export type GoodsPageResult = PageResult<Goods>;
......
......@@ -6,57 +6,44 @@
import { defHttp } from '/@/utils/http/axios';
import { ApiResponse } from '../model/baseModel';
import {
Goods,
GoodsParams,
GoodsPageResult,
GoodsPageResponse,
GoodsResponse,
} from '../model/goods';
import { Goods, GoodsParams, GoodsPageResult, GoodsPageResponse, GoodsResponse } from '../model/goods';
const baseApi = '/v1/product/goods';
/**
* 新增
*/
export const add = (entity: Goods) =>
defHttp.post<Goods>({ url: `${baseApi}/`, data: entity });
export const add = (entity: Goods) => defHttp.post<Goods>({ url: `${baseApi}/add`, data: entity });
/**
* 更新
*/
export const update = (entity: Goods) =>
defHttp.put<Goods>({ url: `${baseApi}/`, data: entity });
export const update = (entity: Goods) => defHttp.post<Goods>({ url: `${baseApi}/updateGoods`, data: entity });
/**
* 删除
*/
export const remove = (id: any) =>
defHttp.delete<Number>({ url: `${baseApi}/${id}` });
export const remove = (id: any) => defHttp.delete<Number>({ url: `${baseApi}/${id}` });
/**
* 分页查询
*/
export const search = (params?: GoodsParams) =>
defHttp.get<GoodsPageResult>({ url: `${baseApi}/search`, params });
export const search = (params?: GoodsParams) => defHttp.get<GoodsPageResult>({ url: `${baseApi}/search`, params });
/**
* 列表查询
*/
export const all = (params?: GoodsParams) =>
defHttp.get<GoodsPageResult>({ url: `${baseApi}/all`, params });
export const all = (params?: GoodsParams) => defHttp.get<GoodsPageResult>({ url: `${baseApi}/all`, params });
/**
* 通过主键查询
*/
export const getById = (id: any) =>
defHttp.get<Goods>({ url: `${baseApi}/${id}` });
export const getById = (id: any) => defHttp.get<Goods>({ url: `${baseApi}/${id}` });
/**
* 单个查询
*/
export const getOne = (params?: GoodsParams) =>
defHttp.get<Goods>({ url: `${baseApi}/one`, params });
export const getOne = (params?: GoodsParams) => defHttp.get<Goods>({ url: `${baseApi}/one`, params });
/**
* 批量删除
......@@ -79,7 +66,9 @@ export const batchUpdate = (entityList: Array<Goods>) =>
/**
* 查询数量
*/
export const count = (params?: GoodsParams) =>
defHttp.get<Number>({ url: `${baseApi}/count`, params });
export const count = (params?: GoodsParams) => defHttp.get<Number>({ url: `${baseApi}/count`, params });
/**
* 产品线查询
*/
export const line = () => defHttp.get<Number>({ url: `/v1/system/third/get/product/line` });
......@@ -6,57 +6,44 @@
import { defHttp } from '/@/utils/http/axios';
import { ApiResponse } from '../model/baseModel';
import {
User,
UserParams,
UserPageResult,
UserPageResponse,
UserResponse,
} from '../model/user';
import { User, UserParams, UserPageResult, UserPageResponse, UserResponse } from '../model/user';
const baseApi = '/v1/system/user';
/**
* 新增
*/
export const add = (entity: User) =>
defHttp.post<User>({ url: `${baseApi}/`, data: entity });
export const add = (entity: User) => defHttp.post<User>({ url: `${baseApi}/`, data: entity });
/**
* 更新
*/
export const update = (entity: User) =>
defHttp.put<User>({ url: `${baseApi}/`, data: entity });
export const update = (entity: User) => defHttp.put<User>({ 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}` });
/**
* 分页查询
*/
export const search = (params?: UserParams) =>
defHttp.get<UserPageResult>({ url: `${baseApi}/search`, params });
export const search = (params?: UserParams) => defHttp.get<UserPageResult>({ url: `${baseApi}/search`, params });
/**
* 列表查询
*/
export const all = (params?: UserParams) =>
defHttp.get<UserPageResult>({ url: `${baseApi}/all`, params });
export const all = (params?: UserParams) => defHttp.get<UserPageResult>({ url: `${baseApi}/all`, params });
/**
* 通过主键查询
*/
export const getById = (id: any) =>
defHttp.get<User>({ url: `${baseApi}/${id}` });
export const getById = (id: any) => defHttp.get<User>({ url: `${baseApi}/${id}` });
/**
* 单个查询
*/
export const getOne = (params?: UserParams) =>
defHttp.get<User>({ url: `${baseApi}/one`, params });
export const getOne = (params?: UserParams) => defHttp.get<User>({ url: `${baseApi}/one`, params });
/**
* 批量删除
......@@ -79,8 +66,7 @@ export const batchUpdate = (entityList: Array<User>) =>
/**
* 查询数量
*/
export const count = (params?: UserParams) =>
defHttp.get<Number>({ url: `${baseApi}/count`, params });
export const count = (params?: UserParams) => defHttp.get<Number>({ url: `${baseApi}/count`, params });
/**
* 用户登录
......@@ -94,8 +80,7 @@ export const login = (loginInfo: { username: string; password: string }) =>
/**
* 用户登出
*/
export const logout = () =>
defHttp.post<any>({ url: `${baseApi}/logout` }, { errorMessageMode: 'none' });
export const logout = () => defHttp.post<any>({ url: `${baseApi}/logout` }, { errorMessageMode: 'none' });
/**
* 用户注册
......@@ -106,8 +91,7 @@ export const register = (user: User) =>
/**
* 当前用户信息
*/
export const info = () =>
defHttp.get<User>({ url: `${baseApi}/info` }, { errorMessageMode: 'none' });
export const info = () => defHttp.get<User>({ url: `${baseApi}/info` }, { errorMessageMode: 'none' });
/**
* 修改密码
......@@ -115,4 +99,7 @@ export const info = () =>
export const changePassword = (passwordInfo: any) =>
defHttp.post<User>({ url: `${baseApi}/change-password`, data: passwordInfo });
/**
* 审核
*/
export const verify = (data: any) => defHttp.post<User>({ url: `${baseApi}/batch/verify`, data });
......@@ -34,7 +34,7 @@
}
.ant-modal-body {
padding: 0;
// padding: 0;
> .scrollbar > .scrollbar__bar.is-horizontal {
display: none;
......
......@@ -41,8 +41,3 @@
-ms-user-select: none;
user-select: none;
}
p {
padding: 0;
margin: 0;
}
......@@ -34,7 +34,7 @@
</a-select>
</a-form-item>
<a-form-item label="分类名称" name="name">
<a-input v-model:value="formData.name" />
<a-input v-model:value="formData.name" :disabled="formData.parentId === 0" />
</a-form-item>
<a-form-item label="排序" name="sort">
<a-input-number v-model:value="formData.sort" :min="0" />
......@@ -56,11 +56,13 @@
</template>
<script lang="ts" setup>
import { defineExpose, ref, reactive, defineEmits, watch, defineProps } from 'vue';
import { defineExpose, ref, reactive, defineEmits, watch, defineProps, onMounted } from 'vue';
import { message } from 'ant-design-vue';
import * as GoodsCategoryApi from '/@/api/product/goodsCategoryApi';
import * as GoodsApi from '/@/api/product/goodsApi';
import { DataItem } from '/@/views/product/goods-category/type';
import { GoodsCategory } from '/@/api/model/goodsCategory';
import { fieldNames, rulesRef } from './schema';
import lodash from 'lodash';
......@@ -80,7 +82,7 @@
// 树结构选项
const classifyTree = ref<DataItem[]>([]);
const thirdProductOption = ref([{ name: '产品线1', id: 1 }]);
const thirdProductOption = ref<any>([]);
// 获取树结构
const getTreeData = () => {
......@@ -109,6 +111,12 @@
formData.lineName = option.key;
};
const handleGetLineList = () => {
GoodsApi.line().then((res) => {
thirdProductOption.value = res;
});
};
const handleOk = () => {
formRef.value.validate().then(() => {
const data = lodash.cloneDeep(formData);
......@@ -159,6 +167,10 @@
},
);
onMounted(() => {
handleGetLineList();
});
defineExpose({ visible });
</script>
......
<template>
<div class="">
<a-upload
v-model:file-list="fileList"
list-type="picture-card"
class="avatar-uploader"
:action="apiUrl"
:before-upload="beforeUpload"
:headers="headers"
name="file"
@change="handleChange"
@preview="handlePreview"
>
<div v-if="fileList.length < 8">
<plus-outlined />
<div style="margin-top: 8px">上传</div>
</div>
</a-upload>
<a-modal :visible="previewVisible" title="预览" :footer="null" @cancel="handleCancel">
<img alt="example" style="width: 100%" :src="previewImage" />
</a-modal>
</div>
</template>
<script lang="ts" setup>
import { ref, defineExpose, defineProps, watch } from 'vue';
import { useGlobSetting } from '/@/hooks/setting';
import { getToken } from '/@/utils/auth';
import { message, UploadChangeParam, UploadProps } from 'ant-design-vue';
const props = defineProps(['editFileList']);
const fileList = ref([]);
const picLoading = ref<boolean>(false);
const globSetting = useGlobSetting();
const apiUrl = globSetting.uploadUrl;
const token = getToken();
const headers = {
Authorization: token,
};
const handleChange = (info: UploadChangeParam) => {
if (info.file.status === 'uploading') {
picLoading.value = true;
return;
}
if (info.file.status === 'done') {
picLoading.value = false;
}
if (info.file.status === 'error') {
picLoading.value = false;
message.error('上传失败');
}
};
const beforeUpload = (file: UploadProps['fileList'][number]) => {
const isJpgOrPng =
file.type === 'image/jpeg' ||
file.type === 'image/png' ||
file.type === 'image/jpg' ||
file.type === 'image/gif' ||
file.type === 'image/webp';
if (!isJpgOrPng) {
message.error('请上传图片格式');
}
// const isLt2M = file.size / 1024 / 1024 < 2;
// if (!isLt2M) {
// message.error('Image must smaller than 2MB!');
// }
return isJpgOrPng;
};
const previewVisible = ref(false);
const previewImage = ref('');
const handleCancel = () => {
previewVisible.value = false;
};
const handlePreview = async (file: UploadProps['fileList'][number]) => {
previewImage.value = file.url;
previewVisible.value = true;
};
watch(
() => props.editFileList,
(n) => {
if (n) {
console.log(n);
fileList.value = n;
}
},
{
immediate: true,
deep: true,
},
);
defineExpose({ fileList });
</script>
<style lang="less" scoped></style>
......@@ -8,13 +8,13 @@
<a-table :dataSource="dataSource" :columns="productColumns" :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" @click="handleEdit(record)">编辑</a-button>
<a-button type="link" @click="handleDelete(record)">删除</a-button>
</template>
</template>
</a-table>
</div>
<a-modal v-model:visible="visible" title="新增" @ok="handleSubmit">
<a-modal v-model:visible="visible" title="新增" @ok="handleSubmit" @cancel="handleCancel">
<a-form
:model="formData"
:label-col="{ span: 6 }"
......@@ -23,11 +23,11 @@
ref="formRef"
:rules="productRulesRef"
>
<a-form-item label="产品编号" name="code">
<a-input v-model:value="formData.code" />
<a-form-item label="产品编号" name="thirdProductId">
<a-input v-model:value="formData.thirdProductId" />
</a-form-item>
<a-form-item label="数量" name="number">
<a-input v-model:value="formData.number" />
<a-form-item label="数量" name="quantity">
<a-input v-model:value="formData.quantity" />
</a-form-item>
</a-form>
</a-modal>
......@@ -35,15 +35,17 @@
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { message } from 'ant-design-vue';
import { ref, reactive, defineExpose, defineProps, watch } from 'vue';
import { productColumns, productRulesRef } from '../schema';
const props = defineProps(['editProductList']);
const visible = ref(false);
const dataSource = ref();
const dataSource = ref<any>([]);
const formRef = ref();
const formData = ref({
code: '',
number: '',
const formData = reactive({
thirdProductId: '',
quantity: '',
});
const handleAdd = () => {
......@@ -52,9 +54,57 @@
const handleSubmit = () => {
formRef.value.validate().then(() => {
visible.value = false;
const index = dataSource.value.findIndex((item) => {
return item.thirdProductId === formData.thirdProductId;
});
if (index != -1) {
dataSource.value[index].quantity = formData.quantity;
} else {
dataSource.value.push({
thirdProductId: formData.thirdProductId,
quantity: formData.quantity,
});
}
message.success('操作成功');
handleCancel();
});
};
const handleEdit = (info) => {
formData.thirdProductId = info.thirdProductId;
formData.quantity = info.quantity;
visible.value = true;
};
const handleDelete = (info) => {
const index = dataSource.value.findIndex((item) => {
return item.thirdProductId === info.thirdProductId;
});
dataSource.value.splice(index, 1);
message.success('删除成功');
};
const handleCancel = () => {
formRef.value.resetFields();
visible.value = false;
};
watch(
() => props.editProductList,
(n) => {
if (n) {
dataSource.value = n;
}
},
{
immediate: true,
},
);
defineExpose({ dataSource });
</script>
<style lang="less" scoped>
......
......@@ -4,8 +4,10 @@
<a-tabs v-model:activeKey="activeKey" centered>
<a-tab-pane key="1" tab="基本信息"><BasicInfo ref="basicInfoRef" @handleSubmit="handleSubmit" /> </a-tab-pane>
<a-tab-pane key="2" tab="商品描述" force-render>Content of Tab Pane 2</a-tab-pane>
<a-tab-pane key="3" tab="商品图片">Content of Tab Pane 3</a-tab-pane>
<a-tab-pane key="4" tab="产品规格"><Product /></a-tab-pane>
<a-tab-pane key="3" tab="商品图片"
><Picture ref="pictureRef" :editFileList="editFileList"></Picture
></a-tab-pane>
<a-tab-pane key="4" tab="产品规格"><Product ref="productRef" :editProductList="editProductList" /></a-tab-pane>
</a-tabs>
<div class="btnWrap">
<a-button type="primary" @click="handleAdd">提交</a-button>
......@@ -21,6 +23,7 @@
import BasicInfo from './components/basicInfo.vue';
import * as GoodsApi from '/@/api/product/goodsApi';
import Product from './components/product.vue';
import Picture from './components/picture.vue';
import { useGo } from '/@/hooks/web/usePage';
import lodash from 'lodash';
import { message } from 'ant-design-vue';
......@@ -28,9 +31,14 @@
const route = useRoute();
const go = useGo();
const basicInfoRef = ref();
const pictureRef = ref();
const productRef = ref();
const activeKey = ref('1');
const id = route.query.id;
let editInfo;
let basicInfo;
const editFileList = ref<any>([]);
const editProductList = ref<any>([]);
const getInfo = () => {
GoodsApi.getById(id).then((res) => {
......@@ -42,6 +50,27 @@
for (const key in basicInfo) {
basicInfo[key] = res[key];
}
if (res.pic) {
const picList = res.pic.split(',');
picList.forEach((url, index) => {
editFileList.value.push({
thumbUrl: url,
url: url,
type: 'image/jpeg',
uid: index,
response: {
result: url,
},
});
});
}
if (res.productList) {
editProductList.value = res.productList;
}
editInfo = res;
});
};
......@@ -62,6 +91,29 @@
} else {
api = GoodsApi.add;
}
if (pictureRef.value) {
const fileList = pictureRef.value.fileList;
let pic = '';
fileList.forEach((item, index) => {
if (index === 0) {
pic = item.response.result;
} else {
pic += `,${item.response.result}`;
}
});
data.pic = pic;
} else if (editInfo && editInfo.pic) {
data.pic = editInfo.pic;
}
if (productRef.value) {
data.productList = productRef.value.dataSource;
} else if (editInfo && editInfo.productList) {
data.productList = editInfo.productList;
}
api(data).then(() => {
message.success('操作成功');
handleBack();
......
......@@ -83,8 +83,8 @@ export const productColumns = [
},
{
title: '产品编号',
dataIndex: 'index',
key: 'index0',
dataIndex: 'thirdProductId',
key: 'thirdProductId',
},
{
title: '产品名称',
......@@ -113,8 +113,8 @@ export const productColumns = [
},
{
title: '数量',
dataIndex: 'index',
key: 'index4',
dataIndex: 'quantity',
key: 'quantity',
},
{
title: '未税价格',
......@@ -138,13 +138,13 @@ export const productColumns = [
];
export const productRulesRef = {
code: [
thirdProductId: [
{
required: true,
message: '请选择产品编号',
},
],
number: [
quantity: [
{
required: true,
message: '请输入数量',
......
export const navList = [
{
id: 1,
title: '产品线',
},
{
id: 2,
title: '正天关节脊柱',
},
{
id: 3,
title: '正天创伤',
},
{
id: 4,
title: 'LINK产品线',
},
{
id: 5,
title: '正天关节',
},
];
......@@ -5,6 +5,10 @@
<a-button v-auth="'AUTH_SYSTEM_ROLE:ADD'" type="primary" @click="handleCreate"> 新增</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'distributorId'">
<span v-if="record.distributorId === 0"> 华润角色</span>
<span v-else> 经销商角色</span>
</template>
<template v-if="column.dataIndex === 'action'">
<TableAction
:actions="[
......
......@@ -6,10 +6,10 @@ export const columns: BasicColumn[] = [
title: '角色名称',
dataIndex: 'name',
},
// {
// title: '操作人',
// dataIndex: 'editorName',
// },
{
title: '角色类型',
dataIndex: 'distributorId',
},
// {
// title: '创建时间',
// dataIndex: 'createTime',
......@@ -29,13 +29,32 @@ export const searchFormSchema: FormSchema[] = [
},
];
export const formSchema: FormSchema[] = [
export const formSchema = [
{
field: 'name',
label: '角色名称',
required: true,
component: 'Input',
},
{
field: 'distributorId',
label: '角色类型',
required: true,
componentProps: {
placeholder: '角色类型',
options: [
{
label: '华润角色',
value: 0,
},
{
label: '经销商角色',
value: -1,
},
],
},
component: 'Select',
},
{
label: '备注',
field: 'remark',
......
......@@ -40,10 +40,7 @@
try {
const values = await validate();
setDrawerProps({ confirmLoading: true });
const {
distributorId,
...rest
} = values;
const { distributorId, ...rest } = values;
const action = !unref(isUpdate) ? UserApi.add : UserApi.update;
const data = !unref(isUpdate)
? {
......@@ -51,7 +48,8 @@
distributorId: distributorId.value,
distributorName: distributorId.label,
}
: Object.assign({},
: Object.assign(
{},
{
...rest,
id: unref(entityId),
......@@ -59,6 +57,7 @@
distributorName: distributorId.label,
},
);
data.roleList = [{ id: data.roleList.value }];
await action(data);
closeDrawer();
emit('success');
......
......@@ -20,6 +20,18 @@
onClick: handleEdit.bind(null, record),
ifShow: hasPermission('AUTH_SYSTEM_USER:EDIT'),
},
{
tooltip: '审核',
icon: 'ant-design:highlight-outlined',
popConfirm: {
title: '是否通过审核',
okText: '通过',
cancelText: '拒绝',
confirm: handleCheck.bind(null, record, 'PASSED'),
cancel: handleCheck.bind(null, record, 'FORBIDDEN'),
},
ifShow: hasPermission('AUTH_SYSTEM_USER:VERIFY') && record.status === 'PENDING_REVIEW',
},
{
tooltip: '删除',
icon: 'ant-design:delete-outlined',
......@@ -50,6 +62,7 @@
import componentSetting from '/@/settings/componentSetting';
import UserDrawer from './drawer.vue';
import { columns, searchFormSchema } from './schema';
import { message } from 'ant-design-vue';
const { hasPermission } = usePermission();
const go = useGo();
......@@ -77,7 +90,7 @@
canResize: false,
rowKey: (record: any) => record.id,
actionColumn: {
width: 80,
width: 120,
title: '操作',
dataIndex: 'action',
fixed: 'right',
......@@ -127,6 +140,13 @@
});
};
const handleCheck = (record: any, status: string) => {
UserApi.verify({ idList: [record.id], status: status }).then(() => {
message.success('审核成功');
reload();
});
};
const handleBatchDelete = () => {
UserApi.batchRemove(checkedKeys.value).then((_) => {
reload();
......
......@@ -127,7 +127,7 @@ export const schema = {
api: RoleApi.all,
params: {},
resultField: 'records',
labelField: 'id',
labelField: 'remark',
valueField: 'id',
allowClear: false,
placeholder: '角色',
......@@ -259,17 +259,7 @@ export const schema = {
],
};
const queryFields = [
'distributorId',
'username',
'realName',
'mobile',
'status',
'deleteStatus',
'editorName',
'createTime',
];
const queryFields = ['distributorId', 'username', 'realName', 'mobile', 'status', 'deleteStatus', 'createTime'];
const editFields = ['distributorId', 'username', 'password', 'realName', 'mobile', 'roleList', 'deleteStatus'];
const tableFields = [
'distributorId',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论