|
|
@@ -15,14 +15,14 @@ |
|
|
|
:size="formSize" |
|
|
|
status-icon |
|
|
|
> |
|
|
|
<s-form-item label="推送设置:" prop="resource"> |
|
|
|
<s-radio-group v-model="ruleForm.resource" :options="pushOptions" /> |
|
|
|
<s-form-item label="推送设置:" prop="pushState"> |
|
|
|
<s-radio-group v-model="ruleForm.pushState" :options="pushOptions" /> |
|
|
|
</s-form-item> |
|
|
|
|
|
|
|
<div class="ruleTitle">推送规则</div> |
|
|
|
<div class="ruleContent"> |
|
|
|
<span>当日预警每达到</span> |
|
|
|
<el-input-number v-model="ruleForm.num" class="mx-4" :min="1" controls-position="right" @change="handleChange" /> |
|
|
|
<el-input-number v-model="ruleForm.daySum" class="mx-4" :min="1" controls-position="right" @change="handleChange" /> |
|
|
|
<span>条时进行推送</span> |
|
|
|
<div class="tips">当日预警数据每达到设置的条数后,会进行消息推送。</div> |
|
|
|
</div> |
|
|
@@ -35,32 +35,33 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="tsx" name="sysconfigPush"> |
|
|
|
import { reactive, ref } from 'vue' |
|
|
|
import { reactive, ref,onMounted } from 'vue' |
|
|
|
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
|
import { abilityApi, getPushInfo,userManageClassManageApi, monitorLIVEApi,SysOrg } from "@/api"; |
|
|
|
interface RuleForm { |
|
|
|
|
|
|
|
resource: string, |
|
|
|
num: number |
|
|
|
pushState: string | boolean, |
|
|
|
daySum: number |
|
|
|
} |
|
|
|
|
|
|
|
const formSize = ref<ComponentSize>('default') |
|
|
|
const ruleFormRef = ref<FormInstance>() |
|
|
|
const ruleForm = reactive<RuleForm>({ |
|
|
|
resource: '0', |
|
|
|
num: 1 |
|
|
|
pushState: false, |
|
|
|
daySum: 1 |
|
|
|
}) |
|
|
|
const pushOptions = [{ |
|
|
|
label: '开启', |
|
|
|
value: '1', |
|
|
|
value: true, |
|
|
|
},{ |
|
|
|
label: '关闭', |
|
|
|
value: '0', |
|
|
|
value: false, |
|
|
|
}] |
|
|
|
|
|
|
|
const rules = reactive<FormRules<RuleForm>>({ |
|
|
|
|
|
|
|
resource: [ |
|
|
|
pushState: [ |
|
|
|
{ |
|
|
|
required: true, |
|
|
|
message: '请选择推送设置', |
|
|
@@ -74,11 +75,20 @@ const handleChange = (value: number) => { |
|
|
|
function isPositiveInteger(value:any) { |
|
|
|
return /^[1-9]\d*$/.test(value); |
|
|
|
} |
|
|
|
onMounted(() => { |
|
|
|
getPushData() |
|
|
|
}); |
|
|
|
async function getPushData() { |
|
|
|
let {data} = await abilityApi.getPushInfo({}) |
|
|
|
ruleForm.daySum = data.daySum; |
|
|
|
ruleForm.pushState = data.pushState; |
|
|
|
console.log(data); |
|
|
|
} |
|
|
|
const submitForm = async (formEl: FormInstance | undefined) => { |
|
|
|
if (!formEl) return |
|
|
|
await formEl.validate((valid, fields) => { |
|
|
|
if (valid) { |
|
|
|
if(!isPositiveInteger(ruleForm.num)) { |
|
|
|
if(!isPositiveInteger(ruleForm.daySum)) { |
|
|
|
|
|
|
|
ElMessage({ |
|
|
|
message: '推送规则条数必须是大于零的整数', |
|
|
@@ -86,10 +96,15 @@ const submitForm = async (formEl: FormInstance | undefined) => { |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
ElMessage({ |
|
|
|
|
|
|
|
abilityApi.pushConfig(ruleForm).then(() => { |
|
|
|
ElMessage({ |
|
|
|
message: '操作成功', |
|
|
|
type: 'success', |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
console.log('submit!') |
|
|
|
} else { |
|
|
|
console.log('error submit!', fields) |
|
|
@@ -106,20 +121,19 @@ const resetForm = (formEl: FormInstance | undefined) => { |
|
|
|
<style lang="scss" scoped> |
|
|
|
.content-main { |
|
|
|
height: 100%; |
|
|
|
|
|
|
|
.ruleTitle { |
|
|
|
margin: 30px 0 20px; |
|
|
|
font-size: 14px; |
|
|
|
font-weight: 600; |
|
|
|
margin: 30px 0 20px 0; |
|
|
|
} |
|
|
|
.ruleContent { |
|
|
|
margin: 20px 0; |
|
|
|
font-size: 14px; |
|
|
|
color: #666666; |
|
|
|
margin: 20px 0; |
|
|
|
.tips { |
|
|
|
margin-top: 10px; |
|
|
|
font-size: 14px; |
|
|
|
color: red; |
|
|
|
margin-top: 10px; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|