Browse Source

fix:修改计划列表打包报错问题

temp
zhaohy 1 month ago
parent
commit
07f1903c98
  1. 156
      hx-ai-intelligent/src/view/equipmentControl/planToAdd/config.ts
  2. 162
      hx-ai-intelligent/src/view/equipmentControl/planToAdd/index.vue

156
hx-ai-intelligent/src/view/equipmentControl/planToAdd/config.ts

@ -1,156 +0,0 @@
import { planToAddApi } from '/@/api/planToAdd';
import { ref } from 'vue';
import { http } from '/nerv-lib/util';
import { getEnum } from '/@/api';
import { NsMessage } from '/nerv-lib/component';
// const enumData: any = await getEnum({ params: { enumType: 'CtrlDeviceType' } });
//由于打包生产环境编译时await报错,故改为return形式
const enumData: any = ()=>{
return getEnum({ params: { enumType: 'CtrlDeviceType' } })
}
export const tableConfig = (
orgId: any,
projectId: any,
mainRef: any,
nsModalFormConfig: any,
modalFormRef: any,
) => {
return ref({
title: '计划库',
api: planToAddApi.getActivatedPlanListByTree,
params: { orgId, projectId, deviceType: enumData.data[0].value },
treeConfig: {
defaultExpandAll: true,
header: {
icon: 'name',
title: '执行计划',
},
params: { projectId, deviceType: enumData.data[0].value },
dynamicParams: {
id: 'id',
pid: 'pid',
level: 'level',
projectId: 'projectId',
deviceType: 'deviceType',
},
api: planToAddApi.getActivatedPlanTree,
fieldNames: {
title: 'name',
key: 'id',
pid: 'pid',
level: 'level',
projectId: 'projectId',
deviceType: 'deviceType',
children: 'childList',
},
formConfig: {
schemas: [
{
field: 'deviceType',
label: '告警优先级',
component: 'nsSelectApi',
autoSubmit: true,
componentProps: {
api: () => getEnum({ params: { enumType: 'CtrlDeviceType' } }),
immediate: true,
resultField: 'data',
labelField: 'label',
valueField: 'value',
placeholder: '请选择告警优先级',
showSearch: true,
autoSelectFirst: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
},
},
],
},
},
rowSelection: null,
columns: [
{
title: '执行顺序',
dataIndex: 'address',
width: 100,
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '计划类型',
dataIndex: 'planGroupName',
},
{
title: '计划名称',
dataIndex: 'planName',
},
{
title: '执行时间',
dataIndex: 'executionTime',
},
],
columnActions: {
title: '操作',
width: 200,
fixed: 'right',
dataIndex: 'tableAction',
actions: [
{
label: '编辑',
name: 'energyAlarmEdit',
dynamicParams: ['uuid', 'appealType'],
handle: (data: any) => {
const obj = { ...data };
nsModalFormConfig.value.title = '编辑';
setTimeout(() => {
nsModalFormConfig.value.data = {
id: obj.id,
};
if (obj.startTime) {
nsModalFormConfig.value.data.createTime = obj.startTime
? [obj.startTime, obj.endTime]
: [];
}
}, 1);
modalFormRef.value?.toggle();
},
},
{
label: '删除',
name: 'energyAlarmDel',
dynamicParams: ['uuid', 'appealType'],
confirm: true,
handle: (data: any) => {
http.post(planToAddApi.updPlan, { id: data.id, isDeleted: 1 }).then((res) => {
if (res.msg === 'success') {
NsMessage.success('操作成功');
mainRef.value?.nsTableRef.reload();
} else {
NsMessage.error(res.msg);
}
});
mainRef.value?.nsTableRef.reload();
},
},
],
},
formConfig: {
schemas: [
{
field: 'planName',
label: '计划标题',
component: 'NsInput',
componentProps: {
allowClear: true,
placeholder: '请输入计划名称关键字',
},
},
],
params: {},
},
// pagination: { pageSizeOptions: false },
rowKey: 'uuid',
});
};

162
hx-ai-intelligent/src/view/equipmentControl/planToAdd/index.vue

@ -9,11 +9,11 @@
<NsModalFrom ref="modalFormRef" v-bind="nsModalFormConfig" />
</template>
<script lang="ts" setup>
import { tableConfig } from './config';
import { ref, onMounted } from 'vue';
import NsModalFrom from '/@/components/ns-modal-form.vue';
import { planToAddApi } from '/@/api/planToAdd';
import { NsMessage } from '/nerv-lib/component';
import { getEnum } from '/@/api';
//
const orgId = ref('');
@ -65,15 +65,159 @@
}
},
});
const config = ref(null);
const enumDataList: any = () => {
return getEnum({ params: { enumType: 'CtrlDeviceType' } });
};
const getConfigData = async () => {
const enumData = await enumDataList();
config.value = {
title: '计划库',
api: planToAddApi.getActivatedPlanListByTree,
params: { orgId, projectId, deviceType: enumData.data[0].value },
treeConfig: {
defaultExpandAll: true,
header: {
icon: 'name',
title: '执行计划',
},
params: { projectId, deviceType: enumData.data[0].value },
dynamicParams: {
id: 'id',
pid: 'pid',
level: 'level',
projectId: 'projectId',
deviceType: 'deviceType',
},
api: planToAddApi.getActivatedPlanTree,
fieldNames: {
title: 'name',
key: 'id',
pid: 'pid',
level: 'level',
projectId: 'projectId',
deviceType: 'deviceType',
children: 'childList',
},
formConfig: {
schemas: [
{
field: 'deviceType',
label: '告警优先级',
component: 'nsSelectApi',
autoSubmit: true,
componentProps: {
api: () => getEnum({ params: { enumType: 'CtrlDeviceType' } }),
immediate: true,
resultField: 'data',
labelField: 'label',
valueField: 'value',
placeholder: '请选择告警优先级',
showSearch: true,
autoSelectFirst: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
},
},
],
},
},
rowSelection: null,
columns: [
{
title: '执行顺序',
dataIndex: 'address',
width: 100,
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '计划类型',
dataIndex: 'planGroupName',
},
{
title: '计划名称',
dataIndex: 'planName',
},
{
title: '执行时间',
dataIndex: 'executionTime',
},
],
columnActions: {
title: '操作',
width: 200,
fixed: 'right',
dataIndex: 'tableAction',
actions: [
{
label: '编辑',
name: 'energyAlarmEdit',
dynamicParams: ['uuid', 'appealType'],
handle: (data: any) => {
const obj = { ...data };
nsModalFormConfig.value.title = '编辑';
setTimeout(() => {
nsModalFormConfig.value.data = {
id: obj.id,
};
if (obj.startTime) {
nsModalFormConfig.value.data.createTime = obj.startTime
? [obj.startTime, obj.endTime]
: [];
}
}, 1);
modalFormRef.value?.toggle();
},
},
{
label: '删除',
name: 'energyAlarmDel',
dynamicParams: ['uuid', 'appealType'],
confirm: true,
handle: (data: any) => {
http.post(planToAddApi.updPlan, { id: data.id, isDeleted: 1 }).then((res) => {
if (res.msg === 'success') {
NsMessage.success('操作成功');
mainRef.value?.nsTableRef.reload();
} else {
NsMessage.error(res.msg);
}
});
mainRef.value?.nsTableRef.reload();
},
},
],
},
formConfig: {
schemas: [
{
field: 'planName',
label: '计划标题',
component: 'NsInput',
componentProps: {
allowClear: true,
placeholder: '请输入计划名称关键字',
},
},
],
params: {},
},
// pagination: { pageSizeOptions: false },
rowKey: 'uuid',
};
//
setTimeout(() => {
mainRef.value?.nsTableRef.reload();
}, 1);
};
//
onMounted(() => {});
const config = tableConfig(
orgId.value,
projectId.value,
mainRef,
nsModalFormConfig,
modalFormRef,
);
onMounted(() => {
getConfigData();
});
defineOptions({
name: 'LedgerIndex', // name
});

Loading…
Cancel
Save