feat:alert silence 列表页面增加 alerts 列

This commit is contained in:
likexuan
2022-04-15 13:06:02 +08:00
parent e9d1e6ce9c
commit 4f5e25bfb6
4 changed files with 429 additions and 272 deletions

View File

@@ -29,6 +29,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
], ],
}, },
hot: true, hot: true,
inline:true,
contentBase: false, // since we use CopyWebpackPlugin. contentBase: false, // since we use CopyWebpackPlugin.
compress: true, compress: true,
host: HOST || config.dev.host, host: HOST || config.dev.host,

View File

@@ -22,7 +22,7 @@ module.exports = {
// host: '0.0.0.0', // can be overwritten by process.env.HOST // host: '0.0.0.0', // can be overwritten by process.env.HOST
host: '127.0.0.1', // can be overwritten by process.env.HOST host: '127.0.0.1', // can be overwritten by process.env.HOST
port: 80, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined port: 80, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false, autoOpenBrowser: true,
errorOverlay: true, errorOverlay: true,
notifyOnErrors: true, notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

View File

@@ -14,7 +14,8 @@
:resizable="false" :resizable="false"
align="center" align="center"
type="selection" type="selection"
width="55"> width="55"
>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-for="(item, index) in customTableTitle" v-for="(item, index) in customTableTitle"
@@ -31,70 +32,131 @@
class="data-column" class="data-column"
> >
<template slot="header"> <template slot="header">
<span class="data-column__span">{{item.label}}</span> <span class="data-column__span">{{ item.label }}</span>
<div class="col-resize-area"></div> <div class="col-resize-area"></div>
</template> </template>
<template slot-scope="scope" :column="item"> <template slot-scope="scope" :column="item">
<template v-if="item.prop === 'duration'"> <template v-if="item.prop === 'duration'">
<el-tooltip :disabled="!scope.row.endAt" effect="light" placement="right"> <el-tooltip
:disabled="!scope.row.endAt"
effect="light"
placement="right"
>
<div slot="content"> <div slot="content">
{{$t('config.terminallog.endTime')}}<br/> {{ $t("config.terminallog.endTime") }}<br />
{{utcTimeToTimezoneStr(scope.row.endAt)}} {{ utcTimeToTimezoneStr(scope.row.endAt) }}
</div> </div>
<span>{{getDuration(scope.row)}}</span> <span>{{ getDuration(scope.row) }}</span>
</el-tooltip> </el-tooltip>
</template> </template>
<template v-else-if="item.prop === 'alertNum'">
<span style="cursor: pointer" @click="$emit('showBottomBox', 'alertMessageTab', scope.row)">
<i
:class="scope.row.alertNum > 0 ? 'gray' : 'green'"
class="nz-icon nz-icon-overview-alert vertical-align-top;"
@mouseenter="tooltipHover(scope.row, true, $event)"
@mouseleave="tooltipHover(scope.row, false, $event)"
></i><span>{{scope.row.alerts}}</span>
</span>
</template>
<template v-else-if="item.prop === 'matchers'"> <template v-else-if="item.prop === 'matchers'">
<span v-for="(item1, i) in labelsSort(scope.row.matchers)" :key="i"> <span v-for="(item1, i) in labelsSort(scope.row.matchers)" :key="i">
<span > <span>
<nz-alert-tag <nz-alert-tag
:key="i" :cursor-point="tagType(item1.name) !== 'info'" :key="i"
:label="item1.name" :cursor-point="tagType(item1.name) !== 'info'"
:type="tagType(item1.name)" :label="item1.name"
:regex="item1.regex" :type="tagType(item1.name)"
style="margin: 5px 0 5px 5px;" :regex="item1.regex"
> style="margin: 5px 0 5px 5px"
{{item1.value}} >
</nz-alert-tag> {{ item1.value }}
</span> </nz-alert-tag>
</span> </span>
</span>
</template> </template>
<template v-else-if="item.prop === 'state'"> <template v-else-if="item.prop === 'state'">
<span v-if="scope.row.state===1" class="silence-active">active</span> <span v-if="scope.row.state === 1" class="silence-active"
<span v-if="scope.row.state===2" class="silence-pending">pending</span> >active</span
<span v-if="scope.row.state===3" class="silence-expired">expired</span> >
<span v-if="scope.row.state === 2" class="silence-pending"
>pending</span
>
<span v-if="scope.row.state === 3" class="silence-expired"
>expired</span
>
</template> </template>
<template v-else-if="item.prop === 'utime'"> <template v-else-if="item.prop === 'utime'">
{{utcTimeToTimezoneStr(scope.row[item.prop])}} {{ utcTimeToTimezoneStr(scope.row[item.prop]) }}
</template> </template>
<template v-else-if="item.prop === 'startAt'"> <template v-else-if="item.prop === 'startAt'">
{{utcTimeToTimezoneStr(scope.row[item.prop])}} {{ utcTimeToTimezoneStr(scope.row[item.prop]) }}
</template> </template>
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop] || '-'}}</span> <span v-else-if="scope.row[item.prop]">{{
scope.row[item.prop] || "-"
}}</span>
<template v-else>-</template> <template v-else>-</template>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column :resizable="false" :width="operationWidth" fixed="right">
:resizable="false" <div slot="header" class="table-operation-title">
:width="operationWidth" {{ $t("overall.option") }}
fixed="right"> </div>
<div slot="header" class="table-operation-title">{{$t('overall.option')}}</div>
<div slot-scope="scope" class="table-operation-items"> <div slot-scope="scope" class="table-operation-items">
<!-- <button :class="{'table-operation-item&#45;&#45;disable': scope.row.state === 3}" class="table-operation-item" v-has="'alertSilence_edit'" @click="$emit('edit', scope.row)" :disabled="scope.row.state === 3"><i class="nz-icon nz-icon-edit"></i></button>--> <!-- <button :class="{'table-operation-item&#45;&#45;disable': scope.row.state === 3}" class="table-operation-item" v-has="'alertSilence_edit'" @click="$emit('edit', scope.row)" :disabled="scope.row.state === 3"><i class="nz-icon nz-icon-edit"></i></button>-->
<button class="table-operation-item" @click="$emit('showBottomBox', 'alertMessageTab', scope.row)"><i class="nz-icon nz-icon-view1"></i></button> <button
<el-dropdown size="medium" v-has="['alertSilence_expire', 'alertSilence_edit']" trigger="click" @command="tableOperation"> class="table-operation-item"
@click="$emit('showBottomBox', 'alertMessageTab', scope.row)"
>
<i class="nz-icon nz-icon-view1"></i>
</button>
<el-dropdown
size="medium"
v-has="['alertSilence_expire', 'alertSilence_edit']"
trigger="click"
@command="tableOperation"
>
<div class="table-operation-item table-operation-item--more"> <div class="table-operation-item table-operation-item--more">
<i class="nz-icon nz-icon-more3"></i> <i class="nz-icon nz-icon-more3"></i>
</div> </div>
<el-dropdown-menu slot="dropdown" class="right-box-select-top right-public-box-dropdown-top"> <el-dropdown-menu
<el-dropdown-item :command="['edit', scope.row]" :class="{'table-operation-item--disable': scope.row.state === 3}" class="table-operation-item" v-has="'alertSilence_edit'" :disabled="scope.row.state === 3"><i class="nz-icon nz-icon-edit"></i><span class="operation-dropdown-text">{{$t('overall.edit')}}</span></el-dropdown-item> slot="dropdown"
<el-dropdown-item v-has="'alertSilence_edit'" :command="['copy', scope.row]"><i class="nz-icon nz-icon-override"></i><span class="operation-dropdown-text">{{$t('overall.duplicate')}}</span></el-dropdown-item> class="right-box-select-top right-public-box-dropdown-top"
<el-dropdown-item v-has="'alertSilence_expire'" :command="['delete', scope.row]"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('buttons.delete')}}</span></el-dropdown-item> >
<el-dropdown-item
:command="['edit', scope.row]"
:class="{
'table-operation-item--disable': scope.row.state === 3,
}"
class="table-operation-item"
v-has="'alertSilence_edit'"
:disabled="scope.row.state === 3"
><i class="nz-icon nz-icon-edit"></i
><span class="operation-dropdown-text">{{
$t("overall.edit")
}}</span></el-dropdown-item
>
<el-dropdown-item
v-has="'alertSilence_edit'"
:command="['copy', scope.row]"
><i class="nz-icon nz-icon-override"></i
><span class="operation-dropdown-text">{{
$t("overall.duplicate")
}}</span></el-dropdown-item
>
<el-dropdown-item
v-has="'alertSilence_expire'"
:command="['delete', scope.row]"
><i class="nz-icon nz-icon-delete"></i
><span class="operation-dropdown-text">{{
$t("buttons.delete")
}}</span></el-dropdown-item
>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
</el-table-column> </el-table-column>
<template slot="empty"> <template slot="empty">
<div v-if="!loading" class="table-no-data"> <div v-if="!loading" class="table-no-data">
<svg class="icon" aria-hidden="true"> <svg class="icon" aria-hidden="true">
<use xlink:href="#nz-icon-no-data-list"></use> <use xlink:href="#nz-icon-no-data-list"></use>
@@ -107,114 +169,130 @@
</template> </template>
<script> <script>
import table from '@/components/common/mixin/table' import table from "@/components/common/mixin/table";
import { calcDurationByStringTimeB } from '@/components/common/js/tools' import { calcDurationByStringTimeB } from "@/components/common/js/tools";
import nzAlertTag from '../../../page/alert/nzAlertTag' import nzAlertTag from "../../../page/alert/nzAlertTag";
import { sameLabels } from '@/components/common/js/constants' import { sameLabels } from "@/components/common/js/constants";
export default { export default {
name: 'alertSilenceTable', name: "alertSilenceTable",
components: { components: {
nzAlertTag nzAlertTag,
}, },
mixins: [table], mixins: [table],
props: { props: {
loading: Boolean, loading: Boolean,
nowTime: {} nowTime: {},
}, },
data () { data() {
return { return {
/* 表格相关 */ /* 表格相关 */
tableTitle: [ tableTitle: [
{ {
label: 'ID', label: "ID",
prop: 'id', prop: "id",
show: true, show: true,
width: 80, width: 80,
sortable: 'custom' sortable: "custom",
}, },
{ {
label: this.$t('alert.silence.name'), label: this.$t("alert.silence.name"),
prop: 'name', prop: "name",
show: true, show: true,
minWidth: 150 minWidth: 150,
}, { },
label: this.$t('alert.silence.matchers'), {
prop: 'matchers', label: this.$t("alert.silence.matchers"),
prop: "matchers",
show: true, show: true,
minWidth: 200, minWidth: 200,
sortable: 'custom' sortable: "custom",
}, { },
label: this.$t('alert.silence.startTime'), {
prop: 'startAt', label: this.$t("alert.alert"),
prop: "alertNum",
show: true,
minWidth: 120,
sortable: "custom",
},
{
label: this.$t("alert.silence.startTime"),
prop: "startAt",
show: true, show: true,
width: 300, width: 300,
sortable: 'custom' sortable: "custom",
}, { },
label: this.$t('config.terminallog.duration'), {
prop: 'duration', label: this.$t("config.terminallog.duration"),
prop: "duration",
show: true, show: true,
width: 120 width: 120,
}, { },
label: this.$t('alert.silence.remark'), {
prop: 'remark', label: this.$t("alert.silence.remark"),
prop: "remark",
show: true, show: true,
width: 120 width: 120,
}, { },
label: this.$t('alert.silence.upTime'), {
prop: 'utime', label: this.$t("alert.silence.upTime"),
prop: "utime",
show: false, show: false,
width: 300 width: 300,
}, { },
label: this.$t('alert.silence.state'), {
prop: 'state', label: this.$t("alert.silence.state"),
prop: "state",
show: true, show: true,
width: 120 width: 120,
} },
] ],
} };
}, },
computed: { computed: {
getDuration () { getDuration() {
return function (record) { return function (record) {
if (record.endAt) { if (record.endAt) {
return calcDurationByStringTimeB(record.startAt, record.endAt) return calcDurationByStringTimeB(record.startAt, record.endAt);
} }
return calcDurationByStringTimeB(record.startAt, this.utcTimeToTimezoneStr(this.nowTime)) return calcDurationByStringTimeB(
} record.startAt,
this.utcTimeToTimezoneStr(this.nowTime)
);
};
}, },
tagType () { tagType() {
return (key) => { return (key) => {
if (sameLabels.find(item => item === key)) { if (sameLabels.find((item) => item === key)) {
return 'normal' return "normal";
} else { } else {
return 'info' return "info";
} }
} };
} },
}, },
methods: { methods: {
labelsSort (obj) { labelsSort(obj) {
obj = obj || [] obj = obj || [];
const buildIn = sameLabels const buildIn = sameLabels;
if (typeof obj === 'string') obj = JSON.parse(obj) if (typeof obj === "string") obj = JSON.parse(obj);
const labels = JSON.parse(JSON.stringify(obj)) const labels = JSON.parse(JSON.stringify(obj));
const result = [] const result = [];
const result2 = [] const result2 = [];
for (const key of buildIn) { for (const key of buildIn) {
labels.forEach(item => { labels.forEach((item) => {
if (item.name === key) { if (item.name === key) {
result.push(item) result.push(item);
} }
}) });
} }
labels.forEach(item => { labels.forEach((item) => {
if (buildIn.indexOf(item.name) === -1) { if (buildIn.indexOf(item.name) === -1) {
result2.push(item) result2.push(item);
} }
}) });
// console.log([...result, ...result2]) // console.log([...result, ...result2])
return [...result, ...result2] return [...result, ...result2];
} },
} },
} };
</script> </script>

View File

@@ -10,11 +10,24 @@
@search="search" @search="search"
> >
<template v-slot:top-tool-right> <template v-slot:top-tool-right>
<button id="roles-add" v-has="'alertSilence_add'" :title="$t('overall.createAlertSilence')" class="top-tool-btn margin-r-10" <button
type="button" @click="add"> id="roles-add"
v-has="'alertSilence_add'"
:title="$t('overall.createAlertSilence')"
class="top-tool-btn margin-r-10"
type="button"
@click="add"
>
<i class="nz-icon-create-square nz-icon"></i> <i class="nz-icon-create-square nz-icon"></i>
</button> </button>
<delete-button id="role-list-batch-delete" v-has="'alertSilence_expire'" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button> <delete-button
id="role-list-batch-delete"
v-has="'alertSilence_expire'"
:api="url"
:delete-objs="batchDeleteObjs"
@after="getTableData"
@before="delFlag = true"
></delete-button>
</template> </template>
<template v-slot:default="slotProps"> <template v-slot:default="slotProps">
<alert-silence-table <alert-silence-table
@@ -31,28 +44,59 @@
@edit="edit" @edit="edit"
@copy="copy" @copy="copy"
@orderBy="tableDataSort" @orderBy="tableDataSort"
@queryMessage="queryMessage"
@reload="getTableData" @reload="getTableData"
@selectionChange="selectionChange" @selectionChange="selectionChange"
@showBottomBox="(targetTab, object) => { $refs.dataList.showBottomBox(targetTab, object) }"></alert-silence-table> @showBottomBox="
(targetTab, object) => {
$refs.dataList.showBottomBox(targetTab, object);
}
"
></alert-silence-table>
</template> </template>
<!-- 分页组件 --> <!-- 分页组件 -->
<template v-slot:pagination> <template v-slot:pagination>
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination> <Pagination
ref="Pagination"
:pageObj="pageObj"
:tableId="tableId"
@pageNo="pageNo"
@pageSize="pageSize"
></Pagination>
</template> </template>
</nz-data-list> </nz-data-list>
<transition name="right-box"> <transition name="right-box">
<alert-silence-box v-if="rightBox.show" :alert-silence="object" @close="closeRightBox"></alert-silence-box> <alert-silence-box
v-if="rightBox.show"
:alert-silence="object"
@close="closeRightBox"
></alert-silence-box>
</transition> </transition>
<!--导出--> <!--导出-->
<div class="export-xlsx"> <div class="export-xlsx">
<el-dialog :modal-append-to-body='false' :show-close="true" :title="importBox.title" <el-dialog
:visible.sync="importBox.show" class="nz-dialog" width="300px" @close="closeDialog"> :modal-append-to-body="false"
:show-close="true"
:title="importBox.title"
:visible.sync="importBox.show"
class="nz-dialog"
width="300px"
@close="closeDialog"
>
<div class="upload-body"> <div class="upload-body">
<button id="alert-msg-exportcur" class="el-button el-button--default el-button--small" @click="exportCur"> <button
<span>{{$t('overall.exportCur')}}</span> id="alert-msg-exportcur"
class="el-button el-button--default el-button--small"
@click="exportCur"
>
<span>{{ $t("overall.exportCur") }}</span>
</button> </button>
<button id="alert-msg-exportall" class="el-button el-button--default el-button--small" @click="exportAll"> <button
<span>{{$t('overall.exportAll')}}</span> id="alert-msg-exportall"
class="el-button el-button--default el-button--small"
@click="exportAll"
>
<span>{{ $t("overall.exportAll") }}</span>
</button> </button>
</div> </div>
</el-dialog> </el-dialog>
@@ -61,232 +105,266 @@
</template> </template>
<script> <script>
import bus from '@/libs/bus' import bus from "@/libs/bus";
import alertSilenceBox from '@/components/common/rightBox/alertSilenceBox' import alertSilenceBox from "@/components/common/rightBox/alertSilenceBox";
import deleteButton from '@/components/common/deleteButton' import deleteButton from "@/components/common/deleteButton";
import nzDataList from '@/components/common/table/nzDataList' import nzDataList from "@/components/common/table/nzDataList";
import dataListMixin from '@/components/common/mixin/dataList' import dataListMixin from "@/components/common/mixin/dataList";
import alertSilenceTable from '@/components/common/table/alert/alertSilenceTable' import alertSilenceTable from "@/components/common/table/alert/alertSilenceTable";
import routerPathParams from '@/components/common/mixin/routerPathParams' import routerPathParams from "@/components/common/mixin/routerPathParams";
export default { export default {
name: 'alertSilence', name: "alertSilence",
components: { components: {
alertSilenceTable, alertSilenceTable,
deleteButton, deleteButton,
nzDataList, nzDataList,
alertSilenceBox alertSilenceBox,
}, },
mixins: [dataListMixin, routerPathParams], mixins: [dataListMixin, routerPathParams],
data () { data() {
return { return {
url: 'alert/silence', url: "alert/silence",
tableId: 'silenceTable', tableId: "silenceTable",
/* 搜素相关 */ /* 搜素相关 */
searchMsg: { // 给搜索框子组件传递的信息 searchMsg: {
// 给搜索框子组件传递的信息
zheze_none: true, zheze_none: true,
searchLabelList: [ searchLabelList: [
{ {
name: 'ID', name: "ID",
type: 'input', type: "input",
label: 'ids', label: "ids",
disabled: false disabled: false,
}, { },
name: this.$t('alert.silence.matchers'), {
type: 'input', name: this.$t("alert.silence.matchers"),
label: 'matchers', type: "input",
disabled: false label: "matchers",
} disabled: false,
] },
],
}, },
// 导出相关 // 导出相关
importBox: { show: false, title: this.$t('overall.exportExcel') }, importBox: { show: false, title: this.$t("overall.exportExcel") },
deleteBox: { show: false, ids: '', remark: '', state: 2 }, deleteBox: { show: false, ids: "", remark: "", state: 2 },
// 创建修改相关 // 创建修改相关
blankObject: { blankObject: {
id: '', id: "",
startAt: '', startAt: "",
endAt: '', endAt: "",
ruleId: '', ruleId: "",
type: 'asset', type: "asset",
linkId: '', linkId: "",
remark: '', remark: "",
time: [], time: [],
matchers: [ matchers: [{ name: "", value: "", regex: 0 }],
{ name: '', value: '', regex: 0 } name: "",
],
name: ''
}, },
nowTime: '' nowTime: "",
} };
}, },
mounted () { mounted() {
this.initEvent() this.initEvent();
}, },
methods: { methods: {
closeRightBox (refresh) { queryMessage(alertRule) {
this.rightBox.show = false console.log(alertRule);
this.copyFlag = false this.$refs.dataList.showBottomBox('alertRuleAlertMessage', alertRule)
this.object = {} },
closeRightBox(refresh) {
this.rightBox.show = false;
this.copyFlag = false;
this.object = {};
if (refresh) { if (refresh) {
this.delFlag = true this.delFlag = true;
this.getTableData() this.getTableData();
} }
}, },
initEvent () { initEvent() {
bus.$on('alert-rule-list-change', () => { bus.$on("alert-rule-list-change", () => {
this.getTableData() this.getTableData();
}) });
bus.$on('dc-list-change', () => { bus.$on("dc-list-change", () => {
this.getTableData() this.getTableData();
}) });
bus.$on('alert-message-change', () => { bus.$on("alert-message-change", () => {
this.getTableData() this.getTableData();
}) });
}, },
exportCur () { exportCur() {
const searchLabel = Object.assign({}, this.searchLabel) const searchLabel = Object.assign({}, this.searchLabel);
this.$set(searchLabel, 'language', localStorage.getItem('nz-language') ? localStorage.getItem('nz-language') : 'en') this.$set(
this.exportExcel(searchLabel) searchLabel,
this.closeDialog() "language",
localStorage.getItem("nz-language")
? localStorage.getItem("nz-language")
: "en"
);
this.exportExcel(searchLabel);
this.closeDialog();
}, },
exportAll () { exportAll() {
const temp = JSON.parse(JSON.stringify(this.searchLabel)) const temp = JSON.parse(JSON.stringify(this.searchLabel));
temp.pageSize = -1 temp.pageSize = -1;
this.$set(temp, 'language', localStorage.getItem('nz-language') ? localStorage.getItem('nz-language') : 'en') this.$set(
this.exportExcel(temp) temp,
this.closeDialog() "language",
localStorage.getItem("nz-language")
? localStorage.getItem("nz-language")
: "en"
);
this.exportExcel(temp);
this.closeDialog();
}, },
closeDialog () { closeDialog() {
this.importBox.show = false this.importBox.show = false;
this.deleteBox.show = false this.deleteBox.show = false;
}, },
getTableData (params) { getTableData(params) {
if (params && Object.keys(params).length > 0) { if (params && Object.keys(params).length > 0) {
for (const key in params) { for (const key in params) {
this.$set(this.searchLabel, key, params[key]) this.$set(this.searchLabel, key, params[key]);
} }
} }
if (this.orderBy) { if (this.orderBy) {
this.$set(this.searchLabel, 'orderBy', this.orderBy) this.$set(this.searchLabel, "orderBy", this.orderBy);
} else { } else {
delete this.searchLabel.orderBy delete this.searchLabel.orderBy;
} }
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo) this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize) this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
this.tools.loading = true this.tools.loading = true;
const alertRuleParam = { const alertRuleParam = {
...this.searchLabel, ...this.searchLabel,
...this.searchCheckBox ...this.searchCheckBox,
} };
const path = this.fromRoute.alertSilence const path = this.fromRoute.alertSilence;
this.updatePath(alertRuleParam, path) this.updatePath(alertRuleParam, path);
this.$get(this.url, { ...this.searchLabel, ...this.searchCheckBox }).then(response => { this.$get(this.url, { ...this.searchLabel, ...this.searchCheckBox }).then(
this.tools.loading = false (response) => {
this.nowTime = this.utcTimeToTimezoneStr(response.time) this.tools.loading = false;
if (response.code === 200) { this.nowTime = this.utcTimeToTimezoneStr(response.time);
for (let i = 0; i < response.data.list.length; i++) { if (response.code === 200) {
response.data.list[i].status = response.data.list[i].status + '' for (let i = 0; i < response.data.list.length; i++) {
// response.data.list[i].startAt = bus.UTCTimeToConfigTimezone(response.data.list[i].startAt) response.data.list[i].status = response.data.list[i].status + "";
// response.data.list[i].endAt = bus.UTCTimeToConfigTimezone(response.data.list[i].endAt) // response.data.list[i].startAt = bus.UTCTimeToConfigTimezone(response.data.list[i].startAt)
} // response.data.list[i].endAt = bus.UTCTimeToConfigTimezone(response.data.list[i].endAt)
this.tableData = response.data.list }
this.pageObj.total = response.data.total this.tableData = response.data.list;
if (!this.scrollbarWrap && this.$refs.dataTable && this.$refs.dataTable.$refs.dataTable) { this.pageObj.total = response.data.total;
this.$nextTick(() => { if (
this.scrollbarWrap = this.$refs.dataTable.$refs.dataTable.bodyWrapper !this.scrollbarWrap &&
this.toTopBtnHandler(this.scrollbarWrap) this.$refs.dataTable &&
}) this.$refs.dataTable.$refs.dataTable
) {
this.$nextTick(() => {
this.scrollbarWrap =
this.$refs.dataTable.$refs.dataTable.bodyWrapper;
this.toTopBtnHandler(this.scrollbarWrap);
});
}
} }
} }
}) );
}, },
add () { add() {
this.blankObject.startAt = bus.getOffsetTimezoneData() this.blankObject.startAt = bus.getOffsetTimezoneData();
this.blankObject.endAt = bus.getOffsetTimezoneData(1) this.blankObject.endAt = bus.getOffsetTimezoneData(1);
this.object = JSON.parse(JSON.stringify(this.blankObject)) this.object = JSON.parse(JSON.stringify(this.blankObject));
this.rightBox.show = true this.rightBox.show = true;
}, },
edit (u, copyFlag) { edit(u, copyFlag) {
this.$get(`${this.url}/${u.id}`).then(response => { this.$get(`${this.url}/${u.id}`).then((response) => {
if (response.code === 200) { if (response.code === 200) {
this.object = { this.object = {
...response.data, ...response.data,
matchers: JSON.parse(response.data.matchers), matchers: JSON.parse(response.data.matchers),
startAt: bus.UTCTimeToConfigTimezone(response.data.startAt), startAt: bus.UTCTimeToConfigTimezone(response.data.startAt),
endAt: bus.UTCTimeToConfigTimezone(response.data.endAt) endAt: bus.UTCTimeToConfigTimezone(response.data.endAt),
} };
if (copyFlag) { if (copyFlag) {
this.object.id = '' this.object.id = "";
this.object.name = this.object.name + '-copy' this.object.name = this.object.name + "-copy";
if (this.object.name.length > 64) { if (this.object.name.length > 64) {
const length = this.object.name.length - 64 const length = this.object.name.length - 64;
this.object.name = u.name.substring(0, u.name.length - length) + '-copy' this.object.name =
u.name.substring(0, u.name.length - length) + "-copy";
} }
} }
this.rightBox.show = true this.rightBox.show = true;
} }
}) });
}, },
copy (u) { copy(u) {
this.edit(u, true) this.edit(u, true);
}, },
del (row) { del(row) {
this.$confirm(this.$t('tip.confirmExpired'), { this.$confirm(this.$t("tip.confirmExpired"), {
confirmButtonText: this.$t('tip.yes'), confirmButtonText: this.$t("tip.yes"),
cancelButtonText: this.$t('tip.no'), cancelButtonText: this.$t("tip.no"),
type: 'warning' type: "warning",
}).then(() => { }).then(() => {
this.$delete(this.url + '?ids=' + row.id + '&state=' + this.state).then(response => { this.$delete(this.url + "?ids=" + row.id + "&state=" + this.state).then(
if (response.code === 200) { (response) => {
this.delFlag = true if (response.code === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) this.delFlag = true;
this.getTableData() this.$message({
} else { duration: 2000,
this.$message.error(response.msg) type: "success",
message: this.$t("tip.deleteSuccess"),
});
this.getTableData();
} else {
this.$message.error(response.msg);
}
} }
}) );
}) });
} },
}, },
created () { created() {
const searchKeys = { const searchKeys = {
// key: path 键 // key: path 键
// value: vue set 参数 // value: vue set 参数
pageNo: { target: this.pageObj, propertyName: 'pageNo', type: 'number' }, pageNo: { target: this.pageObj, propertyName: "pageNo", type: "number" },
pageSize: { target: this.pageObj, propertyName: 'pageSize', type: 'number' }, pageSize: {
orderBy: { target: this.$data, propertyName: 'orderBy', type: 'string' }, target: this.pageObj,
propertyName: "pageSize",
type: "number",
},
orderBy: { target: this.$data, propertyName: "orderBy", type: "string" },
ids: { ids: {
target: this.searchLabel, target: this.searchLabel,
isSearchInput: true, isSearchInput: true,
propertyName: 'ids', propertyName: "ids",
type: 'string', type: "string",
defaultJson: { defaultJson: {
disabled: false, disabled: false,
id: 'ids', id: "ids",
label: 'ids', label: "ids",
name: 'ID', name: "ID",
type: 'input', type: "input",
val: '' val: "",
}, },
jsonKey: 'val' jsonKey: "val",
}, },
matchers: { matchers: {
target: this.searchLabel, target: this.searchLabel,
isSearchInput: true, isSearchInput: true,
propertyName: 'matchers', propertyName: "matchers",
type: 'string', type: "string",
defaultJson: { defaultJson: {
disabled: false, disabled: false,
label: 'matchers', label: "matchers",
name: 'Matcher', name: "Matcher",
type: 'input', type: "input",
val: '' val: "",
}, },
jsonKey: 'val' jsonKey: "val",
} },
} };
this.initQueryFromPath(searchKeys) this.initQueryFromPath(searchKeys);
} },
} };
</script> </script>