|
|
@@ -130,7 +130,7 @@
|
|
|
registerTable,
|
|
|
{
|
|
|
reload,
|
|
|
- getSelectRows,
|
|
|
+ // getSelectRows,
|
|
|
getSelectRowKeys,
|
|
|
clearSelectedRowKeys,
|
|
|
setSelectedRowKeys,
|
|
|
@@ -145,28 +145,19 @@
|
|
|
showTableSetting: false,
|
|
|
tableSetting: { fullScreen: true },
|
|
|
showIndexColumn: false,
|
|
|
- immediate: false,
|
|
|
+ immediate: true,
|
|
|
isCanResizeParent: true,
|
|
|
rowKey: 'id',
|
|
|
pagination: false,
|
|
|
clickToRowSelect: false,
|
|
|
bordered: true,
|
|
|
afterFetch: (data) => {
|
|
|
- console.log('data', data);
|
|
|
- const res = data.map((i) => {
|
|
|
- i.canShow = i.canShow === 1 ? true : false;
|
|
|
- return i;
|
|
|
- });
|
|
|
- console.log('res', res);
|
|
|
-
|
|
|
- const bindIds = data
|
|
|
- .filter((i) => i.isBind === 1)
|
|
|
- .reduce((pre, current) => {
|
|
|
- return pre.concat(current['id']);
|
|
|
- }, []);
|
|
|
- console.log('bindIds', bindIds);
|
|
|
+ let bindIds = [];
|
|
|
data.map((i) => {
|
|
|
- i.canShow === 1 ? true : false;
|
|
|
+ i.canShow = i.canShow === 1 ? true : false;
|
|
|
+ if (i.isBind === 1) {
|
|
|
+ bindIds.push(i.id);
|
|
|
+ }
|
|
|
return i;
|
|
|
});
|
|
|
setSelectedRowKeys(bindIds);
|
|
|
@@ -190,36 +181,34 @@
|
|
|
}
|
|
|
const handleSubmit = async () => {
|
|
|
try {
|
|
|
- const rows = getSelectRows();
|
|
|
+ const rows = getSelectRowKeys();
|
|
|
const rawData = getRawDataSource();
|
|
|
let paramsRow: bindAnchorListParam[];
|
|
|
- console.log('rows', rows);
|
|
|
- if (rows?.length > 0) {
|
|
|
- paramsRow = rows.map((row) => {
|
|
|
- return {
|
|
|
- brandId: String(searchInfo.brandId),
|
|
|
- canShow: row.canShow ? 1 : 0,
|
|
|
- type: 1,
|
|
|
- userId: String(row.id),
|
|
|
- } as bindAnchorListParam;
|
|
|
- });
|
|
|
- await bindUserApi(paramsRow);
|
|
|
- createMessage.success(t('common.optSuccess'));
|
|
|
- } else {
|
|
|
- const unBindUser = rawData.list
|
|
|
- .filter((i) => i.isBind === 1)
|
|
|
- .map((item) => {
|
|
|
- let param: bindAnchorListParam = {};
|
|
|
- param.canShow = item.canShow ? 1 : 0;
|
|
|
- param.type = -1;
|
|
|
- param.brandId = searchInfo.brandId;
|
|
|
- param.userId = String(item.id);
|
|
|
- return param;
|
|
|
- });
|
|
|
- console.log('unBindUser', unBindUser);
|
|
|
- await bindUserApi(unBindUser);
|
|
|
- createMessage.success(t('common.optSuccess'));
|
|
|
- }
|
|
|
+ console.log('rawData', rawData, 'rows', rows, rows?.length);
|
|
|
+ // if (rows?.length > 0) {
|
|
|
+ // paramsRow = rows.map((row) => {
|
|
|
+ // return {
|
|
|
+ // brandId: String(searchInfo.brandId),
|
|
|
+ // canShow: row.canShow ? 1 : 0,
|
|
|
+ // type: 1,
|
|
|
+ // userId: String(row.id),
|
|
|
+ // } as bindAnchorListParam;
|
|
|
+ // });
|
|
|
+ // await bindUserApi(paramsRow);
|
|
|
+ // createMessage.success(t('common.optSuccess'));
|
|
|
+ // } else {
|
|
|
+ paramsRow = rawData.list.map((item) => {
|
|
|
+ let param: bindAnchorListParam = {};
|
|
|
+ param.canShow = item.canShow ? 1 : 0;
|
|
|
+ param.type = rows.includes(item.id) ? 1 : -1;
|
|
|
+ param.brandId = searchInfo.brandId;
|
|
|
+ param.userId = String(item.id);
|
|
|
+ return param;
|
|
|
+ });
|
|
|
+ console.log('paramsRow', paramsRow);
|
|
|
+ await bindUserApi(paramsRow);
|
|
|
+ createMessage.success(t('common.optSuccess'));
|
|
|
+ // }
|
|
|
closeModal();
|
|
|
emit('success');
|
|
|
clearSelectedRowKeys();
|