mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added regex search in DepartmentManagement
This commit is contained in:
@@ -24,22 +24,35 @@
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="16">
|
||||
<el-input
|
||||
v-model="inputInput"
|
||||
class="fill-with"
|
||||
placeholder="请输入内容"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
>
|
||||
<template #prepend>
|
||||
<el-select v-model="selectedType" style="width: 100px">
|
||||
<el-option label="综合搜索" :value="0" />
|
||||
<el-option label="名称" :value="1" />
|
||||
<el-option label="电话" :value="2" />
|
||||
<el-option label="地址" :value="3" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-form-item :error="isRegexLegal ? '' : '非法正则表达式'">
|
||||
<el-input
|
||||
v-model="inputInput"
|
||||
class="fill-with"
|
||||
placeholder="请输入内容"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
@change="handleInputChange"
|
||||
>
|
||||
<template #prepend>
|
||||
<el-select v-model="selectedType" style="width: 100px">
|
||||
<el-option label="综合搜索" :value="0" />
|
||||
<el-option label="名称" :value="1" />
|
||||
<el-option label="电话" :value="2" />
|
||||
<el-option label="地址" :value="3" />
|
||||
</el-select>
|
||||
</template>
|
||||
<template #suffix>
|
||||
<el-tooltip content="正则表达式">
|
||||
<el-checkbox
|
||||
v-model="checkedRegex"
|
||||
label=".*"
|
||||
:true-label="1"
|
||||
@change="handleInputChange"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="-1">
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
@@ -141,7 +154,10 @@ export default {
|
||||
selectedType: 0,
|
||||
searchInput: '',
|
||||
inputInput: '',
|
||||
searchRegex: 0,
|
||||
checkedRegex: 0,
|
||||
currentPage: 1,
|
||||
isRegexLegal: true,
|
||||
pageSize: 50,
|
||||
totalCount: 0,
|
||||
departmentTable: [],
|
||||
@@ -164,13 +180,21 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
loadDepartmentTable() {
|
||||
if (!this.isRegexLegal) {
|
||||
ElMessage.error({
|
||||
dangerouslyUseHTMLString: true,
|
||||
message: '<strong>非法正则表达式</strong>,请重新输入'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.tableLoading = true
|
||||
request
|
||||
.get('/department', {
|
||||
currentPage: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
searchType: this.searchType,
|
||||
searchInput: this.searchInput
|
||||
searchInput: this.searchInput,
|
||||
searchRegex: this.searchRegex ?? 0
|
||||
})
|
||||
.then((res) => {
|
||||
const response = res.data
|
||||
@@ -300,13 +324,30 @@ export default {
|
||||
handleQuery() {
|
||||
this.searchType = _.cloneDeep(this.selectedType)
|
||||
this.searchInput = _.cloneDeep(this.inputInput)
|
||||
this.searchRegex = _.cloneDeep(this.checkedRegex)
|
||||
this.currentPage = 1
|
||||
this.handleInputChange()
|
||||
this.loadDepartmentTable()
|
||||
},
|
||||
handleClear() {
|
||||
this.selectedType = 0
|
||||
this.inputInput = ''
|
||||
this.checkedRegex = 0
|
||||
this.handleQuery()
|
||||
},
|
||||
handleInputChange() {
|
||||
if (this.checkedRegex) {
|
||||
try {
|
||||
RegExp(this.inputInput)
|
||||
this.isRegexLegal = !(
|
||||
this.inputInput.includes('{}') || this.inputInput.includes('[]')
|
||||
)
|
||||
} catch (e) {
|
||||
this.isRegexLegal = false
|
||||
}
|
||||
} else {
|
||||
this.isRegexLegal = true
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
Reference in New Issue
Block a user