Browse Source

feat: 分组管理批量分组,公式编辑

temp
xuziqiang 5 months ago
parent
commit
e0206a228b
  1. 11
      hx-ai-intelligent/src/api/deviceManage.ts
  2. 199
      hx-ai-intelligent/src/view/equipmentManage/group/config.ts
  3. 28
      hx-ai-intelligent/src/view/equipmentManage/group/edit.vue
  4. 123
      hx-ai-intelligent/src/view/equipmentManage/group/editCal.vue
  5. 157
      hx-ai-intelligent/src/view/equipmentManage/group/editFormula.vue
  6. 344
      hx-ai-intelligent/src/view/equipmentManage/group/editGroup.vue
  7. 26
      hx-ai-intelligent/src/view/equipmentManage/group/index.vue
  8. 4
      lib/component/form/form/form-item.vue
  9. 1
      lib/saas/theme/global-antd.less

11
hx-ai-intelligent/src/api/deviceManage.ts

@ -15,4 +15,15 @@ export enum group {
queryGroupPage = `${BASE_URL}/deviceGroup/queryGroupPage`, // 分组列表 queryGroupPage = `${BASE_URL}/deviceGroup/queryGroupPage`, // 分组列表
saveGroupList = `${BASE_URL}/deviceGroup/saveGroupList`, // 分组保存 saveGroupList = `${BASE_URL}/deviceGroup/saveGroupList`, // 分组保存
delGroupList = `${BASE_URL}/deviceGroup/delGroupList`, // 分组删除 delGroupList = `${BASE_URL}/deviceGroup/delGroupList`, // 分组删除
queryGroupInfoPage = `${BASE_URL}/deviceGroup/queryGroupInfoPage`, // 计算列表
queryEditCompute = `${BASE_URL}/deviceGroup/queryEditCompute`, // 计算树
saveComputeList = `${BASE_URL}/deviceGroup/saveComputeList`, // 计算保存
delComputeList = `${BASE_URL}/deviceGroup/delComputeList`, // 计算删除
queryComputeGroup = `${BASE_URL}/deviceGroup/queryComputeGroup`, // 计算分组列表
saveComputeGroup = `${BASE_URL}/deviceGroup/saveComputeGroup`, // 计算分组新增
saveComputeGroupInfo = `${BASE_URL}/deviceGroup/saveComputeGroupInfo`, // 批量分组
delComputeGroup = `${BASE_URL}/deviceGroup/delComputeGroup`, // 分组删除
computeGroupNum = `${BASE_URL}/deviceGroup/computeGroupNum`, // 分组删除
formula = `${BASE_URL}/deviceGroup/formula`, // 编辑公式
queryFormula = `${BASE_URL}/deviceGroup/queryFormula`, // 公式查询
} }

199
hx-ai-intelligent/src/view/equipmentManage/group/config.ts

@ -8,29 +8,32 @@ import { origanizemanage } from '/@/api/origanizemanage';
const tableCalKeyMap = [ const tableCalKeyMap = [
{ {
title: '来源企业', title: '来源企业',
dataIndex: 'orgName', dataIndex: 'linkOrgName',
// textEllipsis: true, textEllipsis: true,
// textNumber: 4, textNumber: 10,
}, },
{ {
title: '设备id', title: '设备id',
textNumber: 10,
dataIndex: 'deviceCode', dataIndex: 'deviceCode',
textEllipsis: true,
}, },
{ {
title: '设备编号', title: '设备编号',
dataIndex: 'deviceName', dataIndex: 'deviceNum',
textNumber: 8,
textEllipsis: true,
}, },
{ {
textNumber: 10,
title: '分组名称', title: '分组名称',
dataIndex: 'position', dataIndex: 'groupName',
}, },
{ {
title: '设备品牌/型号', title: '设备品牌/型号',
dataIndex: 'position', textNumber: 10,
dataIndex: 'deviceNameType',
}, },
{ {
textNumber: 10,
title: '设备状态', title: '设备状态',
dataIndex: 'position', dataIndex: 'position',
}, },
@ -146,6 +149,26 @@ export const editTreeConfig = (orgId) => ({
], ],
}, },
}); });
export const editCalTreeConfig = (orgId) => ({
selectedKeys: ['0-0'],
defaultExpandAll: true,
api: group.queryEditCompute,
params: { orgId },
resultField: 'data.orgInfos',
fieldNames: { title: 'orgName', key: 'orgId' },
formConfig: {
schemas: [
{
field: 'orgName',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入企业名称',
},
},
],
},
});
export const treeConfig = (orgId) => { export const treeConfig = (orgId) => {
return { return {
defaultExpandAll: true, defaultExpandAll: true,
@ -211,9 +234,11 @@ export const tableConfig = (el, elGroup, elFormula, defaultParams) => {
dynamicDisabled: (data: any) => { dynamicDisabled: (data: any) => {
return data.list.length === 0; return data.list.length === 0;
}, },
handle: () => { dynamicParams: { linkIds: 'linkId[]' },
mockData.value.splice(0, 2); confirm: true,
}, isClearCheck: true,
isReload: true,
api: group.delGroupList,
}, },
{ {
label: '批量导出', label: '批量导出',
@ -254,23 +279,6 @@ export const tableConfig = (el, elGroup, elFormula, defaultParams) => {
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx'); doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
}, },
}, },
{
label: '批量分组',
name: 'groupBatGroup',
type: 'primary',
handle: () => {
elGroup.value.toggle();
},
},
{
label: '公式编辑',
name: 'groupFormulaEdit',
type: 'primary',
handle: () => {
elFormula.value.toggle();
},
},
], ],
columns: tableKeyMap, columns: tableKeyMap,
columnActions: { columnActions: {
@ -279,11 +287,11 @@ export const tableConfig = (el, elGroup, elFormula, defaultParams) => {
{ {
label: '删除', label: '删除',
name: 'groupDelete', name: 'groupDelete',
dynamicParams: ['uuid', 'appealType'], dynamicParams: { linkIds: 'linkId[]' },
confirm: true, confirm: true,
handle: () => { isClearCheck: true,
mockData.value.splice(0, 1); isReload: true,
}, api: group.delGroupList,
}, },
], ],
}, },
@ -291,60 +299,17 @@ export const tableConfig = (el, elGroup, elFormula, defaultParams) => {
formConfig: { formConfig: {
schemas: [ schemas: [
{ {
field: 'name', field: 'orgName',
label: '设备名称',
component: 'NsInput', component: 'NsInput',
componentProps: { componentProps: {
placeholder: '请输入', placeholder: '请选择公司',
}, },
}, },
{ {
field: 'provider', field: 'pointNum',
label: '设备厂商',
component: 'NsInput', component: 'NsInput',
componentProps: { componentProps: {
placeholder: '请输入', placeholder: '请输入节点编号',
},
},
{
field: 'payWay',
label: '设备区域',
component: 'NsSelect',
componentProps: {
placeholder: '请选择',
options: [
{
label: '全部',
value: '',
},
],
},
},
{
field: 'createTime',
label: '生产日期',
component: 'NsRangePicker',
fieldMap: ['queryStartDate', 'queryEndDate'],
componentProps: {
valueFormat: 'YYYY-MM-DD',
},
},
{
field: 'createTime1',
label: '采购日期',
component: 'NsRangePicker',
fieldMap: ['queryStartDate', 'queryEndDate'],
componentProps: {
valueFormat: 'YYYY-MM-DD',
},
},
{
field: 'createTime2',
label: '启用日期',
component: 'NsRangePicker',
fieldMap: ['queryStartDate', 'queryEndDate'],
componentProps: {
valueFormat: 'YYYY-MM-DD',
}, },
}, },
], ],
@ -355,13 +320,11 @@ export const tableConfig = (el, elGroup, elFormula, defaultParams) => {
}; };
export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => { export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => {
// 分组节点 // 计算节点
return { return {
title: '点位信息', title: '点位信息',
// api: '/carbon_emission/device/getDeviceList', api: group.queryGroupInfoPage,
value: mockData.value, params: defaultParams.value,
params: defaultParams,
headerActions: [ headerActions: [
{ {
label: '编辑', label: '编辑',
@ -378,9 +341,11 @@ export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => {
dynamicDisabled: (data: any) => { dynamicDisabled: (data: any) => {
return data.list.length === 0; return data.list.length === 0;
}, },
handle: () => { dynamicParams: { ids: 'id[]' },
mockData.value.splice(0, 2); confirm: true,
}, isReload: true,
isClearCheck: true,
api: group.delComputeList,
}, },
{ {
label: '批量导出', label: '批量导出',
@ -421,7 +386,31 @@ export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => {
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx'); doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
}, },
}, },
{
label: '批量分组',
name: 'groupBatGroup',
type: 'primary',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
handle: ({ list }) => {
const ids = list.map(({ id }) => id);
defaultParams.value['saveDeviceInfoIds'] = ids;
elGroup.value.toggle();
},
},
{
label: '公式编辑',
name: 'groupFormulaEdit',
type: 'primary',
handle: () => {
elFormula.value.toggle();
},
},
], ],
scroll: { x: 1400 },
columns: tableCalKeyMap, columns: tableCalKeyMap,
columnActions: { columnActions: {
title: '操作', title: '操作',
@ -429,11 +418,11 @@ export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => {
{ {
label: '删除', label: '删除',
name: 'groupDelete', name: 'groupDelete',
dynamicParams: 'id', dynamicParams: { ids: 'id[]' },
confirm: true, confirm: true,
isReload: true, isReload: true,
isClearCheck: true, isClearCheck: true,
api: group.delGroupList, api: group.delComputeList,
}, },
], ],
}, },
@ -442,17 +431,45 @@ export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => {
schemas: [ schemas: [
{ {
field: 'name', field: 'name',
label: '设备名称', label: '公司',
component: 'NsInput', component: 'NsInput',
componentProps: { componentProps: {
placeholder: '请选择公司', placeholder: '请选择公司',
}, },
}, },
{ {
field: 'deviceCode',
component: 'NsInput',
componentProps: {
placeholder: '请输入设备id',
},
},
{
field: 'deviceNum',
component: 'NsInput',
componentProps: {
placeholder: '请输入设备编号',
},
},
{
field: 'provider', field: 'provider',
component: 'NsInput', component: 'NsInput',
componentProps: { componentProps: {
placeholder: '请输入节点编号', placeholder: '请输入设备状态',
},
},
{
field: 'deviceNameType',
component: 'NsInput',
componentProps: {
placeholder: '请输入设备型号',
},
},
{
field: 'provider',
component: 'NsInput',
componentProps: {
placeholder: '请输入分组名称',
}, },
}, },
], ],

28
hx-ai-intelligent/src/view/equipmentManage/group/edit.vue

@ -14,12 +14,10 @@
v-model:target-keys="targetKeys" v-model:target-keys="targetKeys"
:data-source="dataSource" :data-source="dataSource"
style="height: 100%; width: 66%" style="height: 100%; width: 66%"
oneWay
:listStyle="listStyle" :listStyle="listStyle"
show-search show-search
:render="(item) => item.title" :render="(item) => item.title"
:filter-option="filterOption" :filter-option="filterOption" />
@change="handleChange" />
</div> </div>
</ns-drawer> </ns-drawer>
</template> </template>
@ -29,12 +27,13 @@
import { editTreeConfig } from './config'; import { editTreeConfig } from './config';
import { group } from '/@/api/deviceManage'; import { group } from '/@/api/deviceManage';
import { http } from '/nerv-lib/util/http'; import { http } from '/nerv-lib/util/http';
const emit = defineEmits(['sure']);
const props = defineProps({ params: Object }); const props = defineProps({ params: Object });
const result = JSON.parse(sessionStorage.getItem('ORGID')!); const result = JSON.parse(sessionStorage.getItem('ORGID')!);
const config = computed(() => { const config = computed(() => {
return editTreeConfig(result); return editTreeConfig(result);
}); });
const visible = ref(true); const visible = ref(false);
const dataSource = ref([]); const dataSource = ref([]);
const listStyle = { const listStyle = {
height: '100%', height: '100%',
@ -42,14 +41,19 @@
}; };
const targetKeys = ref([]); const targetKeys = ref([]);
const currentId = ref(''); const currentId = ref('');
const clearData = () => {
dataSource.value = [];
targetKeys.value = [];
};
const toggle = () => { const toggle = () => {
visible.value = !visible.value; visible.value = !visible.value;
clearData();
}; };
const handleChange = (nextTargetKeys: string[], direction: string, moveKeys: string[]) => {
console.log('targetKeys: ', nextTargetKeys); onMounted(() => {
console.log('direction: ', direction); getData(currentId.value);
console.log('moveKeys: ', moveKeys); });
};
const filterOption = (inputValue: string, option: any) => { const filterOption = (inputValue: string, option: any) => {
return option?.title.toLowerCase().indexOf(inputValue.toLowerCase()) > -1; return option?.title.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
@ -65,7 +69,9 @@
saveGroupIds: targetKeys.value, saveGroupIds: targetKeys.value,
}) })
.then(() => { .then(() => {
emit('sure');
NsMessage.success('操作成功'); NsMessage.success('操作成功');
toggle();
}); });
}; };
function treeSelect( function treeSelect(
@ -98,8 +104,8 @@
item['key'] = item.id.toString(); item['key'] = item.id.toString();
return item; return item;
}); });
targetKeys.value = res.data.linkGroups.map((item) => { targetKeys.value = res.data.linkGroups?.map((item) => {
return item.id; return item.id.toString();
}); });
}); });
}; };

123
hx-ai-intelligent/src/view/equipmentManage/group/editCal.vue

@ -0,0 +1,123 @@
<template>
<ns-drawer
v-model:visible="visible"
:width="800"
class="custom-class"
title=" "
destroyOnClose
:ok="btnClick"
:cancel="() => (visible = false)"
placement="right">
<div class="drawerContainer">
<ns-tree-api v-bind="config" @select="treeSelect" />
<a-transfer
v-model:target-keys="targetKeys"
:data-source="dataSource"
style="height: 100%; width: 66%"
:listStyle="listStyle"
show-search
:render="(item) => item.title"
:filter-option="filterOption" />
</div>
</ns-drawer>
</template>
<script lang="ts" setup>
import { computed, onMounted, ref } from 'vue';
import { NsMessage } from '/nerv-lib/component';
import { editCalTreeConfig } from './config';
import { group } from '/@/api/deviceManage';
import { http } from '/nerv-lib/util/http';
const emit = defineEmits(['sure']);
const props = defineProps({ params: Object });
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
const config = computed(() => {
return editCalTreeConfig(result);
});
const visible = ref(false);
const dataSource = ref([]);
const listStyle = {
height: '100%',
width: '100%',
};
const targetKeys = ref([]);
const currentId = ref('');
const clearData = () => {
dataSource.value = [];
targetKeys.value = [];
};
const toggle = () => {
visible.value = !visible.value;
clearData();
};
onMounted(() => {
getData(currentId.value);
});
const filterOption = (inputValue: string, option: any) => {
return option?.title.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
};
const btnClick = () => {
// visible.value = false;
http
.post(group.saveComputeList, {
...props.params,
groupListId: props.params?.id,
saveOrgId: currentId.value,
saveDeviceInfoIds: targetKeys.value,
})
.then(() => {
emit('sure');
NsMessage.success('操作成功');
toggle();
});
};
function treeSelect(
selectedKeys: never[],
e: {
selected: boolean;
selectedNodes: { props: { dataRef: any } }[];
node: any;
event: any;
},
) {
console.log(selectedKeys, e);
const {
dataRef: { title },
} = e.node;
currentId.value = selectedKeys[0];
getData(currentId.value);
}
const getData = (id) => {
http
.post(group.queryEditCompute, {
orgId: result,
queryOrgId: id,
...props.params,
// energyType: props.params.energyType,
})
.then((res) => {
dataSource.value = res.data.deviceInfos?.map((item) => {
item['title'] = item.deviceName;
item['key'] = item.id.toString();
return item;
});
targetKeys.value = res.data.linkGroups?.map((item) => {
return item.id.toString();
});
});
};
defineExpose({
toggle,
});
</script>
<style scoped lang="less">
.drawerContainer {
height: 100%;
display: flex;
justify-content: space-between;
}
</style>

157
hx-ai-intelligent/src/view/equipmentManage/group/editFormula.vue

@ -7,29 +7,67 @@
:cancel="() => (visible = false)" :cancel="() => (visible = false)"
placement="right"> placement="right">
<ns-form :schemas="schemas" :model="model" formLayout="vertical" /> <ns-form :schemas="schemas" :model="model" formLayout="vertical" />
<div
style="
font-size: 16px;
font-weight: bold;
line-height: 24px;
padding: 16px 0;
padding-top: 0;
">
分组列表
</div>
<NsBasicTable v-model:dataSource="mockDataSource" v-bind="basicTableConfig" />
</ns-drawer> </ns-drawer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { NsMessage } from '/nerv-lib/component'; import { NsMessage } from '/nerv-lib/component';
import { group } from '/@/api/deviceManage';
import { http } from '/nerv-lib/util/http';
const emit = defineEmits(['sure']);
const props = defineProps({ params: Object });
const visible = ref(false); const visible = ref(false);
const model = ref({}); const model = ref({});
const toggle = () => { const toggle = () => {
visible.value = !visible.value; visible.value = !visible.value;
visible.value && getTableData();
visible.value && getFormula();
}; };
const mockDataSource = ref([ const mockDataSource = ref([]);
{ const getFormula = () => {
groupName: '1号厂区', http.post(group.queryFormula, props.params).then((res) => {
}, model.value.formula = res.data;
{ });
groupName: '2号厂区', };
}, const getTableData = () => {
{ http.post(group.queryComputeGroup, props.params).then((res) => {
groupName: '3号厂区', mockDataSource.value = res.data;
}, });
]); };
const basicTableConfig = ref({
bordered: true,
placeholder: '请输入',
pagination: false,
rowKey: (record) => record.id,
columns: [
{
title: '分组编号',
dataIndex: 'groupNum',
// customRender: ({ index }) => index + 1,
width: 80,
align: 'center',
},
{
title: '分组名称',
dataIndex: 'groupName',
align: 'center',
},
],
});
const schemas = [ const schemas = [
{ {
field: 'basicInfo', field: 'basicInfo',
@ -44,7 +82,6 @@
label: '', label: '',
field: 'formula', field: 'formula',
component: 'NsTextarea', component: 'NsTextarea',
defaultValue: '(A+B)*2',
formItemProps: { formItemProps: {
wrapperCol: { span: 24 }, wrapperCol: { span: 24 },
}, },
@ -59,52 +96,60 @@
], ],
}, },
}, },
{ // {
field: 'list', // field: 'list',
label: '', // label: '',
displayFormItem: false, // displayFormItem: false,
class: 'ns-form-item-full', // class: 'ns-form-item-full',
component: 'NsChildForm', // component: 'NsChildForm',
componentProps: { // componentProps: {
title: '分组列表', // title: '',
schemas: [ // schemas: [
{ // {
label: '', // label: '',
field: 'NsBasicTable', // field: 'NsBasicTable',
component: 'NsBasicTable', // component: 'NsBasicTable',
formItemProps: { // formItemProps: {
wrapperCol: { span: 24 }, // wrapperCol: { span: 24 },
}, // },
componentProps: { // componentProps: {
disabled: true, // disabled: true,
placeholder: '请输入', // placeholder: '',
dataSource: mockDataSource.value, // dataSource: mockDataSource.value,
pagination: false, // pagination: false,
rowKey: (record) => record.groupName, // rowKey: (record) => record.groupName,
columns: [ // columns: [
{ // {
title: '序号', // title: '',
dataIndex: 'name', // dataIndex: 'name',
customRender: ({ index }) => index + 1, // customRender: ({ index }) => index + 1,
width: 80, // width: 80,
align: 'center', // align: 'center',
}, // },
{ // {
title: '分组名称', // title: '',
dataIndex: 'groupName', // dataIndex: 'groupName',
align: 'center', // align: 'center',
}, // },
], // ],
}, // },
}, // },
], // ],
}, // },
}, // },
]; ];
const btnClick = () => { const btnClick = () => {
visible.value = false; http
NsMessage.success('操作成功'); .post(group.formula, {
...props.params,
...model.value,
})
.then(() => {
emit('sure');
toggle();
NsMessage.success('操作成功');
});
}; };
defineExpose({ defineExpose({

344
hx-ai-intelligent/src/view/equipmentManage/group/editGroup.vue

@ -2,136 +2,260 @@
<ns-drawer <ns-drawer
v-model:visible="visible" v-model:visible="visible"
width="520" width="520"
title="分组编辑" title=" "
:ok="btnClick" :ok="btnClick"
:cancel="() => (visible = false)" :cancel="() => (visible = false)"
placement="right"> placement="right">
<ns-form :schemas="schemas" :model="model" formLayout="vertical" /> <ns-form
:schemas="schemas(inputDisabled)"
:model="model"
formLayout="vertical"
:wrapperCol="{ span: 20 }"
:labelCol="{ span: 4 }">
<template #addonAfter="data">
<template v-if="data.field === 'groupName'">
<div class="iconOP">
<EditOutlined v-if="inputDisabled" @click="() => (inputDisabled = false)" />
<CheckOutlined v-else @click="op" />
</div>
</template>
</template>
</ns-form>
<div
style="
font-size: 16px;
font-weight: bold;
line-height: 24px;
padding: 16px 0;
padding-top: 0;
">
分组列表
<ns-button style="margin-left: 10px" type="primary" @click="addGroup">新增</ns-button>
</div>
<NsBasicTable
v-model:dataSource="mockDataSource"
v-bind="basicTableConfig"
:rowSelection="{
type: 'radio',
onChange: rowSelectChange,
selectedRowKeys,
}" />
</ns-drawer> </ns-drawer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { createVNode, onMounted, ref, unref } from 'vue'; import { createVNode, onMounted, ref, unref } from 'vue';
import { NsMessage } from '/nerv-lib/component'; import { NsMessage } from '/nerv-lib/component';
import { DeleteOutlined } from '@ant-design/icons-vue'; import { DeleteOutlined } from '@ant-design/icons-vue';
import { group } from '/@/api/deviceManage';
import { http } from '/nerv-lib/util/http';
import { EditOutlined, CheckOutlined } from '@ant-design/icons-vue';
import { Popconfirm } from 'ant-design-vue';
const emit = defineEmits(['sure']);
const props = defineProps({ params: Object });
const visible = ref(false); const visible = ref(false);
const model = ref({}); const model = ref({});
const inputDisabled = ref(true);
const selectedRowKeys = ref([]);
let opType = true; // truefalse
const toggle = () => { const toggle = () => {
visible.value = !visible.value; visible.value = !visible.value;
visible.value && getTableData();
}; };
const deleteRow = (index) => {
console.log(index); const startCararcter = 65;
mockDataSource.value.splice(index, 1); const addGroup = () => {
opType = true;
getCode();
const code = startCararcter + mockDataSource.value?.length;
inputDisabled.value = false;
model.value = { groupName: '' };
// if(mockDataSource.value.length)
}; };
const addRow = () => { const op = () => {
console.log(model); inputDisabled.value = !inputDisabled.value;
if (model.value?.groupName) mockDataSource.value.push(unref(model) as any); add();
}; };
const mockDataSource = ref([ //
{ const add = () => {
groupName: '1号厂区', const finalParams = { ...props.params, ...model.value };
}, if (opType) {
{ delete finalParams.id;
groupName: '2号厂区', }
}, http.post(group.saveComputeGroup, finalParams).then(() => {
{ getTableData();
groupName: '3号厂区', NsMessage.success('操作成功');
}, });
]); };
const schemas = [
{ const delGroup = (id) => {
field: 'basicInfo', http.post(group.delComputeGroup, { id }).then(() => {
label: '', getTableData();
displayFormItem: false, NsMessage.success('操作成功');
class: 'ns-form-item-full', });
component: 'NsChildForm', };
componentProps: { const rowSelectChange = (selected, selectedRows) => {
title: '分组信息', opType = false;
schemas: [ console.log(selectedRowKeys, selectedRows);
{ selectedRowKeys.value = selected;
label: '分组编号', model.value = { ...selectedRows[0] };
field: 'groupCode', };
component: 'NsInput', const mockDataSource = ref([]);
defaultValue: 'WDIFHSUNGNDOR', const getTableData = () => {
componentProps: { http.post(group.queryComputeGroup, props.params).then((res) => {
disabled: true, mockDataSource.value = res.data;
placeholder: '请输入', });
}, };
}, const getCode = () => {
{ http.post(group.computeGroupNum, props.params).then((res) => {
label: '分组名称', model.value.groupNum = res.data;
field: 'groupName', });
component: 'NsInput', };
componentProps: { const basicTableConfig = ref({
placeholder: '请输入', bordered: true,
addonAfter: createVNode( placeholder: '请输入',
'div',
{ style: { cursor: 'pointer' }, onclick: addRow }, pagination: false,
'新增', rowKey: (record) => record.id,
), columns: [
}, {
rules: [{ required: true }], title: '分组编号',
}, dataIndex: 'groupNum',
], // customRender: ({ index }) => index + 1,
width: 80,
align: 'center',
},
{
title: '分组名称',
dataIndex: 'groupName',
align: 'center',
}, },
}, {
{ title: '删除',
field: 'list', dataIndex: 'delete',
label: '', width: 80,
displayFormItem: false, align: 'center',
class: 'ns-form-item-full', customRender: ({ record }) =>
component: 'NsChildForm', createVNode(
componentProps: { Popconfirm,
title: '分组列表', { title: '确定删除吗?', placement: 'leftTop', onConfirm: () => delGroup(record.id) },
schemas: [ () => [
{ createVNode(DeleteOutlined, {
label: '', style: { color: 'red', cursor: 'pointer' },
field: 'NsBasicTable', // onClick: () => delGroup(record.id),
component: 'NsBasicTable', }),
formItemProps: { ],
wrapperCol: { span: 24 }, ),
},
],
});
const schemas = (val) => {
return [
{
field: 'basicInfo',
label: '',
displayFormItem: false,
class: 'ns-form-item-full',
component: 'NsChildForm',
componentProps: {
title: '分组信息',
schemas: [
{
label: '分组id',
field: 'id',
component: 'NsInput',
show: false,
},
{
label: '分组编号',
field: 'groupNum',
component: 'NsInput',
componentProps: {
disabled: true,
placeholder: '请输入',
},
}, },
componentProps: { {
disabled: true, label: '分组名称',
placeholder: '请输入', field: 'groupName',
dataSource: mockDataSource.value, component: 'NsInput',
rowSelection: { type: 'radio' }, componentProps: {
pagination: false, placeholder: '请输入',
rowKey: (record) => record.groupName, disabled: val,
columns: [ },
{ rules: [{ required: true }],
title: '序号',
dataIndex: 'name',
customRender: ({ index }) => index + 1,
width: 80,
align: 'center',
},
{
title: '分组名称',
dataIndex: 'groupName',
align: 'center',
},
{
title: '删除',
dataIndex: 'delete',
width: 80,
align: 'center',
customRender: ({ index }) =>
createVNode(DeleteOutlined, {
style: { color: 'red', cursor: 'pointer' },
onClick: () => deleteRow(index),
}),
},
],
}, },
}, ],
], },
}, },
}, // {
]; // field: 'list',
// label: '',
// displayFormItem: false,
// class: 'ns-form-item-full',
// component: 'NsChildForm',
// componentProps: {
// title: '',
// schemas: [
// {
// label: '',
// field: 'NsBasicTable',
// component: 'NsBasicTable',
// formItemProps: {
// wrapperCol: { span: 24 },
// },
// componentProps: {
// bordered: true,
// disabled: true,
// placeholder: '',
// dataSource: mockDataSource.value,
// rowSelection: { type: 'radio', onChange: rowSelectChange },
// pagination: false,
// rowKey: (record) => record.groupName,
// columns: [
// {
// title: '',
// dataIndex: 'name',
// customRender: ({ index }) => index + 1,
// width: 80,
// align: 'center',
// },
// {
// title: '',
// dataIndex: 'groupName',
// align: 'center',
// },
// {
// title: '',
// dataIndex: 'delete',
// width: 80,
// align: 'center',
// customRender: ({ index }) =>
// createVNode(DeleteOutlined, {
// style: { color: 'red', cursor: 'pointer' },
// onClick: () => deleteRow(index),
// }),
// },
// ],
// },
// },
// ],
// },
// },
];
};
const btnClick = () => { const btnClick = () => {
visible.value = false; http
NsMessage.success('操作成功'); .post(group.saveComputeGroupInfo, {
...props.params,
groupListId: selectedRowKeys.value[0],
})
.then(() => {
emit('sure');
toggle();
NsMessage.success('操作成功');
});
}; };
defineExpose({ defineExpose({
@ -144,4 +268,8 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.iconOP {
cursor: pointer;
color: @primary-color;
}
</style> </style>

26
hx-ai-intelligent/src/view/equipmentManage/group/index.vue

@ -1,7 +1,9 @@
<template> <template>
<editDrawer ref="editDrawerRef" :params="defaultParams" /> <!-- 分组编辑按钮 -->
<editGroup ref="editGroupRef" /> <editDrawer ref="editDrawerRef" :params="defaultParams" @sure="handleOk" />
<editFormula ref="editFormulaRef" /> <editCalDrawer ref="editDrawerCalRef" :params="defaultParams" @sure="handleOk" />
<editGroup ref="editGroupRef" :params="defaultParams" @sure="handleOk" />
<editFormula ref="editFormulaRef" :params="defaultParams" @sure="handleOk" />
<!-- <ns-modal ref="modalRef" title="新增" v-model:visible="visible"> <!-- <ns-modal ref="modalRef" title="新增" v-model:visible="visible">
<ns-form ref="formRef" :schemas="formSchema" :model="formData" formLayout="formVertical" /> <ns-form ref="formRef" :schemas="formSchema" :model="formData" formLayout="formVertical" />
@ -22,7 +24,6 @@
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<template v-for="(item, index) in filterAction(actionList, data)" :key="index"> <template v-for="(item, index) in filterAction(actionList, data)" :key="index">
<!-- 全部节点只需要新增子节点 -->
<a-menu-item @click="item.func(data)"> <a-menu-item @click="item.func(data)">
<span>{{ item.title }}</span> <span>{{ item.title }}</span>
</a-menu-item> </a-menu-item>
@ -34,8 +35,8 @@
</template> </template>
</ns-tree-api> </ns-tree-api>
</div> </div>
<ns-view-list-table v-if="defaultType" class="table" v-bind="config" ref="tableRef" /> <ns-view-list-table v-show="defaultType" class="table" v-bind="config" ref="tableRef" />
<ns-view-list-table v-else class="table" v-bind="configCal" ref="tableCalRef" /> <ns-view-list-table v-show="!defaultType" class="table" v-bind="configCal" ref="tableCalRef" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -43,6 +44,7 @@
import { tableConfig, treeConfig, tableConfigCal, formSchema } from './config'; import { tableConfig, treeConfig, tableConfigCal, formSchema } from './config';
import { useParams } from '/nerv-lib/use'; import { useParams } from '/nerv-lib/use';
import editDrawer from './edit.vue'; import editDrawer from './edit.vue';
import editCalDrawer from './editCal.vue';
import editGroup from './editGroup.vue'; import editGroup from './editGroup.vue';
import editFormula from './editFormula.vue'; import editFormula from './editFormula.vue';
import { NsMessage, NsModal } from '/nerv-lib/component'; import { NsMessage, NsModal } from '/nerv-lib/component';
@ -56,15 +58,16 @@
const tableRef = ref(); const tableRef = ref();
const tableCalRef = ref(); const tableCalRef = ref();
const editDrawerRef = ref(); const editDrawerRef = ref();
const editDrawerCalRef = ref();
const editGroupRef = ref(); const editGroupRef = ref();
const editFormulaRef = ref(); const editFormulaRef = ref();
const treeRef = ref(); const treeRef = ref();
const defaultType = ref(true); const defaultType = ref(true);
const result = JSON.parse(sessionStorage.getItem('ORGID')!); const result = JSON.parse(sessionStorage.getItem('ORGID')!);
const defaultParams = ref({ orgId: result, energyType: '用电量', id: 19 }); const defaultParams = ref({ orgId: result, energyType: '用电量', id: '', hxDeviceGroupId: '' });
const config = tableConfig(editDrawerRef, editGroupRef, editFormulaRef, defaultParams); const config = tableConfig(editDrawerRef, editGroupRef, editFormulaRef, defaultParams);
const configCal = tableConfigCal(editDrawerRef, editGroupRef, editFormulaRef, defaultParams); const configCal = tableConfigCal(editDrawerCalRef, editGroupRef, editFormulaRef, defaultParams);
const tConfig = treeConfig(result); const tConfig = treeConfig(result);
const nsModalFormConfig = ref({ const nsModalFormConfig = ref({
api: group.creatOrUpdate, api: group.creatOrUpdate,
@ -161,11 +164,18 @@
} = record; } = record;
defaultParams.value.energyType = energyType; defaultParams.value.energyType = energyType;
defaultParams.value.id = id; defaultParams.value.id = id;
defaultParams.value.hxDeviceGroupId = id;
defaultType.value = pointType === '分组节点'; defaultType.value = pointType === '分组节点';
defaultType.value defaultType.value
? tableRef.value?.nsTableRef.reload() ? tableRef.value?.nsTableRef.reload()
: tableCalRef.value?.nsTableRef.reload(); : tableCalRef.value?.nsTableRef.reload();
}; };
const handleOk = () => {
defaultType.value
? tableRef.value?.nsTableRef.reload()
: tableCalRef.value?.nsTableRef.reload();
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.groupContainer { .groupContainer {

4
lib/component/form/form/form-item.vue

@ -13,7 +13,7 @@
</template> </template>
<component :is="schema.component" v-bind="formProps"> <component :is="schema.component" v-bind="formProps">
<template #[item]="data" v-for="item in Object.keys($slots)"> <template #[item]="data" v-for="item in Object.keys($slots)">
<slot :name="item" v-bind="data || {}"></slot> <slot :name="item" v-bind="data || {}" :field="schema.field"></slot>
</template> </template>
</component> </component>
<!-- <div class="ns-tips">--> <!-- <div class="ns-tips">-->
@ -47,6 +47,7 @@
mapKeys, mapKeys,
upperFirst, upperFirst,
get, get,
cloneDeep,
} from 'lodash-es'; } from 'lodash-es';
import { isInputType } from '/nerv-lib/component/form/form-util'; import { isInputType } from '/nerv-lib/component/form/form-util';
import { useParams } from '/nerv-lib/use/use-params'; import { useParams } from '/nerv-lib/use/use-params';
@ -332,6 +333,7 @@
getFormItemClass, getFormItemClass,
getSlots, getSlots,
formLayout, formLayout,
cloneDeep,
}; };
}, },
beforeCreate() { beforeCreate() {

1
lib/saas/theme/global-antd.less

@ -275,6 +275,7 @@
.ant-empty-description { .ant-empty-description {
color: rgba(0, 0, 0, 0.3); color: rgba(0, 0, 0, 0.3);
margin-bottom: 0;
} }
// 表头加粗 // 表头加粗

Loading…
Cancel
Save