clean app build/release data.

This commit is contained in:
lijiahang
2022-05-27 08:47:23 +08:00
parent 2cca790d97
commit 33015c7898
4 changed files with 400 additions and 8 deletions
@@ -0,0 +1,180 @@
<template>
<a-modal v-model="visible"
title="应用构建 清理"
okText="清理"
:width="400"
:okButtonProps="{props: {disabled: loading}}"
:maskClosable="false"
:destroyOnClose="true"
@ok="clear"
@cancel="close">
<a-spin :spinning="loading">
<div class="data-clear-container">
<!-- 清理区间 -->
<div class="data-clear-range">
<a-radio-group class="nowrap" v-model="submit.range">
<a-radio-button :value="$enum.DATA_CLEAR_RANGE.DAY.value">保留天数</a-radio-button>
<a-radio-button :value="$enum.DATA_CLEAR_RANGE.TOTAL.value">保留条数</a-radio-button>
<a-radio-button :value="$enum.DATA_CLEAR_RANGE.REL_ID.value">清理应用</a-radio-button>
</a-radio-group>
</div>
<!-- 清理参数 -->
<div class="data-clear-params">
<div class="data-clear-param" v-if="$enum.DATA_CLEAR_RANGE.DAY.value === submit.range">
<span class="normal-label clear-label">保留天数</span>
<a-input-number class="param-input"
v-model="submit.reserveDay"
:min="0"
:max="9999"
placeholder="清理后数据所保留的天数"/>
</div>
<div class="data-clear-param" v-if="$enum.DATA_CLEAR_RANGE.TOTAL.value === submit.range">
<span class="normal-label clear-label">保留条数</span>
<a-input-number class="param-input"
v-model="submit.reserveTotal"
:min="0"
:max="9999"
placeholder="清理后数据所保留的条数"/>
</div>
<div class="data-clear-param" v-if="$enum.DATA_CLEAR_RANGE.REL_ID.value === submit.range">
<span class="normal-label clear-label">清理应用</span>
<AppSelector class="param-input"
placeholder="请选择清理的应用"
@change="(e) => submit.relIdList[0] = e"/>
</div>
</div>
<!-- 执行用户 -->
<div class="choose-param-wrapper">
<span class="normal-label clear-label">执行用户</span>
<a-checkbox class="param-input" v-model="iCreated">只清理我执行的</a-checkbox>
</div>
</div>
</a-spin>
</a-modal>
</template>
<script>
import _enum from '@/lib/enum'
import AppSelector from '@/components/app/AppSelector'
export default {
name: 'AppBuildClearModal',
components: {
AppSelector
},
data: function() {
return {
visible: false,
loading: false,
iCreated: true,
submit: {
profileId: null,
reserveDay: null,
reserveTotal: null,
relIdList: [],
range: _enum.DATA_CLEAR_RANGE.DAY.value
}
}
},
methods: {
open(profileId) {
this.submit.profileId = profileId
this.iCreated = true
this.submit.reserveDay = null
this.submit.reserveTotal = null
this.submit.relIdList = []
this.submit.range = this.$enum.DATA_CLEAR_RANGE.DAY.value
this.loading = false
this.visible = true
},
clear() {
if (!this.submit.profileId) {
this.$message.warning('请选择需要清理的环境')
return
}
if (this.submit.range === this.$enum.DATA_CLEAR_RANGE.DAY.value) {
if (this.submit.reserveDay === null) {
this.$message.warning('请输入需要保留的天数')
return
}
} else if (this.submit.range === this.$enum.DATA_CLEAR_RANGE.TOTAL.value) {
if (this.submit.reserveTotal === null) {
this.$message.warning('请输入需要保留的条数')
return
}
} else if (this.submit.range === this.$enum.DATA_CLEAR_RANGE.REL_ID.value) {
if (!this.submit.relIdList.length) {
this.$message.warning('请选择需要清理的应用')
return
}
} else {
return
}
this.$confirm({
title: '确认清理',
content: '清理后数据将无法恢复, 确定要清理吗?',
mask: false,
okText: '确认',
okType: 'danger',
cancelText: '取消',
onOk: () => {
this.doClear()
}
})
},
doClear() {
this.loading = true
this.$api.clearAppBuild({
...this.submit,
iCreated: this.iCreated ? 1 : 2
}).then(({ data }) => {
this.loading = false
this.visible = false
this.$emit('clear')
this.$message.info(`共清理 ${data}条数据`)
}).catch(() => {
this.loading = false
this.$message.error('清理失败')
})
},
close() {
this.visible = false
this.loading = false
}
}
}
</script>
<style lang="less" scoped>
.data-clear-container {
width: 100%;
}
.data-clear-range {
margin-bottom: 24px;
display: flex;
justify-content: center;
}
.clear-label {
width: 64px;
text-align: end;
}
.data-clear-param {
width: 100%;
display: flex;
align-items: center;
}
.param-input {
margin-left: 8px;
width: 236px;
}
.choose-param-wrapper {
margin-top: 12px;
}
</style>
@@ -0,0 +1,196 @@
<template>
<a-modal v-model="visible"
title="应用发布 清理"
okText="清理"
:width="400"
:okButtonProps="{props: {disabled: loading}}"
:maskClosable="false"
:destroyOnClose="true"
@ok="clear"
@cancel="close">
<a-spin :spinning="loading">
<div class="data-clear-container">
<!-- 清理区间 -->
<div class="data-clear-range">
<a-radio-group class="nowrap" v-model="submit.range">
<a-radio-button :value="$enum.DATA_CLEAR_RANGE.DAY.value">保留天数</a-radio-button>
<a-radio-button :value="$enum.DATA_CLEAR_RANGE.TOTAL.value">保留条数</a-radio-button>
<a-radio-button :value="$enum.DATA_CLEAR_RANGE.REL_ID.value">清理应用</a-radio-button>
</a-radio-group>
</div>
<!-- 清理参数 -->
<div class="data-clear-params">
<div class="data-clear-param" v-if="$enum.DATA_CLEAR_RANGE.DAY.value === submit.range">
<span class="normal-label clear-label">保留天数</span>
<a-input-number class="param-input"
v-model="submit.reserveDay"
:min="0"
:max="9999"
placeholder="清理后数据所保留的天数"/>
</div>
<div class="data-clear-param" v-if="$enum.DATA_CLEAR_RANGE.TOTAL.value === submit.range">
<span class="normal-label clear-label">保留条数</span>
<a-input-number class="param-input"
v-model="submit.reserveTotal"
:min="0"
:max="9999"
placeholder="清理后数据所保留的条数"/>
</div>
<div class="data-clear-param" v-if="$enum.DATA_CLEAR_RANGE.REL_ID.value === submit.range">
<span class="normal-label clear-label">清理应用</span>
<AppSelector class="param-input"
placeholder="请选择清理的应用"
@change="(e) => submit.relIdList[0] = e"/>
</div>
</div>
<!-- 创建用户 -->
<div class="choose-param-wrapper">
<span class="normal-label clear-label">创建用户</span>
<a-checkbox class="param-input" v-model="iCreated">只清理我创建的</a-checkbox>
</div>
<!-- 执行用户 -->
<div class="choose-param-wrapper">
<span class="normal-label clear-label">审核用户</span>
<a-checkbox class="param-input" v-model="iAudited">只清理我审核的</a-checkbox>
</div>
<!-- 执行用户 -->
<div class="choose-param-wrapper">
<span class="normal-label clear-label">执行用户</span>
<a-checkbox class="param-input" v-model="iExecute">只清理我执行的</a-checkbox>
</div>
</div>
</a-spin>
</a-modal>
</template>
<script>
import _enum from '@/lib/enum'
import AppSelector from '@/components/app/AppSelector'
export default {
name: 'AppReleaseClearModal',
components: {
AppSelector
},
data: function() {
return {
visible: false,
loading: false,
iCreated: true,
iAudited: false,
iExecute: false,
submit: {
profileId: null,
reserveDay: null,
reserveTotal: null,
relIdList: [],
range: _enum.DATA_CLEAR_RANGE.DAY.value
}
}
},
methods: {
open(profileId) {
this.submit.profileId = profileId
this.iCreated = true
this.iAudited = false
this.iExecute = false
this.submit.reserveDay = null
this.submit.reserveTotal = null
this.submit.relIdList = []
this.submit.range = this.$enum.DATA_CLEAR_RANGE.DAY.value
this.loading = false
this.visible = true
},
clear() {
if (!this.submit.profileId) {
this.$message.warning('请选择需要清理的环境')
return
}
if (this.submit.range === this.$enum.DATA_CLEAR_RANGE.DAY.value) {
if (this.submit.reserveDay === null) {
this.$message.warning('请输入需要保留的天数')
return
}
} else if (this.submit.range === this.$enum.DATA_CLEAR_RANGE.TOTAL.value) {
if (this.submit.reserveTotal === null) {
this.$message.warning('请输入需要保留的条数')
return
}
} else if (this.submit.range === this.$enum.DATA_CLEAR_RANGE.REL_ID.value) {
if (!this.submit.relIdList.length) {
this.$message.warning('请选择需要清理的应用')
return
}
} else {
return
}
this.$confirm({
title: '确认清理',
content: '清理后数据将无法恢复, 确定要清理吗?',
mask: false,
okText: '确认',
okType: 'danger',
cancelText: '取消',
onOk: () => {
this.doClear()
}
})
},
doClear() {
this.loading = true
this.$api.clearAppRelease({
...this.submit,
iCreated: this.iCreated ? 1 : 2,
iAudited: this.iAudited ? 1 : 2,
iExecute: this.iExecute ? 1 : 2
}).then(({ data }) => {
this.loading = false
this.visible = false
this.$emit('clear')
this.$message.info(`共清理 ${data}条数据`)
}).catch(() => {
this.loading = false
this.$message.error('清理失败')
})
},
close() {
this.visible = false
this.loading = false
}
}
}
</script>
<style lang="less" scoped>
.data-clear-container {
width: 100%;
}
.data-clear-range {
margin-bottom: 24px;
display: flex;
justify-content: center;
}
.clear-label {
width: 64px;
text-align: end;
}
.data-clear-param {
width: 100%;
display: flex;
align-items: center;
}
.param-input {
margin-left: 8px;
width: 236px;
}
.choose-param-wrapper {
margin-top: 12px;
}
</style>
+16 -8
View File
@@ -56,6 +56,7 @@
<div class="tools-fixed-right">
<a-button v-if="query.profileId" class="ml16 mr8" type="primary" icon="build" @click="openBuild">构建应用</a-button>
<a-divider type="vertical"/>
<a-icon type="delete" class="tools-icon" title="清理" @click="openClear"/>
<a-icon type="search" class="tools-icon" title="查询" @click="getList({})"/>
<a-icon type="reload" class="tools-icon" title="重置" @click="resetForm"/>
</div>
@@ -154,6 +155,8 @@
<AppBuildDetailDrawer ref="detail"/>
<!-- 日志模态框 -->
<AppBuildLogAppenderModal ref="logView"/>
<!-- 清理模态框 -->
<AppBuildClearModal ref="clear" @clear="getList({})"/>
</div>
</div>
</template>
@@ -165,6 +168,7 @@ import AppBuildModal from '@/components/app/AppBuildModal'
import AppBuildLogAppenderModal from '@/components/log/AppBuildLogAppenderModal'
import _filters from '@/lib/filters'
import _enum from '@/lib/enum'
import AppBuildClearModal from '@/components/clear/AppBuildClearModal'
/**
* 状态判断
@@ -246,6 +250,7 @@ const columns = [
export default {
name: 'AppBuild',
components: {
AppBuildClearModal,
AppBuildLogAppenderModal,
AppBuildModal,
AppSelector,
@@ -345,14 +350,6 @@ export default {
this.getList({})
})
},
resetForm() {
this.$refs.query.resetFields()
this.$refs.appSelector.reset()
this.query.appId = undefined
this.query.status = undefined
this.query.onlyMyself = false
this.getList({})
},
openLogView(e, id) {
if (!e.ctrlKey) {
e.preventDefault()
@@ -364,6 +361,17 @@ export default {
return true
}
},
openClear() {
this.$refs.clear.open(this.query.profileId)
},
resetForm() {
this.$refs.query.resetFields()
this.$refs.appSelector.reset()
this.query.appId = undefined
this.query.status = undefined
this.query.onlyMyself = false
this.getList({})
},
pollStatus() {
if (!this.rows || !this.rows.length) {
return
@@ -56,6 +56,7 @@
<div class="tools-fixed-right">
<a-button v-if="query.profileId" class="ml16 mr8" type="primary" icon="deployment-unit" @click="openRelease">应用发布</a-button>
<a-divider type="vertical"/>
<a-icon type="delete" class="tools-icon" title="清理" @click="openClear"/>
<a-icon type="search" class="tools-icon" title="查询" @click="getList({})"/>
<a-icon type="reload" class="tools-icon" title="重置" @click="resetForm"/>
</div>
@@ -257,6 +258,8 @@
<AppReleaseMachineLogAppenderModal ref="machineAppender"/>
<!-- 定时模态框 -->
<AppReleaseTimedModal ref="releaseTimed" @updated="forceUpdateRows"/>
<!-- 清理模态框 -->
<AppReleaseClearModal ref="clear" @clear="getList({})"/>
</div>
</div>
</template>
@@ -271,6 +274,7 @@ import AppReleaseMachineDetailDrawer from '@/components/app/AppReleaseMachineDet
import AppReleaseMachineLogAppenderModal from '@/components/log/AppReleaseMachineLogAppenderModal'
import _filters from '@/lib/filters'
import AppReleaseLogAppenderModal from '@/components/log/AppReleaseLogAppenderModal'
import AppReleaseClearModal from '@/components/clear/AppReleaseClearModal'
function statusHolder() {
return {
@@ -433,6 +437,7 @@ const innerColumns = [
export default {
name: 'AppRelease',
components: {
AppReleaseClearModal,
AppReleaseLogAppenderModal,
AppReleaseTimedModal,
AppReleaseMachineLogAppenderModal,
@@ -639,6 +644,9 @@ export default {
this.$message.success('已跳过')
})
},
openClear() {
this.$refs.clear.open(this.query.profileId)
},
resetForm() {
this.$refs.query.resetFields()
this.$refs.appSelector.reset()