Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
admin
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
华润手术跟台
admin
Commits
faa48184
提交
faa48184
authored
10月 25, 2022
作者:
袁伟伟
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 商品分类
上级
562f9b12
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
460 行增加
和
453 行删除
+460
-453
.env.development
.env.development
+1
-1
goodsCategoryApi.ts
src/api/product/goodsCategoryApi.ts
+13
-13
index.less
src/components/Modal/src/index.less
+6
-0
index.css
src/css/index.css
+43
-0
index.less
src/style/index.less
+49
-0
detail.vue
src/views/product/goods-category/detail.vue
+0
-57
drawer.vue
src/views/product/goods-category/drawer.vue
+0
-63
index.vue
src/views/product/goods-category/index.vue
+75
-152
modal.vue
src/views/product/goods-category/modal.vue
+79
-0
index.vue
src/views/product/goods/index.vue
+146
-139
schema.ts
src/views/product/goods/schema.ts
+48
-28
没有找到文件。
.env.development
浏览文件 @
faa48184
...
...
@@ -13,7 +13,7 @@ VITE_PUBLIC_PATH=/
VITE_DROP_CONSOLE=false
# Basic interface address SPA
VITE_GLOB_API_URL=http://192.168.10
0.225:8088
VITE_GLOB_API_URL=http://192.168.10
1.69:8087
# File upload address, optional
VITE_GLOB_UPLOAD_URL=/upload
...
...
src/api/product/goodsCategoryApi.ts
浏览文件 @
faa48184
...
...
@@ -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`
,
});
src/components/Modal/src/index.less
浏览文件 @
faa48184
...
...
@@ -108,6 +108,12 @@
}
}
.myModal {
.ant-modal-body {
padding: 24px;
}
}
.ant-modal-confirm .ant-modal-body {
padding: 24px !important;
}
...
...
src/css/index.css
0 → 100644
浏览文件 @
faa48184
.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
;
}
src/style/index.less
0 → 100644
浏览文件 @
faa48184
.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;
}
}
}
}
src/views/product/goods-category/detail.vue
deleted
100644 → 0
浏览文件 @
562f9b12
<
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
>
src/views/product/goods-category/drawer.vue
deleted
100644 → 0
浏览文件 @
562f9b12
<
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
>
src/views/product/goods-category/index.vue
浏览文件 @
faa48184
<
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
:
{
t
ype
:
'checkbox
'
,
selectedRowKeys
:
checkedKeys
,
onChange
:
onSelectChange
,
{
t
itle
:
'排序
'
,
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
>
src/views/product/goods-category/modal.vue
0 → 100644
浏览文件 @
faa48184
<
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
>
src/views/product/goods/index.vue
浏览文件 @
faa48184
<
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'
;
i
mport
{
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'
;
i
nterface
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
:
{
t
ype
:
'checkbox
'
,
selectedRowKeys
:
checkedKeys
,
onChange
:
onSelectChange
,
{
t
itle
:
'产品线
'
,
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
>
src/views/product/goods/schema.ts
浏览文件 @
faa48184
...
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论