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

This commit is contained in:
jackhoo_98 2023-04-01 14:03:16 +08:00
commit 3d5f88cddb
22 changed files with 184 additions and 57 deletions

View File

@ -9,7 +9,7 @@ export const updateMeInfo_api = (data:object) => server.put(`/user/detail`,data)
// 修改登录用户密码
export const updateMepsd_api = (data:object) => server.put(`/user/passwd`,data);
// 第三方账号解绑
export const unBind_api = (appId: string) => server.post(`/application/sso/${appId}/unbind/me`);
export const unBind_api = (appId: string) => server.post(`/application/sso/${appId}/unbind/me`, []);
/**
*
* @param type

View File

@ -67,6 +67,14 @@
</j-upload>
</template>
</j-input>
<j-input
v-else-if="typeMap.get(itemType) === 'password'"
allowClear
type="password"
v-model:value="myValue"
style="width: 100%"
@change='inputChange'
/>
<j-input
v-else
allowClear
@ -148,7 +156,7 @@ const componentsType = ref<ITypes>({
double: 'inputNumber',
string: 'input',
array: 'input',
password: 'input',
password: 'password',
enum: 'select',
boolean: 'select',
date: 'date',

View File

@ -2,6 +2,8 @@ export const LoginPath = '/login'
export const InitHomePath = '/init-home'
export const AccountCenterBindPath = '/account/center/bind'
export const InitLicense = '/init-license'
export const NotificationSubscriptionCode = 'account/NotificationSubscription'
export const NotificationRecordCode = 'account/NotificationRecord'
export const AccountMenu = {
path: '/account',

View File

@ -1,11 +1,12 @@
import { defineStore } from 'pinia'
import { queryOwnThree } from '@/api/system/menu'
import { filterAsyncRouter, findCodeRoute, MenuItem } from '@/utils/menu'
import { isArray } from 'lodash-es'
import { cloneDeep, isArray } from 'lodash-es'
import { usePermissionStore } from './permission'
import router from '@/router'
import { onlyMessage } from '@/utils/comm'
import { AccountMenu } from '@/router/menu'
import { AccountMenu, NotificationRecordCode, NotificationSubscriptionCode } from '@/router/menu'
import { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts'
const defaultOwnParams = [
{
@ -96,6 +97,13 @@ export const useMenuStore = defineStore({
const permission = usePermissionStore()
permission.permissions = {}
const { menusData, silderMenus } = filterAsyncRouter(resp.result)
// 是否存在通知订阅
const hasMessageSub = resp.result.some((item: { code: string }) => item.code === MESSAGE_SUBSCRIBE_MENU_CODE)
console.log('hasMessageSub', hasMessageSub)
if (!hasMessageSub) {
AccountMenu.children = AccountMenu.children.filter((item: { code: string }) => ![NotificationSubscriptionCode, NotificationRecordCode].includes(item.code) )
}
this.menus = findCodeRoute([...resp.result, AccountMenu])
Object.keys(this.menus).forEach((item) => {
const _item = this.menus[item]
@ -112,7 +120,7 @@ export const useMenuStore = defineStore({
}
})
menusData.push(AccountMenu)
this.siderMenus = silderMenus
this.siderMenus = silderMenus.filter((item: { name: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.name))
res(menusData)
}
})

View File

@ -1,3 +1,5 @@
import { MESSAGE_SUBSCRIBE_MENU_DATA } from '@/views/init-home/data/baseMenu'
/**
*
*/
@ -47,3 +49,8 @@ export const SystemConst = {
VERSION_CODE: 'version_code',
AMAP_KEY : 'amap_key',
}
export const USER_CENTER_MENU_CODE = 'account-center'
export const USER_CENTER_MENU_BUTTON_CODE = 'user-center-passwd-update'
export const MESSAGE_SUBSCRIBE_MENU_CODE = 'message-subscribe'
export const MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE = 'message-subscribe-view'

View File

@ -110,7 +110,7 @@
/>
</div>
</div>
<div class="card">
<div class="card" v-if='updatePassword'>
<h3>修改密码</h3>
<div class="content">
<div class="content" style="align-items: flex-end">
@ -245,7 +245,10 @@ import moment from 'moment';
import { getMe_api, getView_api, setView_api } from '@/api/home';
import { isNoCommunity } from '@/utils/utils';
import { userInfoType } from './typing';
import { usePermissionStore } from 'store/permission'
const btnHasPermission = usePermissionStore().hasPermission;
const updatePassword = btnHasPermission('account-center:user-center-passwd-update')
const permission = 'system/User';
const userInfo = ref<userInfoType>({} as any);
//
@ -361,7 +364,7 @@ function getViews() {
.then((resp: any) => {
if (resp?.status === 200) {
if (resp.result) currentView.value = resp.result?.content;
else if (resp.result.username === 'admin') {
else if (resp.result?.username === 'admin') {
currentView.value = 'comprehensive';
} else currentView.value = 'init';
}

View File

@ -163,7 +163,7 @@ const changeType = (val: SelectValue) => {
_value.value.fileType = _value.value.fileType || 'url'
}
if (['date'].includes(val as string)) {
_value.value.format = _value.value.format || 'yyyy-MM-DD HH:mm:ss'
_value.value.format = _value.value.format || 'yyyy-MM-dd HH:mm:ss'
}
emit('changeType', val as string)
}

View File

@ -12,7 +12,7 @@
<script lang="ts" setup>
import { getImage } from '@/utils/comm';
import BaseMenu from '../data/baseMenu';
import BaseMenu, { MESSAGE_SUBSCRIBE_MENU_DATA, USER_CENTER_MENU_DATA } from '../data/baseMenu'
import { getSystemPermission, updateMenus } from '@/api/initHome';
/**
* 获取菜单数据
@ -70,7 +70,8 @@ const menuCount = (menus: any[]) => {
*/
const initMenu = async () => {
return new Promise(async (resolve) => {
const res = await updateMenus(menuDatas.current);
//
const res = await updateMenus([...menuDatas.current!, USER_CENTER_MENU_DATA, MESSAGE_SUBSCRIBE_MENU_DATA]);
if (res.status === 200) {
resolve(true);
} else {

View File

@ -1,3 +1,55 @@
import {
MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
MESSAGE_SUBSCRIBE_MENU_CODE,
USER_CENTER_MENU_BUTTON_CODE,
USER_CENTER_MENU_CODE
} from '@/utils/consts'
export const USER_CENTER_MENU_DATA = {
id: '19a1f2c763e1231f1e1',
accessSupport: { value: 'unsupported', label: '不支持'},
supportDataAccess: false,
code: USER_CENTER_MENU_CODE,
name: '个人中心',
url: '/user-center',
sortIndex: 9999,
granted: true,
buttons: [
{
id: USER_CENTER_MENU_BUTTON_CODE,
name: '修改密码',
permissions: [
{
permission: 'user',
action: ['update-self-pwd']
}
]
}
]
}
export const MESSAGE_SUBSCRIBE_MENU_DATA = {
id: '23a1f2c7123e56731f890',
accessSupport: { value: 'unsupported', label: '不支持'},
supportDataAccess: false,
code: MESSAGE_SUBSCRIBE_MENU_CODE,
name: '通知订阅',
url: '/message-subscribe',
buttons: [
{
id: MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
name: '查看',
permissions: [
{
permission: 'alarm-config',
action: ['query']
}
]
}
],
sortIndex: 9998
}
export default [
// 物联网
{
@ -4015,6 +4067,10 @@ export default [
permission: 'network-card',
actions: ['save'],
},
{
permission: 'device-instance',
actions: ['query'],
},
],
},
{
@ -4218,5 +4274,5 @@ export default [
supportDataAccess: false
},
],
},
}
];

View File

@ -139,9 +139,9 @@ const judgeInitSet = async () => {
window.location.href = '/';
}
};
onMounted(() => {
judgeInitSet();
});
onBeforeMount(() => {
// judgeInitSet();
})
</script>
<style scoped lang="less">
.page-container {

View File

@ -70,6 +70,7 @@
import { queryPlatformNoPage, recharge } from '@/api/iot-card/cardManagement';
import { message } from 'jetlinks-ui-components';
import { PaymentMethod } from '@/views/iot-card/data';
import { onlyMessage } from '@/utils/comm'
const emit = defineEmits(['change', 'save']);
@ -168,6 +169,8 @@ const handleOk = () => {
if (resp.status === 200) {
if (resp.result === '失败') {
message.error('缴费失败')
} else if(!resp.result) {
onlyMessage('操作过于频繁,请稍后再试!', 'warning')
} else {
window.open(resp.result);
}

View File

@ -161,7 +161,7 @@ const saveChange = (val: any) => {
if (val) {
setTimeout(() => {
rechargeRef.value?.reload();
}, 500)
}, 700)
}
};

View File

@ -159,6 +159,7 @@ const paramsValue = reactive<TermsType>({
const formItemContext = Form.useInjectFormItemContext()
const showDelete = ref(false)
const columnOptions: any = inject('filter-params') //
const columnType = ref<string>()
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) //
const valueOptions = ref<any[]>([]) //
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains']
@ -175,6 +176,7 @@ const handOptionByColumn = (option: any) => {
if (option) {
termTypeOptions.value = option.termTypes || []
tabsOptions.value[0].component = option.type
columnType.value = option.type
const _options = isArray(option.options) ? option.options : []
if (option.type === 'boolean') {
valueOptions.value = _options?.map((item: any) => ({ ...item, label: item.name, value: item.id})) || [
@ -289,14 +291,16 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
// timeTypeKeys
if (timeTypeKeys.includes(e.key)) {
if (tabsOptions.value[0].component !== 'int') {
if (columnType.value ==='date') {
if (timeTypeKeys.includes(e.key)) {
if (tabsOptions.value[0].component !== 'int') {
value = undefined
}
tabsOptions.value[0].component = 'int'
} else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') {
value = undefined
tabsOptions.value[0].component = 'date'
}
tabsOptions.value[0].component = 'int'
} else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') {
value = undefined
tabsOptions.value[0].component = 'date'
}
paramsValue.value = {

View File

@ -152,6 +152,7 @@ const paramsValue = reactive<TermsType>({
const showDelete = ref(false)
const columnOptions: any = inject(ContextKey) //
const columnType = ref<string>()
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) //
const valueOptions = ref<any[]>([]) //
const metricOption = ref<any[]>([]) // termType
@ -165,7 +166,7 @@ const handOptionByColumn = (option: any) => {
metricsCacheOption.value = option.metrics?.map((item: any) => ({...item, label: item.name})) || []
tabsOptions.value.length = 1
tabsOptions.value[0].component = option.dataType
columnType.value = option.dataType
if (option.metrics && option.metrics.length) {
tabsOptions.value.push(
@ -281,14 +282,16 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
const oldValue = isArray(paramsValue.value!.value) ? paramsValue.value!.value[0] : paramsValue.value!.value
let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
// timeTypeKeys
if (timeTypeKeys.includes(e.key)) {
if (tabsOptions.value[0].component !== 'int') {
if (columnType.value === 'date') {
if (timeTypeKeys.includes(e.key)) {
if (tabsOptions.value[0].component !== 'int') {
value = undefined
}
tabsOptions.value[0].component = 'int'
} else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') {
value = undefined
tabsOptions.value[0].component = 'date'
}
tabsOptions.value[0].component = 'int'
} else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') {
value = undefined
tabsOptions.value[0].component = 'date'
}
paramsValue.value = {

View File

@ -123,7 +123,6 @@ export const EventEmitter = {
}
export const isActionChange = (_metadata: any, _message: any) => {
console.log(_metadata, _message)
const _properties = _metadata?.properties || [];
const _functions = _metadata?.functions || [];
if (

View File

@ -68,7 +68,7 @@
]"
>
<j-input
:disabled="record.scale !== undefined"
:disabled="record.old_id"
v-model:value="record.name"
placeholder="请输入名称"
/>
@ -104,12 +104,10 @@
/>
</j-form-item>
</template>
<template v-else-if="column.key === 'precision'">
<j-form-item
:name="['data', index, 'precision']"
>
<template v-else-if="column.key === 'scale'">
<j-form-item :name="['data', index, 'scale']">
<j-input-number
v-model:value="record.precision"
v-model:value="record.scale"
:min="0"
:max="99999"
style="width: 100%"
@ -117,7 +115,15 @@
</j-form-item>
</template>
<template v-else-if="column.key === 'notnull'">
<j-form-item :name="['data', index, 'notnull']">
<j-form-item
:name="['data', index, 'notnull']"
:rules="[
{
required: true,
message: '请选择是否不能为空',
},
]"
>
<j-radio-group
v-model:value="record.notnull"
button-style="solid"
@ -132,7 +138,7 @@
</j-form-item>
</template>
<template v-else-if="column.key === 'comment'">
<j-form-item :name="['data', index, 'notnull']">
<j-form-item :name="['data', index, 'comment']">
<j-input
v-model:value="record.comment"
placeholder="请输入说明"
@ -147,7 +153,8 @@
:danger="true"
:popConfirm="{
title: `确认删除`,
onConfirm: () => clickDel(record, index),
onConfirm: () =>
clickDel(record, index),
}"
:disabled="record.status"
>
@ -174,7 +181,7 @@
<j-form-item
label="名称"
name="name"
:required="true"
:required="true"
:rules="[
{
required: true,
@ -217,6 +224,7 @@ import {
delSaveRow_api,
} from '@/api/system/dataSource';
import { onlyMessage } from '@/utils/comm';
import { randomString } from '@/utils/utils';
import { FormInstance, message } from 'ant-design-vue';
import { DataNode } from 'ant-design-vue/lib/tree';
import _ from 'lodash';
@ -243,13 +251,14 @@ const columns = [
},
{
title: '精度',
dataIndex: 'precision',
key: 'precision',
dataIndex: 'scale',
key: 'scale',
},
{
title: '不能为空',
dataIndex: 'notnull',
key: 'notnull',
width: 130
},
{
title: '说明',
@ -287,6 +296,7 @@ const queryTables = (key: string) => {
rdbTables_api(id, key).then((resp: any) => {
table.data = resp.result.columns.map(
(item: object, index: number) => ({
old_id: randomString(),
...item,
index,
}),
@ -348,7 +358,7 @@ const table = reactive({
const addRow = () => {
const initData: dbColumnType = {
precision: 0,
scale: 0,
length: 0,
notnull: false,
type: '',
@ -363,19 +373,22 @@ const clickDel = (row: any, index: number) => {
delSaveRow_api(id, leftData.selectedKeys[0], [row.name]).then(
(resp: any) => {
if (resp.status === 200) {
table.data.splice(index, 1)
table.data.splice(index, 1);
}
},
);
} else {
table.data.splice(index, 1)
};
table.data.splice(index, 1);
}
};
const clickSave = () => {
formRef.value.validate().then((_data: any) => {
const columns = cloneDeep(table.data);
columns.forEach((item) => delete item.index);
columns.forEach((item: any) => {
delete item?.old_id
delete item?.index
});
if (!columns.length) {
onlyMessage('请配置数据源字段', 'error');
return;

View File

@ -29,7 +29,7 @@ export type dbColumnType = {
previousName?: string,
type: String,
length: number,
precision: number,
scale: number,
notnull: boolean,
comment: string,
name: string,

View File

@ -73,6 +73,7 @@ import BaseMenu from '@/views/init-home/data/baseMenu';
import type { AntTreeNodeDropEvent } from 'ant-design-vue/es/tree';
import { cloneDeep } from 'lodash';
import { onlyMessage } from '@/utils/comm';
import { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts'
const selectedKeys: any = ref([]);
const treeData = ref<any>([]);
@ -185,7 +186,7 @@ onMounted(() => {
);
getMenuTree_api(params).then((resp: any) => {
if (resp.status == 200) {
systemMenu.value = resp.result;
systemMenu.value = resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.code));
//
const baseMenuData = developArrToMap(baseMenu.value);
const systemMenuData = developArrToMap(systemMenu.value, true);

View File

@ -84,7 +84,7 @@ import { getMenuTree_api, delMenuInfo_api } from '@/api/system/menu';
import { message } from 'jetlinks-ui-components';
import dayjs from 'dayjs';
import { useUserInfo } from '@/store/userInfo';
import { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts'
const admin = useUserInfo().userInfos?.type.id === 'admin';
const permission = 'system/Menu';
@ -206,7 +206,7 @@ const table = reactive({
return {
code: resp.message,
result: {
data: resp.result,
data: resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.code)),
pageIndex: resp.pageIndex,
pageSize: resp.pageSize,
total: resp.total,

View File

@ -51,6 +51,7 @@
import { FormInstance, message } from 'ant-design-vue';
import PermissTree from '../components/PermissTree.vue';
import { useMenuStore } from '@/store/menu';
import { USER_CENTER_MENU_DATA } from '@/views/init-home/data/baseMenu'
import {
getRoleDetails_api,
@ -71,7 +72,7 @@ const form = reactive({
name: '',
description: '',
},
menus: [],
menus: [USER_CENTER_MENU_DATA],
getForm: () => {
getRoleDetails_api(roleId).then((resp) => {
if (resp.status) {

View File

@ -52,6 +52,7 @@
<j-checkbox
v-model:checked="record.granted"
:indeterminate="record.indeterminate"
:disabled='record.code === USER_CENTER_MENU_CODE'
@change="menuChange(record, true)"
>{{ record.name }}</j-checkbox
>
@ -63,6 +64,7 @@
v-for="button in record.buttons"
v-model:checked="button.granted"
@change="actionChange(record)"
:disabled='[USER_CENTER_MENU_BUTTON_CODE].includes(button.id)'
>{{ button.name }}</j-checkbox
>
</div>
@ -101,6 +103,13 @@
import { cloneDeep, uniqBy } from 'lodash-es';
import { getPrimissTree_api } from '@/api/system/role';
import { getCurrentInstance } from 'vue';
import {
USER_CENTER_MENU_BUTTON_CODE,
MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
USER_CENTER_MENU_CODE,
MESSAGE_SUBSCRIBE_MENU_CODE
} from '@/utils/consts'
const emits = defineEmits(['update:selectItems']);
const route = useRoute();
const props = defineProps({
@ -222,9 +231,10 @@ const init = () => {
() => {
//
const selected = cloneDeep(flatTableData).filter(
(item) =>
(item: any) =>
(item.granted && item.parentId) ||
(item.indeterminate && item.buttons),
(item.indeterminate && item.buttons) ||
item.code === USER_CENTER_MENU_CODE || item.code === MESSAGE_SUBSCRIBE_MENU_CODE, //
);
selected.forEach((item) => {
@ -260,9 +270,17 @@ init();
function getAllPermiss() {
const id = route.params.id as string;
getPrimissTree_api(id).then((resp) => {
tableData.value = resp.result;
const _result = resp.result
//
tableData.value = _result.map((item: { code: string , buttons: any[], granted: boolean}) => {
if (item.code === USER_CENTER_MENU_CODE) {
item.granted = true
item.buttons = item.buttons.map( b => ({...b, granted: true, enabled: true}))
}
return item
});
treeToSimple(resp.result); //
treeToSimple(tableData.value); //
const selectList = flatTableData.filter((item) => item.granted); //
emits('update:selectItems', selectList); //

View File

@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3:
jetlinks-ui-components@^1.0.5:
version "1.0.5"
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#c71ecae61776bff738f43efe46aac7264f092736"
integrity sha512-+1a/4nA5RCiInRFyyaVCMEWSBzNU8lzxOYTTpY0GiNhuJuhGE5AbBsVp9CXXF0lFECK2iqaAElY+QN4Wjms1Dw==
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#8cbd59900e692dd931d289f3d5a6f4541485fd9f"
integrity sha512-ytX39qMt3kkEisURoIKlv2rAhGSvI74/WLLqkP6dJdz4q1k3UpANDtcnrz9rGRwTAKszVQ6kCga6VL6kGJiteQ==
dependencies:
"@vueuse/core" "^9.12.0"
ant-design-vue "^3.2.15"