<template>
|
<div class="app-container">
|
|
<div class="filter-container">
|
<div style="display: block;padding-top: 10px">
|
<div class="basic_search">
|
<span>区域:</span>
|
<el-select v-model="listQuery.filter.province" clearable filterable @change="changeArea('province')">
|
<el-option
|
v-for="item in provinceList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="basic_search">
|
<el-select v-model="listQuery.filter.city" prop="city" clearable filterable @change="changeArea('city')">
|
<el-option
|
v-for="item in cityList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="basic_search">
|
<el-select v-model="listQuery.filter.district" clearable filterable @change="changeArea('district')">
|
<el-option
|
v-for="item in districtList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="basic_search">
|
<el-select v-model="listQuery.filter.street"clearable filterable @change="changeArea('street')" >
|
<el-option
|
v-for="item in streetList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="basic_search">
|
<el-select v-model="listQuery.filter.committee" clearable filterable>
|
<el-option
|
v-for="item in committeeList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
|
</div>
|
<div style="display: block;padding-top: 10px">
|
<div class="basic_search">
|
<span>安全监管分类:</span>
|
<el-select filterable clearable v-model="listQuery.filter.safetysupervision">
|
<el-option
|
v-for="item in safetySuperVisionList"
|
:key="item.id"
|
:label="item.text"
|
:value="item.text"
|
></el-option>
|
</el-select>
|
</div>
|
<div class="basic_search" style="margin-left:10px">
|
<span>国民经济行业分类:</span>
|
<el-select filterable clearable v-model="listQuery.filter.economicindustry">
|
<el-option
|
v-for="item in economicIndustryList"
|
:key="item.id"
|
:label="item.text"
|
:value="item.text"
|
></el-option>
|
</el-select>
|
</div>
|
<div class="basic_search" style="margin-left:10px">
|
<span>许可证是否过期:</span>
|
<el-select filterable clearable v-model="listQuery.filter.valid">
|
<el-option
|
v-for="item in validList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
></el-option>
|
</el-select>
|
</div>
|
<div class="basic_search" style="margin-left:10px">
|
<span>是否注销:</span>
|
<el-select filterable clearable v-model="listQuery.filter.loginValid">
|
<el-option
|
v-for="item in loginValidList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
></el-option>
|
</el-select>
|
</div>
|
</div>
|
<div style="display: block;padding-top: 10px">
|
<div class="basic_search" style="margin-left:10px">
|
<span>企业名称:</span>
|
<el-input v-model="listQuery.filter.enterprisename" style="width:200px">
|
</el-input>
|
</div>
|
<div class="basic_search">
|
<!-- <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-plus" @click="showCreateHandle">新增</el-button>-->
|
<el-button v-if="isSupervision==='null'" style="margin-left: 10px;" type="primary" icon="el-icon-plus" @click="showEnterPriseDetailForm('新增','')">新增</el-button>
|
<el-button v-if="userType === 1" style="margin-left: 10px;" type="primary" @click="logoutHandler">注销</el-button>
|
<el-button v-if="userType === 1" style="margin-left: 10px;" type="primary" @click="recoverLoginBatchHandler">启用</el-button>
|
<el-button v-if="isSupervision==='null'" style="margin-left: 10px;" type="primary" icon="el-icon-upload2" @click="importToExcel">导入</el-button>
|
<el-button style="margin-left: 10px;" type="primary" icon="el-icon-download" @click="exportToExcel">导出</el-button>
|
<el-button style="margin-left: 10px;" type="primary" icon="el-icon-download" @click="exportFeedHandle">导出反馈</el-button>
|
<el-button v-if="userType === 1" style="margin-left: 10px;" type="primary" icon="el-icon-download" @click="importUnitCode">导入单位代码</el-button>
|
<el-button v-if="userType === 1" style="margin-left: 10px;" type="primary" icon="el-icon-download" @click="exportUnitCode">导出单位代码</el-button>
|
<el-button type="primary" icon="el-icon-search" @click="queryHandle" />
|
</div>
|
</div>
|
|
|
|
|
</div>
|
<div class="table_content">
|
<el-table
|
v-loading="listLoading"
|
:key="tableKey"
|
:row-key="getRowKey"
|
:data="enterpriseList"
|
border
|
fit
|
@selection-change="handleSelectionChange"
|
highlight-current-row
|
style="width: 100%;"
|
>
|
<el-table-column
|
type="selection"
|
:reserve-selection="true"
|
width="55">
|
</el-table-column>
|
<el-table-column type="index" label="" align="center" width="60"/>
|
<el-table-column label="单位名称" prop="enterprisename" align="center">
|
</el-table-column>
|
<el-table-column label="属地" prop="province" align="center">
|
<template slot-scope="scope">
|
<span v-if="scope.row.province">{{scope.row.province}}</span>
|
<template v-if="scope.row.city">
|
<span>-</span>
|
<span >{{scope.row.city}}</span>
|
</template>
|
<template v-if="scope.row.district">
|
<span>-</span>
|
<span>{{scope.row.district}}</span>
|
</template>
|
<template v-if="scope.row.street">
|
<span>-</span>
|
<span>{{scope.row.street}}</span>
|
</template>
|
<template v-if="scope.row.committee">
|
<span>-</span>
|
<span>{{scope.row.committee}}</span>
|
</template>
|
</template>
|
</el-table-column>
|
<el-table-column label="企业类型" prop="safetysupervision" align="center">
|
</el-table-column>
|
<el-table-column label="许可证期限" prop="validstarttime" align="center">
|
<template slot-scope="scope">
|
<span v-if="scope.row.validstarttime">{{ scope.row.validstarttime}}</span>
|
<template v-if="scope.row.validendtime">
|
<span>-</span>
|
<span>{{scope.row.validendtime}}</span>
|
</template>
|
</template>
|
</el-table-column>
|
<el-table-column v-if="userType === 1" label="是否注销" prop="loginvalidflag" align="center">
|
<template slot-scope="scope">
|
<span v-if="scope.row.loginvalidflag == null || scope.row.loginvalidflag ">有效</span>
|
<span v-else @click="recoverLogin(scope.row.id)" style="color: red;cursor: pointer">注销</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="治安主管单位" prop="securitysupervisory" align="center">
|
</el-table-column>
|
<el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
|
<template slot-scope="scope">
|
<!-- <el-button type="text" @click="showEditHandle(scope.row)">编辑</el-button>-->
|
<el-button type="text" @click="showEnterPriseDetailForm('修改',scope.row)" >编辑</el-button>
|
<el-button v-if="userType != 3" :disabled="disableRole(scope.row)" type="text" align="center" @click="deleteById('删除',scope.row)" >删除</el-button>
|
<el-button v-if="userType != 3" :disabled="disableRole(scope.row)" type="text" align="center" @click="changeStatus('停用',scope.row)" >{{scope.row.enterprisestatus == '停止'?'启用':'停用'}}</el-button>
|
<!-- <el-button :disabled="scope.row.type==1" type="text" style="color:red;" @click="deleteHandle(scope.row)" v-if="scope.row.infostatus === '待审批' ? false : true ">重置密码</el-button>-->
|
</template>
|
</el-table-column>
|
</el-table>
|
<br>
|
<el-pagination
|
v-show="recordTotal>0"
|
:current-page="currentPage"
|
:page-sizes="[10, 20, 30, 50]"
|
:page-size="pageSize"
|
:total="recordTotal"
|
layout="total, sizes, prev, pager, next, jumper"
|
background
|
style="float:right;"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
/>
|
</div>
|
<enterpriseDetailForm ref="enterpriseDetail" @getinfo="getEnterpriseList"></enterpriseDetailForm>
|
<el-dialog
|
:visible.sync="unitCodeVisible"
|
append-to-body
|
title="导入单位代码"
|
:close-on-click-modal="false"
|
>
|
<el-form
|
ref="importForm"
|
label-position="right"
|
label-width="120px"
|
style="margin-left:50px;width:500px;"
|
element-loading-text="导入中..."
|
>
|
<el-form-item label="导入文件:">
|
<input ref="upload" type="file" accept=".xls, .xlsx" >
|
</el-form-item>
|
<el-form-item label="excel参考模板:">
|
<el-button type="text" @click="viewHandle">下载模板</el-button>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="unitCodeVisible = false">取消</el-button>
|
<el-button type="primary" @click="importHandle()">导入</el-button>
|
</div>
|
</el-dialog>
|
<uploadExcel ref="import" @getinfo="getEnterpriseList"></uploadExcel>
|
<div style="clear: both;"></div>
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import { dictionaryAllItems } from "../../api/dictionary";
|
import enterpriseDetailForm from "./enterpriseDetailForm"
|
import { userList, createUser, deleteUser, updateUser } from '@/api/user'
|
import { enterpriseList,addEnterprise ,deleteEnterprise ,exportEnterprise,deactivateEnterprise,activateEnterprise} from '@/api/enterprise'
|
import { exportFeed} from '@/api/Feed'
|
import { roleList } from '@/api/role'
|
import { parseTime, computePageCount, parseUserType } from '@/utils'
|
import { parseError } from '@/utils/messageDialog'
|
import Cookies from 'js-cookie'
|
import {getCityListData, getProvinceListData} from "../../api/area";
|
import uploadExcel from "./components/uploadExcel";
|
import {exportUnitCode, importEnterprise, importUnitCode,logout,recoverLogin,recoverLoginBatch} from "../../api/enterprise";
|
const exampleFile = require('@/assets/example/companycode.xlsx')
|
|
export default {
|
name: 'UserTable',
|
filters: {
|
parseRoles(roles) {
|
if (!roles) {
|
return
|
}
|
let message = ''
|
for (const role of roles) {
|
message += role.name + ','
|
}
|
if (message) {
|
message = message.substring(0, message.lastIndexOf(','))
|
}
|
return message
|
},
|
filterSafety(value) {
|
if (value) {
|
return '是'
|
} else {
|
return '否'
|
}
|
},
|
filterUserType(value) {
|
return parseUserType(value)
|
},
|
filterPeriod(value) {
|
if (!value) {
|
return
|
}
|
if (value == 'month') {
|
return '一月一次'
|
} else if (value == 'week') {
|
return '一周一次'
|
} else if (value == 'day') {
|
return '一天一次'
|
}
|
}
|
},
|
components:{
|
enterpriseDetailForm,
|
uploadExcel
|
},
|
computed: {
|
...mapGetters([
|
'userType',
|
'name'
|
])
|
},
|
data() {
|
const validateEmail = (rule, value, callback) => {
|
if (value === '') {
|
return callback(new Error('邮箱不能为空'))
|
} else {
|
// 对电子邮件的验证
|
const myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/
|
if (!myreg.test(value)) {
|
return callback(new Error('请输入有效的邮箱格式'))
|
}
|
callback()
|
}
|
}
|
return {
|
pageSize: 10,
|
recordTotal: 0,
|
currentPage: 1,
|
pageTotal: 0,
|
tableKey: 0,
|
enterpriseList: [],
|
enterpriseFilter:{
|
enterprisesize:''
|
},
|
listQuery:{
|
filter: {safetysupervision:'',economicindustry:'',enterprisename:'',province:'',city:'',district:'',street:'',committee:'',valid:'',loginValid:''},
|
pageIndex: 1,
|
pageSize: 10
|
},
|
exportListQuery:{
|
filter: {safetysupervision:'',economicindustry:'',enterprisename:'',province:'',city:'',district:'',street:'',committee:''},
|
},
|
provinceList:[],
|
cityList:[],
|
districtList:[],
|
streetList:[],
|
committeeList:[],
|
economicTypeList:[],
|
validList:[
|
{id:1,name:'未过期'},
|
{id:2,name:'已过期'}
|
],
|
loginValidList:[
|
{id:-1,name:'注销'},
|
{id:1,name:'有效'}
|
],
|
listLoading: true,
|
validTime:['',''],
|
dataForm: {
|
safetysupervision: '',
|
economicindustry: '',
|
enterprisenumber: '',
|
enterprisename: '',
|
enterpriseemail: '',
|
enterprisesize: '',
|
enterprisestatus: '',
|
department: '',
|
devicenumber: '',
|
officeaddress: '',
|
province: '',
|
city: '',
|
district: '',
|
street: '',
|
committee: '',
|
securitysupervisory: '',
|
officephone: '',
|
faxphone: '',
|
registeraddress: '',
|
registertype: '',
|
establishtime: '',
|
qqnumber: '',
|
postcode: '',
|
roomnumber: '',
|
economictype: '',
|
productioncontent: '',
|
businessregisternumber: '',
|
organizationstructurecode: '',
|
validstarttime: '',
|
validendtime: '',
|
employeenumber: '',
|
ispaysafetyinsurance: true,
|
insurancecontractnumber: '',
|
insureamount: '',
|
insurestarttime: '',
|
insureendtime: '',
|
ismajorhazard: '',
|
isspecialequipment: '',
|
isoccupationalhealthinfo: '',
|
isspecialpersonnel: '',
|
selfrecordingcycle: '',
|
isparententerprise: '',
|
parententerprisename: '',
|
legalrepresentative: '',
|
mainprincipal: '',
|
securityofficer: '',
|
informationofficer: '',
|
enterpriselocation: '',
|
},
|
queryForm: {
|
name: ''
|
},
|
dialogFormVisible: false,
|
unitCodeVisible:false,
|
dialogStatus: '',
|
dataFormRules: {
|
// workId: [{ required: true, message: '工号不能为空', trigger: 'blur' }],
|
|
},
|
dialogUserRoleFormVisible: false,
|
userRoleDataForm: {
|
userRoles: [],
|
userId: ''
|
},
|
userRoleDataFormRules: {
|
userRoles: [{ type: 'array', required: true, message: '角色不能为空', trigger: 'change' }]
|
},
|
roleList: [],
|
passwordType: 'password',
|
confirmPasswordType: 'password',
|
templateRadio: '',
|
jobList:[],
|
instituteList: [],
|
departmentList: [],
|
safetySuperVisionList:[],
|
economicIndustryList:[],
|
searchKey: '',
|
searchContent: '',
|
isSupervision:'',
|
multipleSelection: []
|
}
|
},
|
created() {
|
this.isSupervision = Cookies.get('isSupervision')
|
this.getJobList()
|
this.getProvince()
|
this.getEnterpriseList(),
|
this.getEconomicTypeList()
|
this.getSafetySuperVisionList()
|
this.getEconomicIndustryList()
|
},
|
methods: {
|
getEnterpriseList() {
|
const _this = this
|
_this.listLoading = true
|
enterpriseList(this.listQuery).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.recordTotal = res.result.total
|
_this.pageSize = res.result.size
|
_this.pageTotal = computePageCount(res.result.total, res.result.size)
|
_this.currentPage = res.result.current
|
_this.enterpriseList = res.result.records
|
} else {
|
parseError({error: res.message, vm: _this})
|
}
|
_this.listLoading = false
|
}).catch(error => {
|
_this.listLoading = false
|
parseError({error: error, vm: _this})
|
})
|
},//获取企业列表
|
|
getEconomicTypeList() {
|
const _this = this
|
if (_this.levelOptions && _this.levelOptions.length > 0) {
|
return
|
}
|
const params = {}
|
params['dictionaryType'] = '国民经济类型'
|
dictionaryAllItems(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.economicTypeList = res.result
|
} else {
|
parseError({error: res.message, vm: _this})
|
}
|
}).catch(error => {
|
parseError({error: error, vm: _this})
|
})
|
},//获取国民经济类型列表
|
|
getJobList() {
|
const _this = this
|
if (_this.levelOptions && _this.levelOptions.length > 0) {
|
return
|
}
|
const params = {}
|
params['dictionaryType'] = '职务'
|
dictionaryAllItems(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.jobList = res.result
|
} else {
|
parseError({error: res.message, vm: _this})
|
}
|
}).catch(error => {
|
parseError({error: error, vm: _this})
|
})
|
},//获取职业列表
|
|
getSafetySuperVisionList(){
|
const _this = this
|
if (_this.levelOptions && _this.levelOptions.length > 0) {
|
return
|
}
|
const params = {}
|
params['dictionaryType'] = '安全监管分类'
|
dictionaryAllItems(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.safetySuperVisionList = res.result
|
} else {
|
parseError({error: res.message, vm: _this})
|
}
|
}).catch(error => {
|
parseError({error: error, vm: _this})
|
})
|
},//获取安全监管分类
|
|
getEconomicIndustryList(){
|
const _this = this
|
if (_this.levelOptions && _this.levelOptions.length > 0) {
|
return
|
}
|
const params = {}
|
params['dictionaryType'] = '国民经济行业分类'
|
dictionaryAllItems(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.economicIndustryList = res.result
|
} else {
|
parseError({error: res.message, vm: _this})
|
}
|
}).catch(error => {
|
parseError({error: error, vm: _this})
|
})
|
},//获取国民经济类型
|
|
importUnitCode (){
|
this.unitCodeVisible = true
|
},
|
|
async exportUnitCode (){
|
let res = await exportUnitCode()
|
if(res.data.code === '200'){
|
if(res.data.result === null || res.data.result === [] || res.data.result.length === 0){
|
this.$message({
|
type:'warning',
|
message:'无数据可导出'
|
})
|
}else {
|
let allData = res.data.result
|
import('@/vendor/Export2Excel').then((excel) => {
|
const tHeader = [
|
'单位名称',
|
'单位代码',
|
'设备ID',
|
]
|
const filterVal = [
|
'enterprisename',
|
'dlcompanycode',
|
'deviceid',
|
|
]
|
const data = this.formatJson(filterVal, allData)
|
excel.export_json_to_excel({
|
header: tHeader,
|
data,
|
filename: '单位代码'
|
})
|
})
|
}
|
}else{
|
this.$message({
|
message:res.data.message,
|
type:'warning'
|
})
|
}
|
},
|
|
viewHandle() {
|
window.open(exampleFile, '_blank')
|
},
|
|
async importHandle(){
|
const formData = new FormData()
|
const files = this.$refs['upload'].files
|
if (files && files.length > 0) {
|
formData.append('file', files[0])
|
}
|
let res = await importUnitCode(formData)
|
if(res.data.code === "200"){
|
this.unitCodeVisible = false
|
this.getEnterpriseList()
|
this.$notify({
|
title:'成功',
|
duration:2000,
|
message:res.data.result.resultmsg,
|
type:'success'
|
})
|
}else{
|
this.$message({
|
message:res.data.message,
|
type:'warning'
|
})
|
}
|
},
|
|
|
async getProvince(){
|
let res = await getProvinceListData()
|
if(res.data.code === "200"){
|
this.provinceList = res.data.result.provinceList
|
}
|
},//获取省
|
|
async changeArea(value){
|
if(value === 'province'){
|
this.listQuery.filter.city = ''
|
this.listQuery.filter.district = ''
|
this.listQuery.filter.street = ''
|
this.listQuery.filter.committee = ''
|
this.areaListQuery = {
|
type: 2,
|
parenttype: 1,
|
parentname: this.listQuery.filter.province,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.cityList = res.data.result
|
}
|
}else if(value === 'city'){
|
this.listQuery.filter.district = ''
|
this.listQuery.filter.street = ''
|
this.listQuery.filter.committee = ''
|
this.areaListQuery = {
|
type: 3,
|
parenttype: 2,
|
parentname: this.listQuery.filter.city,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.districtList = res.data.result
|
}
|
}else if(value === 'district'){
|
this.listQuery.filter.street = ''
|
this.listQuery.filter.committee = ''
|
this.areaListQuery = {
|
type: 4,
|
parenttype: 3,
|
parentname: this.listQuery.filter.district,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.streetList = res.data.result
|
}
|
}else if(value === 'street'){
|
this.listQuery.filter.committee = ''
|
this.areaListQuery = {
|
type: 5,
|
parenttype: 4,
|
parentname: this.listQuery.filter.street,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.committeeList = res.data.result
|
}
|
}
|
},//市、镇、街道、委员会
|
|
showEnterPriseDetailForm(operateName, value) {
|
this.$refs.enterpriseDetail.openEnterpriseDetailForm(operateName, value, this.economicTypeList, this.jobList,this.safetySuperVisionList,this.economicIndustryList)
|
},//打开企业新增修改
|
|
async deleteById(title,row) {
|
this.$confirm('删除此条信息,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
deleteEnterprise(row.id).then( (res)=>{
|
if(res.data.code === "200"){
|
this.getEnterpriseList()
|
this.$notify({
|
title:'成功',
|
message:'删除成功',
|
type:'success',
|
duration:2000,
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
})
|
},//删除企业
|
async changeStatus(title,row){
|
if (row.enterprisestatus == '停止' ) {
|
this.$confirm('是否确认启用此企业','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
activateEnterprise({id:row.id}).then( (res)=>{
|
if(res.data.code === "200"){
|
this.getEnterpriseList()
|
this.$notify({
|
title:'成功',
|
message:'启用成功',
|
type:'success',
|
duration:2000,
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
})
|
}else {
|
this.$confirm('是否确认禁用此企业','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
deactivateEnterprise({id:row.id}).then( (res)=>{
|
if(res.data.code === "200"){
|
this.getEnterpriseList()
|
this.$notify({
|
title:'成功',
|
message:'禁用成功',
|
type:'success',
|
duration:2000,
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
})
|
}
|
|
|
},
|
importToExcel(){
|
this.$refs.import.showUploadExcel()
|
},//导入企业
|
|
async exportToExcel(){
|
let res = await exportEnterprise(this.listQuery)
|
if(res.data.code === '200'){
|
if(res.data.result === null ||res.data.result === [] || res.data.result.length === 0){
|
this.$message({
|
type:'warning',
|
message:'无数据可导出'
|
})
|
}else {
|
let allData = res.data.result
|
import('@/vendor/Export2Excel').then((excel) => {
|
const tHeader = [
|
'企业名称',
|
'企业编号',
|
'企业类型',
|
'治安主管单位',
|
'标准化等级',
|
'是否有重大危险源',
|
'有效期',
|
'地区',
|
'是否缴纳安全责任险',
|
'保险公司名称',
|
'保单号',
|
'投保金额(元)',
|
'投保开始时间',
|
'投保结束时间',
|
'从业人数',
|
'专职安全生产管理人员及仓库守护、保管人员数量',
|
|
]
|
const filterVal = [
|
'enterprisename',
|
'enterprisenumber',
|
'safetysupervision',
|
'securitysupervisory',
|
'level',
|
'ismajorhazard',
|
'validtime',
|
'location',
|
'ispaysafetyinsurance',
|
'insurancecompany',
|
'insurancecontractnumber',
|
'insureamount',
|
'insurestarttime',
|
'insureendtime',
|
'employeenumber',
|
'personnumber',
|
]
|
const data = this.formatJson(filterVal, allData)
|
excel.export_json_to_excel({
|
header: tHeader,
|
data,
|
filename: '企业'
|
})
|
})
|
}
|
}else{
|
this.$message({
|
message:res.data.message,
|
type:'warning'
|
})
|
}
|
|
},
|
async exportFeedHandle() {
|
let _this = this
|
exportFeed(this.listQuery)
|
.then(function(res) {
|
|
if (res.data.code === '200') {
|
if(res.data.result === null ||res.data.result === [] || res.data.result.length === 0){
|
_this.$message({
|
type:'warning',
|
message:'无数据可导出'
|
})
|
}else {
|
let allData = res.data.result
|
import('@/vendor/Export2Excel').then((excel) => {
|
const tHeader = [
|
'企业名称',
|
'上传时间',
|
'上传人',
|
'发现时间',
|
'内容',
|
]
|
const filterVal = [
|
'enterprisename',
|
'createtime',
|
'createbyname',
|
'findtime',
|
'content',
|
]
|
const data = allData.map(row=>
|
filterVal.map(field=>{
|
if (field == 'createtime' || field == 'findtime'){
|
return parseTime(row[field], '{y}-{m}-{d}')
|
}
|
return row[field]
|
})
|
);
|
|
|
excel.export_json_to_excel({
|
header: tHeader,
|
data,
|
filename: '企业信息反馈'
|
});
|
})
|
}
|
}
|
})
|
},
|
|
formatJson(filterVal, jsonData) {
|
return jsonData.map(v =>
|
filterVal.map(j => {
|
|
return v[j];
|
})
|
);
|
},
|
|
createHandle: function() {
|
const _this = this
|
this.$refs['dataForm'].validate((valid) => {
|
if (valid) {
|
//TODO 密码规则
|
_this.dataForm.validstarttime= _this.validTime[0]
|
_this.dataForm.validendtime= _this.validTime[1]
|
addEnterprise(_this.dataForm).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.dialogFormVisible = false
|
_this.$message({
|
message: '创建成功',
|
type: 'success'
|
})
|
_this.getEnterpriseList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
}
|
})
|
},
|
|
deleteAction: function(row) {
|
const _this = this
|
const params = {}
|
params['id'] = row.id
|
const userName = Cookies.get('userName')
|
const name = Cookies.get('name')
|
params['operator'] = name + '(' + userName + ')'
|
deleteUser(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.$message({
|
message: '删除成功',
|
type: 'success'
|
})
|
_this.getEnterpriseList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
},
|
|
refreshHandle: function() {
|
this.getEnterpriseList()
|
},
|
|
queryHandle: function() {
|
this.currentPage = 1
|
this.getEnterpriseList()
|
},
|
|
resetDataForm() {
|
this.dataForm= {
|
safetysupervision: '',
|
economicindustry: '',
|
enterprisenumber: '',
|
enterprisename: '',
|
enterpriseemail: '',
|
enterprisesize: '',
|
enterprisestatus: '',
|
department: '',
|
devicenumber: '',
|
officeaddress: '',
|
province: '',
|
city: '',
|
district: '',
|
street: '',
|
committee: '',
|
securitysupervisory: '',
|
officephone: '',
|
faxphone: '',
|
registeraddress: '',
|
registertype: '',
|
establishtime: '',
|
qqnumber: '',
|
postcode: '',
|
roomnumber: '',
|
economictype: '',
|
productioncontent: '',
|
businessregisternumber: '',
|
organizationstructurecode: '',
|
validstarttime: '',
|
validendtime: '',
|
employeenumber: '',
|
ispaysafetyinsurance: true,
|
insurancecontractnumber: '',
|
insureamount: '',
|
insurestarttime: '',
|
insureendtime: '',
|
ismajorhazard: '',
|
isspecialequipment: '',
|
isoccupationalhealthinfo: '',
|
isspecialpersonnel: '',
|
selfrecordingcycle: '',
|
isparententerprise: '',
|
parententerprisename: '',
|
legalrepresentative: '',
|
mainprincipal: '',
|
securityofficer: '',
|
informationofficer: '',
|
enterpriselocation: '',
|
}
|
this.validTime = ['', '']
|
|
},
|
|
showCreateHandle() {
|
this.resetDataForm()
|
this.dialogStatus = 'create'
|
this.dialogFormVisible = true
|
this.$nextTick(() => {
|
this.$refs['dataForm'].clearValidate()
|
})
|
},
|
|
updateHandle() {
|
this.$refs['dataForm'].validate((valid) => {
|
const _this = this
|
if (valid) {
|
if (_this.dataForm.password || _this.dataForm.confirmPassword) {
|
if (_this.dataForm.password != _this.dataForm.confirmPassword) {
|
parseError({ error: '密码输入不一致', vm: _this })
|
return
|
}
|
}
|
const userName = Cookies.get('userName')
|
const name = Cookies.get('name')
|
_this.dataForm['operator'] = name + '(' + userName + ')'
|
updateUser(_this.dataForm).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.dialogFormVisible = false
|
_this.$message({
|
message: '更新成功',
|
type: 'success'
|
})
|
_this.getEnterpriseList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}).catch(error => {
|
parseError({ error: error, vm: _this })
|
})
|
}
|
})
|
},
|
|
getRoleList: async function() {
|
const _this = this
|
const params = {}
|
params['returns'] = 'queryAll'
|
params['instituteId'] = _this.instituteId
|
roleList(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
const roleList = res.result
|
_this.roleList = roleList
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
})
|
},
|
|
showAssignRole: async function(row) {
|
await this.getRoleList()
|
|
this.userRoleDataForm.userId = row.id
|
|
this.$nextTick(() => {
|
const assigedRoles = []
|
if (row.roles) {
|
for (const role of row.roles) {
|
assigedRoles.push(role.id)
|
}
|
}
|
this.userRoleDataForm.userRoles = assigedRoles
|
})
|
this.dialogUserRoleFormVisible = true
|
this.$nextTick(() => {
|
this.$refs['userRoleDataForm'].clearValidate()
|
})
|
},
|
|
assignUserRoleHandle: function() {
|
const _this = this
|
this.$refs['userRoleDataForm'].validate((valid) => {
|
if (valid) {
|
const params = {}
|
params['id'] = _this.userRoleDataForm.userId
|
params['roles'] = _this.userRoleDataForm.userRoles
|
updateUser(params).then(response => {
|
const res = response.data
|
if (res.code == 200) {
|
_this.dialogUserRoleFormVisible = false
|
_this.$message({
|
message: '角色分配成功',
|
type: 'success'
|
})
|
_this.getEnterpriseList()
|
} else {
|
parseError({ error: res.message, vm: _this })
|
}
|
})
|
}
|
})
|
},
|
|
showEditHandle(row) {
|
this.resetDataForm()
|
this.dialogStatus = 'editor'
|
this.dataForm.name = row.name
|
this.dataForm.workId = row.workId
|
this.dataForm.job = row.job
|
this.dataForm.isSafety = row.isSafety
|
this.dataForm.email = row.email
|
this.dataForm.phone = row.phone
|
this.dataForm.userType = row.type
|
this.dataForm.instituteId = row.institute ? row.institute.id : ''
|
this.getDepartmentList(this.dataForm.instituteId)
|
this.dataForm.departmentId = row.department ? row.department.id : ''
|
this.dataForm.id = row.id
|
this.dataForm.description = row.description
|
this.dataForm.period = row.period
|
this.dialogFormVisible = true
|
this.$nextTick(() => {
|
this.$refs['dataForm'].clearValidate()
|
})
|
},
|
|
passwordChangeEvent: function(value) {
|
if (this.dataForm.password != value) {
|
parseError({ error: '密码输入不一致', vm: this })
|
}
|
},
|
|
showPwd() {
|
if (this.passwordType === 'password') {
|
this.passwordType = ''
|
} else {
|
this.passwordType = 'password'
|
}
|
},
|
|
showConfirmPwd() {
|
if (this.confirmPasswordType === 'password') {
|
this.confirmPasswordType = ''
|
} else {
|
this.confirmPasswordType = 'password'
|
}
|
},
|
|
handleSizeChange: function(val) {
|
this.listQuery.pageSize = val
|
this.getEnterpriseList()
|
},
|
|
handleCurrentChange: function(val) {
|
this.listQuery.pageIndex = val
|
this.getEnterpriseList()
|
},
|
|
getTemplateRow(row) {
|
console.log(row, '22222')
|
},
|
|
handleInstituteChange(value) {
|
if (value) {
|
this.dataForm.departmentId = ''
|
}
|
},
|
|
disableRole(row) {
|
if (row.type == 1) {
|
return true
|
} else {
|
return false
|
}
|
},
|
|
getRoleInfo(role) {
|
const name = role.institute ? role.institute.name : ''
|
return role.name + '(' + name + ')'
|
}
|
,
|
handleSelectionChange(val) {
|
this.multipleSelection = val.map(item=>item.id);
|
},
|
getRowKey (row) {
|
return row.id
|
},
|
logoutHandler(){
|
this.loginValidFunc(logout)
|
},
|
recoverLoginBatchHandler(){
|
this.loginValidFunc(recoverLoginBatch)
|
},
|
loginValidFunc(fuc){
|
if (this.multipleSelection.length < 1) {
|
this.$message({
|
message: '请选择',
|
type: 'warning'
|
})
|
}else{
|
fuc(this.multipleSelection).then(res=>{
|
if (res.data.code === '200') {
|
this.$message({
|
message: '操作成功',
|
type: 'success'
|
})
|
this.getEnterpriseList()
|
}else{
|
this.$message({
|
message: res.data.message,
|
type: 'error'
|
})
|
}
|
})
|
}
|
},
|
recoverLogin(id){
|
this.$confirm('点击确定恢复该企业登录,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
recoverLogin({id}).then( (res)=>{
|
if(res.data.code === "200"){
|
this.getEnterpriseList()
|
this.$notify({
|
title:'成功',
|
message:'恢复成功',
|
type:'success',
|
duration:2000,
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
})
|
}
|
|
}
|
}
|
</script>
|
|
<style scoped>
|
.basic_search{
|
display:inline-block;
|
}
|
</style>
|