Browse Source

fix:修改计划添加页面

temp
zhaohy 3 months ago
parent
commit
c21a79da87
  1. 8
      hx-ai-intelligent/src/api/planToAdd.ts
  2. 4
      hx-ai-intelligent/src/components/ns-modal-form.vue
  3. 62
      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'; import { BASE_URL } from './index';
export enum planToAddApi { export enum planToAddApi {
getActivatedPlanTree = `${BASE_URL}/api/deviceCtrlPlan/getActivatedPlanTree`, //计划树 getActivatedPlanTree = `${BASE_URL}/api/deviceCtrlPlan/getPlanLibTree`, //计划树
getActivatedPlanListByTree = `${BASE_URL}/api/deviceCtrlPlan/getActivatedPlanListByTree`, //计划列表 getActivatedPlanListByTree = `${BASE_URL}/api/deviceCtrlPlan/getPageAblePlanListByTree`, //计划列表
updPlan = `${BASE_URL}/api/deviceCtrlPlan/updateActivatedPlan`, //修改计划 updPlan = `${BASE_URL}/api/deviceCtrlPlan/updateCtrlPlan`, //修改计划
delPlan = `${BASE_URL}/api/deviceCtrlPlan/deleteCtrlPlanByIdList`, //修改计划
addPlan = `${BASE_URL}/api/deviceCtrlPlan/addCtrlPlan`, //添加计划
} }

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

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

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

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

8
lib/component/table/table.vue

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

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

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

Loading…
Cancel
Save