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

This commit is contained in:
easy 2023-03-17 11:51:18 +08:00
commit 8dd84e062d
9 changed files with 76 additions and 45 deletions

View File

@ -40,7 +40,7 @@
</j-button> </j-button>
</template> </template>
</template> </template>
<j-tooltip v-else title="没有权限"> <j-tooltip v-else title="暂无权限,请联系管理员">
<slot v-if="noButton"></slot> <slot v-if="noButton"></slot>
<j-button v-else v-bind="props" :disabled="_isPermission" :style="props.style"> <j-button v-else v-bind="props" :disabled="_isPermission" :style="props.style">
<slot></slot> <slot></slot>

View File

@ -49,7 +49,7 @@
<j-input <j-input
v-model:value="form.id" v-model:value="form.id"
placeholder="请输入ID" placeholder="请输入ID"
:disabled="disabled" :disabled="idDisabled"
/> />
</j-form-item> </j-form-item>
<j-form-item label="名称" name="name"> <j-form-item label="名称" name="name">
@ -149,6 +149,7 @@ import { Form } from 'ant-design-vue';
import { getImage } from '@/utils/comm.ts'; import { getImage } from '@/utils/comm.ts';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import DialogTips from '../DialogTips/index.vue'; import DialogTips from '../DialogTips/index.vue';
import { useProductStore } from '@/store/product';
import { filterTreeSelectNode, filterSelectNode } from '@/utils/comm'; import { filterTreeSelectNode, filterSelectNode } from '@/utils/comm';
import { FILE_UPLOAD } from '@/api/comm'; import { FILE_UPLOAD } from '@/api/comm';
import { isInput } from '@/utils/regular'; import { isInput } from '@/utils/regular';
@ -159,7 +160,7 @@ import {
CheckOutlined, CheckOutlined,
DeleteOutlined, DeleteOutlined,
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
const productStore = useProductStore();
const emit = defineEmits(['success']); const emit = defineEmits(['success']);
const props = defineProps({ const props = defineProps({
title: { title: {
@ -178,6 +179,7 @@ const visible = ref<boolean>(false);
const logoLoading = ref<boolean>(false); const logoLoading = ref<boolean>(false);
const formRef = ref(); const formRef = ref();
const disabled = ref<boolean>(false); const disabled = ref<boolean>(false);
const idDisabled = ref<boolean>(false);
const useForm = Form.useForm; const useForm = Form.useForm;
const _selectedRowKeys = ref([]); const _selectedRowKeys = ref([]);
const photoValue = ref('/images/device-product.png'); const photoValue = ref('/images/device-product.png');
@ -296,6 +298,7 @@ watch(
*/ */
const show = (data: any) => { const show = (data: any) => {
if (props.isAdd === 2) { if (props.isAdd === 2) {
productStore.refresh(data.id);
form.name = data.name; form.name = data.name;
form.classifiedId = data.classifiedId; form.classifiedId = data.classifiedId;
form.classifiedName = data.classifiedName; form.classifiedName = data.classifiedName;
@ -303,7 +306,8 @@ const show = (data: any) => {
form.deviceType = data.deviceType.value; form.deviceType = data.deviceType.value;
form.describe = form.describe; form.describe = form.describe;
form.id = data.id; form.id = data.id;
disabled.value = true; disabled.value = productStore.current?.accessId ? true : false;
idDisabled.value = true;
} else if (props.isAdd === 1) { } else if (props.isAdd === 1) {
form.name = ''; form.name = '';
form.classifiedId = ''; form.classifiedId = '';
@ -313,6 +317,7 @@ const show = (data: any) => {
form.describe = undefined; form.describe = undefined;
form.id = undefined; form.id = undefined;
disabled.value = false; disabled.value = false;
disabled.vlaue = false;
} }
visible.value = true; visible.value = true;
}; };

View File

@ -395,7 +395,7 @@ const beforeUpload = (file: any) => {
} }
return true; return true;
} catch { } catch {
message.error('请上传json格式文件'); // message.error('json');
} }
return true; return true;
}; };

View File

@ -317,9 +317,14 @@ watch(
() => _vis.value, () => _vis.value,
(val) => { (val) => {
if (!val) { if (!val) {
formRef.value.resetFields(); formRef.value?.resetFields(); // resetFields
// , // ,
formData.value.id = undefined; Object.keys(formData.value).forEach((key: string) => {
if (key === 'id') formData.value.id = undefined;
else if (key === 'deviceId')
formData.value.deviceId = route.query.id;
else formData.value[key] = '';
});
} }
}, },
); );

View File

@ -53,7 +53,7 @@
> >
<j-input <j-input
v-model:value="formData.id" v-model:value="formData.id"
placeholder="请输入" placeholder="请输入ID"
:disabled="!!route.query.id" :disabled="!!route.query.id"
/> />
</j-form-item> </j-form-item>

View File

@ -1,6 +1,6 @@
export const PROVIDER_OPTIONS = [ export const PROVIDER_OPTIONS = [
{ label: '固定地址', value: 'fixed-media' },
{ label: 'GB/T28181', value: 'gb28181-2016' }, { label: 'GB/T28181', value: 'gb28181-2016' },
{ label: '固定地址', value: 'fixed-media' },
] ]
export const streamMode = [ export const streamMode = [
{ label: 'UDP', value: 'UDP' }, { label: 'UDP', value: 'UDP' },

View File

@ -78,7 +78,12 @@
...item.tooltip, ...item.tooltip,
}" }"
@click="item.onClick" @click="item.onClick"
:hasPermission="'media/Device:' + item.key" :hasPermission="
'media/Device:' +
(item.key !== 'updateChannel'
? item.key
: 'update')
"
> >
<AIcon <AIcon
type="DeleteOutlined" type="DeleteOutlined"
@ -124,7 +129,10 @@
@click="i.onClick" @click="i.onClick"
type="link" type="link"
style="padding: 0px" style="padding: 0px"
:hasPermission="'media/Device:' + i.key" :hasPermission="
'media/Device:' +
(i.key !== 'updateChannel' ? i.key : 'update')
"
> >
<template #icon><AIcon :type="i.icon" /></template> <template #icon><AIcon :type="i.icon" /></template>
</PermissionButton> </PermissionButton>
@ -318,7 +326,7 @@ const getActions = (
}, },
}, },
{ {
key: 'view', // updateChannel key: 'updateChannel',
text: '更新通道', text: '更新通道',
tooltip: { tooltip: {
title: title:
@ -366,6 +374,8 @@ const getActions = (
icon: 'DeleteOutlined', icon: 'DeleteOutlined',
}, },
]; ];
return actions; return data.provider === 'fixed-media'
? actions.filter((f: any) => f.key !== 'updateChannel')
: actions;
}; };
</script> </script>

View File

@ -68,14 +68,16 @@ const treeData = ref<any[]>([]);
const getDeviceList = async () => { const getDeviceList = async () => {
const res = await cascadeApi.getMediaTree({ paging: false }); const res = await cascadeApi.getMediaTree({ paging: false });
if (res.success) { if (res.success) {
treeData.value = res.result.map((m: any) => { treeData.value = res.result
const extra: any = {}; .sort((a: any, b: any) => a.createTime - b.createTime)
extra.isLeaf = isLeaf(m); .map((m: any) => {
return { const extra: any = {};
...m, extra.isLeaf = isLeaf(m);
...extra, return {
}; ...m,
}); ...extra,
};
});
} }
}; };
getDeviceList(); getDeviceList();

View File

@ -271,21 +271,31 @@ const getActions = (
/** /**
* 自动绑定 * 自动绑定
*/ */
const handleAutoBind = () => { const handleAutoBind = async () => {
const arr = dataSource.value await getTableData([
.filter((item: any) => item.userId && item.status.value === 'error') {
.map((i: any) => { column: `id$user-third$${props.data.type}_${props.data.provider}$not`,
return { },
userId: i.userId, ]);
providerName: i.userName, const params = dataSource.value
thirdPartyUserId: i.thirdPartyUserId, .filter((f: any) => f.userId && f.status.value === 'error')
}; .map((m: any) => ({
}); userId: m.userId,
providerName: m.thirdPartyUserName,
thirdPartyUserId: m.thirdPartyUserId,
}));
configApi.dingTalkBindUser(arr, props.data.id).then(() => { if (props.data.type === 'dingTalk') {
message.success('操作成功'); configApi.dingTalkBindUser(params, props.data.id).then(() => {
getTableData(); message.success('操作成功');
}); getTableData();
});
} else if (props.data.type === 'weixin') {
configApi.weChatBindUser(params, props.data.id).then(() => {
message.success('操作成功');
getTableData();
});
}
}; };
/** /**
@ -335,9 +345,9 @@ const getAllUsers = async (terms?: any) => {
*/ */
const dataSource = ref<any>([]); const dataSource = ref<any>([]);
const tableLoading = ref(false); const tableLoading = ref(false);
const getTableData = () => { const getTableData = (terms?: any) => {
tableLoading.value = true; tableLoading.value = true;
Promise.all<any>([getDeptUsers(), getBindUsers(), getAllUsers()]) Promise.all<any>([getDeptUsers(), getBindUsers(), getAllUsers(terms)])
.then((res) => { .then((res) => {
dataSource.value = []; dataSource.value = [];
const [deptUsers, bindUsers, unBindUsers] = res; const [deptUsers, bindUsers, unBindUsers] = res;
@ -359,7 +369,7 @@ const getTableData = () => {
thirdPartyUserId: deptUser.id, thirdPartyUserId: deptUser.id,
thirdPartyUserName: deptUser.name, thirdPartyUserName: deptUser.name,
bindId: bindUser?.id, bindId: bindUser?.id,
userId: bindUser?.userId, userId: unBindUser?.id,
userName: unBindUser userName: unBindUser
? `${unBindUser.name}(${unBindUser.username})` ? `${unBindUser.name}(${unBindUser.username})`
: bindUser?.providerName, : bindUser?.providerName,
@ -420,7 +430,6 @@ const handleBind = (row: any) => {
getAllUsers([ getAllUsers([
{ {
column: `id$user-third$${props.data.type}_${props.data.provider}$not`, column: `id$user-third$${props.data.type}_${props.data.provider}$not`,
// value: props.data.id,
}, },
]); ]);
}; };