Browse Source

fix:修改计划添加页面

temp
zhaohy 2 months ago
parent
commit
c21a79da87
  1. 8
      hx-ai-intelligent/src/api/planToAdd.ts
  2. 12
      hx-ai-intelligent/src/components/ns-modal-form.vue
  3. 76
      hx-ai-intelligent/src/view/equipmentControl/planToAdd/index.vue
  4. 8
      lib/component/table/table.vue
  5. 5
      lib/component/tree/tree-api.vue

8
hx-ai-intelligent/src/api/planToAdd.ts

@ -1,7 +1,9 @@
import { BASE_URL } from './index';
export enum planToAddApi {
getActivatedPlanTree = `${BASE_URL}/api/deviceCtrlPlan/getActivatedPlanTree`, //计划树
getActivatedPlanListByTree = `${BASE_URL}/api/deviceCtrlPlan/getActivatedPlanListByTree`, //计划列表
updPlan = `${BASE_URL}/api/deviceCtrlPlan/updateActivatedPlan`, //修改计划
getActivatedPlanTree = `${BASE_URL}/api/deviceCtrlPlan/getPlanLibTree`, //计划树
getActivatedPlanListByTree = `${BASE_URL}/api/deviceCtrlPlan/getPageAblePlanListByTree`, //计划列表
updPlan = `${BASE_URL}/api/deviceCtrlPlan/updateCtrlPlan`, //修改计划
delPlan = `${BASE_URL}/api/deviceCtrlPlan/deleteCtrlPlanByIdList`, //修改计划
addPlan = `${BASE_URL}/api/deviceCtrlPlan/addCtrlPlan`, //添加计划
}

12
hx-ai-intelligent/src/components/ns-modal-form.vue

@ -66,10 +66,14 @@
httpRequest({ api, params: data, pathParams: params, requestConfig })
.then((res) => {
NsMessage.success('操作成功', 1, () => {
toggle();
success && success(res);
});
if (res.msg === 'success') {
NsMessage.success('操作成功', 1, () => {
toggle();
success && success(res);
});
} else {
NsMessage.error(res.msg);
}
})
.finally(() => {
setLoading(false);

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

@ -1,12 +1,33 @@
<template>
<ns-view-list-table ref="mainRef" v-bind="config">
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'executionTime'">
{{ getData(record) }}
<div style="width: 100%; height: 100%; position: relative">
<ns-view-list-table ref="mainRef" v-bind="config">
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'executionTime'">
{{ getData(record) }}
</template>
<template v-if="column.dataIndex === 'executeStatus'">
<div
:style="{
color: {
'0': '#ccc',
'1': 'rgba(255, 165, 0, 1)',
'2': 'rgb(57, 215, 187)',
'3': 'rgb(255, 0, 0)',
}[record.executeStatus.value],
}">
{{ record.executeStatus.label }}</div
>
</template>
</template>
</template>
</ns-view-list-table>
<NsModalFrom ref="modalFormRef" v-bind="nsModalFormConfig" />
</ns-view-list-table>
<a-button
type="primary"
style="position: absolute; bottom: 20px; height: 30px; left: 13%"
@click="addPlan"
>添加</a-button
>
<NsModalFrom ref="modalFormRef" v-bind="nsModalFormConfig" />
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
@ -14,6 +35,7 @@
import { planToAddApi } from '/@/api/planToAdd';
import { NsMessage } from '/nerv-lib/component';
import { getEnum } from '/@/api';
import { http } from '/nerv-lib/util';
//
const orgId = ref('');
@ -24,6 +46,24 @@
projectId.value = results.projectId;
const mainRef = ref(null);
const modalFormRef = ref(null);
const addPlan = () => {
if (mainRef.value.nsTableRef.treeElRef.selectedRow.node.planLib) {
http
.get(planToAddApi.addPlan, {
libId: mainRef.value.nsTableRef.treeElRef.selectedRow.node.planLib.id,
})
.then((res) => {
if (res.msg === 'success') {
NsMessage.success('添加成功');
mainRef.value?.nsTableRef.reload();
} else {
NsMessage.error(res.msg);
}
});
} else {
NsMessage.warning('只有最后一级才能添加');
}
};
const getData = (record: any) => {
return record.startTime
? record.startTime.substring(0, 10) + ' - ' + record.endTime.substring(0, 10)
@ -67,8 +107,6 @@
success: (data: any) => {
if (data.msg === 'success') {
mainRef.value?.nsTableRef.reload();
} else {
NsMessage.error(data.msg);
}
},
});
@ -81,7 +119,7 @@
config.value = {
title: '计划库',
api: planToAddApi.getActivatedPlanListByTree,
params: { orgId, projectId, ctrlType: enumData.data[0].value },
params: { orgId, projectId },
treeConfig: {
defaultExpandAll: true,
header: {
@ -90,20 +128,13 @@
},
params: { projectId, ctrlType: enumData.data[0].value },
dynamicParams: {
id: 'id',
pid: 'pid',
level: 'level',
projectId: 'projectId',
ctrlType: 'ctrlType',
treeId: 'id',
},
api: planToAddApi.getActivatedPlanTree,
fieldNames: {
title: 'name',
key: 'id',
pid: 'pid',
level: 'level',
projectId: 'projectId',
ctrlType: 'ctrlType',
children: 'childList',
},
formConfig: {
@ -151,6 +182,10 @@
dataIndex: 'planName',
},
{
title: '执行状态',
dataIndex: 'executeStatus',
},
{
title: '执行时间',
dataIndex: 'executionTime',
},
@ -166,9 +201,8 @@
name: 'energyAlarmEdit',
dynamicParams: ['uuid', 'appealType'],
handle: (data: any) => {
console.log(mainRef.value, '数据');
if (data?.executeStatus?.value === 2) {
NsMessage.warning('当前计划正在执行,无法进行编辑。如需编辑,请先停止计划.');
NsMessage.warning('当前计划正在执行,无法进行编辑。如需编辑,请先停止计划');
} else {
const obj = { ...data };
nsModalFormConfig.value.title = '编辑';
@ -192,7 +226,7 @@
dynamicParams: ['uuid', 'appealType'],
confirm: true,
handle: (data: any) => {
http.post(planToAddApi.updPlan, [data.id]).then((res) => {
http.post(planToAddApi.delPlan, [data.id]).then((res) => {
if (res.msg === 'success') {
NsMessage.success('操作成功');
mainRef.value?.nsTableRef.reload();

8
lib/component/table/table.vue

@ -17,7 +17,11 @@
<!-- todo drag -->
<div class="ns-part-tree" v-if="!isEmpty(treeConfig)">
<ns-tree-api v-bind="getTreeBindValue" @reload="reload" @select="treeSelect" />
<ns-tree-api
ref="treeElRef"
v-bind="getTreeBindValue"
@reload="reload"
@select="treeSelect" />
</div>
<div class="ns-part-table">
<a-spin :spinning="tableState.loading">
@ -220,6 +224,7 @@
setup(props, { attrs, emit }) {
const tableElRef = ref(null);
const formElRef = ref(null);
const treeElRef = ref(null);
const dataRef = ref([]);
const treeParamsRef = ref({});
const formParamsRef = ref({});
@ -632,6 +637,7 @@
reload,
clearCheck,
formElRef,
treeElRef,
tableElRef,
getColumnActions,
getTableBindValues,

5
lib/component/tree/tree-api.vue

@ -43,6 +43,7 @@
const treeData = ref(props.treeData);
const selectedKeys = ref(props.selectedKeys || []);
const selectedRow = ref(props.selectedRow || {});
const { httpRequest } = useApi();
const requestConfig: AxiosRequestConfig = { method: 'get' };
const route = useRoute();
@ -87,6 +88,7 @@
const handleSelect = (keys: any, selectedRows: any) => {
if (props.cancelable || !isEmpty(keys)) {
selectedKeys.value = keys;
selectedRow.value = selectedRows;
// props.onSelect && props.onSelect(keys, selectedRows);
emit('select', keys, selectedRows);
}
@ -147,9 +149,10 @@
const clearSelectedKeys = () => {
selectedKeys.value = [];
selectedRow.value = {};
};
defineExpose({ treeReload, clearSelectedKeys });
defineExpose({ treeReload, clearSelectedKeys, selectedKeys, selectedRow });
</script>
<style lang="less" scoped>
@gap: 16px;

Loading…
Cancel
Save