1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Optimize query blanks

This commit is contained in:
gzw
2023-06-06 23:31:00 +08:00
parent fbec78bd3a
commit 5eabfed153
2 changed files with 81 additions and 60 deletions

View File

@@ -51,6 +51,8 @@
</el-row> </el-row>
<el-table <el-table
v-loading="dataLoading"
element-loading-text="加载中..."
:data="tableData" :data="tableData"
border border
:header-cell-style="{ background: 'aliceblue' }" :header-cell-style="{ background: 'aliceblue' }"
@@ -153,7 +155,7 @@
</el-dialog> </el-dialog>
</template> </template>
<script lang="ts"> <script lang="ts">
import { SIZE_ICON_SM, SIZE_ICON_XL } from '@/constants/Common.constants.js' import { DATABASE_SELECT_OK, SIZE_ICON_SM, SIZE_ICON_XL } from '@/constants/Common.constants.js'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/el-message.css' import 'element-plus/theme-chalk/el-message.css'
@@ -185,7 +187,7 @@ export default {
attTime: '' attTime: ''
}, },
isDisabled: false, isDisabled: false,
dataLoading: true,
options: [ options: [
{ {
value: 1, value: 1,
@@ -226,22 +228,26 @@ export default {
.then((response) => { .then((response) => {
this.users = response.data.data this.users = response.data.data
}) })
.catch((reportError) => { .catch((reportError) => {})
console.log(reportError)
})
}, },
// 获取所有考勤信息 // 获取所有考勤信息
getAttendances() { getAttendances() {
this.dataLoading = true
request request
.get('/attendance/findAllAttendance') .get('/attendance/findAllAttendance')
.then((response) => { .then((response) => {
if (response.data.code === DATABASE_SELECT_OK) {
this.dataLoading = false
this.tableData = response.data.data this.tableData = response.data.data
}
}) })
.catch((reportError) => { .catch((reportError) => {
console.log(reportError) this.dataLoading = false
}) })
}, },
getAttendancesByTime() { getAttendancesByTime() {
this.dataLoading = true
if (this.attTime.length !== 0) {
const start = this.handleDateFormatUTC(this.attTime[0]) const start = this.handleDateFormatUTC(this.attTime[0])
const end = this.handleDateFormatUTC(this.attTime[1]) const end = this.handleDateFormatUTC(this.attTime[1])
request request
@@ -250,19 +256,25 @@ export default {
endTime: end endTime: end
}) })
.then((response) => { .then((response) => {
if (response.data.code === DATABASE_SELECT_OK) {
this.dataLoading = false
this.tableData = response.data.data this.tableData = response.data.data
ElMessage({ ElMessage({
message: '查询成功', message: '查询成功',
type: 'success' type: 'success'
}) })
}
}) })
.catch((reportError) => { .catch((reportError) => {
console.log(reportError) this.dataLoading = false
ElMessage({ ElMessage({
message: '查询失败', message: '查询失败',
type: 'error' type: 'error'
}) })
}) })
} else {
this.getAttendances()
}
}, },
handleDateFormatUTC(date) { handleDateFormatUTC(date) {
let newFormat = '' let newFormat = ''
@@ -303,12 +315,9 @@ export default {
request request
.post('/attendance/saveAttendance', formData) .post('/attendance/saveAttendance', formData)
.then((response) => { .then((response) => {
console.log(response)
this.getAttendances() this.getAttendances()
}) })
.catch((reportError) => { .catch((reportError) => {})
console.log(reportError)
})
}, },
// 获取更改数据 // 获取更改数据
viewUpdate(row) { viewUpdate(row) {
@@ -344,7 +353,6 @@ export default {
.delete('/attendance/delAttendance/' + id) .delete('/attendance/delAttendance/' + id)
.then((response) => { .then((response) => {
if (response) { if (response) {
console.log(response)
ElMessage({ ElMessage({
message: '删除成功', message: '删除成功',
type: 'success' type: 'success'
@@ -357,9 +365,7 @@ export default {
}) })
} }
}) })
.catch((reportError) => { .catch((reportError) => {})
console.log(reportError)
})
}, },
// 批量删除 // 批量删除
handleSelectionChange(val) { handleSelectionChange(val) {
@@ -384,9 +390,7 @@ export default {
}) })
} }
}) })
.catch((reportError) => { .catch((reportError) => {})
console.log(reportError)
})
} }
}, },
created() { created() {

View File

@@ -34,6 +34,8 @@
</el-row> </el-row>
<el-table <el-table
v-loading="dataLoading"
element-loading-text="加载中..."
:data="tableData" :data="tableData"
border border
:header-cell-style="{ background: 'aliceblue' }" :header-cell-style="{ background: 'aliceblue' }"
@@ -94,7 +96,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { SIZE_ICON_SM, SIZE_ICON_XL } from '@/constants/Common.constants.js' import { DATABASE_SELECT_OK, SIZE_ICON_SM, SIZE_ICON_XL } from '@/constants/Common.constants.js'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/el-message.css' import 'element-plus/theme-chalk/el-message.css'
import _ from 'lodash' import _ from 'lodash'
@@ -108,7 +110,7 @@ export default {
id: '', id: '',
userId: '', userId: '',
username: '', username: '',
attTime: '', attTime: [],
attTimeB: [], attTimeB: [],
status: '', status: '',
pageNum: 1, pageNum: 1,
@@ -116,6 +118,7 @@ export default {
total: 0, total: 0,
nowTime: new Date(), nowTime: new Date(),
formLabelWidth: '80px', formLabelWidth: '80px',
dataLoading: true,
value1: '', value1: '',
form: { form: {
userId: '', userId: '',
@@ -162,6 +165,8 @@ export default {
}, },
getOneAttendancesByTime() { getOneAttendancesByTime() {
this.dataLoading = true
if (this.attTimeB.length !== 0) {
const start = this.handleDateFormatUTC(this.attTimeB[0]) const start = this.handleDateFormatUTC(this.attTimeB[0])
const end = this.handleDateFormatUTC(this.attTimeB[1]) const end = this.handleDateFormatUTC(this.attTimeB[1])
request request
@@ -170,27 +175,39 @@ export default {
endTime: end endTime: end
}) })
.then((response) => { .then((response) => {
if (response.data.code === DATABASE_SELECT_OK) {
this.dataLoading = false
this.tableData = response.data.data this.tableData = response.data.data
ElMessage({ ElMessage({
message: '查询成功', message: '查询成功',
type: 'success' type: 'success'
}) })
}
}) })
.catch((reportError) => { .catch((reportError) => {
this.dataLoading = false
ElMessage({ ElMessage({
message: '查询失败', message: '查询失败',
type: 'error' type: 'error'
}) })
this.getAttendancesByUserId()
}) })
} else {
this.getAttendancesByUserId()
}
}, },
getAttendancesByUserId() { getAttendancesByUserId() {
this.dataLoading = true
request request
.get('/attendance/selectAttendance') .get('/attendance/selectAttendance')
.then((response) => { .then((response) => {
if (response.data.code === DATABASE_SELECT_OK) {
this.dataLoading = false
this.tableData = response.data.data this.tableData = response.data.data
}
})
.catch((reportError) => {
this.dataLoading = false
}) })
.catch((reportError) => {})
}, },
resetForm() { resetForm() {
this.$refs.form.resetFields() this.$refs.form.resetFields()