fix:修改计划添加页面
This commit is contained in:
@@ -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`, //添加计划
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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: {
|
||||
@@ -150,6 +181,10 @@
|
||||
title: '计划名称',
|
||||
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();
|
||||
|
Reference in New Issue
Block a user