feat: 优化 400请求的提示,优化tagsearch

This commit is contained in:
ibuler
2020-06-02 11:38:51 +08:00
parent 8d688ee2df
commit 69ceea5fc6
11 changed files with 43 additions and 23 deletions

View File

@@ -954,9 +954,13 @@ export default {
this.loading = false
})
},
search(attrs) {
search(attrs, reset) {
// Orange 重置查询对象
this.innerQuery = merge(this.innerQuery, attrs)
if (reset) {
this.innerQuery = merge({}, attrs)
} else {
this.innerQuery = merge(this.innerQuery, attrs)
}
return this.getList()
},
searchDate(attrs) {

View File

@@ -102,8 +102,8 @@ export default {
searchDate(attrs) {
return this.$refs.table.searchDate(attrs)
},
search(attrs) {
return this.$refs.table.search(attrs)
search(attrs, reset) {
return this.$refs.table.search(attrs, reset)
},
getQuery() {
return this.$refs.table.getQuery()

View File

@@ -94,7 +94,7 @@ export default {
this.$axios.put(
this.upLoadUrl,
item.file,
{ headers: { 'Content-Type': 'text/csv' }, disableFlashMsg: true }
{ headers: { 'Content-Type': 'text/csv' }, disableFlashErrorMsg: true }
).then((data) => {
const msg = this.$t('common.imExport.updateSuccessMsg', { count: data.length })
this.onSuccess(msg)
@@ -106,7 +106,7 @@ export default {
this.$axios.post(
this.upLoadUrl,
item.file,
{ headers: { 'Content-Type': 'text/csv' }, disableFlashMsg: true }
{ headers: { 'Content-Type': 'text/csv' }, disableFlashErrorMsg: true }
).then((data) => {
const msg = this.$t('common.imExport.createSuccessMsg', { count: data.length })
this.onSuccess(msg)

View File

@@ -9,7 +9,6 @@
import ActionsGroup from '@/components/ActionsGroup'
import DialogAction from './ImExportDialog'
import { cleanActions } from './utils'
import _ from 'lodash'
const defaultTrue = { type: Boolean, default: true }
@@ -65,9 +64,6 @@ export default {
}
},
methods: {
handleSearch: _.debounce(function() {
this.searchTable({ search: this.keyword })
}, 500),
handleTagSearch(val) {
this.searchTable(val)
},

View File

@@ -58,10 +58,9 @@ export default {
this.dataTable.getList()
},
search(attrs) {
return this.dataTable.search(attrs)
return this.dataTable.search(attrs, true)
},
handleDateChange(attrs) {
console.log(attrs)
this.iTableConfig.extraQuery = {
date_from: attrs[0],
date_to: attrs[1]

View File

@@ -63,9 +63,9 @@ export default {
watch: {
filterTags: {
handler(val) {
if (val) {
this.$emit('tagSearch', this.filterMaps)
}
console.log(this.filterTags)
this.$nextTick(() => this.$emit('tagSearch', this.filterMaps))
// this.$emit('tagSearch', this.filterMaps)
},
deep: true
}

View File

@@ -133,6 +133,7 @@
},
"common": {
"CrontabHelpTips": "eg每周日 03:05 执行 <5 3 * * 0> <br> 提示: 使用5位 Linux crontab 表达式 <分 时 日 月 星期> <a href='https://tool.lu/crontab/' target='_blank'>在线工具</a> <br>注意: 如果同时设置了定期执行和周期执行,优先使用定期执行",
"BadRequestErrorMsg": "请求错误,请检查填写内容",
"Action": "动作",
"Actions": "操作",
"Activate": "激活",

View File

@@ -132,6 +132,7 @@
},
"common": {
"CrontabHelpTips": "eg: Every Sunday 03:05 run <5 3 * * 0> <br>Tips:Using 5 digits linux crontab expressions<min hour day month week> (<a href='https://tool.lu/crontab/' target='_blank'>Online tools</a>) <br>Note:If both Regularly perform and Cycle perform are set,give priority to Regularly perform",
"BadRequestErrorMsg" : "Bad request, please check again",
"Action": "Action",
"Actions": "Actions",
"Activate": "Activate",

View File

@@ -65,10 +65,22 @@ function ifUnauthorized({ response, error }) {
}
}
function ifBadRequest({ response, error }) {
console.log(response)
if (response.status === 400) {
error.message = i18n.t('common.BadRequestErrorMsg')
}
}
function flashErrorMsg({ response, error }) {
if (!response.config.disableFlashMsg) {
if (!response.config.disableFlashErrorMsg) {
let msg = error.message
const data = response.data
if (data && (data.error || data.msg)) {
msg = data.error || data.msg
}
Message({
message: error.message,
message: msg,
type: 'error',
duration: 5 * 1000
})
@@ -102,6 +114,7 @@ service.interceptors.response.use(
const response = error.response
ifUnauthorized({ response, error })
ifBadRequest({ response, error })
flashErrorMsg({ response, error })
return Promise.reject(error)
}

View File

@@ -20,7 +20,7 @@ export default {
showOverflowTooltip: true
},
ip: {
width: '130px'
width: '140px'
},
status: {
width: '80px'

View File

@@ -15,13 +15,19 @@ export default {
url: '/api/v1/audits/operate-logs/',
columns: ['user', 'action', 'resource_type', 'resource', 'remote_addr', 'datetime'],
columnsMeta: {
},
hasSelection: false
datetime: {
width: '160px'
},
remote_addr: {
width: '140px'
},
action: {
width: '90px'
}
}
},
headerActions: {
hasSelection: false,
hasCreate: false,
hasBulkDelete: false,
hasLeftActions: false,
hasImport: false,
hasRefresh: false
}