添加列表头点击可进行检索的功能
This commit is contained in:
parent
474773c966
commit
36c9bb578f
|
|
@ -34,7 +34,7 @@
|
||||||
<template #headerCell="{ column }">
|
<template #headerCell="{ column }">
|
||||||
<!-- update-begin--author:sunjianlei---date:220230630---for:【QQYUN-5571】自封装选择列,解决数据行选择卡顿问题 -->
|
<!-- update-begin--author:sunjianlei---date:220230630---for:【QQYUN-5571】自封装选择列,解决数据行选择卡顿问题 -->
|
||||||
<CustomSelectHeader v-if="isCustomSelection(column)" v-bind="selectHeaderProps"/>
|
<CustomSelectHeader v-if="isCustomSelection(column)" v-bind="selectHeaderProps"/>
|
||||||
<HeaderCell v-else :column="column" />
|
<HeaderCell v-else :column="column" @headerSearch="handleHeaderSearch" />
|
||||||
<!-- update-end--author:sunjianlei---date:220230630---for:【QQYUN-5571】自封装选择列,解决数据行选择卡顿问题 -->
|
<!-- update-end--author:sunjianlei---date:220230630---for:【QQYUN-5571】自封装选择列,解决数据行选择卡顿问题 -->
|
||||||
</template>
|
</template>
|
||||||
<!-- 增加对antdv3.x兼容 -->
|
<!-- 增加对antdv3.x兼容 -->
|
||||||
|
|
@ -122,6 +122,7 @@
|
||||||
'change',
|
'change',
|
||||||
'columns-change',
|
'columns-change',
|
||||||
'table-redo',
|
'table-redo',
|
||||||
|
'handleHeaderSearch',
|
||||||
],
|
],
|
||||||
setup(props, { attrs, emit, slots, expose }) {
|
setup(props, { attrs, emit, slots, expose }) {
|
||||||
const tableElRef = ref(null);
|
const tableElRef = ref(null);
|
||||||
|
|
@ -206,6 +207,11 @@
|
||||||
emit
|
emit
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function handleHeaderSearch(item){
|
||||||
|
console.log("🚀 ~ handleHeaderSearch ~ item:", item)
|
||||||
|
emit("header-search", item)
|
||||||
|
}
|
||||||
|
|
||||||
function handleTableChange(...args) {
|
function handleTableChange(...args) {
|
||||||
onTableChange.call(undefined, ...args);
|
onTableChange.call(undefined, ...args);
|
||||||
emit('change', ...args);
|
emit('change', ...args);
|
||||||
|
|
@ -460,6 +466,7 @@
|
||||||
getSummaryProps,
|
getSummaryProps,
|
||||||
showSummaryRef,
|
showSummaryRef,
|
||||||
// update-end--author:liaozhiyang---date:20240425---for:【pull/1201】添加antd的TableSummary功能兼容老的summary(表尾合计)
|
// update-end--author:liaozhiyang---date:20240425---for:【pull/1201】添加antd的TableSummary功能兼容老的summary(表尾合计)
|
||||||
|
handleHeaderSearch
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,19 @@
|
||||||
<EditTableHeaderCell v-if="getIsEdit">
|
<EditTableHeaderCell v-if="getIsEdit">
|
||||||
{{ getTitle }}
|
{{ getTitle }}
|
||||||
</EditTableHeaderCell>
|
</EditTableHeaderCell>
|
||||||
<span v-else>{{ getTitle }}</span>
|
<span v-else>
|
||||||
|
<span v-if="isShowDb" @click="handleClick">
|
||||||
|
<span v-if="searchParam != paramKey">{{ getTitle }}<Icon icon="ant-design:search-outlined" /></span>
|
||||||
|
<span v-if="searchParam == paramKey"><input :value="paramValue" style="width: 80px;" placeholder="输入参数值" @blur="handleBlur($event)" @keyup.enter="handleBlur($event)" /></span>
|
||||||
|
</span>
|
||||||
|
<span v-else>{{ getTitle }}</span>
|
||||||
|
</span>
|
||||||
<BasicHelp v-if="getHelpMessage" :text="getHelpMessage" :class="`${prefixCls}__help`" />
|
<BasicHelp v-if="getHelpMessage" :text="getHelpMessage" :class="`${prefixCls}__help`" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PropType } from 'vue';
|
import type { PropType } from 'vue';
|
||||||
import type { BasicColumn } from '../types/table';
|
import type { BasicColumn } from '../types/table';
|
||||||
import { defineComponent, computed } from 'vue';
|
import { defineComponent, computed,ref } from 'vue';
|
||||||
import BasicHelp from '/@/components/Basic/src/BasicHelp.vue';
|
import BasicHelp from '/@/components/Basic/src/BasicHelp.vue';
|
||||||
import EditTableHeaderCell from './EditTableHeaderIcon.vue';
|
import EditTableHeaderCell from './EditTableHeaderIcon.vue';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
|
|
@ -25,9 +31,21 @@
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
|
||||||
const { prefixCls } = useDesign('basic-table-header-cell');
|
|
||||||
|
|
||||||
|
emits: [
|
||||||
|
'headerSearch',
|
||||||
|
],
|
||||||
|
setup(props,{emit}) {
|
||||||
|
const { prefixCls } = useDesign('basic-table-header-cell');
|
||||||
|
// const emit = defineEmits(['headerSearch']);
|
||||||
|
const isShowDb = computed(() => {
|
||||||
|
var search = props.column?.search?true:false;
|
||||||
|
console.log("🚀 ~ props.column:", props.column)
|
||||||
|
return search;
|
||||||
|
});
|
||||||
|
let searchParam = ref<string>('');
|
||||||
|
let paramValue = ref<string>('');
|
||||||
|
const paramKey = computed(() => props.column?.key);
|
||||||
const getIsEdit = computed(() => !!props.column?.edit);
|
const getIsEdit = computed(() => !!props.column?.edit);
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
// update-begin--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
|
// update-begin--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
|
||||||
|
|
@ -41,7 +59,20 @@
|
||||||
});
|
});
|
||||||
const getHelpMessage = computed(() => props.column?.helpMessage);
|
const getHelpMessage = computed(() => props.column?.helpMessage);
|
||||||
|
|
||||||
return { prefixCls, getIsEdit, getTitle, getHelpMessage };
|
function handleBlur(event){
|
||||||
|
const value = event.target.value; // 从事件对象中获取值
|
||||||
|
console.log("event.target", event.target);
|
||||||
|
console.log("handleBlur", value);
|
||||||
|
searchParam.value = "";
|
||||||
|
paramValue.value = "";
|
||||||
|
emit('headerSearch', {key:paramKey.value,value:value});
|
||||||
|
}
|
||||||
|
function handleClick() {
|
||||||
|
console.log("🚀 ~ item:", props.column)
|
||||||
|
searchParam.value = (props.column?.key as string) || '';
|
||||||
|
paramValue.value = "";
|
||||||
|
}
|
||||||
|
return { prefixCls, getIsEdit, getTitle, getHelpMessage,isShowDb,handleClick,paramKey,searchParam,paramValue,handleBlur };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,8 @@ export interface BasicColumn extends ColumnProps<Recordable> {
|
||||||
value: string;
|
value: string;
|
||||||
children?: unknown[] | (((props: Record<string, unknown>) => unknown[]) & (() => unknown[]) & (() => unknown[]));
|
children?: unknown[] | (((props: Record<string, unknown>) => unknown[]) & (() => unknown[]) & (() => unknown[]));
|
||||||
}[];
|
}[];
|
||||||
|
//是否搜索
|
||||||
|
search?: boolean;
|
||||||
//
|
//
|
||||||
flag?: 'INDEX' | 'DEFAULT' | 'CHECKBOX' | 'RADIO' | 'ACTION';
|
flag?: 'INDEX' | 'DEFAULT' | 'CHECKBOX' | 'RADIO' | 'ACTION';
|
||||||
// update-begin--author:liaozhiyang---date:20240724---for:【issues/6908】多语言无刷新切换时,BasicColumn和FormSchema里面的值不能正常切换
|
// update-begin--author:liaozhiyang---date:20240724---for:【issues/6908】多语言无刷新切换时,BasicColumn和FormSchema里面的值不能正常切换
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,15 @@ export const columns: BasicColumn[] = [
|
||||||
{
|
{
|
||||||
title: '物料名称',
|
title: '物料名称',
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: 'materialName'
|
dataIndex: 'materialName',
|
||||||
|
search: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '物料编码',
|
title: '物料编码',
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: 'materialNo',
|
dataIndex: 'materialNo',
|
||||||
width:'100px'
|
width:'100px',
|
||||||
|
search: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '规格型号',
|
title: '规格型号',
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="container-height" style="width:calc(100% - 300px);float: left;">
|
<div class="container-height" style="width:calc(100% - 300px);float: left;">
|
||||||
<!--引用表格-->
|
<!--引用表格-->
|
||||||
<BasicTable @register="registerTable">
|
<BasicTable @register="registerTable" @headerSearch="handleHeaderSearch">
|
||||||
<!--插槽:table标题-->
|
<!--插槽:table标题-->
|
||||||
<!-- <template #tableTitle>
|
<!-- <template #tableTitle>
|
||||||
<a-button type="primary" v-auth="'configMaterialInfo:config_material_info:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
<a-button type="primary" v-auth="'configMaterialInfo:config_material_info:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||||
|
|
@ -391,6 +391,12 @@ const registerMedicationDrawer = ref();
|
||||||
const qianyiDrawer = ref();
|
const qianyiDrawer = ref();
|
||||||
const wlqianyiDrawer = ref();
|
const wlqianyiDrawer = ref();
|
||||||
|
|
||||||
|
function handleHeaderSearch(item){
|
||||||
|
console.log("🚀 ~ handleHeaderSearch ~ 11111item:", item)
|
||||||
|
queryParam[item.key] = "*"+item.value+"*";
|
||||||
|
console.log("🚀 ~ handleHeaderSearch ~ queryParam:", queryParam)
|
||||||
|
reload();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 点击菜单
|
* 点击菜单
|
||||||
* @param index 菜单索引
|
* @param index 菜单索引
|
||||||
|
|
@ -704,7 +710,10 @@ function searchQuery() {
|
||||||
function searchReset() {
|
function searchReset() {
|
||||||
formRef.value.resetFields();
|
formRef.value.resetFields();
|
||||||
selectedRowKeys.value = [];
|
selectedRowKeys.value = [];
|
||||||
queryParam.treeId = null;
|
Object.keys(queryParam).forEach(key => {
|
||||||
|
queryParam[key] = null; // 或者 undefined、'' 根据你的需求
|
||||||
|
});
|
||||||
|
// queryParam.treeId = null;
|
||||||
//刷新数据
|
//刷新数据
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue