diff --git a/src/components/SearchBar/SearchBarEx.vue b/src/components/SearchBar/SearchBarEx.vue
new file mode 100644
index 00000000..7565074f
--- /dev/null
+++ b/src/components/SearchBar/SearchBarEx.vue
@@ -0,0 +1,204 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ showMore ? '收起' : '展开更多' }}
+
+
+
+
+
+
+
+
+
+ 搜索
+ 重置
+
+ 新增
+
+
+ 导出
+
+
+
+
+
+
+
+
diff --git a/src/views/pm/customer/index.vue b/src/views/pm/customer/index.vue
index d685594b..b28f7cd4 100644
--- a/src/views/pm/customer/index.vue
+++ b/src/views/pm/customer/index.vue
@@ -1,87 +1,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ showMore ? '收起' : '展开更多' }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 搜索
- 重置
-
- 新增
-
-
- 导出
-
-
-
-
-
+
@@ -132,7 +58,8 @@
import download from '@/utils/download'
import { CustomerApi, CustomerVO } from '@/api/pm/customer'
import CustomerForm from './CustomerForm.vue'
-import { ref, onMounted, computed } from 'vue'
+import { ref, onMounted, reactive } from 'vue'
+import SearchBarEx from "@/components/SearchBar/SearchBarEx.vue";
/** 客户信息 列表 */
defineOptions({ name: 'Customer' })
@@ -151,11 +78,20 @@ const queryParams = reactive({
contacts: undefined,
phone: undefined,
address: undefined,
+ address2: undefined,
+ date: undefined,
+ dateRange: undefined,
+ treeSelect: undefined,
// 可以继续添加其他字段
})
-const queryFormRef = ref() // 搜索的表单
-const exportLoading = ref(false) // 导出的加载中
-const showMore = ref(false) // 控制更多搜索项的显示
+const formRef = ref()
+
+// 属下拉调用示例
+// const treeData = [
+// { id: 1, label: '一级 1', children: [{ id: 4, label: '二级 1-1' }] },
+// { id: 2, label: '一级 2', children: [{ id: 5, label: '二级 2-1' }] },
+// { id: 3, label: '一级 3', children: [{ id: 6, label: '二级 3-1' }] }
+// ]
// 定义所有搜索字段
const allFields = [
@@ -164,18 +100,14 @@ const allFields = [
{ label: '联系人', prop: 'contacts' },
{ label: '电话', prop: 'phone' },
{ label: '地址', prop: 'address' },
- // 可以继续添加其他字段
+ // 调用示例
+ // { label: '下拉菜单', prop: 'address2', component: 'el-select', options: [{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }] },
+ // { label: '日期选择', prop: 'date', component: 'el-date-picker', props: { type: 'date', format: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD' } },
+ // { label: '日期范围选择', prop: 'dateRange', component: 'el-date-picker', props: { type: 'daterange', rangeSeparator: '-', startPlaceholder: '开始日期', endPlaceholder: '结束日期', format: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD' } },
+ // { label: '树形选择', prop: 'treeSelect', component: 'el-tree-select', treeData: treeData, treeProps: { label: 'label', children: 'children' }, nodeKey: 'id' }
]
-// 计算可见字段和隐藏字段
-const visibleFields = computed(() => allFields.slice(0, 4))
-const hiddenFields = computed(() => allFields.slice(4))
-const hasMoreFields = computed(() => allFields.length > 4)
-/** 切换更多搜索项的显示 */
-const toggleShowMore = () => {
- showMore.value = !showMore.value
-}
/** 查询列表 */
const getList = async () => {
@@ -190,19 +122,23 @@ const getList = async () => {
}
/** 搜索按钮操作 */
-const handleQuery = () => {
- queryParams.pageNo = 1
+const handleQuery = (params: any) => {
+ Object.assign(queryParams, params)
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
- queryFormRef.value.resetFields()
- handleQuery()
+ for (const key in queryParams) {
+ if (key !== 'pageNo' && key !== 'pageSize') {
+ queryParams[key] = undefined
+ }
+ }
+ queryParams.pageNo = 1
+ getList()
}
/** 添加/修改操作 */
-const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
@@ -226,13 +162,9 @@ const handleExport = async () => {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
- exportLoading.value = true
const data = await CustomerApi.exportCustomer(queryParams)
download.excel(data, '客户信息.xls')
- } catch {
- } finally {
- exportLoading.value = false
- }
+ } catch {}
}
/** 初始化 **/
diff --git a/src/views/pm/subcontractor/index.vue b/src/views/pm/subcontractor/index.vue
index 8dc3259c..1d10a8a5 100644
--- a/src/views/pm/subcontractor/index.vue
+++ b/src/views/pm/subcontractor/index.vue
@@ -1,87 +1,14 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ showMore ? '收起' : '展开更多' }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 搜索
- 重置
-
- 新增
-
-
- 导出
-
-
-
-
-
+
@@ -130,7 +57,8 @@
import download from '@/utils/download'
import { SubcontractorApi, SubcontractorVO } from '@/api/pm/subcontractor'
import SubcontractorForm from './SubcontractorForm.vue'
-import { ref, onMounted, computed } from 'vue'
+import { ref, onMounted, reactive } from 'vue'
+import SearchBarEx from "@/components/SearchBar/SearchBarEx.vue";
/** 供应商信息 列表 */
defineOptions({ name: 'Subcontractor' })
@@ -149,10 +77,9 @@ const queryParams = reactive({
contacts: undefined,
phone: undefined,
address: undefined,
+ // 可以继续添加其他字段
})
-const queryFormRef = ref() // 搜索的表单
-const exportLoading = ref(false) // 导出的加载中
-const showMore = ref(false) // 控制更多搜索项的显示
+const formRef = ref()
// 定义所有搜索字段
const allFields = [
@@ -161,18 +88,9 @@ const allFields = [
{ label: '联系人', prop: 'contacts' },
{ label: '电话', prop: 'phone' },
{ label: '地址', prop: 'address' },
+ // 可以继续添加其他字段
]
-// 计算可见字段和隐藏字段
-const visibleFields = computed(() => allFields.slice(0, 4))
-const hiddenFields = computed(() => allFields.slice(4))
-const hasMoreFields = computed(() => allFields.length > 4)
-
-/** 切换更多搜索项的显示 */
-const toggleShowMore = () => {
- showMore.value = !showMore.value
-}
-
/** 查询列表 */
const getList = async () => {
loading.value = true
@@ -186,19 +104,23 @@ const getList = async () => {
}
/** 搜索按钮操作 */
-const handleQuery = () => {
- queryParams.pageNo = 1
+const handleQuery = (params: any) => {
+ Object.assign(queryParams, params)
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
- queryFormRef.value.resetFields()
- handleQuery()
+ for (const key in queryParams) {
+ if (key !== 'pageNo' && key !== 'pageSize') {
+ queryParams[key] = undefined
+ }
+ }
+ queryParams.pageNo = 1
+ getList()
}
/** 添加/修改操作 */
-const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
@@ -222,13 +144,9 @@ const handleExport = async () => {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
- exportLoading.value = true
const data = await SubcontractorApi.exportSubcontractor(queryParams)
download.excel(data, '供应商信息.xls')
- } catch {
- } finally {
- exportLoading.value = false
- }
+ } catch {}
}
/** 初始化 **/
@@ -236,7 +154,3 @@ onMounted(() => {
getList()
})
-
-