|
|
@@ -1,6 +1,5 @@
|
|
|
<script setup lang="tsx">
|
|
|
-import { onMounted, reactive, ref, unref, useTemplateRef } from 'vue'
|
|
|
-import { getStaffJobs, delStaffJobs, addStaffJobs, putStaffJobs } from '@/api/staff'
|
|
|
+import { reactive, ref, unref, useTemplateRef } from 'vue'
|
|
|
import { useTable } from '@/hooks/web/useTable'
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
import { Table, TableColumn } from '@/components/Table'
|
|
|
@@ -8,36 +7,27 @@ import { ContentWrap } from '@/components/ContentWrap'
|
|
|
import { Dialog } from '@/components/Dialog'
|
|
|
import { BaseButton } from '@/components/Button'
|
|
|
import { ElDivider, ElMessage, ElMessageBox } from 'element-plus'
|
|
|
-import { jobsData } from '@/api/staff/types'
|
|
|
import Write from './components/Write.vue'
|
|
|
-import { getStaffCategory } from '@/api/staff'
|
|
|
+import { categoryData } from '@/api/goods/types'
|
|
|
import { TableImage } from '@/components/tableImage'
|
|
|
-import { getProductCategory } from '@/api/goods'
|
|
|
-const CategoryList = ref<any[]>([])
|
|
|
-onMounted(() => {
|
|
|
- getStaffCategory({
|
|
|
- page: 1,
|
|
|
- limit: 100
|
|
|
- }).then((res) => {
|
|
|
- CategoryList.value = res.data.list.map((res) => {
|
|
|
- return {
|
|
|
- label: `${res.type_chs}[${res.name}]`,
|
|
|
- value: res.id
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
-})
|
|
|
+import {
|
|
|
+ getProductCategory,
|
|
|
+ putProductCategory,
|
|
|
+ delProductCategory,
|
|
|
+ addProductCategory
|
|
|
+} from '@/api/goods'
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
const { tableRegister, tableState, tableMethods } = useTable({
|
|
|
fetchDataApi: async () => {
|
|
|
const res = await getProductCategory({
|
|
|
+ pid: 0,
|
|
|
page: unref(currentPage) || 1,
|
|
|
limit: unref(pageSize) || 10
|
|
|
})
|
|
|
return {
|
|
|
- list: res.data.list,
|
|
|
- total: res.data.count || 0
|
|
|
+ list: res.data,
|
|
|
+ total: res.data.length || 0
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -53,7 +43,7 @@ const tableColumns = reactive<TableColumn[]>([
|
|
|
width: 70
|
|
|
},
|
|
|
{
|
|
|
- field: 'cate_name',
|
|
|
+ field: 'name',
|
|
|
label: '分类名称',
|
|
|
minWidth: 100
|
|
|
},
|
|
|
@@ -128,10 +118,12 @@ const action = async (type: string, row?: any) => {
|
|
|
if (type == 'edit') {
|
|
|
dialogTitle.value = t('exampleDemo.edit')
|
|
|
currentRow.value = {
|
|
|
+ pid: row.pid,
|
|
|
id: row.id,
|
|
|
name: row.name,
|
|
|
is_show: row.is_show == 1 ? true : false,
|
|
|
- default_price: row.default_price //一口价
|
|
|
+ image: row.image || [], //一口价
|
|
|
+ sort: row.sort
|
|
|
}
|
|
|
}
|
|
|
dialogVisible.value = true
|
|
|
@@ -143,7 +135,7 @@ const delAction = (row: any) => {
|
|
|
type: 'warning'
|
|
|
})
|
|
|
.then(async () => {
|
|
|
- const re = await delStaffJobs(row.id)
|
|
|
+ const re = await delProductCategory(row.id)
|
|
|
if (re) {
|
|
|
ElMessage({
|
|
|
showClose: true,
|
|
|
@@ -160,17 +152,18 @@ const save = async () => {
|
|
|
const formData = await write?.submit()
|
|
|
if (formData) {
|
|
|
saveLoading.value = true
|
|
|
- const data: jobsData = {
|
|
|
+ const data: categoryData = {
|
|
|
id: formData.id || '',
|
|
|
name: formData.name, //分类名称
|
|
|
- cate_id: formData.cate_id, //类型
|
|
|
+ pid: formData.pid, //类型
|
|
|
is_show: formData.is_show ? 1 : 0, //是否启用
|
|
|
- default_price: formData.default_price //一口价
|
|
|
+ image: formData.image[0] || '', //一口价
|
|
|
+ sort: formData.sort
|
|
|
}
|
|
|
if (actionType.value === 'edit') {
|
|
|
- await putStaffJobs(data)
|
|
|
+ await putProductCategory(data)
|
|
|
} else if (actionType.value === 'add') {
|
|
|
- await addStaffJobs(data)
|
|
|
+ await addProductCategory(data)
|
|
|
}
|
|
|
ElMessage({
|
|
|
showClose: true,
|
|
|
@@ -205,8 +198,8 @@ const save = async () => {
|
|
|
/>
|
|
|
</ContentWrap>
|
|
|
|
|
|
- <Dialog v-model="dialogVisible" :title="dialogTitle" width="500px" maxHeight="150px">
|
|
|
- <Write ref="writeRef" :category="CategoryList" :current-row="currentRow" />
|
|
|
+ <Dialog v-model="dialogVisible" :title="dialogTitle" width="500px">
|
|
|
+ <Write ref="writeRef" :current-row="currentRow" />
|
|
|
<template #footer>
|
|
|
<BaseButton type="primary" :loading="saveLoading" @click="save">
|
|
|
{{ t('exampleDemo.save') }}
|