Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b18bf8a9
authored
Apr 02, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REVIEW 商品属性
parent
5a5202d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
54 deletions
+53
-54
src/views/mall/product/property/value/ValueForm.vue
+14
-13
src/views/mall/product/property/value/index.vue
+39
-41
No files found.
src/views/mall/product/property/value/
f
orm.vue
→
src/views/mall/product/property/value/
ValueF
orm.vue
View file @
b18bf8a9
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
label-width=
"80px"
label-width=
"80px"
v-loading=
"formLoading"
v-loading=
"formLoading"
>
>
<el-form-item
label=
"属性
id
"
prop=
"category"
>
<el-form-item
label=
"属性
编号
"
prop=
"category"
>
<el-input
v-model=
"formData.propertyId"
disabled=
""
/>
<el-input
v-model=
"formData.propertyId"
disabled=
""
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"名称"
prop=
"name"
>
<el-form-item
label=
"名称"
prop=
"name"
>
...
@@ -18,16 +18,13 @@
...
@@ -18,16 +18,13 @@
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<template
#
footer
>
<template
#
footer
>
<div
class=
"dialog-footer"
>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"modelVisible = false"
>
取 消
</el-button>
<el-button
@
click=
"modelVisible = false"
>
取 消
</el-button>
</div>
</
template
>
</
template
>
</Dialog>
</Dialog>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
*
as
PropertyApi
from
'@/api/mall/product/property'
import
*
as
PropertyApi
from
'@/api/mall/product/property'
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
...
@@ -35,13 +32,12 @@ const modelVisible = ref(false) // 弹窗的是否展示
...
@@ -35,13 +32,12 @@ const modelVisible = ref(false) // 弹窗的是否展示
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
defaultFormData
:
PropertyApi
.
PropertyValueVO
=
{
const
formData
=
ref
(
{
id
:
undefined
,
id
:
undefined
,
propertyId
:
undefined
,
propertyId
:
undefined
,
name
:
''
,
name
:
''
,
remark
:
''
remark
:
''
}
})
const
formData
=
ref
({
...
defaultFormData
})
const
formRules
=
reactive
({
const
formRules
=
reactive
({
propertyId
:
[{
required
:
true
,
message
:
'属性不能为空'
,
trigger
:
'blur'
}],
propertyId
:
[{
required
:
true
,
message
:
'属性不能为空'
,
trigger
:
'blur'
}],
name
:
[{
required
:
true
,
message
:
'名称不能为空'
,
trigger
:
'blur'
}]
name
:
[{
required
:
true
,
message
:
'名称不能为空'
,
trigger
:
'blur'
}]
...
@@ -49,12 +45,12 @@ const formRules = reactive({
...
@@ -49,12 +45,12 @@ const formRules = reactive({
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
/** 打开弹窗 */
/** 打开弹窗 */
const
open
Modal
=
async
(
type
:
string
,
propertyId
:
number
,
id
?:
number
)
=>
{
const
open
=
async
(
type
:
string
,
propertyId
:
number
,
id
?:
number
)
=>
{
modelVisible
.
value
=
true
modelVisible
.
value
=
true
modelTitle
.
value
=
t
(
'action.'
+
type
)
modelTitle
.
value
=
t
(
'action.'
+
type
)
formType
.
value
=
type
formType
.
value
=
type
defaultFormData
.
propertyId
=
propertyId
resetForm
()
resetForm
()
formData
.
value
.
propertyId
=
propertyId
// 修改时,设置数据
// 修改时,设置数据
if
(
id
)
{
if
(
id
)
{
formLoading
.
value
=
true
formLoading
.
value
=
true
...
@@ -65,7 +61,7 @@ const openModal = async (type: string, propertyId: number, id?: number) => {
...
@@ -65,7 +61,7 @@ const openModal = async (type: string, propertyId: number, id?: number) => {
}
}
}
}
}
}
defineExpose
({
open
Modal
})
// 提供 openModal
方法,用于打开弹窗
defineExpose
({
open
})
// 提供 open
方法,用于打开弹窗
/** 提交表单 */
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
...
@@ -95,7 +91,12 @@ const submitForm = async () => {
...
@@ -95,7 +91,12 @@ const submitForm = async () => {
/** 重置表单 */
/** 重置表单 */
const
resetForm
=
()
=>
{
const
resetForm
=
()
=>
{
formData
.
value
=
{
...
defaultFormData
}
formData
.
value
=
{
id
:
undefined
,
propertyId
:
undefined
,
name
:
''
,
remark
:
''
}
formRef
.
value
?.
resetFields
()
formRef
.
value
?.
resetFields
()
}
}
</
script
>
</
script
>
src/views/mall/product/property/value/index.vue
View file @
b18bf8a9
<
template
>
<
template
>
<content-wrap>
<!-- 搜索工作栏 -->
<!-- 搜索工作栏 -->
<ContentWrap>
<el-form
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"属性项"
prop=
"propertyId"
>
<el-form-item
label=
"属性项"
prop=
"propertyId"
>
<el-select
v-model=
"queryParams.propertyId"
>
<el-select
v-model=
"queryParams.propertyId"
class=
"!w-240px"
>
<el-option
<el-option
v-for=
"item in propertyOptions"
v-for=
"item in propertyOptions"
:key=
"item.id"
:key=
"item.id"
...
@@ -18,19 +24,27 @@
...
@@ -18,19 +24,27 @@
placeholder=
"请输入名称"
placeholder=
"请输入名称"
clearable
clearable
@
keyup
.
enter=
"handleQuery"
@
keyup
.
enter=
"handleQuery"
class=
"!w-240px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
type=
"primary"
@
click=
"openModal('create')"
v-hasPermi=
"['infra:config:create']"
>
<el-button
plain
type=
"primary"
@
click=
"openForm('create')"
v-hasPermi=
"['product:property:create']"
>
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
</el-button>
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</ContentWrap>
<!-- 列表 -->
<!-- 列表 -->
<el-table
v-loading=
"loading"
:data=
"list"
align=
"center"
>
<ContentWrap>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table-column
label=
"编号"
align=
"center"
prop=
"id"
/>
<el-table-column
label=
"编号"
align=
"center"
prop=
"id"
/>
<el-table-column
label=
"名称"
align=
"center"
prop=
"name"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"名称"
align=
"center"
prop=
"name"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"备注"
align=
"center"
prop=
"remark"
:show-overflow-tooltip=
"true"
/>
<el-table-column
label=
"备注"
align=
"center"
prop=
"remark"
:show-overflow-tooltip=
"true"
/>
...
@@ -46,8 +60,8 @@
...
@@ -46,8 +60,8 @@
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"open
Modal
('update', scope.row.id)"
@
click=
"open
Form
('update', scope.row.id)"
v-hasPermi=
"['
infra:config
:update']"
v-hasPermi=
"['
product:property
:update']"
>
>
编辑
编辑
</el-button>
</el-button>
...
@@ -55,7 +69,7 @@
...
@@ -55,7 +69,7 @@
link
link
type=
"danger"
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['
infra:config
:delete']"
v-hasPermi=
"['
product:property
:delete']"
>
>
删除
删除
</el-button>
</el-button>
...
@@ -69,30 +83,30 @@
...
@@ -69,30 +83,30 @@
v-model:limit=
"queryParams.pageSize"
v-model:limit=
"queryParams.pageSize"
@
pagination=
"getList"
@
pagination=
"getList"
/>
/>
</
content-w
rap>
</
ContentW
rap>
<!-- 表单弹窗:添加/修改 -->
<!-- 表单弹窗:添加/修改 -->
<
value-form
ref=
"modal
Ref"
@
success=
"getList"
/>
<
ValueForm
ref=
"form
Ref"
@
success=
"getList"
/>
</template>
</template>
<
script
setup
lang=
"ts"
name=
"Config"
>
<
script
setup
lang=
"ts"
name=
"Config"
>
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
*
as
PropertyApi
from
'@/api/mall/product/property'
import
*
as
PropertyApi
from
'@/api/mall/product/property'
import
ValueForm
from
'./
f
orm.vue'
import
ValueForm
from
'./
ValueF
orm.vue'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
{
params
}
=
useRoute
()
// 查询参数
const
loading
=
ref
(
true
)
// 列表的加载中
const
loading
=
ref
(
true
)
// 列表的加载中
const
total
=
ref
(
0
)
// 列表的总页数
const
total
=
ref
(
0
)
// 列表的总页数
const
list
=
ref
([])
// 列表的数据
const
list
=
ref
([])
// 列表的数据
const
propertyOptions
=
ref
<
any
[]
>
([])
const
queryParams
=
reactive
({
const
defaultPropertyId
=
ref
()
const
queryParams
=
reactive
<
any
>
({
pageNo
:
1
,
pageNo
:
1
,
pageSize
:
10
,
pageSize
:
10
,
name
:
undefined
,
propertyId
:
Number
(
params
.
propertyId
)
,
propertyId
:
undefined
name
:
undefined
})
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
queryFormRef
=
ref
()
// 搜索的表单
const
propertyOptions
=
ref
([])
// 属性项的列表
/** 查询参数列表 */
/** 查询参数列表 */
const
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
...
@@ -106,20 +120,6 @@ const getList = async () => {
...
@@ -106,20 +120,6 @@ const getList = async () => {
}
}
}
}
/** 属性项下拉框数据 */
const
getPropertyList
=
async
()
=>
{
const
data
=
await
PropertyApi
.
getPropertyList
({})
propertyOptions
.
value
=
data
}
/** 查询字典类型详细 */
const
getProperty
=
async
(
propertyId
:
number
)
=>
{
const
data
=
await
PropertyApi
.
getProperty
(
propertyId
)
queryParams
.
propertyId
=
data
.
id
defaultPropertyId
.
value
=
data
.
id
await
getList
()
}
/** 搜索按钮操作 */
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
queryParams
.
pageNo
=
1
...
@@ -133,9 +133,9 @@ const resetQuery = () => {
...
@@ -133,9 +133,9 @@ const resetQuery = () => {
}
}
/** 添加/修改操作 */
/** 添加/修改操作 */
const
modal
Ref
=
ref
()
const
form
Ref
=
ref
()
const
open
Modal
=
(
type
:
string
,
id
?:
number
)
=>
{
const
open
Form
=
(
type
:
string
,
id
?:
number
)
=>
{
modalRef
.
value
.
openModal
(
type
,
defaultP
ropertyId
,
id
)
formRef
.
value
.
open
(
type
,
queryParams
.
p
ropertyId
,
id
)
}
}
/** 删除按钮操作 */
/** 删除按钮操作 */
...
@@ -152,11 +152,9 @@ const handleDelete = async (id: number) => {
...
@@ -152,11 +152,9 @@ const handleDelete = async (id: number) => {
}
}
/** 初始化 **/
/** 初始化 **/
const
router
=
useRouter
()
onMounted
(
async
()
=>
{
onMounted
(()
=>
{
await
getList
()
const
propertyId
:
number
=
// 属性项下拉框数据
router
.
currentRoute
.
value
.
params
&&
(
router
.
currentRoute
.
value
.
params
.
propertyId
as
any
)
propertyOptions
.
value
=
await
PropertyApi
.
getPropertyList
({})
getProperty
(
propertyId
)
getPropertyList
()
})
})
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment