Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev
This commit is contained in:
commit
ea48417454
|
@ -14,7 +14,7 @@
|
|||
>
|
||||
{{ slotProps.route.breadcrumbName }}
|
||||
</a>
|
||||
<span v-else >{{ slotProps.route.breadcrumbName }}</span>
|
||||
<span v-else style='cursor: pointer' >{{ slotProps.route.breadcrumbName }}</span>
|
||||
</template>
|
||||
<template #rightContentRender>
|
||||
<div class="right-content">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import type { BranchesType, FormModelType, SceneItem } from '@/views/rule-engine/Scene/typings'
|
||||
import type { FormModelType, SceneItem } from '@/views/rule-engine/Scene/typings'
|
||||
import { detail } from '@/api/rule-engine/scene'
|
||||
import { cloneDeep, isArray } from 'lodash-es'
|
||||
import { randomString } from '@/utils/utils'
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
label="密码"
|
||||
name="newPassword"
|
||||
:rules="[
|
||||
{ required: true,message:'请输入密码' },
|
||||
{ required: true, message: '请输入密码' },
|
||||
{ validator: checkMothods.new, trigger: 'blur' },
|
||||
]"
|
||||
>
|
||||
<j-input-password
|
||||
v-model:value="form.newPassword"
|
||||
placeholder="请输入姓名"
|
||||
placeholder="请输入密码"
|
||||
/>
|
||||
</j-form-item>
|
||||
<j-form-item
|
||||
|
@ -44,7 +44,7 @@
|
|||
>
|
||||
<j-input-password
|
||||
v-model:value="form.confirmPassword"
|
||||
placeholder="请输入姓名"
|
||||
placeholder="请再次输入密码"
|
||||
/>
|
||||
</j-form-item>
|
||||
</j-form>
|
||||
|
@ -64,7 +64,7 @@ const emits = defineEmits(['ok', 'update:visible']);
|
|||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
}>();
|
||||
const loading = ref(false)
|
||||
const loading = ref(false);
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = ref<formType>({
|
||||
oldPassword: '',
|
||||
|
@ -102,7 +102,9 @@ const checkMothods = {
|
|||
},
|
||||
confirm: async (_rule: Rule, value: string) => {
|
||||
if (!value) return Promise.reject();
|
||||
|
||||
else if (form.value.newPassword && value !== form.value.newPassword) {
|
||||
formRef.value?.validate('newPassword');
|
||||
}
|
||||
try {
|
||||
const resp: any = await validateField_api('password', value);
|
||||
if (resp.status === 200 && !resp.result.passed)
|
||||
|
@ -116,18 +118,20 @@ const checkMothods = {
|
|||
|
||||
const handleOk = () => {
|
||||
formRef.value?.validate().then(() => {
|
||||
loading.value = true
|
||||
loading.value = true;
|
||||
const params = {
|
||||
oldPassword: form.value.oldPassword,
|
||||
newPassword: form.value.newPassword,
|
||||
};
|
||||
updateMepsd_api(params).then((resp) => {
|
||||
updateMepsd_api(params)
|
||||
.then((resp) => {
|
||||
if (resp.status === 200) {
|
||||
message.success('保存成功');
|
||||
emits('ok');
|
||||
emits('update:visible', false);
|
||||
}
|
||||
}).finally(()=>loading.value = false)
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
});
|
||||
};
|
||||
console.clear();
|
||||
|
|
|
@ -114,10 +114,7 @@
|
|||
<h3>修改密码</h3>
|
||||
<div class="content">
|
||||
<div class="content" style="align-items: flex-end">
|
||||
<lock-outlined
|
||||
style="color: #1d39c4; font-size: 70px"
|
||||
/>
|
||||
<!-- <AIcon type="LockOutlined" /> -->
|
||||
<AIcon type="LockOutlined" style="color: #1d39c4; font-size: 70px" />
|
||||
<span
|
||||
style="margin-left: 5px; color: rgba(0, 0, 0, 0.55)"
|
||||
>安全性高的密码可以使帐号更安全。建议您定期更换密码,设置一个包含字母,符号或数字中至少两项且长度超过8位的密码</span
|
||||
|
@ -232,7 +229,6 @@
|
|||
import PermissionButton from '@/components/PermissionButton/index.vue';
|
||||
import EditInfoDialog from './components/EditInfoDialog.vue';
|
||||
import EditPasswordDialog from './components/EditPasswordDialog.vue';
|
||||
import { LockOutlined } from '@ant-design/icons-vue';
|
||||
import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable';
|
||||
import { LocalStore, getImage } from '@/utils/comm';
|
||||
import { message, UploadChangeParam, UploadFile } from 'ant-design-vue';
|
||||
|
@ -247,7 +243,7 @@ import { isNoCommunity } from '@/utils/utils';
|
|||
import { userInfoType } from './typing';
|
||||
|
||||
const permission = 'system/User';
|
||||
const userInfo = ref<userInfoType>({});
|
||||
const userInfo = ref<userInfoType>({} as any);
|
||||
// 第三方账号
|
||||
const bindList = ref<any[]>([]);
|
||||
const bindIcon = {
|
||||
|
|
|
@ -93,7 +93,13 @@ const formModel = ref<formState>({
|
|||
description: '',
|
||||
});
|
||||
const rules = ref({
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
name: [
|
||||
{ required: true, message: '请输入名称', trigger: 'blur' },
|
||||
{
|
||||
max: 64,
|
||||
message: '最多可输入64个字符',
|
||||
},
|
||||
],
|
||||
sortIndex: [{ required: true, message: '请输入排序', trigger: 'blur' }],
|
||||
});
|
||||
const visible = ref(false);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
ref="tableRef"
|
||||
:columns="table.columns"
|
||||
:dataSource="dataSource"
|
||||
model="table"
|
||||
model="TABLE"
|
||||
:defaultParams="{
|
||||
paging: false,
|
||||
sorts: [
|
||||
|
@ -35,7 +35,7 @@
|
|||
</PermissionButton>
|
||||
</template>
|
||||
<template #action="slotProps">
|
||||
<j-space :size="16">
|
||||
<j-space>
|
||||
<template
|
||||
v-for="i in getActions(slotProps, 'table')"
|
||||
:key="i.key"
|
||||
|
@ -222,23 +222,31 @@ const getActions = (
|
|||
|
||||
const table = reactive({
|
||||
columns: [
|
||||
{ title: '名称', dataIndex: 'name', key: 'name' },
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
ellipsis: true,
|
||||
width:600
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sortIndex',
|
||||
key: 'sortIndex',
|
||||
scopedSlots: true,
|
||||
width:200
|
||||
},
|
||||
{
|
||||
title: '说明',
|
||||
dataIndex: 'description',
|
||||
key: 'description',
|
||||
width:700
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
width: 250,
|
||||
ellipsis: true,
|
||||
scopedSlots: true,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -269,7 +269,8 @@
|
|||
<!-- 选择设备 -->
|
||||
<j-modal
|
||||
title="设备接入配置"
|
||||
:visible="visible"
|
||||
v-if="visible"
|
||||
visible
|
||||
width="1200px"
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
|
@ -280,6 +281,7 @@
|
|||
:columns="query.columns"
|
||||
target="deviceModal"
|
||||
@search="search"
|
||||
type='simple'
|
||||
/>
|
||||
<JProTable
|
||||
:columns="query.columns"
|
||||
|
@ -442,6 +444,7 @@ const showModal = () => {
|
|||
* 关闭弹窗
|
||||
*/
|
||||
const cancel = () => {
|
||||
queryParams.value = {};
|
||||
visible.value = false;
|
||||
};
|
||||
/**
|
||||
|
@ -968,6 +971,7 @@ const submitData = async () => {
|
|||
message.success('操作成功!');
|
||||
}
|
||||
visible.value = false;
|
||||
queryParams.value = {};
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
placeholder="请选择产品分类"
|
||||
:tree-data="treeList"
|
||||
@change="valueChange"
|
||||
allow-clear
|
||||
:fieldNames="{ label: 'name', value: 'id' }"
|
||||
:filterTreeNode="
|
||||
(v, option) => filterSelectNode(v, option)
|
||||
|
|
|
@ -202,7 +202,7 @@ const columns = [
|
|||
scopedSlots: true,
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
title: '产品名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
},
|
||||
|
|
|
@ -34,8 +34,11 @@ const props = defineProps({
|
|||
const { cardData, cardTitle } = toRefs(props);
|
||||
|
||||
const jumpPage = (item: bootConfig) => {
|
||||
if (item.auth === undefined || item.auth) _jumpPage(item.link, item.params);
|
||||
else message.warning('暂无权限,请联系管理员');
|
||||
if (item.auth === undefined || item.auth) {
|
||||
_jumpPage(item.link, item.params);
|
||||
} else {
|
||||
message.warning('暂无权限,请联系管理员');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -37,8 +37,11 @@ const { cardData, cardTitle } = toRefs(props);
|
|||
const { jumpPage: _jumpPage } = useMenuStore();
|
||||
|
||||
const jumpPage = (item: bootConfig) => {
|
||||
if (item.auth === undefined || item.auth) _jumpPage(item.link, item.params);
|
||||
else message.warning('暂无权限,请联系管理员');
|
||||
if (item.auth === undefined || item.auth) {
|
||||
_jumpPage(item.link, item.params);
|
||||
} else {
|
||||
message.warning('暂无权限,请联系管理员');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<j-row :gutter="24">
|
||||
<j-col :span="12"><DeviceCountCard /></j-col>
|
||||
<j-col :span="12"><BasicCountCard /></j-col>
|
||||
<j-col :span="24" style="margin-top: 24px;">
|
||||
<j-col :span="24" style="margin-top: 24px">
|
||||
<PlatformPicCard image="/images/home/content1.svg" />
|
||||
</j-col>
|
||||
</j-row>
|
||||
|
@ -157,7 +157,7 @@ const deviceStepDetails: recommendList[] = [
|
|||
linkUrl: 'device/Instance',
|
||||
auth: devicePermission('import'),
|
||||
params: {
|
||||
type: 'import'
|
||||
type: 'import',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -227,17 +227,4 @@ const opsStepDetails: recommendList[] = [
|
|||
|
||||
const productDialogVisible = ref(false);
|
||||
const deviceDialogVisible = ref(false);
|
||||
|
||||
|
||||
|
||||
// 设备管理-产品---新增弹窗 {save:true}
|
||||
// 设备管理-产品-产品详情---设备接入标签页 {id: 'xxxx', tab:'xxx'}
|
||||
// 规则引擎-规则编排---新增弹窗 {save: true}
|
||||
|
||||
|
||||
// 设备管理-设备---新增弹窗
|
||||
// 设备管理-设备---导入弹窗
|
||||
// 设备管理-设备-设备详情---设备诊断标签页
|
||||
|
||||
// 运维管理-日志管理---系统日志标签页
|
||||
</script>
|
||||
|
|
|
@ -46,9 +46,6 @@ const opsBootConfig: bootConfig[] = [
|
|||
english: 'STEP3',
|
||||
label: '实时监控',
|
||||
link: 'link/DashBoard',
|
||||
params: {
|
||||
type: 'add',
|
||||
},
|
||||
},
|
||||
];
|
||||
const opsStepDetails: recommendList[] = [
|
||||
|
|
|
@ -38,7 +38,9 @@ const props = defineProps({
|
|||
|
||||
// 跳转页面
|
||||
const jumpPage = (row: recommendList) => {
|
||||
if (row.auth === false) return message.warning('暂无权限,请联系管理员');
|
||||
if (row.auth === false) {
|
||||
return message.warning('暂无权限,请联系管理员');
|
||||
}
|
||||
row.onClick ? row.onClick(row) : _jumpPage(row.linkUrl, row.params);
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -52,7 +52,9 @@ const props = defineProps<{
|
|||
|
||||
// 弹窗控制
|
||||
const confirm = () => {
|
||||
if (selectedKeys.value.length < 1) return message.warn('请选择设备');
|
||||
if (selectedKeys.value.length < 1) {
|
||||
return message.warn('请选择设备');
|
||||
}
|
||||
emits('confirm', selectedKeys.value[0]);
|
||||
emits('update:visible', false);
|
||||
};
|
||||
|
|
|
@ -46,8 +46,8 @@ const form = ref({
|
|||
|
||||
const productList = ref<[productItem] | []>([]);
|
||||
const getOptions = () => {
|
||||
getProductList_api().then((resp: any) => {
|
||||
productList.value = resp.result
|
||||
getProductList_api().then(({ result }: any) => {
|
||||
productList.value = result
|
||||
.filter((i: any) => !i?.accessId)
|
||||
.map((item: { name: any; id: any }) => ({
|
||||
label: item.name,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<page-container>
|
||||
<div class="iot-home-container" v-loading="loading">
|
||||
<div class="iot-home-container">
|
||||
<InitHome v-if="currentView === 'init'" @refresh="setCurrentView" />
|
||||
<DeviceHome v-else-if="currentView === 'device'" />
|
||||
<DevOpsHome v-else-if="currentView === 'ops'" />
|
||||
|
@ -54,25 +54,26 @@ import { getMe_api, getView_api } from '@/api/home';
|
|||
import { getAppInfo_api } from '@/api/system/apply';
|
||||
|
||||
const currentView = ref<string>('');
|
||||
const loading = ref<boolean>(true);
|
||||
const clientId = useUserInfo().$state.userInfos.id;
|
||||
const secureKey = ref<string>('');
|
||||
const showKey = ref(false);
|
||||
// 获取选择的视图
|
||||
const setCurrentView = () => {
|
||||
getView_api().then((resp: any) => {
|
||||
if (resp.status === 200) {
|
||||
if (resp.result) {
|
||||
if (resp.result.username === 'admin')
|
||||
currentView.value = 'comprehensive';
|
||||
else currentView.value = resp.result?.content;
|
||||
} else currentView.value = 'init';
|
||||
getView_api().then(({ status, result }: any) => {
|
||||
if (status === 200) {
|
||||
currentView.value = 'init';
|
||||
if (result) {
|
||||
currentView.value =
|
||||
result.username === 'admin'
|
||||
? 'comprehensive'
|
||||
: result?.content;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (isNoCommunity) {
|
||||
// 判断是否是api用户 是则跳转 否则获取选中的视图
|
||||
// 判断是否是api用户 不是则获取选中的视图
|
||||
getMe_api().then((resp: any) => {
|
||||
if (resp && resp.status === 200) {
|
||||
const isApiUser = resp.result.dimensions.find(
|
||||
|
@ -85,10 +86,14 @@ if (isNoCommunity) {
|
|||
getAppInfo_api(clientId).then((resp: any) => {
|
||||
secureKey.value = resp.result.apiServer.secureKey;
|
||||
});
|
||||
} else setCurrentView();
|
||||
} else {
|
||||
setCurrentView();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else setCurrentView();
|
||||
} else {
|
||||
setCurrentView();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
@ -39,21 +39,27 @@
|
|||
v-if='showDouble'
|
||||
icon='icon-canshu'
|
||||
placeholder='参数值'
|
||||
value-name='id'
|
||||
label-name='name'
|
||||
:options='valueOptions'
|
||||
:metricOptions='metricOption'
|
||||
:metricOptions='columnOptions'
|
||||
:tabsOptions='tabsOptions'
|
||||
v-model:value='paramsValue.value.value'
|
||||
v-model:source='paramsValue.value.source'
|
||||
@select='valueSelect'
|
||||
/>
|
||||
<ParamsDropdown
|
||||
v-else
|
||||
icon='icon-canshu'
|
||||
placeholder='参数值'
|
||||
value-name='id'
|
||||
label-name='name'
|
||||
:options='valueOptions'
|
||||
:metricOptions='metricOption'
|
||||
:metricOptions='columnOptions'
|
||||
:tabsOptions='tabsOptions'
|
||||
v-model:value='paramsValue.value.value'
|
||||
v-model:source='paramsValue.value.source'
|
||||
@select='valueSelect'
|
||||
/>
|
||||
<j-popconfirm title='确认删除?' @confirm='onDelete'>
|
||||
<div v-show='showDelete' class='button-delete'> <AIcon type='CloseOutlined' /></div>
|
||||
|
@ -74,7 +80,6 @@ import DropdownButton from '../../components/DropdownButton'
|
|||
import { getOption } from '../../components/DropdownButton/util'
|
||||
import ParamsDropdown, { DoubleParamsDropdown } from '../../components/ParamsDropdown'
|
||||
import { inject } from 'vue'
|
||||
import { ContextKey } from '../../components/Terms/util'
|
||||
import { useSceneStore } from 'store/scene'
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
|
@ -112,7 +117,7 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
branchName: {
|
||||
actionName: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
|
@ -120,6 +125,10 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
branchName: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
value: {
|
||||
type: Object as PropType<TermsType>,
|
||||
default: () => ({
|
||||
|
@ -147,24 +156,19 @@ const showDelete = ref(false)
|
|||
const columnOptions: any = inject('filter-params') //
|
||||
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // 条件值
|
||||
const valueOptions = ref<any[]>([]) // 默认手动输入下拉
|
||||
const metricOption = ref<any[]>([]) //
|
||||
const tabsOptions = ref<Array<TabsOption>>([{ label: '内置参数', key: 'upper', component: 'tree' }])
|
||||
// { label: '手动输入', key: 'fixed', component: 'string' },
|
||||
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin']
|
||||
|
||||
const tabsOptions = ref<Array<TabsOption>>(
|
||||
[
|
||||
{ label: '手动输入', key: 'fixed', component: 'string' },
|
||||
{ label: '内置参数', key: 'upper', component: 'tree' }
|
||||
]
|
||||
)
|
||||
|
||||
const handOptionByColumn = (option: any) => {
|
||||
if (option) {
|
||||
termTypeOptions.value = option.termTypes || []
|
||||
metricOption.value = option.metrics || []
|
||||
tabsOptions.value.length = 1
|
||||
tabsOptions.value[0].component = option.dataType
|
||||
|
||||
if (option.metrics && option.metrics.length) {
|
||||
tabsOptions.value.push(
|
||||
{ label: '指标值', key: 'metric', component: 'select' }
|
||||
)
|
||||
}
|
||||
|
||||
if (option.dataType === 'boolean') {
|
||||
valueOptions.value = [
|
||||
{ label: '是', value: true },
|
||||
|
@ -177,24 +181,17 @@ const handOptionByColumn = (option: any) => {
|
|||
}
|
||||
} else {
|
||||
termTypeOptions.value = []
|
||||
metricOption.value = []
|
||||
valueOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
const option = getOption(columnOptions.value, paramsValue.column, 'id')
|
||||
console.log(option)
|
||||
handOptionByColumn(option)
|
||||
})
|
||||
|
||||
const showDouble = computed(() => {
|
||||
const isRange = paramsValue.termType ? ['nbtw', 'btw', 'in', 'nin'].includes(paramsValue.termType) : false
|
||||
if (metricOption.value.length) {
|
||||
metricOption.value = metricOption.value.filter(item => isRange ? item.range : !item.range)
|
||||
} else {
|
||||
metricOption.value = []
|
||||
}
|
||||
const isRange = paramsValue.termType ? arrayParamsKey.includes(paramsValue.termType) : false
|
||||
return isRange
|
||||
})
|
||||
|
||||
|
@ -219,14 +216,19 @@ const columnSelect = () => {
|
|||
emit('update:value', { ...paramsValue })
|
||||
}
|
||||
|
||||
const termsTypeSelect = () => {
|
||||
const termsTypeSelect = (e: { key: string }) => {
|
||||
const value = arrayParamsKey.includes(e.key) ? [ undefined, undefined ] : undefined
|
||||
paramsValue.value = {
|
||||
source: tabsOptions.value[0].key,
|
||||
value: undefined
|
||||
value: value
|
||||
}
|
||||
emit('update:value', { ...paramsValue })
|
||||
}
|
||||
|
||||
const valueSelect = () => {
|
||||
emit('update:value', { ...paramsValue })
|
||||
}
|
||||
|
||||
const termAdd = () => {
|
||||
const terms = {
|
||||
column: undefined,
|
||||
|
@ -238,11 +240,11 @@ const termAdd = () => {
|
|||
type: 'and',
|
||||
key: `params_${new Date().getTime()}`
|
||||
}
|
||||
formModel.value.branches?.[props.branchName]?.then?.[props.thenName]?.actions?.[props.name].terms?.push(terms)
|
||||
formModel.value.branches?.[props.branchName]?.then?.[props.thenName]?.actions?.[props.actionName].terms?.[props.termsName].terms?.push(terms)
|
||||
}
|
||||
|
||||
const onDelete = () => {
|
||||
formModel.value.branches?.[props.branchName]?.then?.[props.thenName]?.actions?.[props.name].terms?.splice(props.name, 1)
|
||||
formModel.value.branches?.[props.branchName]?.then?.[props.thenName]?.actions?.[props.actionName].terms?.[props.termsName].terms?.splice(props.name, 1)
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
/>
|
||||
</j-form-item>
|
||||
</div>
|
||||
<div v-if='isLast' class='terms-group-add'>
|
||||
<div v-if='isLast' class='terms-group-add' @click='addTerms'>
|
||||
<div class='terms-content'>
|
||||
<AIcon type='PlusOutlined' style='font-size: 12px;padding-right: 4px;' />
|
||||
<span>分组</span>
|
||||
|
@ -53,22 +53,20 @@
|
|||
</template>
|
||||
|
||||
<script setup lang='ts' name='FilterGroup'>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useSceneStore } from 'store/scene'
|
||||
import DropdownButton from '../../components/DropdownButton'
|
||||
import FilterItem from './FilterCondition.vue'
|
||||
import { isArray } from 'lodash-es'
|
||||
import { queryBuiltInParams } from '@/api/rule-engine/scene'
|
||||
import { provide } from 'vue'
|
||||
import { randomString } from '@/utils/utils'
|
||||
import { useParams } from '@/views/rule-engine/Scene/Save/util'
|
||||
|
||||
const sceneStore = useSceneStore()
|
||||
const { data: formModel } = storeToRefs(sceneStore)
|
||||
|
||||
const columnOptions = ref<any>([])
|
||||
|
||||
|
||||
provide('filter-params', columnOptions)
|
||||
|
||||
const props = defineProps({
|
||||
isFirst: {
|
||||
type: Boolean,
|
||||
|
@ -100,6 +98,16 @@ const props = defineProps({
|
|||
}
|
||||
})
|
||||
|
||||
const { columnOptions } = useParams({
|
||||
branch: props.branchName,
|
||||
branchGroup: props.thenName,
|
||||
action: props.actionName
|
||||
}, [
|
||||
formModel.value.branches![props.branchName].then[props.thenName].actions[props.actionName]
|
||||
])
|
||||
|
||||
provide('filter-params', columnOptions)
|
||||
|
||||
const termsOptions = computed(() => {
|
||||
return formModel.value.branches![props.branchName].then[props.thenName].actions[props.actionName].terms?.[props.name].terms
|
||||
})
|
||||
|
@ -114,66 +122,80 @@ const mouseout = () => {
|
|||
showDelete.value = false
|
||||
}
|
||||
|
||||
const onDelete = () => {
|
||||
const addTerms = () => {
|
||||
const item: any = {
|
||||
type: 'and',
|
||||
key: randomString(),
|
||||
terms: [
|
||||
{
|
||||
column: undefined,
|
||||
value: {
|
||||
type: 'fixed',
|
||||
value: undefined
|
||||
},
|
||||
termType: undefined,
|
||||
type: 'and',
|
||||
key: randomString()
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
formModel.value
|
||||
.branches![props.branchName]
|
||||
.then[props.thenName]
|
||||
.actions[props.actionName]
|
||||
.terms?.push(item)
|
||||
}
|
||||
|
||||
const getParams = () => {
|
||||
const params = {
|
||||
branch: props.branchName,
|
||||
branchGroup: props.thenName,
|
||||
action: props.actionName
|
||||
}
|
||||
const data = formModel.value.branches!.filter(item => !!item)
|
||||
queryBuiltInParams({
|
||||
...formModel.value,
|
||||
branches: data,
|
||||
}, params).then(res => {
|
||||
if (res.success) {
|
||||
columnOptions.value = res.result
|
||||
}
|
||||
})
|
||||
const onDelete = () => {
|
||||
formModel.value
|
||||
.branches![props.branchName]
|
||||
.then[props.thenName]
|
||||
.actions[props.actionName]
|
||||
.terms?.splice(props.name, 1)
|
||||
}
|
||||
|
||||
const rules = [
|
||||
{
|
||||
validator(_: any, v?: Record<string, any>) {
|
||||
// console.log('-----v',v)
|
||||
console.log('-----v',v)
|
||||
if (v !== undefined) {
|
||||
if (!Object.keys(v).length) {
|
||||
return Promise.reject(new Error('该数据已发生变更,请重新配置'));
|
||||
return Promise.reject(new Error('该数据已发生变更,请重新配置'))
|
||||
}
|
||||
if (!v.column) {
|
||||
return Promise.reject(new Error('请选择参数'));
|
||||
return Promise.reject(new Error('请选择参数'))
|
||||
}
|
||||
|
||||
if (!v.termType) {
|
||||
return Promise.reject(new Error('请选择操作符'));
|
||||
return Promise.reject(new Error('请选择操作符'))
|
||||
}
|
||||
|
||||
if (v.value === undefined) {
|
||||
return Promise.reject(new Error('请选择或输入参数值'));
|
||||
return Promise.reject(new Error('请选择或输入参数值'))
|
||||
} else {
|
||||
if (
|
||||
isArray(v.value.value) &&
|
||||
v.value.value.some((_v: any) => _v === undefined)
|
||||
) {
|
||||
return Promise.reject(new Error('请选择或输入参数值'));
|
||||
return Promise.reject(new Error('请选择或输入参数值'))
|
||||
} else if (v.value.value === undefined) {
|
||||
return Promise.reject(new Error('请选择或输入参数值'));
|
||||
return Promise.reject(new Error('请选择或输入参数值'))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Promise.reject(new Error('请选择参数'));
|
||||
return Promise.reject(new Error('请选择参数'))
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
nextTick(() => {
|
||||
getParams()
|
||||
})
|
||||
// watchEffect(() => {
|
||||
// if (formModel.value.branches![props.branchName].then[props.thenName].actions[props.actionName]) {
|
||||
// getParams()
|
||||
// }
|
||||
// })
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
@ -630,32 +630,6 @@ watch(() => props.data, () => {
|
|||
align-items: baseline;
|
||||
}
|
||||
|
||||
//.terms-params-content {
|
||||
// position: relative;
|
||||
// display: flex;
|
||||
// background-color: #fafafa;
|
||||
// border: unset;
|
||||
// row-gap: 16px;
|
||||
//
|
||||
// &.no-border {
|
||||
// border: none;
|
||||
// }
|
||||
//
|
||||
// .terms-params-item {
|
||||
// display: flex;
|
||||
// align-items: center;
|
||||
// }
|
||||
//
|
||||
// .ant-form-item {
|
||||
// margin-bottom: 8px;
|
||||
// &:not(:first-child) {
|
||||
// .ant-form-item-explain-error {
|
||||
// padding-left: 80px !important;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
.term-type-warp {
|
||||
// display: inline-block;
|
||||
width: 50px;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<ParamsDropdown
|
||||
v-model:value='myValue[0]'
|
||||
v-model:source='mySource'
|
||||
:valueName='valueName'
|
||||
:labelName='labelName'
|
||||
:options='options'
|
||||
:icon='icon'
|
||||
:placeholder='placeholder'
|
||||
|
@ -12,6 +14,8 @@
|
|||
<ParamsDropdown
|
||||
v-model:value='myValue[1]'
|
||||
v-model:source='mySource'
|
||||
:valueName='valueName'
|
||||
:labelName='labelName'
|
||||
:icon='icon'
|
||||
:placeholder='placeholder'
|
||||
:tabs-options='tabsOptions'
|
||||
|
|
|
@ -81,7 +81,7 @@ import ValueItem from '@/components/ValueItem/index.vue'
|
|||
import type { ValueType } from './typings'
|
||||
import { defaultSetting } from './typings'
|
||||
import { DropdownMenus, DropdownTimePicker} from '../DropdownButton'
|
||||
import { getComponent, getOption } from '../DropdownButton/util'
|
||||
import { getOption } from '../DropdownButton/util'
|
||||
|
||||
type Emit = {
|
||||
(e: 'update:value', data: ValueType): void
|
||||
|
@ -109,29 +109,26 @@ nextTick(() => {
|
|||
const tabsChange = (e: string) => {
|
||||
mySource.value = e
|
||||
myValue.value = undefined
|
||||
}
|
||||
|
||||
const updateValue = () => {
|
||||
emit('update:source', mySource.value)
|
||||
emit('update:value', myValue.value)
|
||||
emit('update:value', undefined)
|
||||
emit('select', {})
|
||||
}
|
||||
|
||||
const treeSelect = (e: any) => {
|
||||
const treeSelect = (v: any, option: any) => {
|
||||
const node = option.node
|
||||
visible.value = false
|
||||
label.value = e.fullname || e.name
|
||||
emit('update:value', e[props.valueName])
|
||||
emit('select', e)
|
||||
label.value = node.fullname || node.name
|
||||
emit('update:value', node[props.valueName])
|
||||
emit('select', node)
|
||||
}
|
||||
|
||||
const valueItemChange = (e: string) => {
|
||||
console.log('valueItemSelect', e)
|
||||
label.value = e
|
||||
emit('update:value', e)
|
||||
emit('select', e)
|
||||
}
|
||||
|
||||
const onSelect = (e: string, option: any) => {
|
||||
console.log(e, option)
|
||||
visible.value = false
|
||||
label.value = option.label
|
||||
emit('update:value', e)
|
||||
|
@ -150,7 +147,8 @@ const visibleChange = (v: boolean) => {
|
|||
}
|
||||
|
||||
watchEffect(() => {
|
||||
const option = getOption(props.options, props.value as string, props.valueName) // 回显label值
|
||||
const _options = props.source === 'upper' ? props.metricOptions : props.options
|
||||
const option = getOption(_options, props.value as string, props.valueName) // 回显label值
|
||||
myValue.value = props.value
|
||||
mySource.value = props.source
|
||||
if (option) {
|
||||
|
|
|
@ -149,6 +149,7 @@ const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // 条件值
|
|||
const valueOptions = ref<any[]>([]) // 默认手动输入下拉
|
||||
const metricOption = ref<any[]>([]) // 根据termType获取对应指标值
|
||||
const tabsOptions = ref<Array<TabsOption>>([{ label: '手动输入', key: 'manual', component: 'string' }])
|
||||
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin']
|
||||
let metricsCacheOption: any[] = [] // 缓存指标值
|
||||
|
||||
const handOptionByColumn = (option: any) => {
|
||||
|
@ -187,7 +188,7 @@ watchEffect(() => {
|
|||
})
|
||||
|
||||
const showDouble = computed(() => {
|
||||
const isRange = paramsValue.termType ? ['nbtw', 'btw', 'in', 'nin'].includes(paramsValue.termType) : false
|
||||
const isRange = paramsValue.termType ? arrayParamsKey.includes(paramsValue.termType) : false
|
||||
if (metricsCacheOption.length) {
|
||||
metricOption.value = metricsCacheOption.filter(item => isRange ? item.range : !item.range)
|
||||
} else {
|
||||
|
@ -217,10 +218,11 @@ const columnSelect = () => {
|
|||
emit('update:value', { ...paramsValue })
|
||||
}
|
||||
|
||||
const termsTypeSelect = () => {
|
||||
const termsTypeSelect = (e: { key: string }) => {
|
||||
const value = arrayParamsKey.includes(e.key) ? [ undefined, undefined ] : undefined
|
||||
paramsValue.value = {
|
||||
source: tabsOptions.value[0].key,
|
||||
value: undefined
|
||||
value: value
|
||||
}
|
||||
emit('update:value', { ...paramsValue })
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import { storeToRefs } from 'pinia';
|
|||
import { useSceneStore } from 'store/scene'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { provide } from 'vue'
|
||||
import { ContextKey } from './util'
|
||||
import { ContextKey, handleParamsData } from './util'
|
||||
import { getParseTerm } from '@/api/rule-engine/scene'
|
||||
import type { FormModelType } from '@/views/rule-engine/Scene/typings'
|
||||
import Branches from './Branchs.vue'
|
||||
|
@ -65,17 +65,6 @@ const change = (e: boolean) => {
|
|||
open.value = e
|
||||
}
|
||||
|
||||
const handleParamsData = (data: any[]): any[] => {
|
||||
return data?.map(item => {
|
||||
return {
|
||||
...item,
|
||||
key: item.column,
|
||||
disabled: !!item.children,
|
||||
children: handleParamsData(item.children)
|
||||
}
|
||||
}) || []
|
||||
}
|
||||
|
||||
const queryColumn = (dataModel: FormModelType) => {
|
||||
const cloneDevice = cloneDeep(dataModel)
|
||||
cloneDevice.branches = cloneDevice.branches?.filter(item => !!item)
|
||||
|
|
|
@ -1 +1,12 @@
|
|||
export const ContextKey = 'columnOptions'
|
||||
|
||||
export const handleParamsData = (data: any[], key: string = 'column'): any[] => {
|
||||
return data?.map(item => {
|
||||
return {
|
||||
...item,
|
||||
key: item[key],
|
||||
disabled: !!item.children,
|
||||
children: handleParamsData(item.children, key)
|
||||
}
|
||||
}) || []
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
import { queryBuiltInParams } from '@/api/rule-engine/scene'
|
||||
import { handleParamsData } from './components/Terms/util'
|
||||
import { useSceneStore } from 'store/scene'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import type { FormModelType } from '@/views/rule-engine/Scene/typings'
|
||||
|
||||
interface Params {
|
||||
branch: number
|
||||
branchGroup: number
|
||||
action: number
|
||||
}
|
||||
|
||||
export const getParams = (params: Params, sceneModel: FormModelType): Promise<any[]> => {
|
||||
return new Promise(res => {
|
||||
const data = sceneModel.branches!.filter(item => !!item)
|
||||
queryBuiltInParams({
|
||||
...sceneModel,
|
||||
branches: data
|
||||
}, params).then(resp => {
|
||||
if (resp.success) {
|
||||
res(resp.result as any[])
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param params
|
||||
*/
|
||||
export const useParams = (params: Params, effect: any[] = []) => {
|
||||
const sceneStore = useSceneStore()
|
||||
const { data: formModel } = storeToRefs(sceneStore)
|
||||
const columnOptions = ref<any[]>([])
|
||||
|
||||
const handleParams = async () => {
|
||||
const _data = await getParams(params, formModel.value)
|
||||
columnOptions.value = handleParamsData(_data, 'id')
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
if (effect[0]) {
|
||||
handleParams()
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
columnOptions
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue