Forráskód Böngészése

fix: 添加热门推荐,规格搜索

cmy 2 hónapja
szülő
commit
9e060f82a7
4 módosított fájl, 1615 hozzáadás és 1551 törlés
  1. 69 67
      src/api/goods/types.ts
  2. 941 945
      src/views/Goods/edit/add.vue
  3. 602 536
      src/views/Goods/list/index.vue
  4. 3 3
      vite.config.ts

+ 69 - 67
src/api/goods/types.ts

@@ -1,90 +1,92 @@
 export interface categoryData {
-  id?: number
-  pid: number
-  name: string //真实姓名
-  image: string //图标
-  is_show: 1 | 0 //是否显示
-  sort: number //排序
+	id ?: number
+	pid : number
+	name : string //真实姓名
+	image : string //图标
+	is_show : 1 | 0 //是否显示
+	sort : number //排序
 }
 interface attrs {
-  attr_name: string //属性名
-  attr_values: string[] //属性值
+	attr_name : string //属性名
+	attr_values : string[] //属性值
 }
 export interface attrsValue {
-  suk: string //规格参数
-  image: string[] | string //商品图片
-  stock: number //库存
-  price: number //商品价格
-  ot_price: number //商品原价
-  cost: number //商品成本价
-  detail: object //商品规格详情
+	suk : string //规格参数
+	image : string[] | string //商品图片
+	stock : number //库存
+	price : number //商品价格
+	ot_price : number //商品原价
+	cost : number //商品成本价
+	detail : object //商品规格详情
 }
 export interface goodsData {
-  store_id: number | string
-  id?: number
-  name: string //商品名称
-  video_open: 0 | 1 | true | false //商品视频是否开启:0关闭 1开启
-  video_link?: string //视频链接
-  image: string[] //主图
-  slider_image: string[] //轮播图
-  info?: string //简介
-  keyword?: string[] | string //关键词
-  cate_ids: number[] //分类
-  postage: number //上楼费
-  temp_id?: string //上楼费模板ID
-  unit_name: string //单位
-  sales?: number //销量
-  ficti?: number //虚拟销量
-  spec_type: 0 | 1 //规格模式:0=单规格,1=多规格
-  is_show: 0 | 1 //状态:0=未上架,1=上架
-  attrs: attrs[] //规格
-  attrs_value: attrsValue[] //规格参数
-  sort: number //排序
-  description: string //商品内容
+	rule_id:number
+	hot : 0 | 1 | true | false
+	store_id : number | string
+	id ?: number
+	name : string //商品名称
+	video_open : 0 | 1 | true | false //商品视频是否开启:0关闭 1开启
+	video_link ?: string //视频链接
+	image : string[] //主图
+	slider_image : string[] //轮播图
+	info ?: string //简介
+	keyword ?: string[] | string //关键词
+	cate_ids : number[] //分类
+	postage : number //上楼费
+	temp_id ?: string //上楼费模板ID
+	unit_name : string //单位
+	sales ?: number //销量
+	ficti ?: number //虚拟销量
+	spec_type : 0 | 1 //规格模式:0=单规格,1=多规格
+	is_show : 0 | 1 //状态:0=未上架,1=上架
+	attrs : attrs[] //规格
+	attrs_value : attrsValue[] //规格参数
+	sort : number //排序
+	description : string //商品内容
 }
 export interface goodsSearch {
-  name?: string
-  page?: number
-  limit?: number
-  cate_ids?: number | ''
-  store_id?: number | ''
-  is_del?: 'all' | '0' | '1' //是否删除:0否1是
-  is_show?: 'all' | '0' | '1' //状态:0=未上架,1=上架
-  is_verify?: 'all' | '0' | '1' | '-1' | '-2' //审核状态:-2=强制下架,-1=未通过,0=待审核,1=通过
+	name ?: string
+	page ?: number
+	limit ?: number
+	cate_ids ?: number | ''
+	store_id ?: number | ''
+	is_del ?: 'all' | '0' | '1' //是否删除:0否1是
+	is_show ?: 'all' | '0' | '1' //状态:0=未上架,1=上架
+	is_verify ?: 'all' | '0' | '1' | '-1' | '-2' //审核状态:-2=强制下架,-1=未通过,0=待审核,1=通过
 }
 export interface auditData {
-  id: number
-  is_verify: -1 | 1 //审核状态:-1=拒绝,1=通过
-  refusal: string //未通过原因
+	id : number
+	is_verify : -1 | 1 //审核状态:-1=拒绝,1=通过
+	refusal : string //未通过原因
 }
 
 export interface searchProductRule {
-  rule_name?: string
-  page?: number
-  limit?: number
+	rule_name ?: string
+	page ?: number
+	limit ?: number
 }
 export interface productRuleValue {
-  attrHidden: '' | true | false
-  detail: string[]
-  detailValue: string
-  value: string
+	attrHidden : '' | true | false
+	detail : string[]
+	detailValue : string
+	value : string
 }
 export interface productRule {
-  id: number
-  rule_name: string
-  rule_value: productRuleValue[]
+	id : number
+	rule_name : string
+	rule_value : productRuleValue[]
 }
 /**
  * 添加商品规格项目
  */
 export interface AttrBaseItem {
-  bar_code: string
-  cost: number
-  detail: object
-  ot_price: number
-  pic: string[]
-  price: number
-  stock: number
-  weight: number
-  volume: number
-}
+	bar_code : string
+	cost : number
+	detail : object
+	ot_price : number
+	pic : string[]
+	price : number
+	stock : number
+	weight : number
+	volume : number
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 941 - 945
src/views/Goods/edit/add.vue


+ 602 - 536
src/views/Goods/list/index.vue

@@ -1,553 +1,619 @@
 <script setup lang="tsx">
-import { onMounted, reactive, ref, unref, watch } from 'vue'
-import {
-  delProduct,
-  getProduct,
-  getProductCategory,
-  postProductStatus,
-  postProductAudit
-} from '@/api/goods'
-import { getStoreList } from '@/api/store'
-import { useI18n } from '@/hooks/web/useI18n'
-import { Search } from '@/components/Search'
-import { FormSchema } from '@/components/Form'
-import { ContentWrap } from '@/components/ContentWrap'
-import { BaseButton } from '@/components/Button'
-import { goodsSearch } from '@/api/goods/types'
-import {
-  ElMessageBox,
-  ElSwitch,
-  ElDivider,
-  ElDropdown,
-  ElDropdownMenu,
-  ElDropdownItem,
-  ElTable,
-  ElTableColumn,
-  ElPagination,
-  ElMessage,
-  ElTabs,
-  ElTabPane,
-  ElText
-} from 'element-plus'
-import type { Action } from 'element-plus'
-import { TableImage } from '@/components/tableImage'
-import BatchSet from './components/BatchSet.vue'
-import { useSearch } from '@/hooks/web/useSearch'
-import Icon from '@/components/Icon/src/Icon.vue'
-import { useRouter } from 'vue-router'
-const { push } = useRouter()
-const { searchRegister, searchMethods } = useSearch()
-const { setSchema, setValues, getFormData } = searchMethods
-const { t } = useI18n()
-// tab切换查询参数
-const tabsConfig = reactive({
-  up: {
-    title: '出售中商品',
-    total: 0,
-    search: { is_show: '1', is_del: '0', is_verify: '1' }
-  }, //出售中商品
-  dom: {
-    title: '仓库中商品',
-    total: 0,
-    search: { is_show: '0', is_del: '0', is_verify: '1' }
-  }, //仓库中商品
-  examine: {
-    title: '待审核商品',
-    total: 0,
-    search: { is_show: 'all', is_del: '0', is_verify: '0' }
-  }, //待审核商品
-  trash: {
-    title: '商品回收站',
-    total: 0,
-    search: { is_show: 'all', is_del: '1', is_verify: 'all' }
-  }, //商品回收站
-  all: {
-    title: '高级查询',
-    total: 0,
-    search: { is_show: 'all', is_del: 'all', is_verify: 'all' }
-  } //高级查询
-})
-const currentPage = ref(1)
-const pageSize = ref(10)
-const dataList = ref<any[]>([])
-const loading = ref(false)
+	import {
+		onMounted,
+		reactive,
+		ref,
+		unref,
+		watch
+	} from 'vue'
+	import {
+		delProduct,
+		getProduct,
+		getProductCategory,
+		postProductStatus,
+		postProductAudit,
+		getProductRule
+	} from '@/api/goods'
+	import {
+		getStoreList
+	} from '@/api/store'
+	import {
+		useI18n
+	} from '@/hooks/web/useI18n'
+	import {
+		Search
+	} from '@/components/Search'
+	import {
+		FormSchema
+	} from '@/components/Form'
+	import {
+		ContentWrap
+	} from '@/components/ContentWrap'
+	import {
+		BaseButton
+	} from '@/components/Button'
+	import {
+		goodsSearch
+	} from '@/api/goods/types'
+	import {
+		ElMessageBox,
+		ElSwitch,
+		ElDivider,
+		ElDropdown,
+		ElDropdownMenu,
+		ElDropdownItem,
+		ElTable,
+		ElTableColumn,
+		ElPagination,
+		ElMessage,
+		ElTabs,
+		ElTabPane,
+		ElText
+	} from 'element-plus'
+	import type {
+		Action
+	} from 'element-plus'
+	import {
+		TableImage
+	} from '@/components/tableImage'
+	import BatchSet from './components/BatchSet.vue'
+	import {
+		useSearch
+	} from '@/hooks/web/useSearch'
+	import Icon from '@/components/Icon/src/Icon.vue'
+	import {
+		useRouter
+	} from 'vue-router'
+	const {
+		push
+	} = useRouter()
+	const {
+		searchRegister,
+		searchMethods
+	} = useSearch()
+	const {
+		setSchema,
+		setValues,
+		getFormData
+	} = searchMethods
+	const {
+		t
+	} = useI18n()
+	// tab切换查询参数
+	const tabsConfig = reactive({
+		up: {
+			title: '出售中商品',
+			total: 0,
+			search: {
+				is_show: '1',
+				is_del: '0',
+				is_verify: '1'
+			}
+		}, //出售中商品
+		dom: {
+			title: '仓库中商品',
+			total: 0,
+			search: {
+				is_show: '0',
+				is_del: '0',
+				is_verify: '1'
+			}
+		}, //仓库中商品
+		examine: {
+			title: '待审核商品',
+			total: 0,
+			search: {
+				is_show: 'all',
+				is_del: '0',
+				is_verify: '0'
+			}
+		}, //待审核商品
+		trash: {
+			title: '商品回收站',
+			total: 0,
+			search: {
+				is_show: 'all',
+				is_del: '1',
+				is_verify: 'all'
+			}
+		}, //商品回收站
+		all: {
+			title: '高级查询',
+			total: 0,
+			search: {
+				is_show: 'all',
+				is_del: 'all',
+				is_verify: 'all'
+			}
+		} //高级查询
+	})
+	const currentPage = ref(1)
+	const pageSize = ref(10)
+	const dataList = ref < any[] > ([])
+	const loading = ref(false)
 
-onMounted(async () => {
-  try {
-    getTabNumber('examine') //待审核商品数量
-    getTabNumber('dom') //仓鼠中商品数量
-    getTabNumber('trash') //商品回收站
-    getList()
-    getStroe()
-  } catch (error) {
-    console.error('Failed to fetch data:', error)
-    // 可以在这里添加更详细的错误处理逻辑,例如显示错误信息给用户
-  }
-})
-const getList = async () => {
-  try {
-    loading.value = true
-    // 提取 unref 操作以减少冗余
-    const page = unref(currentPage) || 1
-    const limit = unref(pageSize) || 10
-    const searchParamsValue = unref(searchParams)
-    const { data } = await getProduct({
-      page,
-      limit,
-      ...searchParamsValue
-    })
-    // 处理边界条件
-    if (data && data.list && data.count !== undefined) {
-      dataList.value = data.list.map((item) => {
-        item.is_show_bol = Boolean(item.is_show)
-        return item
-      })
-      tabsConfig[activeName.value].total = data.count
-    } else {
-      // 处理数据为空的情况
-      dataList.value = []
-      tabsConfig[activeName.value].total = 0
-    }
-  } catch (error) {
-    // 异常处理
-    console.error('获取产品列表失败:', error)
-    // 可以在这里添加错误提示或其他处理逻辑
-  } finally {
-    loading.value = false
-    // 确保无论成功与否,都会将加载状态设置为 false
-  }
-}
-const getStroe = () => {
-  getStoreList({
-    page: 1,
-    limit: 100
-  }).then((res) => {
-    console.log(res, '1123123')
-  })
-}
+	onMounted(async () => {
+		try {
+			getTabNumber('examine') //待审核商品数量
+			getTabNumber('dom') //仓鼠中商品数量
+			getTabNumber('trash') //商品回收站
+			getList()
+			getStroe()
+		} catch (error) {
+			console.error('Failed to fetch data:', error)
+			// 可以在这里添加更详细的错误处理逻辑,例如显示错误信息给用户
+		}
+	})
+	const getList = async () => {
+		try {
+			loading.value = true
+			// 提取 unref 操作以减少冗余
+			const page = unref(currentPage) || 1
+			const limit = unref(pageSize) || 10
+			const searchParamsValue = unref(searchParams)
+			const {
+				data
+			} = await getProduct({
+				page,
+				limit,
+				...searchParamsValue
+			})
+			// 处理边界条件
+			if (data && data.list && data.count !== undefined) {
+				dataList.value = data.list.map((item) => {
+					item.is_show_bol = Boolean(item.is_show)
+					return item
+				})
+				tabsConfig[activeName.value].total = data.count
+			} else {
+				// 处理数据为空的情况
+				dataList.value = []
+				tabsConfig[activeName.value].total = 0
+			}
+		} catch (error) {
+			// 异常处理
+			console.error('获取产品列表失败:', error)
+			// 可以在这里添加错误提示或其他处理逻辑
+		} finally {
+			loading.value = false
+			// 确保无论成功与否,都会将加载状态设置为 false
+		}
+	}
+	const getStroe = () => {
+		getStoreList({
+			page: 1,
+			limit: 100
+		}).then((res) => {
+			console.log(res, '1123123')
+		})
+	}
 
-const getTabNumber = async (name) => {
-  const search = tabsConfig[name].search
-  try {
-    const { data } = await getProduct(search)
-    // 处理边界条件
-    if (data && data.list && data.count !== undefined) {
-      tabsConfig[name].total = data.count
-    } else {
-      // 处理数据为空的情况
-      tabsConfig[name].total = 0
-    }
-  } catch (error) {
-    // 异常处理
-    console.error('获取产品列表失败:', error)
-    // 可以在这里添加错误提示或其他处理逻辑
-  } finally {
-    loading.value = false
-    // 确保无论成功与否,都会将加载状态设置为 false
-  }
-}
-const searchSchema = reactive<FormSchema[]>([
-  {
-    field: 'name',
-    label: '商品名称',
-    component: 'Input',
-    componentProps: {
-      placeholder: '请填写商品名称'
-    }
-  },
-  {
-    field: 'store_id',
-    label: '门店',
-    component: 'Select',
-    componentProps: {
-      placeholder: '请选择要搜索的门店'
-    },
-    optionApi: async () => {
-      const { data } = await getStoreList({ page: 1, limit: 100 })
-      return data.list.map((item) => {
-        return {
-          value: item.id,
-          label: item.name
-        }
-      })
-    }
-  },
-  {
-    field: 'is_verify',
-    label: '审核状态',
-    hidden: true,
-    component: 'Select',
-    value: 'all',
-    componentProps: {
-      placeholder: '全部',
-      options: [
-        {
-          value: 'all',
-          label: '全部'
-        },
-        {
-          value: '-2',
-          label: '强制下架'
-        },
-        {
-          value: '-1',
-          label: '未通过'
-        },
-        {
-          value: '0',
-          label: '待审核'
-        },
-        {
-          value: '1',
-          label: '通过'
-        }
-      ]
-    }
-  },
-  {
-    field: 'is_show',
-    label: '上下架',
-    hidden: true,
+	const getTabNumber = async (name) => {
+		const search = tabsConfig[name].search
+		try {
+			const {
+				data
+			} = await getProduct(search)
+			// 处理边界条件
+			if (data && data.list && data.count !== undefined) {
+				tabsConfig[name].total = data.count
+			} else {
+				// 处理数据为空的情况
+				tabsConfig[name].total = 0
+			}
+		} catch (error) {
+			// 异常处理
+			console.error('获取产品列表失败:', error)
+			// 可以在这里添加错误提示或其他处理逻辑
+		} finally {
+			loading.value = false
+			// 确保无论成功与否,都会将加载状态设置为 false
+		}
+	}
+	const searchSchema = reactive < FormSchema[] > ([{
+			field: 'name',
+			label: '商品名称',
+			component: 'Input',
+			componentProps: {
+				placeholder: '请填写商品名称'
+			}
+		},
+		{
+			field: 'store_id',
+			label: '门店',
+			component: 'Select',
+			componentProps: {
+				placeholder: '请选择要搜索的门店'
+			},
+			optionApi: async () => {
+				const {
+					data
+				} = await getStoreList({
+					page: 1,
+					limit: 100
+				})
+				return data.list.map((item) => {
+					return {
+						value: item.id,
+						label: item.name
+					}
+				})
+			}
+		},
+		{
+			field: 'is_verify',
+			label: '审核状态',
+			hidden: true,
+			component: 'Select',
+			value: 'all',
+			componentProps: {
+				placeholder: '全部',
+				options: [{
+						value: 'all',
+						label: '全部'
+					},
+					{
+						value: '-2',
+						label: '强制下架'
+					},
+					{
+						value: '-1',
+						label: '未通过'
+					},
+					{
+						value: '0',
+						label: '待审核'
+					},
+					{
+						value: '1',
+						label: '通过'
+					}
+				]
+			}
+		},
+		{
+			field: 'is_show',
+			label: '上下架',
+			hidden: true,
 
-    component: 'Select',
-    value: 'all',
-    componentProps: {
-      placeholder: '全部',
-      options: [
-        {
-          value: 'all',
-          label: '全部'
-        },
-        {
-          value: '1',
-          label: '上架'
-        },
-        {
-          value: '0',
-          label: '未上架'
-        }
-      ]
-    }
-  },
-  {
-    field: 'is_del',
-    label: '是否删除',
-    hidden: true,
-    component: 'Select',
-    value: 'all',
-    componentProps: {
-      placeholder: '全部',
-      options: [
-        {
-          value: 'all',
-          label: '全部'
-        },
-        {
-          value: '0',
-          label: '未删除'
-        },
-        {
-          value: '1',
-          label: '已删除'
-        }
-      ]
-    }
-  },
-  {
-    field: 'cate_ids',
-    label: '商品分类',
-    component: 'Cascader',
-    componentProps: {
-      placeholder: '请选择商品分类',
-      props: {
-        lazy: true,
-        lazyLoad(node, resolve) {
-          getProductCategory({ page: 1, limit: 100, pid: node.value || -1 }).then((res) => {
-            console.log(res)
-            const nodes = res.data.map((item) => {
-              return {
-                value: item.id,
-                label: item.name,
-                leaf: !item.hasChildren
-              }
-            })
-            resolve(nodes)
-          })
-        }
-      }
-    }
-  }
-])
+			component: 'Select',
+			value: 'all',
+			componentProps: {
+				placeholder: '全部',
+				options: [{
+						value: 'all',
+						label: '全部'
+					},
+					{
+						value: '1',
+						label: '上架'
+					},
+					{
+						value: '0',
+						label: '未上架'
+					}
+				]
+			}
+		},
+		{
+			field: 'is_del',
+			label: '是否删除',
+			hidden: true,
+			component: 'Select',
+			value: 'all',
+			componentProps: {
+				placeholder: '全部',
+				options: [{
+						value: 'all',
+						label: '全部'
+					},
+					{
+						value: '0',
+						label: '未删除'
+					},
+					{
+						value: '1',
+						label: '已删除'
+					}
+				]
+			}
+		},
+		{
+			field: 'cate_ids',
+			label: '商品分类',
+			component: 'Cascader',
+			componentProps: {
+				placeholder: '请选择商品分类',
+				props: {
+					lazy: true,
+					lazyLoad(node, resolve) {
+						getProductCategory({
+							page: 1,
+							limit: 100,
+							pid: node.value || -1
+						}).then((res) => {
+							console.log(res)
+							const nodes = res.data.map((item) => {
+								return {
+									value: item.id,
+									label: item.name,
+									leaf: !item.hasChildren
+								}
+							})
+							resolve(nodes)
+						})
+					}
+				}
+			}
+		},
+		{
+			field: 'rule_id',
+			label: '商品规格',
+			component: 'Cascader',
+			componentProps: {
+				placeholder: '请选择商品规格',
+				props: {
+					lazy: true,
+					lazyLoad(_, resolve) {
+						getProductRule({
+							page: 1,
+							limit: 100,
+						}).then((res) => {
+							const nodes = res.data.map((item) => {
+								return {
+									value: item.id,
+									label: item.rule_name
+,
+									leaf:true
+								}
+							})
+							resolve(nodes)
+						})
+					}
+				}
+			}
+		}
+	])
 
-const searchParams = ref<goodsSearch>({
-  name: '',
-  cate_ids: '',
-  store_id: '',
-  is_show: '1',
-  is_del: '0',
-  is_verify: '1'
-})
-const setSearchParams = (data: any) => {
-  searchParams.value = data
-  getList()
-}
+	const searchParams = ref < goodsSearch > ({
+		name: '',
+		cate_ids: '',
+		store_id: '',
+		is_show: '1',
+		is_del: '0',
+		is_verify: '1'
+	})
+	const setSearchParams = (data: any) => {
+		searchParams.value = data
+		getList()
+	}
 
-const action = async (type: string, id?: number) => {
-  push(`/goods/edit/${type}/${id || 0}`)
-}
-const delPr = async (id: number, is_del: 0 | 1) => {
-  let title = '移除'
-  if (is_del == 0) {
-    title = '恢复'
-  }
-  ElMessageBox.confirm(`是否${title}商品?`, {
-    confirmButtonText: `${title}`,
-    cancelButtonText: '取消',
-    type: 'warning'
-  })
-    .then(async () => {
-      await delProduct(id, is_del)
-      getList()
+	const action = async (type: string, id ? : number) => {
+		push(`/goods/edit/${type}/${id || 0}`)
+	}
+	const delPr = async (id: number, is_del: 0 | 1) => {
+		let title = '移除'
+		if (is_del == 0) {
+			title = '恢复'
+		}
+		ElMessageBox.confirm(`是否${title}商品?`, {
+				confirmButtonText: `${title}`,
+				cancelButtonText: '取消',
+				type: 'warning'
+			})
+			.then(async () => {
+				await delProduct(id, is_del)
+				getList()
 
-      ElMessage({
-        showClose: true,
-        message: `${title}成功`,
-        type: 'success'
-      })
-    })
-    .catch(() => {})
-}
+				ElMessage({
+					showClose: true,
+					message: `${title}成功`,
+					type: 'success'
+				})
+			})
+			.catch(() => {})
+	}
 
-const selectChange = (res) => {
-  selectList.value = res
-}
-const selectList = ref<any[]>([])
-const dialogSet = ref(false)
-const allSet = () => {
-  dialogSet.value = true
-}
-watch(currentPage, (val) => {
-  if (val) {
-    // console.log(val)
-    currentPage.value = val
-    getList()
-  }
-})
-const changeStatus = async (val: any, id: number) => {
-  console.log(val, id, 'val')
-  try {
-    const res = await postProductStatus(id, val)
-    if (res) {
-      ElMessage.success('设置成功')
-    }
-  } catch (error) {
-    console.log(error)
-  } finally {
-    getList()
-  }
-  console.log()
-}
-const activeName = ref('up')
+	const selectChange = (res) => {
+		selectList.value = res
+	}
+	const selectList = ref < any[] > ([])
+	const dialogSet = ref(false)
+	const allSet = () => {
+		dialogSet.value = true
+	}
+	watch(currentPage, (val) => {
+		if (val) {
+			// console.log(val)
+			currentPage.value = val
+			getList()
+		}
+	})
+	const changeStatus = async (val: any, id: number) => {
+		console.log(val, id, 'val')
+		try {
+			const res = await postProductStatus(id, val)
+			if (res) {
+				ElMessage.success('设置成功')
+			}
+		} catch (error) {
+			console.log(error)
+		} finally {
+			getList()
+		}
+		console.log()
+	}
+	const activeName = ref('up')
 
-const tabsClick = async (res) => {
-  if (!res || !res.paneName) {
-    console.error('Invalid res or paneName')
-    return
-  }
-  // if (res.paneName === activeName.value) {
-  //   return
-  // }
-  //保存当前分类
-  // activeName.value = res.paneName
-  try {
-    // 设置 schema 配置
-    const schemaConfig = res.paneName === 'all' ? false : true
-    setSchema([
-      { field: 'is_verify', path: 'hidden', value: schemaConfig },
-      { field: 'is_del', path: 'hidden', value: schemaConfig },
-      { field: 'is_show', path: 'hidden', value: schemaConfig }
-    ])
+	const tabsClick = async (res) => {
+		if (!res || !res.paneName) {
+			console.error('Invalid res or paneName')
+			return
+		}
+		// if (res.paneName === activeName.value) {
+		//   return
+		// }
+		//保存当前分类
+		// activeName.value = res.paneName
+		try {
+			// 设置 schema 配置
+			const schemaConfig = res.paneName === 'all' ? false : true
+			setSchema([{
+					field: 'is_verify',
+					path: 'hidden',
+					value: schemaConfig
+				},
+				{
+					field: 'is_del',
+					path: 'hidden',
+					value: schemaConfig
+				},
+				{
+					field: 'is_show',
+					path: 'hidden',
+					value: schemaConfig
+				}
+			])
 
-    if (tabsConfig[res.paneName].search) {
-      await setValues(tabsConfig[res.paneName].search)
-    } else {
-      console.warn(`Unknown paneName: ${res.paneName}`)
-    }
-    const data = await getFormData()
-    setSearchParams(data)
-  } catch (error) {
-    console.error('Error in handleClick:', error)
-  }
-}
-const auditMessageBox = (id: number) => {
-  ElMessageBox.confirm('请选择审核结果', '审核', {
-    distinguishCancelAndClose: true,
-    confirmButtonText: '通过',
-    cancelButtonText: '未通过'
-  })
-    .then(() => {
-      audit(id, 1, '')
-    })
-    .catch((action: Action) => {
-      if (action == 'cancel') {
-        ElMessageBox.prompt('请输入拒绝理由', '提示', {
-          inputPlaceholder: '输入正确的拒绝理由以便修改'
-        }).then((res) => {
-          audit(id, -1, res.value)
-          console.log(res)
-        })
-      }
-    })
-}
+			if (tabsConfig[res.paneName].search) {
+				await setValues(tabsConfig[res.paneName].search)
+			} else {
+				console.warn(`Unknown paneName: ${res.paneName}`)
+			}
+			const data = await getFormData()
+			setSearchParams(data)
+		} catch (error) {
+			console.error('Error in handleClick:', error)
+		}
+	}
+	const auditMessageBox = (id: number) => {
+		ElMessageBox.confirm('请选择审核结果', '审核', {
+				distinguishCancelAndClose: true,
+				confirmButtonText: '通过',
+				cancelButtonText: '未通过'
+			})
+			.then(() => {
+				audit(id, 1, '')
+			})
+			.catch((action: Action) => {
+				if (action == 'cancel') {
+					ElMessageBox.prompt('请输入拒绝理由', '提示', {
+						inputPlaceholder: '输入正确的拒绝理由以便修改'
+					}).then((res) => {
+						audit(id, -1, res.value)
+						console.log(res)
+					})
+				}
+			})
+	}
 
-const audit = async (id, is_verify, refusal) => {
-  try {
-    const res = await postProductAudit({
-      id,
-      refusal,
-      is_verify
-    })
-    if (res && res.status == 200) {
-      let title = '审核通过'
-      if (is_verify == -1) {
-        title = '已拒绝'
-      }
-      ElMessage.success(title)
-      getList()
-    }
-  } catch (error) {
-    console.log(error)
-  }
-}
+	const audit = async (id, is_verify, refusal) => {
+		try {
+			const res = await postProductAudit({
+				id,
+				refusal,
+				is_verify
+			})
+			if (res && res.status == 200) {
+				let title = '审核通过'
+				if (is_verify == -1) {
+					title = '已拒绝'
+				}
+				ElMessage.success(title)
+				getList()
+			}
+		} catch (error) {
+			console.log(error)
+		}
+	}
 </script>
 
 <template>
-  <ContentWrap>
-    <ElTabs v-model="activeName" @tab-click="tabsClick">
-      <ElTabPane
-        v-for="(item, index) in tabsConfig"
-        :key="index"
-        :label="`${item.title}${item.total > 0 ? `(${item.total})` : ''}`"
-        :name="index"
-        >{{ index }}
-      </ElTabPane>
-    </ElTabs>
-    <div class="max-w-1000px">
-      <Search
-        :schema="searchSchema"
-        @reset="setSearchParams"
-        @search="setSearchParams"
-        @register="searchRegister"
-        buttonPosition="right"
-      />
-    </div>
-    <div class="mb-10px">
-      <BaseButton type="primary" @click="action('add')">{{ t('exampleDemo.add') }}</BaseButton>
-      <BaseButton @click="allSet" :disabled="selectList.length == 0">批量设置</BaseButton>
-    </div>
-    <ElTable @selection-change="selectChange" v-loading="loading" node-key="id" :data="dataList">
-      <ElTableColumn type="selection" prop="selection" />
-      <ElTableColumn prop="id" headerAlign="center" align="center" label="ID" width="70" />
-      <ElTableColumn prop="avatar" headerAlign="center" align="center" label="商品图片" width="80">
-        <template #default="{ row }">
-          <TableImage :src="row.image" alt="商品图片" />
-        </template>
-      </ElTableColumn>
-      <ElTableColumn prop="name" label="商品名称" minWidth="180" />
-      <ElTableColumn prop="store_name" label="门店" minWidth="150" />
-      <ElTableColumn prop="price" label="商品售价" minWidth="80" />
-      <ElTableColumn prop="stock" label="库存" minWidth="80" />
-      <ElTableColumn prop="sales" label="销量" minWidth="80" />
-      <ElTableColumn prop="is_show" label="上下架" minWidth="80">
-        <template #default="{ row }">
-          <ElSwitch
-            active-text="上架"
-            inactive-text="下架"
-            inline-prompt
-            :active-value="1"
-            :inactive-value="0"
-            v-model="row.is_show"
-            @change="(val) => changeStatus(val, row.id)"
-          />
-        </template>
-      </ElTableColumn>
-      <ElTableColumn v-if="activeName == 'all'" prop="is_verify" label="审核状态" minWidth="80">
-        <template #default="{ row }">
-          <ElText v-if="row.is_verify == 1" type="success">已通过</ElText>
-          <ElText v-if="row.is_verify == 0" type="primary">待审核</ElText>
-          <ElText v-if="row.is_verify == -1" type="danger">已拒绝</ElText>
-        </template>
-      </ElTableColumn>
-      <ElTableColumn v-if="activeName == 'all'" prop="price" label="删除状态" minWidth="80">
-        <template #default="{ row }">
-          <ElText v-if="row.is_del == 1" type="danger">已删除</ElText>
-          <ElText v-if="row.is_del == 0" type="primary">未删除</ElText>
-        </template>
-      </ElTableColumn>
-      <ElTableColumn
-        prop="action"
-        label="操作"
-        headerAlign="center"
-        align="center"
-        width="190"
-        :showOverflowTooltip="false"
-        fixed="right"
-      >
-        <template #default="{ row }">
-          <BaseButton link size="small" type="primary" @click="action('edit', row.id)">
-            编辑
-          </BaseButton>
-          <ElDivider direction="vertical" />
-          <BaseButton
-            v-if="activeName == 'examine'"
-            link
-            size="small"
-            type="primary"
-            @click="auditMessageBox(row.id)"
-          >
-            审核
-          </BaseButton>
-          <ElDivider v-if="activeName == 'examine'" direction="vertical" />
-          <ElDropdown>
-            <BaseButton link size="small" type="info">
-              <Icon icon="vi-ep:more-filled" />
-            </BaseButton>
-            <template #dropdown
-              ><ElDropdownMenu>
-                <ElDropdownItem v-if="activeName != 'trash'" @click="delPr(row.id, 1)"
-                  >移到回收站
-                </ElDropdownItem>
-                <ElDropdownItem v-if="activeName == 'trash'" @click="delPr(row.id, 0)"
-                  >恢复商品
-                </ElDropdownItem>
-              </ElDropdownMenu>
-            </template>
-          </ElDropdown>
-        </template>
-      </ElTableColumn>
-    </ElTable>
-    <ElPagination
-      v-model:current-page="currentPage"
-      v-model:page-size="pageSize"
-      layout="sizes, prev, pager, next, jumper, ->, total"
-      :page-sizes="[10, 20, 30, 40, 50, 100]"
-      class="mt-10px"
-      :total="tabsConfig[activeName].total"
-    />
-  </ContentWrap>
+	<ContentWrap>
+		<ElTabs v-model="activeName" @tab-click="tabsClick">
+			<ElTabPane v-for="(item, index) in tabsConfig" :key="index"
+				:label="`${item.title}${item.total > 0 ? `(${item.total})` : ''}`" :name="index"></ElTabPane>
+		</ElTabs>
+		<div class="max-w-1000px">
+			<Search :schema="searchSchema" @reset="setSearchParams" @search="setSearchParams" @register="searchRegister"
+				buttonPosition="right" />
+		</div>
+		<div class="mb-10px">
+			<BaseButton type="primary" @click="action('add')">{{ t('exampleDemo.add') }}</BaseButton>
+			<BaseButton @click="allSet" :disabled="selectList.length == 0">批量设置</BaseButton>
+		</div>
+		<ElTable @selection-change="selectChange" v-loading="loading" node-key="id" :data="dataList">
+			<ElTableColumn type="selection" prop="selection" />
+			<ElTableColumn prop="id" headerAlign="center" align="center" label="ID" width="70" />
+			<ElTableColumn prop="avatar" headerAlign="center" align="center" label="商品图片" width="80">
+				<template #default="{ row }">
+					<TableImage :src="row.image" alt="商品图片" />
+				</template>
+			</ElTableColumn>
+			<ElTableColumn prop="name" label="商品名称" minWidth="180" />
+			<ElTableColumn prop="store_name" label="门店" minWidth="150" />
+			<ElTableColumn prop="price" label="商品售价" minWidth="80" />
+			<ElTableColumn prop="stock" label="库存" minWidth="80" />
+			<ElTableColumn prop="sales" label="销量" minWidth="80" />
+			<ElTableColumn prop="is_show" label="上下架" minWidth="80">
+				<template #default="{ row }">
+					<ElSwitch active-text="上架" inactive-text="下架" inline-prompt :active-value="1" :inactive-value="0"
+						v-model="row.is_show" @change="(val) => changeStatus(val, row.id)" />
+				</template>
+			</ElTableColumn>
+			<ElTableColumn v-if="activeName == 'all'" prop="is_verify" label="审核状态" minWidth="80">
+				<template #default="{ row }">
+					<ElText v-if="row.is_verify == 1" type="success">已通过</ElText>
+					<ElText v-if="row.is_verify == 0" type="primary">待审核</ElText>
+					<ElText v-if="row.is_verify == -1" type="danger">已拒绝</ElText>
+				</template>
+			</ElTableColumn>
+			<ElTableColumn v-if="activeName == 'all'" prop="price" label="删除状态" minWidth="80">
+				<template #default="{ row }">
+					<ElText v-if="row.is_del == 1" type="danger">已删除</ElText>
+					<ElText v-if="row.is_del == 0" type="primary">未删除</ElText>
+				</template>
+			</ElTableColumn>
+			<ElTableColumn prop="action" label="操作" headerAlign="center" align="center" width="190"
+				:showOverflowTooltip="false" fixed="right">
+				<template #default="{ row }">
+					<BaseButton link size="small" type="primary" @click="action('edit', row.id)">
+						编辑
+					</BaseButton>
+					<ElDivider direction="vertical" />
+					<BaseButton v-if="activeName == 'examine'" link size="small" type="primary"
+						@click="auditMessageBox(row.id)">
+						审核
+					</BaseButton>
+					<ElDivider v-if="activeName == 'examine'" direction="vertical" />
+					<ElDropdown>
+						<BaseButton link size="small" type="info">
+							<Icon icon="vi-ep:more-filled" />
+						</BaseButton>
+						<template #dropdown>
+							<ElDropdownMenu>
+								<ElDropdownItem v-if="activeName != 'trash'" @click="delPr(row.id, 1)">移到回收站
+								</ElDropdownItem>
+								<ElDropdownItem v-if="activeName == 'trash'" @click="delPr(row.id, 0)">恢复商品
+								</ElDropdownItem>
+							</ElDropdownMenu>
+						</template>
+					</ElDropdown>
+				</template>
+			</ElTableColumn>
+		</ElTable>
+		<ElPagination v-model:current-page="currentPage" v-model:page-size="pageSize"
+			layout="sizes, prev, pager, next, jumper, ->, total" :page-sizes="[10, 20, 30, 40, 50, 100]" class="mt-10px"
+			:total="tabsConfig[activeName].total" />
+	</ContentWrap>
 
-  <BatchSet
-    :where="searchParams"
-    v-model="dialogSet"
-    :select-list="selectList"
-    @confirm="getList()"
-  />
+	<BatchSet :where="searchParams" v-model="dialogSet" :select-list="selectList" @confirm="getList()" />
 </template>
 <style lang="less">
-.example-showcase .el-dropdown-link {
-  display: flex;
-  color: var(--el-color-primary);
-  cursor: pointer;
-  align-items: center;
-}
-</style>
+	.example-showcase .el-dropdown-link {
+		display: flex;
+		color: var(--el-color-primary);
+		cursor: pointer;
+		align-items: center;
+	}
+</style>

+ 3 - 3
vite.config.ts

@@ -145,17 +145,17 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
       proxy: {
         // 选项写法
         '/api': {
-          target: 'https://zhuangxiu.qiniu1314.com',
+          target: 'https://shop.maowankj.com',
           changeOrigin: true
           // rewrite: (path) => path.replace(/^\/api/, '')
         },
         '/adminapi': {
-          target: 'https://zhuangxiu.qiniu1314.com',
+          target: 'https://shop.maowankj.com',
           changeOrigin: true
           // rewrite: (path) => path.replace(/^\//, '')
         },
         '/uploads': {
-          target: 'https://zhuangxiu.qiniu1314.com',
+          target: 'https://shop.maowankj.com',
           changeOrigin: true
           // rewrite: (path) => path.replace(/^\//, '')
         },

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott