第一次提交
This commit is contained in:
337
src/views/yunxinwei/alarm/components/edit.vue
Normal file
337
src/views/yunxinwei/alarm/components/edit.vue
Normal file
@@ -0,0 +1,337 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑' : '新建'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="选择设备" name="equipmentCode">
|
||||
<EquipmentSelect
|
||||
dict-code="equipmentCode"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="报警类型" name="alarmType">
|
||||
<DictSelect
|
||||
dict-code="alarmType"
|
||||
v-model:value="form.alarmType"
|
||||
placeholder="选择报警类型"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="上传图片" name="images">-->
|
||||
<!-- <ele-image-upload-->
|
||||
<!-- v-model:value="images"-->
|
||||
<!-- :limit="1"-->
|
||||
<!-- :drag="true"-->
|
||||
<!-- :multiple="true"-->
|
||||
<!-- :upload-handler="uploadHandler"-->
|
||||
<!-- @upload="onUpload"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="备注" name="comments">-->
|
||||
<!-- <a-textarea-->
|
||||
<!-- :rows="4"-->
|
||||
<!-- :maxlength="200"-->
|
||||
<!-- placeholder="请输入备注"-->
|
||||
<!-- v-model:value="form.comments"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="处理状态" name="status">-->
|
||||
<!-- <a-radio-group v-model:value="form.status">-->
|
||||
<!-- <a-radio :value="0">未处理</a-radio>-->
|
||||
<!-- <a-radio :value="1">已处理</a-radio>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { EquipmentAlarm } from '@/api/apps/equipment/alarm/model';
|
||||
import {
|
||||
addEquipmentAlarm,
|
||||
updateEquipmentAlarm
|
||||
} from '@/api/apps/equipment/alarm';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import DictSelect from '@/components/DictSelect/index.vue';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
// import MultiSpec from './MultiSpec.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: EquipmentAlarm | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const disabled = ref(false);
|
||||
// 选择日期
|
||||
const batteryDeliveryTime = ref<Dayjs>();
|
||||
const ctiveTime = ref<Dayjs>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 选项卡位置
|
||||
// const activeKey = ref('1');
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<EquipmentAlarm>({
|
||||
id: undefined,
|
||||
equipmentCode: undefined,
|
||||
handleTime: undefined,
|
||||
alarmType: undefined,
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0,
|
||||
merchantCode: undefined
|
||||
});
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: FILE_THUMBNAIL + data.path,
|
||||
status: 'done'
|
||||
});
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择设备',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
alarmType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择报警类型',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
// status: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'number',
|
||||
// message: '请选择设备状态',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
// sortNumber: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'number',
|
||||
// message: '请输入排序号',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
// images: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请选择设备图片',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (images.value.length == 0) {
|
||||
// return Promise.reject('请上传设备图片');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
// content: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请输入文章内容',
|
||||
// trigger: 'blur',
|
||||
// validator: async (_rule: RuleObject, value: string) => {
|
||||
// if (content.value == '') {
|
||||
// return Promise.reject('请输入文字内容');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateEquipmentAlarm(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 获取第一张图片作为封面图
|
||||
images.value.map((d, i) => {
|
||||
if (i === 0) {
|
||||
form.image = d.url;
|
||||
}
|
||||
});
|
||||
const equipmentAlarmForm = {
|
||||
...form,
|
||||
files: JSON.stringify(images.value),
|
||||
content: content.value,
|
||||
batteryDeliveryTime: batteryDeliveryTime.value?.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
),
|
||||
ctiveTime: ctiveTime.value?.format('YYYY-MM-DD HH:mm:ss')
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateEquipmentAlarm
|
||||
: addEquipmentAlarm;
|
||||
saveOrUpdate(equipmentAlarmForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
if (props.data.batteryDeliveryTime) {
|
||||
batteryDeliveryTime.value = dayjs(
|
||||
props.data.batteryDeliveryTime,
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
ctiveTime.value = dayjs(props.data.ctiveTime, 'YYYY-MM-DD');
|
||||
} else {
|
||||
batteryDeliveryTime.value = undefined;
|
||||
ctiveTime.value = undefined;
|
||||
}
|
||||
// images.value = JSON.parse(String(props.data.files));
|
||||
content.value = props.data.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
135
src/views/yunxinwei/alarm/components/search.vue
Normal file
135
src/views/yunxinwei/alarm/components/search.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<!-- <a-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- class="ele-btn-icon"-->
|
||||
<!-- :v-role="`superAdmin`"-->
|
||||
<!-- @click="add"-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>新建</span>-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-button-->
|
||||
<!-- danger-->
|
||||
<!-- type="primary"-->
|
||||
<!-- class="ele-btn-icon"-->
|
||||
<!-- :v-role="`superAdmin`"-->
|
||||
<!-- @click="removeBatch"-->
|
||||
<!-- v-if="props.selection.length > 0"-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <DeleteOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>批量删除</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
|
||||
<a-select-option value="equipmentCode">设备编号</a-select-option>
|
||||
<a-select-option value="alarmType">报警类型</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<!-- <CustomerSelect-->
|
||||
<!-- v-model:value="where.equipmentId"-->
|
||||
<!-- :placeholder="`按设备筛选`"-->
|
||||
<!-- @select="onSelect"-->
|
||||
<!-- @clear="onClear"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { EquipmentAlarmParam } from '@/api/apps/equipment/alarm/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<EquipmentAlarmParam>({
|
||||
id: undefined,
|
||||
alarmType: '',
|
||||
equipmentCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
if (type.value == 'alarmType') {
|
||||
where.alarmType = searchText.value;
|
||||
where.equipmentCode = undefined;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
where.alarmType = undefined;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
const handleTabs = (e) => {
|
||||
listType.value = e.target.value;
|
||||
if (listType.value == 'all') {
|
||||
resetFields();
|
||||
}
|
||||
if (listType.value == 'onSale') {
|
||||
where.status = 0;
|
||||
}
|
||||
if (listType.value == 'offSale') {
|
||||
where.status = 1;
|
||||
}
|
||||
if (listType.value == 'soldOut') {
|
||||
where.stockTotal = 0;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
search();
|
||||
};
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
250
src/views/yunxinwei/alarm/index.vue
Normal file
250
src/views/yunxinwei/alarm/index.vue
Normal file
@@ -0,0 +1,250 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="电池报警">
|
||||
<div class="ele-text-secondary"> 电池报警记录。 </div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 800 }"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'equipmentCode'">
|
||||
<a @click="openEdit(record)">{{ record.equipmentCode }}</a>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
{{ timeAgo(record.createTime) }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--suppress TypeScriptValidateTypes -->
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import {
|
||||
pageEquipmentAlarm,
|
||||
removeEquipmentAlarm,
|
||||
removeBatchEquipmentAlarm
|
||||
} from '@/api/apps/equipment/alarm';
|
||||
import type {
|
||||
EquipmentAlarm,
|
||||
EquipmentAlarmParam
|
||||
} from '@/api/apps/equipment/alarm/model';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
// import { getDictionaryOptions } from '@/utils/common';
|
||||
// import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '设备编号',
|
||||
dataIndex: 'equipmentCode',
|
||||
key: 'equipmentCode',
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '所属商户',
|
||||
dataIndex: 'merchantName',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '报警类型',
|
||||
dataIndex: 'alarmType',
|
||||
key: 'alarmType',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<EquipmentAlarm[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<EquipmentAlarm | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
// const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.brand = filters.brand;
|
||||
}
|
||||
return pageEquipmentAlarm({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: EquipmentAlarmParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: EquipmentAlarm) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
// const openInfo = (row?: EquipmentAlarm) => {
|
||||
// current.value = row ?? null;
|
||||
// showEdit.value = true;
|
||||
// };
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: EquipmentAlarm) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeEquipmentAlarm(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchEquipmentAlarm(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'EquipmentAlarmIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user