<template>
|
<div class="app-container">
|
<div class="filter-container">
|
<div class="basic_search">
|
<span>单位名称:</span>
|
<el-input v-model="company" style="width:200px">
|
</el-input>
|
</div>
|
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-refresh" @click="refreshHandle">搜索</el-button>
|
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-plus" @click="showUnitForm('','新增')">新增</el-button>
|
</div>
|
<div class="table_content">
|
<el-table
|
v-loading="listLoading"
|
:key="tableKey"
|
:data="unitData"
|
border
|
fit
|
highlight-current-row
|
style="width: 100%;"
|
>
|
<el-table-column label="单位名称" prop="company" align="center">
|
</el-table-column>
|
<el-table-column label="单位代码" prop="code" align="center">
|
</el-table-column>
|
<el-table-column label="是否为主体单位" prop="ismain" align="center">
|
<template slot-scope="scope">
|
{{ scope.row.ismain | parseMain}}
|
</template>
|
</el-table-column>
|
<el-table-column label="联系人" prop="contactname" align="center">
|
</el-table-column>
|
<el-table-column label="联系电话" prop="contactphone" align="center">
|
</el-table-column>
|
<el-table-column label="地址" prop="address" align="center">
|
<template slot-scope="scope">
|
<div>
|
<span>{{scope.row.province}}</span>
|
<span v-if="scope.row.city !== null && scope.row.city !== '' && scope.row.province !== undefined">{{"-" + scope.row.city}}</span>
|
<span v-if="scope.row.area !== null && scope.row.area !== '' && scope.row.city !== undefined">{{"-" + scope.row.area}}</span>
|
<span v-if="scope.row.town !== null && scope.row.town !== '' && scope.row.town !== undefined">{{"-" + scope.row.town}}</span>
|
<span v-if="scope.row.committee !== null && scope.row.committee !== '' && scope.row.committee !== undefined">{{"-" + scope.row.committee}}</span>
|
</div>
|
<div></div>
|
</template>
|
</el-table-column>
|
<el-table-column label="创建者" prop="createdby" align="center">
|
</el-table-column>
|
<el-table-column label="创建时间" prop="createddate" align="center">
|
</el-table-column>
|
<el-table-column label="是否黑名单" prop="isbanned" align="center">
|
<template slot-scope="scope">
|
<span>{{ scope.row.isbanned | parseIsBanned }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width">
|
<template slot-scope="scope">
|
<el-button type="text" @click="showUnitForm(scope.row,'编辑')">编辑</el-button>
|
<!-- <el-button type="text" style="color: red" @click="deleteById(scope.row)">删除</el-button>-->
|
<el-button type="text" style="color: red" @click="addBlack(scope.row)">黑名单</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<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"
|
/>
|
<br>
|
</div>
|
<el-dialog :title="title" :visible.sync="unitFormVisible" :modal-append-to-body="false" :close-on-click-modal="false" width="40%">
|
<el-form ref="dataForm" :rules="unitFormRules" :model="unitForm" label-position="right" label-width="100px" style="margin-left:50px;width:500px;">
|
<el-form-item label="单位名称">
|
<el-input v-model="unitForm.company"></el-input>
|
</el-form-item>
|
<el-form-item label="单位代码">
|
<el-input v-model="unitForm.code"></el-input>
|
</el-form-item>
|
<el-form-item label="是否为主体单位:" prop="ismain">
|
<el-select v-model.trim="unitForm.ismain" auto-complete="on" style="width:100%;">
|
<el-option
|
v-for="item in isMainList"
|
:key="item.id"
|
:value="item.id"
|
:label="item.name"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="联系人">
|
<el-input v-model="unitForm.contactname"></el-input>
|
</el-form-item>
|
<el-form-item label="联系电话">
|
<el-input v-model="unitForm.contactphone"></el-input>
|
</el-form-item>
|
<el-form-item label="省">
|
<el-select v-model="unitForm.province" clearable filterable @change="changeArea('province')" style="width:100%;">
|
<el-option
|
v-for="item in provinceList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="市">
|
<el-select v-model="unitForm.city" prop="city" clearable filterable @change="changeArea('city')" style="width:100%;">
|
<el-option
|
v-for="item in cityList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="区">
|
<el-select v-model="unitForm.area" clearable filterable @change="changeArea('area')" style="width:100%;">
|
<el-option
|
v-for="item in districtList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="街道">
|
<el-select v-model="unitForm.town" clearable filterable @change="changeArea('town')" style="width:100%;">
|
<el-option
|
v-for="item in streetList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="居委会">
|
<el-select v-model="unitForm.community" clearable filterable style="width:100%;">
|
<el-option
|
v-for="item in committeeList"
|
:key="item.id"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
<div align="right">
|
<el-button @click="unitFormVisible = false">取消</el-button>
|
<el-button type="primary" @click="submitUnit()">确认</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import { computePageCount } from '../../../utils'
|
import { addUnit, deleteUnit, getUnitList, updateUnit } from '../../../api/unitManage'
|
import { getDistrict } from '../../../api/user'
|
import { parseError } from '../../../utils/messageDialog'
|
import { getCityListData } from '../../../api/area'
|
import { addBlack } from '../../../api/blackList'
|
|
export default {
|
name: 'index',
|
filters: {
|
parseMain(type){
|
if(type === 1){
|
return "是"
|
}else if(type === 0){
|
return "否"
|
}
|
},
|
parseIsBanned(value){
|
if(value === 1){
|
return "是"
|
}else if(value === 0){
|
return "否"
|
}
|
},
|
},
|
computed: {
|
...mapGetters([
|
'userType'
|
])
|
},
|
data() {
|
return {
|
tableKey: 0,
|
unitData: [],
|
listLoading: false,
|
pageSize: 10,
|
recordTotal: 0,
|
currentPage: 1,
|
pageTotal: 0,
|
title:'',
|
company:'',
|
code:'',
|
unitFormVisible:false,
|
unitFormRules:{},
|
unitForm:{
|
id:'',
|
company:'',
|
code:'',
|
contactname:'',
|
contactphone:'',
|
province:'',
|
city:'',
|
area:'',
|
town:'',
|
committee:'',
|
isbanned:'',
|
},
|
provinceList:[],
|
cityList:[],
|
districtList:[],
|
committeeList:[],
|
streetList:[],
|
isMainList:[{id:1,name:'是'},{id:0,name:'否'}],
|
}
|
},
|
created() {
|
this.getUnitData()
|
this.getProvince()
|
},
|
methods: {
|
async getUnitData(){
|
this.listLoading = true
|
let params = {}
|
params['pageIndex'] = this.currentPage
|
params['pageSize'] = this.pageSize
|
params['company'] = this.company
|
params['isMain'] = false
|
let res = await getUnitList(params)
|
if(res.data.code === '200'){
|
this.recordTotal = res.data.result.totalCount
|
this.pageSize = res.data.result.pageSize
|
this.pageTotal = computePageCount(res.data.result.totalCount, res.data.result.pageSize)
|
this.currentPage = res.data.result.pageIndex
|
this.unitData = res.data.result.result
|
}else{
|
this.$message({
|
message:res.data.message,
|
type:'warning'
|
})
|
}
|
this.listLoading = false
|
},
|
showUnitForm(value,type){
|
this.unitFormVisible = true
|
if(type === '新增'){
|
this.title = '新增'
|
this.unitForm = {
|
id:'',
|
company:'',
|
code:'',
|
contactname:'',
|
contactphone:'',
|
province:'',
|
city:'',
|
area:'',
|
town:'',
|
committee:'',
|
isbanned:'',
|
}
|
}else{
|
this.title = '修改'
|
this.unitForm = value
|
}
|
},
|
submitUnit(){
|
if(this.title === '新增'){
|
addUnit(this.unitForm).then((res)=>{
|
if(res.data.code === '200'){
|
this.unitFormVisible = false
|
this.getUnitData()
|
this.$notify({
|
type:'success',
|
duration:2000,
|
message:'新增成功',
|
title:'成功'
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
}else{
|
updateUnit(this.unitForm).then((res)=>{
|
if(res.data.code === '200'){
|
this.unitFormVisible = false
|
this.getUnitData()
|
this.$notify({
|
type:'success',
|
duration:2000,
|
title:'成功',
|
message:'编辑成功'
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
}
|
},
|
deleteById(val){
|
this.$confirm('删除此条信息,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
deleteUnit({id:val.id}).then( ()=>{
|
this.getUnitData()
|
this.$notify({
|
title:'成功',
|
message:'删除成功',
|
type:'success',
|
duration:2000,
|
})
|
})
|
})
|
},
|
addBlack(val){
|
this.$confirm('将此单位添加黑名单,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
addBlack({company:val.company}).then( ()=>{
|
this.getUnitData()
|
this.$notify({
|
title:'成功',
|
message:'删除成功',
|
type:'success',
|
duration:2000,
|
})
|
})
|
})
|
},
|
refreshHandle(){
|
this.getUnitData()
|
},
|
handleSizeChange(val){
|
this.pageSize = val
|
this.getUnitData()
|
},
|
handleCurrentChange(val){
|
this.currentPage = val
|
this.getUnitData()
|
},
|
|
getProvince(){
|
const params = {}
|
params['parenttype'] = 0
|
params['type'] = 1
|
getDistrict(params).then(response => {
|
const res = response.data
|
if (res.code == 200){
|
this.provinceList = res.result;
|
} else {
|
parseError({ error: res.data.message, vm: _this })
|
}
|
}).catch(error => {
|
})
|
},
|
async changeArea(value){
|
if(value === 'province'){
|
this.unitForm.city = ''
|
this.unitForm.area = ''
|
this.unitForm.town = ''
|
this.unitForm.community = ''
|
this.areaListQuery = {
|
type: 2,
|
parenttype: 1,
|
parentname: this.unitForm.province,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.cityList = res.data.result
|
}
|
}else if(value === 'city'){
|
this.unitForm.area = ''
|
this.unitForm.town = ''
|
this.unitForm.community = ''
|
this.areaListQuery = {
|
type: 3,
|
parenttype: 2,
|
parentname: this.unitForm.city,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.districtList = res.data.result
|
}
|
}else if(value === 'area'){
|
this.unitForm.town = ''
|
this.unitForm.community = ''
|
this.areaListQuery = {
|
type: 4,
|
parenttype: 3,
|
parentname: this.unitForm.area,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.streetList = res.data.result
|
}
|
}else if(value === 'town'){
|
this.unitForm.community = ''
|
this.areaListQuery = {
|
type: 5,
|
parenttype: 4,
|
parentname: this.unitForm.town,
|
}
|
let res = await getCityListData(this.areaListQuery)
|
if(res.data.code === "200"){
|
this.committeeList = res.data.result
|
}
|
}
|
},//市、镇、街道、委员会
|
}
|
}
|
</script>
|
<style scoped>
|
.basic_search{
|
display:inline-block;
|
padding-bottom: 10px;
|
}
|
</style>
|