featfeat:修改bug,添加monmentjs处理时间

This commit is contained in:
xiongchengqiang 2020-05-22 09:57:26 +08:00
parent 64c19be5e5
commit 85fb4f3f9d
7 changed files with 74 additions and 42 deletions

View File

@ -26,6 +26,7 @@
"gulp-replace": "0.6.1", "gulp-replace": "0.6.1",
"gulp-shell": "0.6.5", "gulp-shell": "0.6.5",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"moment": "^2.26.0",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"npm": "^6.14.4", "npm": "^6.14.4",
"sass-loader": "6.0.6", "sass-loader": "6.0.6",

View File

@ -1,5 +1,7 @@
import Vue from 'vue' import Vue from 'vue'
import router from '@/router' import router from '@/router'
import moment from 'moment'
// import store from '@/store' // import store from '@/store'
/** /**
@ -56,3 +58,12 @@ export function clearLoginInfo () {
// store.commit('resetStore') // store.commit('resetStore')
router.options.isAddDynamicMenuRoutes = false router.options.isAddDynamicMenuRoutes = false
} }
/**
* 获取几个月前的数据
*/
export function getDataForMonth (mon = 0) {
let now = moment().format().split('T')[0]
let before = moment().add(-mon, 'M').format().split('T')[0]
return [before, now]
}

View File

@ -43,6 +43,11 @@
<span class="contant-name">{{info.jobBeginTime}}</span> <span class="contant-name">{{info.jobBeginTime}}</span>
</div> </div>
<div class="contant" v-if="info.companySeniority">
<span class="contant-label">司龄:</span>
<span class="contant-name">{{info.companySeniority}}</span>
</div>
<div class="contant" v-if="info.workExperience"> <div class="contant" v-if="info.workExperience">
<span class="contant-label">工作经历:</span> <span class="contant-label">工作经历:</span>
<span class="contant-name" v-html="info.workExperience" style="white-space: pre-wrap;"></span> <span class="contant-name" v-html="info.workExperience" style="white-space: pre-wrap;"></span>

View File

@ -22,7 +22,7 @@
<div class="block"> <div class="block">
<el-form :inline="true"> <el-form :inline="true">
<el-form-item label="员工姓名"> <el-form-item label="员工姓名">
<el-input clearable v-model="query.name" @keyup.enter.native="getTable"></el-input> <el-input clearable v-model="query.name" @keyup.enter.native="handleGetTable"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="人员状态"> <el-form-item label="人员状态">
<el-select v-model="query.staffStatus" placeholder="请选择"> <el-select v-model="query.staffStatus" placeholder="请选择">
@ -181,10 +181,11 @@ export default {
this.$message.error(result.msg) this.$message.error(result.msg)
} }
}, },
//
handleNodeClick (data) { handleNodeClick (data) {
// highlight - current // highlight - current
this.query.departmentId = data.departmentId this.query.departmentId = data.departmentId
this.handleGetTableList() this.handleGetTable()
}, },
// //
async handleGetMenuList () { async handleGetMenuList () {

View File

@ -13,7 +13,7 @@
<span class="staff-archives-bule">{{dataInfo.managementRate}}%</span> <span class="staff-archives-bule">{{dataInfo.managementRate}}%</span>
</div> </div>
<div class="staff-archives-content"> <div class="staff-archives-content">
<span class="staff-archives-yellow">近三个月</span>新入职员工 <span class="staff-archives-yellow" v-if="monthLetter.index">{{monthLetter.title}}</span>新入职员工
<span class="staff-archives-bule">{{dataInfo.newStaffCount}}</span>离职员工 <span class="staff-archives-bule">{{dataInfo.newStaffCount}}</span>离职员工
<span class="staff-archives-bule">{{dataInfo.leaveStaffCount}}</span>离职率为 <span class="staff-archives-bule">{{dataInfo.leaveStaffCount}}</span>离职率为
<span class="staff-archives-bule">{{dataInfo.leaveRate}}%</span> <span class="staff-archives-bule">{{dataInfo.leaveRate}}%</span>
@ -29,6 +29,12 @@ export default {
default: () => { default: () => {
return {} return {}
} }
},
monthLetter: {
type: Object,
default: () => {
return {}
}
} }
}, },
data () { data () {

View File

@ -22,8 +22,16 @@
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
@change="changeData" @change="changeData"
:picker-options="pickerOptions"
></el-date-picker> ></el-date-picker>
<div>
<el-button
v-for="i in Datalist"
:key="i.Month"
:type="index==i.Month?'primary':'info'"
size="mini"
@click="handleChangeData(i)"
>{{i.title}}</el-button>
</div>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button> <el-button type="primary" @click="onSubmit">查询</el-button>
@ -48,9 +56,25 @@
<script> <script>
import { apiOrganizationList } from '@/api/api_staff' import { apiOrganizationList } from '@/api/api_staff'
import { getDataForMonth } from '@/utils'
export default { export default {
data () { data () {
return { return {
Datalist: [{
Month: 1,
title: '近一个月'
}, {
Month: 3,
title: '近三个月'
}, {
Month: 6,
title: '近半年'
}, {
Month: 12,
title: '近一年'
}],
index: null,
title: null,
value2: [], value2: [],
isChooseObj: {}, isChooseObj: {},
isChoose: false, isChoose: false,
@ -61,41 +85,6 @@ export default {
}, },
formInline: { formInline: {
value: [] value: []
},
pickerOptions: {
shortcuts: [{
text: '最近一个月',
onClick (picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
}
}, {
text: '最近三个月',
onClick (picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
picker.$emit('pick', [start, end])
}
}, {
text: '最近半年',
onClick (picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 180)
picker.$emit('pick', [start, end])
}
}, {
text: '最近一年',
onClick (picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 360)
picker.$emit('pick', [start, end])
}
}]
} }
} }
}, },
@ -106,7 +95,17 @@ export default {
}, },
mounted () { }, mounted () { },
methods: { methods: {
handleChangeData (data) {
this.index = data.Month
this.title = data.title
let dataList = getDataForMonth(data.Month)
this.formInline.value = dataList
this.formInline.beginDate = data[0]
this.formInline.endDate = data[1]
},
changeData (data) { changeData (data) {
this.index = null
this.title = null
this.formInline.beginDate = data[0] this.formInline.beginDate = data[0]
this.formInline.endDate = data[1] this.formInline.endDate = data[1]
}, },
@ -120,11 +119,18 @@ export default {
departmentId: this.formInline.departmentId, departmentId: this.formInline.departmentId,
beginDate: this.formInline.beginDate, beginDate: this.formInline.beginDate,
endDate: this.formInline.endDate endDate: this.formInline.endDate
} }
this.$emit('submit', obj) let monthLetter = {
index: this.index,
title: this.title
}
this.$emit('submit', obj, monthLetter)
}, },
restValue () { restValue () {
this.formInline = {} this.formInline = {}
this.index = null
this.title = null
}, },
onsumbit () { onsumbit () {
this.formInline = Object.assign({}, this.formInline, this.isChooseObj) this.formInline = Object.assign({}, this.formInline, this.isChooseObj)

View File

@ -6,7 +6,7 @@
<query-form @submit="submit" /> <query-form @submit="submit" />
</el-card> </el-card>
<el-card> <el-card>
<employees-number :dataInfo="dataInfo" /> <employees-number :monthLetter="monthLetter" :dataInfo="dataInfo" />
</el-card> </el-card>
<div class="staff-archives-chart"> <div class="staff-archives-chart">
<el-card v-if="dataInfo.genderDistribution"> <el-card v-if="dataInfo.genderDistribution">
@ -41,6 +41,7 @@ export default {
}, },
data () { data () {
return { return {
monthLetter: {},
dataInfo: {} dataInfo: {}
} }
}, },
@ -71,7 +72,8 @@ export default {
async initData () { async initData () {
await this.handleGetEmployeessItuation() await this.handleGetEmployeessItuation()
}, },
submit (data) { submit (data, monthLetter) {
this.monthLetter = monthLetter
this.handleGetEmployeessItuation(data) this.handleGetEmployeessItuation(data)
} }
}, },