|
@@ -2,11 +2,11 @@
|
|
import { ContentWrap } from '@/components/ContentWrap'
|
|
import { ContentWrap } from '@/components/ContentWrap'
|
|
import { Search } from '@/components/Search'
|
|
import { Search } from '@/components/Search'
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
-import { ElButton, ElTag } from 'element-plus'
|
|
|
|
|
|
+import { ElButton } from 'element-plus'
|
|
import { Table } from '@/components/Table'
|
|
import { Table } from '@/components/Table'
|
|
-import { getTableListApi, delTableListApi } from '@/api/table'
|
|
|
|
|
|
+import { getTableListApi, delTableListApi } from '@/api/manage/product'
|
|
import { useTable } from '@/hooks/web/useTable'
|
|
import { useTable } from '@/hooks/web/useTable'
|
|
-import { TableData } from '@/api/table/types'
|
|
|
|
|
|
+import { ProductTableData } from '@/api/table/types'
|
|
import { ref, unref } from 'vue'
|
|
import { ref, unref } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
import { useEmitt } from '@/hooks/event/useEmitt'
|
|
import { useEmitt } from '@/hooks/event/useEmitt'
|
|
@@ -21,7 +21,7 @@ defineOptions({
|
|
|
|
|
|
const { push } = useRouter()
|
|
const { push } = useRouter()
|
|
|
|
|
|
-const ids = ref<string[]>([])
|
|
|
|
|
|
+const id = ref<string>('')
|
|
|
|
|
|
const searchParams = ref({})
|
|
const searchParams = ref({})
|
|
const setSearchParams = (params: any) => {
|
|
const setSearchParams = (params: any) => {
|
|
@@ -33,7 +33,7 @@ const { tableRegister, tableState, tableMethods } = useTable({
|
|
fetchDataApi: async () => {
|
|
fetchDataApi: async () => {
|
|
const { currentPage, pageSize } = tableState
|
|
const { currentPage, pageSize } = tableState
|
|
const res = await getTableListApi({
|
|
const res = await getTableListApi({
|
|
- pageIndex: unref(currentPage),
|
|
|
|
|
|
+ pageNum: unref(currentPage),
|
|
pageSize: unref(pageSize),
|
|
pageSize: unref(pageSize),
|
|
...unref(searchParams)
|
|
...unref(searchParams)
|
|
})
|
|
})
|
|
@@ -43,12 +43,12 @@ const { tableRegister, tableState, tableMethods } = useTable({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
fetchDelApi: async () => {
|
|
fetchDelApi: async () => {
|
|
- const res = await delTableListApi(unref(ids))
|
|
|
|
|
|
+ const res = await delTableListApi(unref(id))
|
|
return !!res
|
|
return !!res
|
|
}
|
|
}
|
|
})
|
|
})
|
|
const { loading, dataList, total, currentPage, pageSize } = tableState
|
|
const { loading, dataList, total, currentPage, pageSize } = tableState
|
|
-const { getList, getElTableExpose, delList, setColumn } = tableMethods
|
|
|
|
|
|
+const { getList, delList, setColumn } = tableMethods
|
|
|
|
|
|
getList()
|
|
getList()
|
|
|
|
|
|
@@ -66,41 +66,8 @@ const { t } = useI18n()
|
|
const appStore = usePageStore()
|
|
const appStore = usePageStore()
|
|
const crudSchemas: CrudSchema[] = [
|
|
const crudSchemas: CrudSchema[] = [
|
|
{
|
|
{
|
|
- field: 'selection',
|
|
|
|
- search: {
|
|
|
|
- hidden: true
|
|
|
|
- },
|
|
|
|
- form: {
|
|
|
|
- hidden: true
|
|
|
|
- },
|
|
|
|
- detail: {
|
|
|
|
- hidden: true
|
|
|
|
- },
|
|
|
|
- table: {
|
|
|
|
- type: 'selection',
|
|
|
|
- hidden: false
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- field: 'index',
|
|
|
|
- label: t('tableDemo.index'),
|
|
|
|
- type: 'index',
|
|
|
|
- search: {
|
|
|
|
- hidden: true
|
|
|
|
- },
|
|
|
|
- table: {
|
|
|
|
- hidden: false
|
|
|
|
- },
|
|
|
|
- form: {
|
|
|
|
- hidden: true
|
|
|
|
- },
|
|
|
|
- detail: {
|
|
|
|
- hidden: true
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- field: 'title',
|
|
|
|
- label: t('tableDemo.title'),
|
|
|
|
|
|
+ field: 'productName',
|
|
|
|
+ label: '产品名称',
|
|
search: {
|
|
search: {
|
|
component: 'Input'
|
|
component: 'Input'
|
|
},
|
|
},
|
|
@@ -118,35 +85,27 @@ const crudSchemas: CrudSchema[] = [
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- field: 'author',
|
|
|
|
- label: t('tableDemo.author'),
|
|
|
|
- search: {
|
|
|
|
- hidden: true
|
|
|
|
|
|
+ field: 'productIntroduction',
|
|
|
|
+ label: '产品简介',
|
|
|
|
+ form: {
|
|
|
|
+ component: 'Input',
|
|
|
|
+ componentProps: {
|
|
|
|
+ type: 'textarea'
|
|
|
|
+ },
|
|
|
|
+ colProps: {
|
|
|
|
+ span: 24
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- table: {
|
|
|
|
- hidden: false
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- field: 'display_time',
|
|
|
|
- label: t('tableDemo.displayTime'),
|
|
|
|
search: {
|
|
search: {
|
|
hidden: true
|
|
hidden: true
|
|
},
|
|
},
|
|
table: {
|
|
table: {
|
|
hidden: false
|
|
hidden: false
|
|
- },
|
|
|
|
- form: {
|
|
|
|
- component: 'DatePicker',
|
|
|
|
- componentProps: {
|
|
|
|
- type: 'datetime',
|
|
|
|
- valueFormat: 'YYYY-MM-DD HH:mm:ss'
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- field: 'importance',
|
|
|
|
- label: t('tableDemo.importance'),
|
|
|
|
|
|
+ field: 'productPrice',
|
|
|
|
+ label: '产品价格',
|
|
search: {
|
|
search: {
|
|
hidden: true
|
|
hidden: true
|
|
},
|
|
},
|
|
@@ -154,50 +113,13 @@ const crudSchemas: CrudSchema[] = [
|
|
hidden: false
|
|
hidden: false
|
|
},
|
|
},
|
|
form: {
|
|
form: {
|
|
- component: 'Select',
|
|
|
|
- componentProps: {
|
|
|
|
- style: {
|
|
|
|
- width: '100%'
|
|
|
|
- },
|
|
|
|
- options: [
|
|
|
|
- {
|
|
|
|
- label: '重要',
|
|
|
|
- value: 3
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '良好',
|
|
|
|
- value: 2
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '一般',
|
|
|
|
- value: 1
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- detail: {
|
|
|
|
- slots: {
|
|
|
|
- default: (data: any) => {
|
|
|
|
- return (
|
|
|
|
- <ElTag
|
|
|
|
- type={
|
|
|
|
- data.importance === 1 ? 'success' : data.importance === 2 ? 'warning' : 'danger'
|
|
|
|
- }
|
|
|
|
- >
|
|
|
|
- {data.importance === 1
|
|
|
|
- ? t('tableDemo.important')
|
|
|
|
- : data.importance === 2
|
|
|
|
- ? t('tableDemo.good')
|
|
|
|
- : t('tableDemo.commonly')}
|
|
|
|
- </ElTag>
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ component: 'InputNumber',
|
|
|
|
+ value: 0
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- field: 'pageviews',
|
|
|
|
- label: t('tableDemo.pageviews'),
|
|
|
|
|
|
+ field: 'productStock',
|
|
|
|
+ label: '产品库存',
|
|
search: {
|
|
search: {
|
|
hidden: true
|
|
hidden: true
|
|
},
|
|
},
|
|
@@ -210,8 +132,8 @@ const crudSchemas: CrudSchema[] = [
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- field: 'content',
|
|
|
|
- label: t('exampleDemo.content'),
|
|
|
|
|
|
+ field: 'productDetailed',
|
|
|
|
+ label: '产品详情',
|
|
search: {
|
|
search: {
|
|
hidden: true
|
|
hidden: true
|
|
},
|
|
},
|
|
@@ -305,16 +227,16 @@ const AddAction = () => {
|
|
|
|
|
|
const delLoading = ref(false)
|
|
const delLoading = ref(false)
|
|
|
|
|
|
-const delData = async (row: TableData | null) => {
|
|
|
|
- const elTableExpose = await getElTableExpose()
|
|
|
|
- ids.value = row ? [row.id] : elTableExpose?.getSelectionRows().map((v: TableData) => v.id) || []
|
|
|
|
|
|
+const delData = async (row: ProductTableData) => {
|
|
|
|
+ if (!row.id) return
|
|
|
|
+ id.value = row?.id
|
|
delLoading.value = true
|
|
delLoading.value = true
|
|
- await delList(unref(ids).length).finally(() => {
|
|
|
|
|
|
+ await delList(unref(id).length).finally(() => {
|
|
delLoading.value = false
|
|
delLoading.value = false
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-const action = (row: TableData, type: string) => {
|
|
|
|
|
|
+const action = (row: ProductTableData, type: string) => {
|
|
push(`/manage/product-${type}?id=${row.id}`)
|
|
push(`/manage/product-${type}?id=${row.id}`)
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
@@ -325,9 +247,6 @@ const action = (row: TableData, type: string) => {
|
|
|
|
|
|
<div class="mb-10px">
|
|
<div class="mb-10px">
|
|
<ElButton type="primary" @click="AddAction">{{ t('exampleDemo.add') }}</ElButton>
|
|
<ElButton type="primary" @click="AddAction">{{ t('exampleDemo.add') }}</ElButton>
|
|
- <ElButton :loading="delLoading" type="danger" @click="delData(null)">
|
|
|
|
- {{ t('exampleDemo.del') }}
|
|
|
|
- </ElButton>
|
|
|
|
<TableSetting page="ProductPage" :data="crudSchemas" @set-schemas="setSchemas" />
|
|
<TableSetting page="ProductPage" :data="crudSchemas" @set-schemas="setSchemas" />
|
|
</div>
|
|
</div>
|
|
|
|
|