Browse Source

【治理排行-网格建设打分】后台管理开发-王公峰-2020-06-16

master
wanggongfeng 5 years ago
parent
commit
d2b467b3aa
  1. 199
      src/views/modules/kpi/kpicommunitybuilding-add-or-update.vue
  2. 207
      src/views/modules/kpi/kpicommunitybuilding.vue

199
src/views/modules/kpi/kpicommunitybuilding-add-or-update.vue

@ -0,0 +1,199 @@
<template>
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'">
<el-form-item label="部门名称" prop="deptId" label-width="120px">
<el-cascader
ref="name"
v-model="dataForm.joinDeptIdsArr"
:options="options"
:props="{ multiple: false, emitPath: false, checkStrictly: true }"
@visible-change="changeHandle"
style="width:80%;"
:disabled="dataForm.id?true:false"
>
</el-cascader>
</el-form-item>
<el-form-item label="考核年月" prop="monthYear" label-width="120px">
<el-date-picker v-model="dataForm.monthYear" :disabled="dataForm.id?true:false"
type="month" clearable placeholder="选择月"
value-format="yyyy-MM" format="yyyy-MM">
</el-date-picker>
</el-form-item>
<el-form-item label="民主协商机制" prop="democraticConsultationMechanism" label-width="120px">
<el-input-number v-model="dataForm.democraticConsultationMechanism" :min="0" :max="3" label="民主协商机制分数" :precision="1"></el-input-number>
</el-form-item>
<el-form-item label="居民公约制度" prop="residentConventionSystem" label-width="120px">
<el-input-number v-model="dataForm.residentConventionSystem" :min="0" :max="3" label="居民公约制度分数" :precision="1"></el-input-number>
</el-form-item>
<el-form-item label="网格协商案例" prop="gridNegotiationCase" label-width="120px">
<el-input-number v-model="dataForm.gridNegotiationCase" :min="0" :max="4" label="网格协商案例分数" :precision="1"></el-input-number>
</el-form-item>
</el-form>
<template slot="footer">
<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
<el-button type="primary" :disabled="isAble" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
</template>
</el-dialog>
</template>
<script>
import debounce from 'lodash/debounce'
export default {
data () {
return {
visible: false,
dataForm: {
id: '',
deptId: '',
deptName: '',
deptTypeKey: '',
monthYear: '',
democraticConsultationMechanism: '',
residentConventionSystem: '',
gridNegotiationCase: '',
parentDeptIds: '',
parentDeptNames: '',
allDeptIds: '',
allDeptNames: '',
revision: '',
createdBy: '',
createdTime: '',
updatedBy: '',
updatedTime: '',
delFlag: '',
joinDeptIdsArr: ''
},
options: [],
isAble: false
}
},
computed: {
dataRule () {
return {
deptId: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
deptName: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
deptTypeKey: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
monthYear: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
democraticConsultationMechanism: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
residentConventionSystem: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
gridNegotiationCase: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
joinDeptIdsArr: [
{ required: false, message: this.$t('validate.required'), trigger: 'blur' }
]
}
}
},
created: function () {
this.getOptions()
},
methods: {
init () {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.getInfo()
}
})
},
getOptions () {
this.$http
.get(`/sys/user/deptOptions/getDeptAuthByUser`)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.options = res.data.options
})
.catch(() => {})
},
changeHandle (value, selectedData) {
let parentDeptIds = ''
let parentDeptNames = ''
let allDeptIds = ''
let allDeptNames = ''
let deptId = ''
let deptName = ''
if (this.$refs['name'].getCheckedNodes() !== null && this.$refs['name'].getCheckedNodes().length > 0) {
var path = this.$refs['name'].getCheckedNodes()[0].path
var pathLabels = this.$refs['name'].getCheckedNodes()[0].pathLabels
for (var i = 0; i < path.length; i++) {
if (i < path.length - 1) {
parentDeptIds += path[i] + ','
} else {
deptId = path[i]
}
allDeptIds += path[i] + ','
}
for (var j = 0; j < pathLabels.length; j++) {
if (j < pathLabels.length - 1) {
parentDeptNames += pathLabels[j] + '-'
} else {
deptName = pathLabels[j]
}
allDeptNames += pathLabels[j] + '-'
}
}
this.dataForm.parentDeptIds = parentDeptIds.length > 0 ? parentDeptIds.substring(0, parentDeptIds.length - 1) : parentDeptIds
this.dataForm.parentDeptNames = parentDeptNames.length > 0 ? parentDeptNames.substring(0, parentDeptNames.length - 1) : parentDeptNames
this.dataForm.allDeptIds = allDeptIds.length > 0 ? allDeptIds.substring(0, allDeptIds.length - 1) : allDeptIds
this.dataForm.allDeptNames = allDeptNames.length > 0 ? allDeptNames.substring(0, allDeptNames.length - 1) : allDeptNames
this.dataForm.deptId = deptId
this.dataForm.deptName = deptName
},
//
getInfo () {
this.$http.get(`/kpi/kpicommunitybuilding/${this.dataForm.id}`).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.dataForm = {
...this.dataForm,
...res.data
}
}).catch(() => {})
},
//
dataFormSubmitHandle: debounce(function () {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false
}
this.isAble = true
this.$http[!this.dataForm.id ? 'post' : 'put']('/kpi/kpicommunitybuilding/', this.dataForm).then(({ data: res }) => {
if (res.code !== 0) {
this.isAble = false
return this.$message.error(res.msg)
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.isAble = false
this.dataForm.joinDeptIdsArr = ''
this.dataForm.deptId = ''
this.visible = false
this.$emit('refreshDataList')
}
})
}).catch(() => {})
})
}, 1000, { 'leading': true, 'trailing': false })
}
}
</script>

207
src/views/modules/kpi/kpicommunitybuilding.vue

@ -0,0 +1,207 @@
<template>
<el-card shadow="never" class="aui-card--fill">
<div class="mod-kpi__kpicommunitybuilding}">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-form-item label="部门">
<el-cascader
v-model="deptIdList"
:options="options"
:props="{ checkStrictly: true }"
filterable
clearable
></el-cascader>
</el-form-item>
</el-form-item>
<el-form-item label="考核周期起始月">
<el-date-picker v-model="dataForm.monthYear"
type="month" clearable placeholder="选择月"
value-format="yyyy-MM" format="yyyy-MM">
</el-date-picker>
</el-form-item>
<el-form-item label="部门类型" prop="deptTypeKey">
<el-select v-model="dataForm.deptTypeKey" placeholder="部门类型" clearable>
<el-option v-for="item in paramNameArr" :key="item.dictValue" :label="item.dictName" :value="item.dictValue" ></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">{{ $t('query') }}</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
</el-form-item>
<el-form-item>
<el-button type="info" @click="exportTemplate()">导出录入模板</el-button>
</el-form-item>
<el-form-item>
<el-upload class="upload-demo"
ref="upload"
v-loading="dataListLoading"
:action="uploadUrl"
:limit="1"
:on-success='uploadSuccess'
:on-error='errorExceed'
accept=".xls,.xlsx">
<el-button type="primary">导入打分结果</el-button>
</el-upload>
</el-form-item>
<el-form-item>
<el-button v-if="$hasPermission('kpi:kpicommunitybuilding:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
</el-form-item>
</el-form>
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
<el-table-column label="序号" header-align="center" align="center" width="50px">
<template slot-scope="scope">
{{scope.$index+1}}
</template>
</el-table-column>
<el-table-column prop="deptName" label="部门" header-align="center" align="center"></el-table-column>
<el-table-column prop="monthYear" label="年月" header-align="center" align="center"></el-table-column>
<el-table-column prop="democraticConsultationMechanism" label="民主协商机制分数" header-align="center" align="center"></el-table-column>
<el-table-column prop="residentConventionSystem" label="居民公约制度分数" header-align="center" align="center"></el-table-column>
<el-table-column prop="gridNegotiationCase" label="网格协商案例分数" header-align="center" align="center"></el-table-column>
<el-table-column prop="parentDeptNames" label="上级部门" header-align="center" align="center"></el-table-column>
<el-table-column prop="allDeptNames" label="所有部门" header-align="center" align="center"></el-table-column>
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
<el-button v-if="$hasPermission('kpi:kpicommunitybuilding:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="limit"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="pageSizeChangeHandle"
@current-change="pageCurrentChangeHandle">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</el-card>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './kpicommunitybuilding-add-or-update'
import Cookies from 'js-cookie'
import qs from 'qs'
export default {
mixins: [mixinViewModule],
data () {
return {
mixinViewModuleOptions: {
getDataListURL: '/kpi/kpicommunitybuilding/page',
getDataListIsPage: true,
deleteURL: '/kpi/kpicommunitybuilding',
deleteIsBatch: true,
exportTemplateURL: '/kpi/kpicommunitybuilding/exportTemplate'
},
dataForm: {
id: '',
deptTypeKey: '',
monthYear: '',
deptId: ''
},
//
deptIdList: [],
options: [],
paramNameArr: []
}
},
components: {
AddOrUpdate
},
watch: {
'deptIdList': function (val) {
if (val.length === 0) {
this.dataForm.deptId = ''
} else if (val.length > 0) {
this.dataForm.deptId = this.deptIdList[val.length - 1]
}
}
},
created: function () {
this.getOptions()
this.getParamListInfo('dept_type')
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/kpi/kpicommunitybuilding/importManualScoreExcel?token=${Cookies.get('token')}`
},
methods: {
getOptions () {
this.$http
.get(`/sys/user/deptOptions/getDeptAuthByUser`)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.options = res.data.options
})
.catch(() => {})
},
// code
getParamListInfo (dictType) {
this.$http.get(`/sys/dict/listSimple/` + dictType).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
if (dictType === 'dept_type') {
this.paramNameArr = res.data
}
}).catch(() => {})
},
exportTemplate () {
let remindInfo = ''
let monthYear = this.dataForm.monthYear
let deptTypeKey = this.dataForm.deptTypeKey
let deptId = this.dataForm.deptId
if (!deptId) {
remindInfo += '部门、'
}
if (!monthYear) {
remindInfo += '考核周期起始月、'
}
if (!deptTypeKey) {
remindInfo += '部门类型、'
}
if (remindInfo.length > 0) {
remindInfo = remindInfo.substring(0, remindInfo.length - 1)
return this.$message.error(remindInfo + '不能为空!')
}
let params = qs.stringify({
'token': Cookies.get('token'),
'monthYear': monthYear,
'deptTypeKey': deptTypeKey,
'deptId': deptId
})
window.location.href = `${window.SITE_CONFIG['apiURL']}${this.mixinViewModuleOptions.exportTemplateURL}?${params}`
},
errorExceed (file, fileList) {
this.$message.error('上传失败请重试')
},
uploadSuccess (response, file, fileList) {
this.dataListLoading = false
this.$refs.upload.clearFiles()
if (response.code !== 0 || (response.data !== null && response.data.length > 0)) {
this.errordataList = response.data
if (this.errordataList != null && this.errordataList.length > 0) {
this.faultDataVisible = true
} else {
this.$message.error(response.msg)
}
return
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.getDataList()
}
})
}
}
}
</script>
Loading…
Cancel
Save