Popup报表弹窗支持翻页选择数据、解决Popup报表弹窗全选问题 #765

pull/755/merge
zhangdaiscott 2023-09-23 15:43:41 +08:00
parent e7e495d99e
commit da55e94a66
4 changed files with 96 additions and 20 deletions

View File

@ -125,6 +125,8 @@
},
] = usePopBiz(getBindValue, tableRef);
pagination.pageSizeOptions = ['10', '100', '300'];
const showSearchFlag = computed(() => unref(queryInfo) && unref(queryInfo).length > 0);
/**
*监听code
@ -246,4 +248,7 @@
:deep(.jeecg-basic-table .ant-table-wrapper .ant-table-title){
min-height: 0;
}
:deep(.ant-select-selector){
min-width: 95px;
}
</style>

View File

@ -215,7 +215,7 @@
import { CompTypeEnum } from '/@/enums/CompTypeEnum.ts';
import { JDictSelectTag, JTreeSelect, JCategorySelect, JSelectUserByDept, JSelectDept, JPopup, JAreaLinkage,JInput,JSearchSelect } from '/@/components/Form';
export default defineComponent({
name: 'JPopupOnlReport',
name: 'SearchFormItem',
components: {
//JOnlineSearchSelect
JDictSelectTag,

View File

@ -7,7 +7,7 @@ import { OnlineColumn } from '/@/components/jeecg/OnLine/types/onlineConfig';
import { h } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useMethods } from '/@/hooks/system/useMethods';
import { importViewsFile } from '/@/utils';
import { importViewsFile, _eval } from '/@/utils';
export function usePopBiz(ob, tableRef?) {
// update-begin--author:liaozhiyang---date:20230811---for【issues/675】子表字段Popup弹框数据不更新
@ -111,22 +111,35 @@ export function usePopBiz(ob, tableRef?) {
* @param selectRow
*/
function onSelectChange(selectedRowKeys: (string | number)[]) {
// update-begin--author:liaozhiyang---date:20230919---for【QQYUN-4263】跨页选择导出问题
if (!selectedRowKeys || selectedRowKeys.length == 0) {
selectRows.value = [];
checkedKeys.value = [];
} else {
// update-begin--author:liaozhiyang---date:20230830---for【issues/726】JPopup组件里的表格全选没有选中数据
selectRows.value = [];
for (let i = 0; i < selectedRowKeys.length; i++) {
let combineKey = combineRowKey(getRowByKey(selectedRowKeys[i]));
let keys = unref(checkedKeys);
if (combineKey && keys.indexOf(combineKey) != -1) {
let row = getRowByKey(selectedRowKeys[i]);
row && selectRows.value.push(row);
}
if (selectRows.value.length > selectedRowKeys.length) {
// 取消
selectRows.value.forEach((item, index) => {
const rowKey = combineRowKey(item);
if (!selectedRowKeys.find((key) => key === rowKey)) {
selectRows.value.splice(index, 1);
}
});
} else {
// 新增
const append: any = [];
const beforeRowKeys = selectRows.value.map((item) => combineRowKey(item));
selectedRowKeys.forEach((key) => {
if (!beforeRowKeys.find((item) => item === key)) {
// 那就是新增选中的行
const row = getRowByKey(key);
row && append.push(row);
}
});
selectRows.value = [...selectRows.value, ...append];
}
// update-end--author:liaozhiyang---date:20230830---for【issues/726】JPopup组件里的表格全选没有选中数据
checkedKeys.value = [...selectedRowKeys];
}
checkedKeys.value = selectedRowKeys;
// update-end--author:liaozhiyang---date:20230919---for【QQYUN-4263】跨页选择导出问题
}
/**
*
@ -437,7 +450,9 @@ export function usePopBiz(ob, tableRef?) {
if (jsPattern.test(href)) {
href = href.replace(jsPattern, function (text, s0) {
try {
return eval(s0);
// update-begin--author:liaozhiyang---date:20230904---for【QQYUN-6390】eval替换成new Function解决build警告
return _eval(s0);
// update-end--author:liaozhiyang---date:20230904---for【QQYUN-6390】eval替换成new Function解决build警告
} catch (e) {
console.error(e);
return text;
@ -466,7 +481,7 @@ export function usePopBiz(ob, tableRef?) {
let keys = unref(checkedKeys);
if (keys.length > 0) {
params['force_id'] = keys
.map((i) => (getRowByKey(i) as any)?.id)
.map((i) => selectRows.value.find((item) => combineRowKey(item) === i)?.id)
.filter((i) => i != null && i !== '')
.join(',');
}
@ -699,17 +714,17 @@ export function usePopBiz(ob, tableRef?) {
arr1.push(record);
arr2.push(rowKey);
checkedKeys.value = arr2;
selectRows.value = arr1;
//selectRows.value = arr1;
} else {
if (unref(checkedKeys).indexOf(rowKey) < 0) {
//不存在就选中
checkedKeys.value.push(rowKey);
selectRows.value.push(record);
//selectRows.value.push(record);
} else {
//已选中就取消
let rowKey_index = unref(checkedKeys).indexOf(rowKey);
checkedKeys.value.splice(rowKey_index, 1);
selectRows.value.splice(rowKey_index, 1);
//selectRows.value.splice(rowKey_index, 1);
}
}
// update-begin--author:liaozhiyang---date:20230914---for【issues/5357】点击行选中

View File

@ -301,8 +301,10 @@ export function importViewsFile(path): Promise<any> {
* @param token
*/
export function goJmReportViewPage(url, id, token) {
// update-begin--author:liaozhiyang---date:20230904---for【QQYUN-6390】eval替换成new Function解决build警告
// URL支持{{ window.xxx }}占位符变量
url = url.replace(/{{([^}]+)?}}/g, (_s1, s2) => eval(s2))
url = url.replace(/{{([^}]+)?}}/g, (_s1, s2) => _eval(s2))
// update-end--author:liaozhiyang---date:20230904---for【QQYUN-6390】eval替换成new Function解决build警告
if (url.includes('?')) {
url += '&'
} else {
@ -311,4 +313,58 @@ export function goJmReportViewPage(url, id, token) {
url += `id=${id}`
url += `&token=${token}`
window.open(url)
}
}
/**
*
*/
export function getRandomColor(index?) {
const colors = [
'rgb(100, 181, 246)',
'rgb(77, 182, 172)',
'rgb(255, 183, 77)',
'rgb(229, 115, 115)',
'rgb(149, 117, 205)',
'rgb(161, 136, 127)',
'rgb(144, 164, 174)',
'rgb(77, 208, 225)',
'rgb(129, 199, 132)',
'rgb(255, 138, 101)',
'rgb(133, 202, 205)',
'rgb(167, 214, 118)',
'rgb(254, 225, 89)',
'rgb(251, 199, 142)',
'rgb(239, 145, 139)',
'rgb(169, 181, 255)',
'rgb(231, 218, 202)',
'rgb(252, 128, 58)',
'rgb(254, 161, 172)',
'rgb(194, 163, 205)',
];
return index && index < 19 ? colors[index] : colors[Math.floor((Math.random()*(colors.length-1)))];
}
export function getRefPromise(componentRef) {
return new Promise((resolve) => {
(function next() {
const ref = componentRef.value;
if (ref) {
resolve(ref);
} else {
setTimeout(() => {
next();
}, 100);
}
})();
});
}
/**
* 2023-09-04
* liaozhiyang
* new Functioneval
*/
export function _eval(str: string) {
return new Function(`return ${str}`)();
}