diff --git a/src/utils/DeviceManagementApi.js b/src/utils/DeviceManagementApi.js index 2506347d930a916d53afee2ce24ba4f915bfddc6..f66a33e3e5dfb3f03e486a43bc6b1dfb5da43bca 100644 --- a/src/utils/DeviceManagementApi.js +++ b/src/utils/DeviceManagementApi.js @@ -30,3 +30,12 @@ export function getConfigData() { export function getOperationLogs(query) { return postRequest('api/api/logs/all', query) } + +// 获取提醒设置信息 +export function getRemindInformation() { + return getRequest('api/api/configure/get/remind') +} + +export function updateRemind(query) { + return postRequest('api/api/configure/update/remind', query) +} diff --git a/src/utils/config.js b/src/utils/config.js index 9b06deefa156791489c9bdb76e029fd93f323937..1b55f6602927669be942e12e6e2ea8be2e149db7 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -1,6 +1,6 @@ module.exports = { - // baseUrl: 'localhost:2011' + baseUrl: 'localhost:2011' // baseUrl: '49.234.81.196:2011' // baseUrl: '192.168.0.100:2011' - baseUrl: '120.25.106.20:2011' + // baseUrl: '120.25.106.20:2011' } diff --git a/src/views/DataManagement/ReminderSettings.vue b/src/views/DataManagement/ReminderSettings.vue index c3191e46326c59a865af766da8eed81f02ecd60a..aaaa33afe0586c6dc2419ce8e495b5a934d87a79 100644 --- a/src/views/DataManagement/ReminderSettings.vue +++ b/src/views/DataManagement/ReminderSettings.vue @@ -14,14 +14,17 @@ @@ -30,14 +33,14 @@ v-for="(email, index) in dailyNewspaperForm.emails" :key="email.key" :label="'发送至邮箱' + (index+1)" - :prop="'emails.' + index + '.value'" + :prop="'emails.' + index" :rules="[ { required: true, message: '请输入邮箱地址', trigger: 'blur' }, { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] } ]" > @@ -66,26 +69,36 @@
- + + + + @@ -113,26 +126,44 @@
- + + + + @@ -164,9 +195,7 @@ import BreadCrumb from '@/components/BreadCrumb' import EmptyCard from '@/components/EmptyCard' -import { downloadExcel, getReportData } from '@/utils/api' -import fileDownload from 'js-file-download' - +import { getRemindInformation, updateRemind } from '../../utils/DeviceManagementApi' export default { components: { EmptyCard, @@ -176,22 +205,21 @@ export default { return { dailyNewspaperForm: { time: '', - emails: [{ - value: '' - }] + emails: [] }, + dailyNewspaperFormTemp: {}, policeForm: { - emails: [{ - value: '' - }], - fazhi: '' + emails: [], + police: '', + interval: '' }, + policeFormTemp: {}, utilizationRatioForm: { - number: '', - emails: [{ - value: '' - }] + inactivity: '', + emails: [], + inactivityTime: '' }, + utilizationRatioFormTemp: {}, inner: { title: '提醒设置' }, @@ -289,8 +317,11 @@ export default { multipleSelection: [] // 选中值 } }, - computed: {}, - watch: {}, + computed: { + }, + watch: { + + }, created() { }, @@ -339,10 +370,7 @@ export default { }, addDailyNewspaperFormEmail() { if (this.dailyNewspaperForm.emails.length < 2) { - this.dailyNewspaperForm.emails.push({ - value: '', - key: Date.now() - }) + this.dailyNewspaperForm.emails.push('') } else { this.$message({ message: '温馨提示:最多添加两个邮箱!', @@ -352,10 +380,7 @@ export default { }, addPoliceFormEmail() { if (this.policeForm.emails.length < 2) { - this.policeForm.emails.push({ - value: '', - key: Date.now() - }) + this.policeForm.emails.push('') } else { this.$message({ message: '温馨提示:最多添加两个邮箱!', @@ -365,10 +390,7 @@ export default { }, addUtilizationRatioFormEmail() { if (this.utilizationRatioForm.emails.length < 2) { - this.utilizationRatioForm.emails.push({ - value: '', - key: Date.now() - }) + this.utilizationRatioForm.emails.push('') } else { this.$message({ message: '温馨提示:最多添加两个邮箱!', @@ -379,41 +401,65 @@ export default { submitForm(formName) { this.$refs[formName].validate((valid) => { if (valid) { - alert('submit!') - } else { - console.log('error submit!!') - return false + if (formName === 'dailyNewspaperForm') { + const query = { + type: 'daily', + value: this.dailyNewspaperForm.time, + email: this.dailyNewspaperForm.emails + } + // 修改 + updateRemind(query).then() + } else if (formName === 'policeForm') { + const query = { + type: 'threshold', + value: this.policeForm.police, + email: this.policeForm.emails, + time: this.policeForm.interval + } + // 修改 + updateRemind(query).then() + } else if (formName === 'utilizationRatioForm') { + const query = { + type: 'Inactivity', + value: this.utilizationRatioForm.inactivity, + email: this.utilizationRatioForm.emails, + time: this.utilizationRatioForm.inactivityTime + } + // 修改 + updateRemind(query).then() + } } }) }, resetForm(formName) { - this.$refs[formName].resetFields() - }, - async getData() { - this.loading = true - if (this.searchFrom.endTime === null) { - this.searchFrom.endTime = '' - } - if (this.searchFrom.startTime === null) { - this.searchFrom.startTime = '' - } - try { - const { currentPage, pageSize } = this.pager - const query = { - pager: { currentPage, pageSize }, - searchObject: this.searchFrom + if (formName === 'dailyNewspaperForm') { + this.dailyNewspaperForm = { + time: '', + emails: [''] } - const res = await getReportData(query) - if (res.code === 200) { - this.pager.totalPage = JSON.parse(JSON.stringify(res.data.result.totalPage)) * 10 - this.tableData = res.data.result.tableData + } else if (formName === 'policeForm') { + this.policeForm = { + emails: [''], + police: '', + interval: '' + } + } else if (formName === 'utilizationRatioForm') { + this.utilizationRatioForm = { + inactivity: '', + emails: [''], + inactivityTime: '' } - } catch (err) { - this.$message.error(err.message) - } finally { - this.loading = false } }, + async getData() { + await getRemindInformation().then(resp => { + if (resp !== undefined && resp !== null) { + this.dailyNewspaperForm = resp.dailyNewspaperForm + this.policeForm = resp.policeForm + this.utilizationRatioForm = resp.utilizationRatioForm + } + }) + }, // 分页 change(val) { this.pager.currentPage = val @@ -428,31 +474,6 @@ export default { // 选择函数 handleSelectionChange(val) { this.multipleSelection = val - }, - async download() { - if (this.multipleSelection.length < 1) { - this.$message.warning('至少选择一项') - } else { - this.downloadLoading = true - const date = new Date() - const year = date.getFullYear() - const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 - const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() - try { - const Array = [] - this.multipleSelection.forEach(i => { - Array.push(i.id) - }) - const res = await downloadExcel(Array) - const time = year + '-' + month + '-' + day - fileDownload(res, `${time}.xlsx`) - } catch (err) { - console.log(err) - this.$message.error(err) - } finally { - this.downloadLoading = false - } - } } } }