|
@@ -20,6 +20,7 @@
|
|
left-icon=""
|
|
left-icon=""
|
|
right-icon="search"
|
|
right-icon="search"
|
|
@search="handleSearch"
|
|
@search="handleSearch"
|
|
|
|
+ @clear="handleClear"
|
|
@click-right-icon="handleSearch(searchValueRef)"
|
|
@click-right-icon="handleSearch(searchValueRef)"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
@@ -49,12 +50,24 @@
|
|
<van-dropdown-menu class="font-semibold">
|
|
<van-dropdown-menu class="font-semibold">
|
|
<van-dropdown-item
|
|
<van-dropdown-item
|
|
v-model="type1ValueRef"
|
|
v-model="type1ValueRef"
|
|
- :options="typeOptions1Ref"
|
|
|
|
|
|
+ :options="
|
|
|
|
+ typeOptions1Ref.map((item) => ({
|
|
|
|
+ text: item.toolName,
|
|
|
|
+ value: item.id
|
|
|
|
+ }))
|
|
|
|
+ "
|
|
|
|
+ title="一级分类"
|
|
@change="handleChangeDropdownOfType1"
|
|
@change="handleChangeDropdownOfType1"
|
|
/>
|
|
/>
|
|
<van-dropdown-item
|
|
<van-dropdown-item
|
|
v-model="type2ValueRef"
|
|
v-model="type2ValueRef"
|
|
- :options="typeOptions2Ref"
|
|
|
|
|
|
+ :options="
|
|
|
|
+ typeOptions2Ref.map((item) => ({
|
|
|
|
+ text: item.toolName,
|
|
|
|
+ value: item.id
|
|
|
|
+ }))
|
|
|
|
+ "
|
|
|
|
+ title="二级分类"
|
|
@change="handleChangeDropdownOfType2"
|
|
@change="handleChangeDropdownOfType2"
|
|
/>
|
|
/>
|
|
</van-dropdown-menu>
|
|
</van-dropdown-menu>
|
|
@@ -68,12 +81,12 @@
|
|
<div class="menu-content">
|
|
<div class="menu-content">
|
|
<div
|
|
<div
|
|
class="menu-item"
|
|
class="menu-item"
|
|
- :class="[typeItem.value === type1ValueRef ? 'active' : '']"
|
|
|
|
|
|
+ :class="[typeItem.id === type1ValueRef ? 'active' : '']"
|
|
v-for="typeItem in typeOptions1Ref"
|
|
v-for="typeItem in typeOptions1Ref"
|
|
- :key="typeItem.value"
|
|
|
|
- @click="handleChangeDropdownOfType1(typeItem.value)"
|
|
|
|
|
|
+ :key="typeItem.id"
|
|
|
|
+ @click="handleChangeDropdownOfType1(typeItem.id)"
|
|
>
|
|
>
|
|
- {{ typeItem.text }}
|
|
|
|
|
|
+ {{ typeItem.toolName }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -82,12 +95,12 @@
|
|
<div class="menu-content">
|
|
<div class="menu-content">
|
|
<div
|
|
<div
|
|
class="menu-item"
|
|
class="menu-item"
|
|
- :class="[typeItem.value === type2ValueRef ? 'active' : '']"
|
|
|
|
|
|
+ :class="[typeItem.id === type2ValueRef ? 'active' : '']"
|
|
v-for="typeItem in typeOptions2Ref"
|
|
v-for="typeItem in typeOptions2Ref"
|
|
- :key="typeItem.value"
|
|
|
|
- @click="handleChangeDropdownOfType2(typeItem.value)"
|
|
|
|
|
|
+ :key="typeItem.id"
|
|
|
|
+ @click="handleChangeDropdownOfType2(typeItem.id)"
|
|
>
|
|
>
|
|
- {{ typeItem.text }}
|
|
|
|
|
|
+ {{ typeItem.toolName }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -102,15 +115,17 @@
|
|
@load="onLoad"
|
|
@load="onLoad"
|
|
>
|
|
>
|
|
<div class="tool-card-content w-full px-4 flex flex-wrap md:max-w-[1440px] mx-auto">
|
|
<div class="tool-card-content w-full px-4 flex flex-wrap md:max-w-[1440px] mx-auto">
|
|
- <div class="tool-card" v-for="item in toolsListRef" :key="item">
|
|
|
|
- <div class="tool-img bg-[url('/src/assets/images/2-001.png')]"></div>
|
|
|
|
|
|
+ <div class="tool-card" v-for="item in toolsListRef" :key="item" @click="handleDetail(item)">
|
|
|
|
+ <div class="tool-img" :class="`bg-[url('${devPath + item.picturePath}')]`"></div>
|
|
<div class="px-3 pt-2 flex-1 flex flex-col">
|
|
<div class="px-3 pt-2 flex-1 flex flex-col">
|
|
- <div class="font-[PingFang-Heavy] truncate">手枪式铆枪</div>
|
|
|
|
|
|
+ <div class="font-[PingFang-Heavy] truncate">{{ item.toolName }}</div>
|
|
<div class="text-[#585F66] text-xs mt-1 line-clamp-2 break-all">
|
|
<div class="text-[#585F66] text-xs mt-1 line-clamp-2 break-all">
|
|
- 配10#20#30#40#拉头配10#20#30#40#拉头配10#20#30#40#拉头拉头配10#20#30#40#拉头
|
|
|
|
|
|
+ {{ item.describe }}
|
|
</div>
|
|
</div>
|
|
<div class="flex-1 flex items-center justify-end">
|
|
<div class="flex-1 flex items-center justify-end">
|
|
- <span class="text-2xl font-['DIN'] font-semibold text-[#004EA2]">146</span>
|
|
|
|
|
|
+ <span class="text-2xl font-['DIN'] font-semibold text-[#004EA2]">{{
|
|
|
|
+ item.toolNum
|
|
|
|
+ }}</span>
|
|
<span class="text-sm font-['PingFang-Heavy'] font-semibold ml-1 text-[#004EA2]"
|
|
<span class="text-sm font-['PingFang-Heavy'] font-semibold ml-1 text-[#004EA2]"
|
|
>件</span
|
|
>件</span
|
|
>
|
|
>
|
|
@@ -129,6 +144,12 @@ import { ref, computed } from 'vue'
|
|
import useAppStore from '@/stores/app.js'
|
|
import useAppStore from '@/stores/app.js'
|
|
import { getFillNums } from '@/utils'
|
|
import { getFillNums } from '@/utils'
|
|
import { hotToolsList, menuList1, menuList2, menuList3 } from './mock'
|
|
import { hotToolsList, menuList1, menuList2, menuList3 } from './mock'
|
|
|
|
+import { listTools } from '@/api/index.js'
|
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
|
+
|
|
|
|
+const devPath = import.meta.env.VITE_APP_BASE_API
|
|
|
|
+const router = useRouter()
|
|
|
|
+const route = useRoute()
|
|
|
|
|
|
const appStore = useAppStore()
|
|
const appStore = useAppStore()
|
|
// 当前设备类型
|
|
// 当前设备类型
|
|
@@ -143,44 +164,88 @@ const hotToolsRef = ref(hotToolsList)
|
|
const type1ValueRef = ref('1')
|
|
const type1ValueRef = ref('1')
|
|
const type2ValueRef = ref('')
|
|
const type2ValueRef = ref('')
|
|
// 分类列表1级
|
|
// 分类列表1级
|
|
-const typeOptions1Ref = ref(menuList1)
|
|
|
|
|
|
+const typeOptions1Ref = ref([])
|
|
// 分类列表2级
|
|
// 分类列表2级
|
|
-const typeOptions2Ref = ref(menuList2)
|
|
|
|
|
|
+const typeOptions2Ref = ref([])
|
|
|
|
|
|
const toolsListRef = ref([])
|
|
const toolsListRef = ref([])
|
|
const loadingRef = ref(false)
|
|
const loadingRef = ref(false)
|
|
const finished = ref(false)
|
|
const finished = ref(false)
|
|
// 末尾补齐的个数
|
|
// 末尾补齐的个数
|
|
const noneCardNum = ref(0)
|
|
const noneCardNum = ref(0)
|
|
-
|
|
|
|
const onLoad = () => {
|
|
const onLoad = () => {
|
|
- loadingRef.value = true
|
|
|
|
// 异步更新数据
|
|
// 异步更新数据
|
|
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
|
|
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
|
|
- setTimeout(() => {
|
|
|
|
- for (let i = 0; i < 20; i++) {
|
|
|
|
- toolsListRef.value.push(toolsListRef.value.length + 1)
|
|
|
|
- }
|
|
|
|
- noneCardNum.value = getFillNums('.tool-card-content', toolsListRef.value, 220)
|
|
|
|
-
|
|
|
|
- // 加载状态结束
|
|
|
|
- loadingRef.value = false
|
|
|
|
-
|
|
|
|
- // 数据全部加载完成
|
|
|
|
- if (toolsListRef.value.length >= 100) {
|
|
|
|
- finished.value = true
|
|
|
|
- }
|
|
|
|
- }, 1000)
|
|
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
+ // for (let i = 0; i < 20; i++) {
|
|
|
|
+ // toolsListRef.value.push(toolsListRef.value.length + 1)
|
|
|
|
+ // }
|
|
|
|
+ noneCardNum.value = getFillNums('.tool-card-content', toolsListRef.value, 220)
|
|
|
|
+ // // 加载状态结束
|
|
|
|
+ loadingRef.value = false
|
|
|
|
+ // // 数据全部加载完成
|
|
|
|
+ // if (toolsListRef.value.length >= 100) {
|
|
|
|
+ // finished.value = true
|
|
|
|
+ // }
|
|
|
|
+ // }, 1000)
|
|
}
|
|
}
|
|
|
|
+const init = () => {
|
|
|
|
+ loadingRef.value = false
|
|
|
|
+ // 一级分类
|
|
|
|
+ listTools({
|
|
|
|
+ level: '1',
|
|
|
|
+ pageSize: 999
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ typeOptions1Ref.value = res.rows
|
|
|
|
+ })
|
|
|
|
+ if (route.query.id) {
|
|
|
|
+ searchValueRef.value = route.query.toolName
|
|
|
|
+ type1ValueRef.value = route.query.id
|
|
|
|
+ listTools({
|
|
|
|
+ level: '2',
|
|
|
|
+ parentId: route.query.id,
|
|
|
|
+ pageSize: 999
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ typeOptions2Ref.value = res.rows
|
|
|
|
+ })
|
|
|
|
+ listTools({
|
|
|
|
+ level: '3',
|
|
|
|
+ parentId: route.query.id,
|
|
|
|
+ pageSize: 999,
|
|
|
|
+ delFlag: 0
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ toolsListRef.value = res.rows
|
|
|
|
+ })
|
|
|
|
+ type2ValueRef.value = ''
|
|
|
|
+ } else {
|
|
|
|
+ Promise.allSettled([
|
|
|
|
+ // 二级分类
|
|
|
|
+ listTools({
|
|
|
|
+ level: '2',
|
|
|
|
+ pageSize: 999
|
|
|
|
+ }),
|
|
|
|
+ // 未选中分类 默认列表
|
|
|
|
+ listTools({
|
|
|
|
+ level: '3',
|
|
|
|
+ delFlag: 0,
|
|
|
|
+ pageSize: 999
|
|
|
|
+ })
|
|
|
|
+ ]).then((res) => {
|
|
|
|
+ typeOptions2Ref.value = res[0].value.rows
|
|
|
|
+ toolsListRef.value = res[1].value.rows
|
|
|
|
+ onLoad()
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+init()
|
|
|
|
|
|
const resetList = () => {
|
|
const resetList = () => {
|
|
- toolsListRef.value = [];
|
|
|
|
|
|
+ toolsListRef.value = []
|
|
noneCardNum.value = 0
|
|
noneCardNum.value = 0
|
|
}
|
|
}
|
|
|
|
|
|
// 搜索
|
|
// 搜索
|
|
-const handleSearch = (value) => {
|
|
|
|
- console.log('搜索', value)
|
|
|
|
|
|
+const handleSearch = () => {
|
|
onLoad()
|
|
onLoad()
|
|
}
|
|
}
|
|
// 点击热门关键字搜索
|
|
// 点击热门关键字搜索
|
|
@@ -193,15 +258,44 @@ const handleKeySearch = (toolName) => {
|
|
const handleChangeDropdownOfType1 = (value) => {
|
|
const handleChangeDropdownOfType1 = (value) => {
|
|
resetList()
|
|
resetList()
|
|
type1ValueRef.value = value
|
|
type1ValueRef.value = value
|
|
- typeOptions2Ref.value = value === '1' ? menuList2 : menuList3
|
|
|
|
|
|
+ listTools({
|
|
|
|
+ level: '2',
|
|
|
|
+ parentId: value,
|
|
|
|
+ pageSize: 999
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ typeOptions2Ref.value = res.rows
|
|
|
|
+ })
|
|
|
|
+ listTools({
|
|
|
|
+ level: '3',
|
|
|
|
+ parentId: value,
|
|
|
|
+ pageSize: 999,
|
|
|
|
+ delFlag: 0
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ toolsListRef.value = res.rows
|
|
|
|
+ handleSearch(value)
|
|
|
|
+ })
|
|
type2ValueRef.value = ''
|
|
type2ValueRef.value = ''
|
|
- handleSearch(value)
|
|
|
|
}
|
|
}
|
|
// 点击二级菜单
|
|
// 点击二级菜单
|
|
const handleChangeDropdownOfType2 = (value) => {
|
|
const handleChangeDropdownOfType2 = (value) => {
|
|
resetList()
|
|
resetList()
|
|
|
|
+ listTools({
|
|
|
|
+ level: '3',
|
|
|
|
+ parentId: value,
|
|
|
|
+ pageSize: 999
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ toolsListRef.value = res.rows
|
|
|
|
+ handleSearch(value)
|
|
|
|
+ })
|
|
type2ValueRef.value = value
|
|
type2ValueRef.value = value
|
|
- handleSearch(value)
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const handleClear = () => {
|
|
|
|
+ searchValueRef.value = ''
|
|
|
|
+}
|
|
|
|
+const handleDetail = (row) => {
|
|
|
|
+ console.log(row)
|
|
|
|
+ router.push({ path: '/detail', query: { id: row.id, toolName: row.toolName } })
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|