Skip to content

Commit 5a5202d

Browse files
committed
REVIEW 商品属性
1 parent 616243a commit 5a5202d

File tree

4 files changed

+44
-31
lines changed

4 files changed

+44
-31
lines changed

src/api/mall/product/property.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const getProperty = (id: number): Promise<PropertyVO> => {
6161
}
6262

6363
// 获得属性项分页
64-
export const getPropertyPage = (params: PageParam & any) => {
64+
export const getPropertyPage = (params: PageParam) => {
6565
return request.get({ url: '/product/property/page', params })
6666
}
6767

src/views/mall/product/category/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
placeholder="请输入分类名称"
1515
clearable
1616
@keyup.enter="handleQuery"
17+
class="!w-240px"
1718
/>
1819
</el-form-item>
1920
<el-form-item>

src/views/mall/product/property/form.vue renamed to src/views/mall/product/property/PropertyForm.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,24 @@
2424
</template>
2525
<script setup lang="ts">
2626
import * as PropertyApi from '@/api/mall/product/property'
27-
2827
const { t } = useI18n() // 国际化
2928
const message = useMessage() // 消息弹窗
3029
3130
const modelVisible = ref(false) // 弹窗的是否展示
3231
const modelTitle = ref('') // 弹窗的标题
3332
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
3433
const formType = ref('') // 表单的类型:create - 新增;update - 修改
35-
const defaultFormData: PropertyApi.PropertyVO = {
34+
const formData = ref({
3635
id: undefined,
3736
name: ''
38-
}
39-
const formData = ref({ ...defaultFormData })
37+
})
4038
const formRules = reactive({
4139
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
4240
})
4341
const formRef = ref() // 表单 Ref
4442
4543
/** 打开弹窗 */
46-
const openModal = async (type: string, id?: number) => {
44+
const open = async (type: string, id?: number) => {
4745
modelVisible.value = true
4846
modelTitle.value = t('action.' + type)
4947
formType.value = type
@@ -58,7 +56,7 @@ const openModal = async (type: string, id?: number) => {
5856
}
5957
}
6058
}
61-
defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
59+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
6260
6361
/** 提交表单 */
6462
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
@@ -88,7 +86,10 @@ const submitForm = async () => {
8886
8987
/** 重置表单 */
9088
const resetForm = () => {
91-
formData.value = { ...defaultFormData }
89+
formData.value = {
90+
id: undefined,
91+
name: ''
92+
}
9293
formRef.value?.resetFields()
9394
}
9495
</script>

src/views/mall/product/property/index.vue

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,53 @@
11
<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+
>
511
<el-form-item label="名称" prop="name">
612
<el-input
713
v-model="queryParams.name"
814
placeholder="请输入名称"
915
clearable
1016
@keyup.enter="handleQuery"
17+
class="!w-240px"
1118
/>
1219
</el-form-item>
1320
<el-form-item label="创建时间" prop="createTime">
1421
<el-date-picker
1522
v-model="queryParams.createTime"
1623
value-format="YYYY-MM-DD HH:mm:ss"
1724
type="daterange"
18-
range-separator="-"
1925
start-placeholder="开始日期"
2026
end-placeholder="结束日期"
2127
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
28+
class="!w-240px"
2229
/>
2330
</el-form-item>
2431
<el-form-item>
2532
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
2633
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
27-
<el-button type="primary" @click="openModal('create')" v-hasPermi="['infra:config:create']">
34+
<el-button
35+
plain
36+
type="primary"
37+
@click="openForm('create')"
38+
v-hasPermi="['product:property:create']"
39+
>
2840
<Icon icon="ep:plus" class="mr-5px" /> 新增
2941
</el-button>
3042
</el-form-item>
3143
</el-form>
44+
</ContentWrap>
3245

33-
<!-- 列表 -->
34-
<el-table v-loading="loading" :data="list" align="center">
46+
<!-- 列表 -->
47+
<ContentWrap>
48+
<el-table v-loading="loading" :data="list">
3549
<el-table-column label="编号" align="center" prop="id" />
36-
<el-table-column label="名称" align="center" :show-overflow-tooltip="true">
37-
<template #default="scope">
38-
<router-link :to="'/property/value/' + scope.row.id" class="link-type">
39-
<span>{{ scope.row.name }}</span>
40-
</router-link>
41-
</template>
42-
</el-table-column>
50+
<el-table-column label="名称" align="center" />
4351
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
4452
<el-table-column
4553
label="创建时间"
@@ -53,16 +61,19 @@
5361
<el-button
5462
link
5563
type="primary"
56-
@click="openModal('update', scope.row.id)"
57-
v-hasPermi="['infra:config:update']"
64+
@click="openForm('update', scope.row.id)"
65+
v-hasPermi="['product:property:update']"
5866
>
5967
编辑
6068
</el-button>
69+
<el-button link type="primary">
70+
<router-link :to="'/property/value/' + scope.row.id">属性值</router-link>
71+
</el-button>
6172
<el-button
6273
link
6374
type="danger"
6475
@click="handleDelete(scope.row.id)"
65-
v-hasPermi="['infra:config:delete']"
76+
v-hasPermi="['product:property:delete']"
6677
>
6778
删除
6879
</el-button>
@@ -76,15 +87,15 @@
7687
v-model:limit="queryParams.pageSize"
7788
@pagination="getList"
7889
/>
79-
</content-wrap>
90+
</ContentWrap>
8091

8192
<!-- 表单弹窗:添加/修改 -->
82-
<property-form ref="modalRef" @success="getList" />
93+
<PropertyForm ref="formRef" @success="getList" />
8394
</template>
8495
<script setup lang="ts" name="Config">
8596
import { dateFormatter } from '@/utils/formatTime'
8697
import * as PropertyApi from '@/api/mall/product/property'
87-
import PropertyForm from './form.vue'
98+
import PropertyForm from './PropertyForm.vue'
8899
const message = useMessage() // 消息弹窗
89100
const { t } = useI18n() // 国际化
90101
@@ -124,9 +135,9 @@ const resetQuery = () => {
124135
}
125136
126137
/** 添加/修改操作 */
127-
const modalRef = ref()
128-
const openModal = (type: string, id?: number) => {
129-
modalRef.value.openModal(type, id)
138+
const formRef = ref()
139+
const openForm = (type: string, id?: number) => {
140+
formRef.value.open(type, id)
130141
}
131142
132143
/** 删除按钮操作 */

0 commit comments

Comments
 (0)