1
1
<template >
2
- <content-wrap >
3
- <!-- 搜索工作栏 -->
4
- <el-form :model =" queryParams" ref =" queryFormRef" :inline =" true" label-width =" 68px" >
2
+ <!-- 搜索工作栏 -->
3
+ <ContentWrap >
4
+ <el-form
5
+ class =" -mb-15px"
6
+ :model =" queryParams"
7
+ ref =" queryFormRef"
8
+ :inline =" true"
9
+ label-width =" 68px"
10
+ >
5
11
<el-form-item label =" 属性项" prop =" propertyId" >
6
- <el-select v-model =" queryParams.propertyId" >
12
+ <el-select v-model =" queryParams.propertyId" class = " !w-240px " >
7
13
<el-option
8
14
v-for =" item in propertyOptions"
9
15
:key =" item.id"
18
24
placeholder =" 请输入名称"
19
25
clearable
20
26
@keyup.enter =" handleQuery"
27
+ class =" !w-240px"
21
28
/>
22
29
</el-form-item >
23
30
<el-form-item >
24
31
<el-button @click =" handleQuery" ><Icon icon =" ep:search" class =" mr-5px" /> 搜索</el-button >
25
32
<el-button @click =" resetQuery" ><Icon icon =" ep:refresh" class =" mr-5px" /> 重置</el-button >
26
- <el-button type =" primary" @click =" openModal('create')" v-hasPermi =" ['infra:config:create']" >
33
+ <el-button
34
+ plain
35
+ type =" primary"
36
+ @click =" openForm('create')"
37
+ v-hasPermi =" ['product:property:create']"
38
+ >
27
39
<Icon icon =" ep:plus" class =" mr-5px" /> 新增
28
40
</el-button >
29
41
</el-form-item >
30
42
</el-form >
43
+ </ContentWrap >
31
44
32
- <!-- 列表 -->
33
- <el-table v-loading =" loading" :data =" list" align =" center" >
45
+ <!-- 列表 -->
46
+ <ContentWrap >
47
+ <el-table v-loading =" loading" :data =" list" >
34
48
<el-table-column label =" 编号" align =" center" prop =" id" />
35
49
<el-table-column label =" 名称" align =" center" prop =" name" :show-overflow-tooltip =" true" />
36
50
<el-table-column label =" 备注" align =" center" prop =" remark" :show-overflow-tooltip =" true" />
46
60
<el-button
47
61
link
48
62
type =" primary"
49
- @click =" openModal ('update', scope.row.id)"
50
- v-hasPermi =" ['infra:config :update']"
63
+ @click =" openForm ('update', scope.row.id)"
64
+ v-hasPermi =" ['product:property :update']"
51
65
>
52
66
编辑
53
67
</el-button >
54
68
<el-button
55
69
link
56
70
type =" danger"
57
71
@click =" handleDelete(scope.row.id)"
58
- v-hasPermi =" ['infra:config :delete']"
72
+ v-hasPermi =" ['product:property :delete']"
59
73
>
60
74
删除
61
75
</el-button >
69
83
v-model:limit =" queryParams.pageSize"
70
84
@pagination =" getList"
71
85
/>
72
- </content-wrap >
86
+ </ContentWrap >
73
87
74
88
<!-- 表单弹窗:添加/修改 -->
75
- <value-form ref =" modalRef " @success =" getList" />
89
+ <ValueForm ref =" formRef " @success =" getList" />
76
90
</template >
77
91
<script setup lang="ts" name="Config">
78
92
import { dateFormatter } from ' @/utils/formatTime'
79
93
import * as PropertyApi from ' @/api/mall/product/property'
80
- import ValueForm from ' ./form .vue'
94
+ import ValueForm from ' ./ValueForm .vue'
81
95
const message = useMessage () // 消息弹窗
82
96
const { t } = useI18n () // 国际化
97
+ const { params } = useRoute () // 查询参数
83
98
84
99
const loading = ref (true ) // 列表的加载中
85
100
const total = ref (0 ) // 列表的总页数
86
101
const list = ref ([]) // 列表的数据
87
- const propertyOptions = ref <any []>([])
88
- const defaultPropertyId = ref ()
89
- const queryParams = reactive <any >({
102
+ const queryParams = reactive ({
90
103
pageNo: 1 ,
91
104
pageSize: 10 ,
92
- name: undefined ,
93
- propertyId : undefined
105
+ propertyId: Number ( params . propertyId ) ,
106
+ name : undefined
94
107
})
95
108
const queryFormRef = ref () // 搜索的表单
109
+ const propertyOptions = ref ([]) // 属性项的列表
96
110
97
111
/** 查询参数列表 */
98
112
const getList = async () => {
@@ -106,20 +120,6 @@ const getList = async () => {
106
120
}
107
121
}
108
122
109
- /** 属性项下拉框数据 */
110
- const getPropertyList = async () => {
111
- const data = await PropertyApi .getPropertyList ({})
112
- propertyOptions .value = data
113
- }
114
-
115
- /** 查询字典类型详细 */
116
- const getProperty = async (propertyId : number ) => {
117
- const data = await PropertyApi .getProperty (propertyId )
118
- queryParams .propertyId = data .id
119
- defaultPropertyId .value = data .id
120
- await getList ()
121
- }
122
-
123
123
/** 搜索按钮操作 */
124
124
const handleQuery = () => {
125
125
queryParams .pageNo = 1
@@ -133,9 +133,9 @@ const resetQuery = () => {
133
133
}
134
134
135
135
/** 添加/修改操作 */
136
- const modalRef = ref ()
137
- const openModal = (type : string , id ? : number ) => {
138
- modalRef .value .openModal (type , defaultPropertyId , id )
136
+ const formRef = ref ()
137
+ const openForm = (type : string , id ? : number ) => {
138
+ formRef .value .open (type , queryParams . propertyId , id )
139
139
}
140
140
141
141
/** 删除按钮操作 */
@@ -152,11 +152,9 @@ const handleDelete = async (id: number) => {
152
152
}
153
153
154
154
/** 初始化 **/
155
- const router = useRouter ()
156
- onMounted (() => {
157
- const propertyId: number =
158
- router .currentRoute .value .params && (router .currentRoute .value .params .propertyId as any )
159
- getProperty (propertyId )
160
- getPropertyList ()
155
+ onMounted (async () => {
156
+ await getList ()
157
+ // 属性项下拉框数据
158
+ propertyOptions .value = await PropertyApi .getPropertyList ({})
161
159
})
162
160
</script >
0 commit comments