Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev

This commit is contained in:
leiqiaochu 2023-03-13 13:54:55 +08:00
commit bfa2f21160
2 changed files with 31 additions and 36 deletions

View File

@ -76,7 +76,7 @@ const deviceBootConfig: bootConfig[] = [
{ {
english: 'STEP1', english: 'STEP1',
label: '创建产品', label: '创建产品',
link: '/iot/device/Product', link: 'device/Product',
auth: productPermission('add'), auth: productPermission('add'),
image: '/images/home/guide-home1.png', image: '/images/home/guide-home1.png',
params: { params: {
@ -86,7 +86,7 @@ const deviceBootConfig: bootConfig[] = [
{ {
english: 'STEP2', english: 'STEP2',
label: '创建设备', label: '创建设备',
link: '/iot/device/Instance', link: 'device/Instance',
auth: devicePermission('add'), auth: devicePermission('add'),
image: '/images/home/guide-home1.png', image: '/images/home/guide-home1.png',
params: { params: {
@ -96,7 +96,7 @@ const deviceBootConfig: bootConfig[] = [
{ {
english: 'STEP3', english: 'STEP3',
label: '规则引擎', label: '规则引擎',
link: '/iot/rule-engine/Instance', link: 'rule-engine/Instance',
auth: rulePermission('add'), auth: rulePermission('add'),
image: '/images/home/guide-home3.png', image: '/images/home/guide-home3.png',
params: { params: {

View File

@ -10,18 +10,18 @@
:gridColumn="2" :gridColumn="2"
:params="queryParams" :params="queryParams"
:rowSelection="{ :rowSelection="{
selectedRowKeys: table._selectedRowKeys.value, selectedRowKeys: tableData._selectedRowKeys,
onChange:(keys:string[])=>table._selectedRowKeys.value = [...keys] onChange:(keys:string[])=>tableData._selectedRowKeys = [...keys],
onSelectNone: table.cancelSelect
}" }"
:columns="columns" :columns="columns"
@cancelSelect="table.cancelSelect"
> >
<template #headerTitle> <template #headerTitle>
<j-space> <j-space>
<PermissionButton <PermissionButton
:uhasPermission="`${permission}:assert`" :uhasPermission="`${permission}:assert`"
type="primary" type="primary"
@click="table.clickAdd" @click="dialogs.addShow = true"
> >
<AIcon type="PlusOutlined" />资产分配 <AIcon type="PlusOutlined" />资产分配
</PermissionButton> </PermissionButton>
@ -62,9 +62,7 @@
:value="slotProps" :value="slotProps"
:actions="table.getActions(slotProps, 'card')" :actions="table.getActions(slotProps, 'card')"
v-bind="slotProps" v-bind="slotProps"
:active=" :active="tableData._selectedRowKeys.includes(slotProps.id)"
table._selectedRowKeys.value.includes(slotProps.id)
"
@click="table.onSelectChange" @click="table.onSelectChange"
:status="slotProps.state?.value" :status="slotProps.state?.value"
:statusText="slotProps.state?.text" :statusText="slotProps.state?.text"
@ -105,7 +103,7 @@
class="card-item-content-value" class="card-item-content-value"
> >
{{ {{
table.permissionList.value.length && tableData.permissionList.length &&
table.getPermissLabel( table.getPermissLabel(
slotProps.permission, slotProps.permission,
) )
@ -164,7 +162,7 @@
<template #permission="slotProps"> <template #permission="slotProps">
{{ {{
table.permissionList.value.length && tableData.permissionList.length &&
table.getPermissLabel(slotProps.permission) table.getPermissLabel(slotProps.permission)
}} }}
</template> </template>
@ -202,7 +200,7 @@
v-model:visible="dialogs.addShow" v-model:visible="dialogs.addShow"
:query-columns="columns" :query-columns="columns"
:parent-id="props.parentId" :parent-id="props.parentId"
:all-permission="table.permissionList.value" :all-permission="tableData.permissionList"
asset-type="product" asset-type="product"
@confirm="table.addConfirm" @confirm="table.addConfirm"
/> />
@ -212,7 +210,7 @@
:ids="dialogs.selectIds" :ids="dialogs.selectIds"
:permission-list="dialogs.permissList" :permission-list="dialogs.permissList"
:parent-id="props.parentId" :parent-id="props.parentId"
:all-permission="table.permissionList.value" :all-permission="tableData.permissionList"
asset-type="product" asset-type="product"
@confirm="table.refresh" @confirm="table.refresh"
/> />
@ -315,11 +313,12 @@ const columns = [
const queryParams = ref({}); const queryParams = ref({});
const tableRef = ref(); const tableRef = ref();
const table = { const tableData = reactive({
_selectedRowKeys: ref<string[]>([]), _selectedRowKeys: [] as string[],
selectedRows: [] as any[], selectedRows: [] as any[],
permissionList: ref<any[]>([]), permissionList: [] as any[],
});
const table = {
init: () => { init: () => {
table.getPermissionDict(); table.getPermissionDict();
watch( watch(
@ -360,12 +359,12 @@ const table = {
// //
getPermissionDict: () => { getPermissionDict: () => {
getPermissionDict_api().then((resp: any) => { getPermissionDict_api().then((resp: any) => {
table.permissionList.value = resp.result; tableData.permissionList = resp.result;
}); });
}, },
// //
getPermissLabel: (values: string[]) => { getPermissLabel: (values: string[]) => {
const permissionList = table.permissionList.value; const permissionList = tableData.permissionList;
if (permissionList.length < 1 || values.length < 1) return ''; if (permissionList.length < 1 || values.length < 1) return '';
const result = values.map( const result = values.map(
(key) => permissionList.find((item: any) => item.id === key)?.name, (key) => permissionList.find((item: any) => item.id === key)?.name,
@ -374,21 +373,22 @@ const table = {
}, },
// //
onSelectChange: (row: any) => { onSelectChange: (row: any) => {
const selectedRowKeys = table._selectedRowKeys.value; const selectedRowKeys = tableData._selectedRowKeys;
const index = selectedRowKeys.indexOf(row.id); const index = selectedRowKeys.indexOf(row.id);
if (index === -1) { if (index === -1) {
selectedRowKeys.push(row.id); selectedRowKeys.push(row.id);
table.selectedRows.push(row); tableData.selectedRows.push(row);
} else { } else {
selectedRowKeys.splice(index, 1); selectedRowKeys.splice(index, 1);
table.selectedRows.splice(index, 1); tableData.selectedRows.splice(index, 1);
} }
}, },
// //
cancelSelect: () => { cancelSelect: () => {
table._selectedRowKeys.value = []; console.log(1111);
table.selectedRows = []; tableData._selectedRowKeys = [];
tableData.selectedRows = [];
}, },
// //
getData: (params: object, parentId: string) => getData: (params: object, parentId: string) =>
@ -444,8 +444,6 @@ const table = {
}), }),
// //
requestFun: async (oParams: any) => { requestFun: async (oParams: any) => {
table._selectedRowKeys.value = [];
table.selectedRows = [];
if (props.parentId) { if (props.parentId) {
const params = { const params = {
...oParams, ...oParams,
@ -486,21 +484,18 @@ const table = {
}; };
} }
}, },
clickAdd: () => {
dialogs.addShow = true;
},
clickEdit: (row?: any) => { clickEdit: (row?: any) => {
const ids = row ? [row.id] : [...table._selectedRowKeys.value]; const ids = row ? [row.id] : [...tableData._selectedRowKeys];
if (row || table.selectedRows.length === 1) { if (row || tableData.selectedRows.length === 1) {
const permissionList = const permissionList =
row?.permission || table.selectedRows[0].permission; row?.permission || tableData.selectedRows[0].permission;
dialogs.selectIds = ids; dialogs.selectIds = ids;
dialogs.permissList = permissionList; dialogs.permissList = permissionList;
dialogs.editShow = true; dialogs.editShow = true;
return; return;
} else if (table.selectedRows.length === 0) return; } else if (tableData.selectedRows.length === 0) return;
const permissionList = table.selectedRows.map( const permissionList = tableData.selectedRows.map(
(item) => item.permission, (item) => item.permission,
); );
const mixPermissionList = intersection(...permissionList) as string[]; const mixPermissionList = intersection(...permissionList) as string[];
@ -510,7 +505,7 @@ const table = {
dialogs.editShow = true; dialogs.editShow = true;
}, },
clickUnBind: (row?: any) => { clickUnBind: (row?: any) => {
const ids = row ? [row.id] : [...table._selectedRowKeys.value]; const ids = row ? [row.id] : [...tableData._selectedRowKeys];
if (ids.length < 1) return message.warning('请勾选需要解绑的数据'); if (ids.length < 1) return message.warning('请勾选需要解绑的数据');
const params = [ const params = [
{ {