提交 7e65dfdb authored 作者: liuluyu's avatar liuluyu

风险监测指标增加批量删除

上级 a76b863c
<template> <template>
<div> <div>
<!--引用表格--> <!--引用表格-->
<BasicTable @register="registerTable" @edit-end="handleEditEnd" @edit-cancel="handleEditCancel" :beforeEditSubmit="beforeEditSubmit"> <BasicTable
@register="registerTable"
@edit-end="handleEditEnd"
@edit-cancel="handleEditCancel"
:beforeEditSubmit="beforeEditSubmit"
:rowSelection="rowSelection"
>
<!--插槽:table标题--> <!--插槽:table标题-->
<template #tableTitle> <template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" @click="handleCaluculatAllMetric" preIcon="ant-design:plus-outlined">计算所有指标值</a-button> <a-button type="primary" @click="handleCaluculatAllMetric" preIcon="ant-design:plus-outlined">计算所有指标值</a-button>
<a-button type="primary" @click="handleCustomImport" preIcon="ant-design:plus-outlined">从EXCEL导入</a-button> <a-button type="primary" @click="handleCustomImport" preIcon="ant-design:plus-outlined">从EXCEL导入</a-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button
>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
</template> </template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template> </template>
<!--字段回显插槽--> <!--字段回显插槽-->
<template #htmlSlot="{text}"> <template #htmlSlot="{ text }">
<div v-html="text"></div> <div v-html="text"></div>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'tolVal'"> <template v-if="column.key === 'tolVal'">{{ record.stTolVal }}~{{ record.tolVal }}</template>
{{record.stTolVal}}~{{record.tolVal}} <template v-if="column.key === 'warnVal'"> ({{ record.tolVal }}~{{ record.warnVal }}</template>
</template> <template v-if="column.key === 'intvVal'">{{ record.warnVal }}~{{ record.intvVal }}</template>
<template v-if="column.key === 'warnVal'">
({{record.tolVal}}~{{record.warnVal}}
</template>
<template v-if="column.key === 'intvVal'">
{{record.warnVal}}~{{record.intvVal}}
</template>
</template> </template>
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
...@@ -37,58 +51,54 @@ ...@@ -37,58 +51,54 @@
</template> </template>
<script lang="ts" name="metric-metricMonitorSet" setup> <script lang="ts" name="metric-metricMonitorSet" setup>
import {ref, computed, unref} from 'vue'; import { ref, computed, unref } from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import {useModal} from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage' import { useListPage } from '/@/hooks/system/useListPage';
import MetricMonitorSetFomulaModal from './components/MetricMonitorSetFomulaModal.vue' import MetricMonitorSetFomulaModal from './components/MetricMonitorSetFomulaModal.vue';
import {columns, searchFormSchema,formSchema} from './MetricMonitorSet.data'; import { columns, searchFormSchema, formSchema } from './MetricMonitorSet.data';
import {listCombined, deleteOne, batchDelete,caluculatAllMetric,saveOrUpdate,batchImmportCalculate} from './MetricMonitorSet.api'; import { listCombined, deleteOne, batchDelete, caluculatAllMetric, saveOrUpdate, batchImmportCalculate } from './MetricMonitorSet.api';
import Import from '/@/views/audit/common/components/import.vue' import Import from '/@/views/audit/common/components/import.vue';
const [registerModal, {openModal}] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerFomulasModal, {openModal:openFomulasModal}] = useModal(); const [registerFomulasModal, { openModal: openFomulasModal }] = useModal();
const refImport = ref() const refImport = ref();
//注册table数据 //注册table数据
const { tableContext} = useListPage({ const { tableContext } = useListPage({
tableProps:{ tableProps: {
title: '监测方案', title: '监测方案',
api: listCombined, api: listCombined,
columns, columns,
canResize:true, canResize: true,
formConfig: { formConfig: {
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter:true, autoSubmitOnEnter: true,
showAdvancedButton:true, showAdvancedButton: true,
fieldMapToNumber: [ fieldMapToNumber: [],
], fieldMapToTime: [],
fieldMapToTime: [
],
}, },
actionColumn: { actionColumn: {
width: 150, width: 150,
fixed:'right' fixed: 'right',
}, },
} },
}) });
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
mtrcCtp:2, mtrcCtp: 2,
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
...@@ -122,13 +132,13 @@ ...@@ -122,13 +132,13 @@
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 成功回调 * 成功回调
...@@ -139,7 +149,7 @@ ...@@ -139,7 +149,7 @@
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record){ function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '编辑',
...@@ -149,37 +159,38 @@ ...@@ -149,37 +159,38 @@
// label: '编辑公式', // label: '编辑公式',
// onClick: handleFormulas.bind(null, record), // onClick: handleFormulas.bind(null, record),
// } // }
] ];
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record){ function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
onClick: handleDetail.bind(null, record), onClick: handleDetail.bind(null, record),
}, { },
{
label: '删除', label: '删除',
popConfirm: { popConfirm: {
title: '是否确认删除', title: '是否确认删除',
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
} },
} },
] ];
} }
function handleEditEnd({ record, index, key, value }: Recordable) { function handleEditEnd({ record, index, key, value }: Recordable) {
handleSuccess() handleSuccess();
return false; return false;
} }
async function beforeEditSubmit({ record, index, key, value }) { async function beforeEditSubmit({ record, index, key, value }) {
let tmpPbj = { let tmpPbj = {
id:record.id, id: record.id,
mtrcNo:record.mtrcNo, mtrcNo: record.mtrcNo,
} };
tmpPbj[key] = value tmpPbj[key] = value;
await saveOrUpdate(tmpPbj); await saveOrUpdate(tmpPbj);
} }
...@@ -187,20 +198,19 @@ ...@@ -187,20 +198,19 @@
console.log('cancel'); console.log('cancel');
} }
function handleCaluculatAllMetric(){ function handleCaluculatAllMetric() {
caluculatAllMetric() caluculatAllMetric();
} }
const importCallback = async (datas) => { const importCallback = async (datas) => {
//const transformedData = transformData(datas,pid); //const transformedData = transformData(datas,pid);
await batchImmportCalculate(datas); await batchImmportCalculate(datas);
await reload(); await reload();
} };
const handleCustomImport = () => { const handleCustomImport = () => {
refImport.value.iniData(formSchema) refImport.value.iniData(formSchema);
} };
// function transformData(originalArray) { // function transformData(originalArray) {
// return originalArray.map(item => ({ // return originalArray.map(item => ({
...@@ -214,11 +224,6 @@ ...@@ -214,11 +224,6 @@
// }] // }]
// })); // }));
// } // }
</script> </script>
<style scoped> <style scoped></style>
</style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论