Files
ipms-sjy-ui/src/views/mall/product/property/value/index.vue

164 lines
4.4 KiB
Vue
Raw Normal View History

<template>
2023-04-02 09:46:45 +08:00
<!-- 搜索工作栏 -->
<ContentWrap>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="属性项" prop="propertyId">
<el-select v-model="queryParams.propertyId" class="!w-240px" disabled>
<el-option
v-for="item in propertyOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
clearable
@keyup.enter="handleQuery"
2023-04-02 09:46:45 +08:00
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<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>
2023-04-02 09:46:45 +08:00
<el-button
plain
type="primary"
@click="openForm('create')"
v-hasPermi="['product:property:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</el-form-item>
</el-form>
2023-04-02 09:46:45 +08:00
</ContentWrap>
2023-04-02 09:46:45 +08:00
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
2023-10-01 21:11:47 +08:00
<el-table-column label="编号" align="center" min-width="60" prop="id" />
<el-table-column label="属性值名称" align="center" min-width="150" prop="name" />
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
:formatter="dateFormatter"
/>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
2023-04-02 09:46:45 +08:00
@click="openForm('update', scope.row.id)"
v-hasPermi="['product:property:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
2023-04-02 09:46:45 +08:00
v-hasPermi="['product:property:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
2023-04-02 09:46:45 +08:00
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
2023-04-02 09:46:45 +08:00
<ValueForm ref="formRef" @success="getList" />
</template>
2023-06-21 19:35:11 +08:00
<script lang="ts" setup>
import { dateFormatter } from '@/utils/formatTime'
import * as PropertyApi from '@/api/mall/product/property'
2023-04-02 09:46:45 +08:00
import ValueForm from './ValueForm.vue'
2023-06-21 19:14:34 +08:00
defineOptions({ name: 'ProductPropertyValue' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
2023-04-02 09:46:45 +08:00
const { params } = useRoute() // 查询参数
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
2023-04-02 09:46:45 +08:00
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
2023-04-02 09:46:45 +08:00
propertyId: Number(params.propertyId),
name: undefined
})
const queryFormRef = ref() // 搜索的表单
2023-04-02 09:46:45 +08:00
const propertyOptions = ref([]) // 属性项的列表
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await PropertyApi.getPropertyValuePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
2023-04-02 09:46:45 +08:00
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, queryParams.propertyId, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
2023-09-01 00:49:42 +08:00
await PropertyApi.deletePropertyValue(id)
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
/** 初始化 **/
2023-04-02 09:46:45 +08:00
onMounted(async () => {
await getList()
// 属性项下拉框数据
propertyOptions.value.push(await PropertyApi.getProperty(queryParams.propertyId))
})
</script>