123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449 |
- <template>
- <el-card shadow="never" class="page">
- <div class="system-user-search">
- <el-form :model="tableData.param" ref="queryRef" inline @keyup.enter.native="dataList">
- <el-form-item label="配置名称" prop="keyWord">
- <el-input v-model="tableData.param.keyWord" placeholder="请输入配置名称" clearable style="width: 240px" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" class="ml10" @click="dataList">
- <el-icon>
- <ele-Search />
- </el-icon>
- 查询
- </el-button>
- <el-button @click="resetQuery(queryRef)">
- <el-icon>
- <ele-Refresh />
- </el-icon>
- 重置
- </el-button>
- <el-button type="primary" class="ml10" @click="onOpenAdd">
- <el-icon>
- <ele-FolderAdd />
- </el-icon>
- 新增通知
- </el-button>
- </el-form-item>
- </el-form>
- </div>
- <div class="flex1">
- <el-row>
- <el-col :span="8" v-for="(item, index) in tableData.data" :key="index">
- <div class="grid-content card">
- <div class="ant-card">
- <div class="ant-card-body">
- <div class="pro-table-card-item">
- <div class="card-item-avatar">
- <img width="88" height="88" :src="'/imgs/notice/' + tableData.param.sendGateway + '.svg'" alt="" />
- </div>
- <div class="card-item-body">
- <div class="card-item-header" style="width: 100%;">
- <div class="ellipsis">
- <div class="ellipsis card-item-header-name" style="width: 100%; height: 45px">{{ item.title }}</div>
- <div class="card-item-header-name" style="display: none"></div>
- </div>
- </div>
- <div class="card-item-content">
- 通知方式:<el-tag>{{ item.types == 1 ? '即时发送' : '预约发送' }}</el-tag>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="card-tools">
- <div class="card-button" @click="onOpenEdit(item)">
- <el-button type="primary" class="ml10" text bg>
- <el-icon>
- <ele-Edit />
- </el-icon>
- 修改
- </el-button>
- </div>
- <div class="card-button" @click="onOpenEditTem(item)">
- <el-button type="primary" text bg>
- <el-icon>
- <ele-Wallet />
- </el-icon>
- 模板配置
- </el-button>
- </div>
- <div class="card-button" @click="onRowDel(item)">
- <el-button type="danger" text bg>
- <el-icon>
- <ele-Delete />
- </el-icon>
- 删除
- </el-button>
- </div>
- </div>
- </div>
- </el-col>
- </el-row>
- </div>
- <div style="text-align: center;padding: 28px;" v-if="(tableData.total == 0)">暂无数据</div>
- <pagination v-show="tableData.total > 0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="dataList" />
- <EditDic ref="editDicRef" @dataList="dataList" />
- <EditTemDic ref="temeditDicRef" @dataList="dataList" />
- </el-card>
- </template>
- <script lang="ts">
- import { toRefs, reactive, onMounted, ref, getCurrentInstance, defineComponent } from 'vue';
- import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
- import EditDic from './component/setEdit.vue';
- import EditTemDic from './component/temEdit.vue';
- import api from '/@/api/notice';
- import { useRoute } from 'vue-router';
- // 定义接口来定义对象的类型
- interface TableDataRow {
- id: number;
- keyWord: string;
- sendGateway: string;
- type: string;
- }
- interface TableDataState {
- ids: number[];
- tableData: {
- data: Array<TableDataRow>;
- total: number;
- loading: boolean;
- param: {
- pageNum: number;
- pageSize: number;
- keyWord: string;
- sendGateway: string;
- types: string;
- };
- };
- }
- export default defineComponent({
- name: 'setlist',
- components: { EditDic, EditTemDic },
- setup() {
- const { proxy } = getCurrentInstance() as any;
- // const { notice_send_gateway } = proxy.useDict('notice_send_gateway');
- const addDicRef = ref();
- const editDicRef = ref();
- const temeditDicRef = ref();
- const detailRef = ref();
- const queryRef = ref();
- const route = useRoute();
- const state = reactive<TableDataState>({
- type: '',
- tableData: {
- data: [],
- total: 0,
- loading: false,
- param: {
- pageNum: 1,
- pageSize: 20,
- keyWord: '',
- sendGateway: '',
- types: '',
- },
- },
- });
- // 初始化表格数据
- const initTableData = () => {
- state.tableData.param.sendGateway = route.params.id;
- dataList();
- };
- const dataList = () => {
- state.tableData.loading = true;
- api.config
- .getList(state.tableData.param)
- .then((res: any) => {
- state.tableData.data = res.Data;
- state.tableData.total = res.Total;
- })
- .finally(() => (state.tableData.loading = false));
- };
- // 打开新增菜单弹窗
- const onOpenAdd = (row?: TableDataRow) => {
- editDicRef.value.openDialog(null, state.tableData.param.sendGateway);
- };
- // 打开修改模型弹窗
- const onOpenEdit = (row: TableDataRow) => {
- editDicRef.value.openDialog({ ...row }, state.tableData.param.sendGateway);
- };
- const onOpenEditTem = (row: TableDataRow) => {
- temeditDicRef.value.opentemDialog(row.id, state.tableData.param.sendGateway);
- };
- const onRowDel = (row?: TableDataRow) => {
- let msg = '你确定要删除所选数据?';
- let ids: number[] = [];
- if (row) {
- msg = `此操作将永久删除:“${row.title}”,是否继续?`;
- ids = row.id;
- } else {
- ids = state.ids;
- }
- if (ids.length === 0) {
- ElMessage.error('请选择要删除的数据。');
- return;
- }
- ElMessageBox.confirm(msg, '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(() => {
- api.config.delete(ids).then(() => {
- ElMessage.success('删除成功');
- dataList();
- });
- })
- .catch(() => { });
- };
- // 页面加载时
- onMounted(() => {
- initTableData();
- });
- /** 重置按钮操作 */
- const resetQuery = (formEl: FormInstance | undefined) => {
- if (!formEl) return;
- formEl.resetFields();
- dataList();
- };
- const onActionStatus = (item: TableDataRow[]) => {
- if (item.status == 0) {
- alarm.common.deploy({ id: item.id }).then((res: any) => {
- dataList();
- });
- } else {
- alarm.common.undeploy({ id: item.id }).then((res: any) => {
- dataList();
- });
- }
- };
- return {
- onActionStatus,
- onOpenEditTem,
- temeditDicRef,
- addDicRef,
- editDicRef,
- detailRef,
- queryRef,
- onOpenAdd,
- onOpenEdit,
- onRowDel,
- dataList,
- resetQuery,
- ...toRefs(state),
- };
- },
- });
- </script>
- <style scoped>
- .el-col-12 {
- padding: 10px;
- }
- .el-button.is-text:not(.is-disabled).is-has-bg {
- background-color: var(--next-border-color-light);
- }
- .card {
- padding: 10px;
- }
- .ant-card {
- box-sizing: border-box;
- margin: 10px;
- width: 98%;
- font-size: 14px;
- font-variant: tabular-nums;
- border: 1px solid var(--next-border-color-light);
- line-height: 1.5;
- list-style: none;
- font-feature-settings: 'tnum';
- position: relative;
- border-radius: 2px;
- transition: all 0.3s;
- overflow: hidden;
- }
- .ant-card-body {
- padding: 24px;
- zoom: 1;
- overflow: hidden;
- }
- .pro-table-card-item {
- display: flex;
- }
- .pro-table-card-item .card-item-avatar {
- margin-right: 16px;
- }
- .pro-table-card-item .card-item-body {
- display: flex;
- flex-direction: column;
- flex-grow: 1;
- width: 0;
- }
- .pro-table-card-item .card-item-body .card-item-header {
- display: flex;
- width: calc(100% - 86px);
- margin-bottom: 12px;
- }
- .pro-table-card-item .card-item-body .card-item-content {
- display: flex;
- flex-wrap: wrap;
- }
- .pro-table-card-item .card-item-body .card-item-content>div {
- width: 50%;
- }
- .ellipsis {
- display: -webkit-box;
- overflow: hidden;
- text-align: left;
- text-overflow: ellipsis;
- word-break: break-all;
- }
- .card-item-body .card-item-header .card-item-header-name {
- font-weight: 700;
- font-size: 16px;
- }
- .card-state {
- position: absolute;
- top: 30px;
- right: -12px;
- display: flex;
- justify-content: center;
- width: 100px;
- padding: 2px 0;
- background-color: rgba(89, 149, 245, 0.15);
- transform: skewX(45deg);
- }
- .card-state.success {
- background-color: #f6ffed;
- }
- .iot-card .card-warp .card-content .card-state.error {
- background-color: rgba(229, 0, 18, 0.1);
- }
- .card-state .card-state-content {
- transform: skewX(-45deg);
- }
- .ant-badge-status-success {
- background-color: #52c41a;
- }
- .ant-badge-status-error {
- background-color: #ff4d4f;
- }
- .ant-badge-status-dot {
- position: relative;
- top: -1px;
- display: inline-block;
- width: 6px;
- height: 6px;
- vertical-align: middle;
- border-radius: 50%;
- }
- .card-tools {
- display: flex;
- margin-top: 2px;
- }
- .card-tools .card-button:not(:last-child) {
- margin-right: 8px;
- }
- .card-tools .card-button {
- display: flex;
- flex-grow: 1;
- }
- .card-tools .card-button>span,
- .card-tools .card-button button {
- width: 100%;
- border-radius: 0;
- }
- .ant-btn-link {
- border-color: transparent;
- background: transparent;
- box-shadow: none;
- }
- .ant-badge-status-text {
- margin-left: 8px;
- color: rgba(0, 0, 0, 0.85);
- font-size: 14px;
- }
- .ant-btn {
- line-height: 1.5715;
- position: relative;
- display: inline-block;
- font-weight: 400;
- white-space: nowrap;
- text-align: center;
- background-image: none;
- cursor: pointer;
- transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- touch-action: manipulation;
- height: 32px;
- padding: 4px 15px;
- font-size: 14px;
- border-radius: 2px;
- }
- .ant-btn>.anticon {
- line-height: 1;
- }
- .ant-btn>span {
- display: inline-block;
- }
- .cardflex {
- display: flex;
- justify-content: space-between;
- }
- .statusname {
- font-size: 30px;
- margin-top: 10px;
- margin-bottom: 15px;
- }
- .comtest {
- margin-top: 20px;
- height: 30px;
- line-height: 30px;
- }
- </style>
|