Commit e64c0b14 authored by 高宇's avatar 高宇

单位管理

parent 8f0362ba
import request from '@/utils/request'
import Qs from 'qs'
/**
* 1. 列表查询
* 2. 查询详细信息
* 3. 新增
* 4. 修改
* 5. 逻辑删除
* 6. 导出
*
*/
// 1. 查询单位管理列表
export function listSysUnit(query) {
return request({
url: '/sysunit/querySysUnitByPagination',
method: 'get',
params: query
})
}
// 2. 查询单位管理详细信息
export function getSysUnit(businessId) {
return request({
url: '/sysunit/detail/' + businessId,
method: 'get'
})
}
// 3. 新增单位管理
export function addSysUnit(data) {
data = Qs.stringify(data)
return request({
url: '/sysunit/add',
method: 'post',
data: data
})
}
// 4. 修改单位管理
export function updateSysUnit(data) {
const businessId = data.businessId
data = Qs.stringify(data)
return request({
url: '/sysunit/update/' + businessId,
method: 'put',
data
})
}
// 5. 逻辑删除单位管理
export function delSysUnit(businessId) {
return request({
url: '/sysunit/deleteLogical/' + businessId,
method: 'delete'
})
}
// 6. 导出单位管理
export function exportSysUnit(query) {
return request({
url: '/sysunit/export',
method: 'get',
params: query,
responseType: 'blob'
})
}
......@@ -179,3 +179,4 @@ export function uploadFalseFile(params) {
responseType: 'blob'
})
}
<template>
<div class="unitManagement_module">
单位
</div>
<div class="unitManagement_module">
<div class="search" style="border-bottom: 14px solid #f4f4f4">
<el-form ref="queryForm" style="padding: 0 0 0 10px" class="formClass" :model="queryParams" :inline="true">
<el-form-item prop="unitType" label="单位类型">
<el-select v-model="queryParams.unitType" clearable placeholder="单位类型">
<el-option
v-for="(item,index) in unitTypeList"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item prop="unitName" label="单位名称">
<el-input
v-model="queryParams.unitName"
placeholder="单位名称"
clearable
:maxlength="255"
size="small"
style="width: 200px"
/>
</el-form-item>
<el-form-item prop="unitNumber" label="管理员账号">
<el-input
v-model="queryParams.unitNumber"
placeholder="管理员账号"
clearable
:maxlength="255"
size="small"
style="width: 200px"
/>
</el-form-item>
<el-form-item>
<el-button
:class="commonField.queryClass"
:type="commonField.typePrimary"
:icon="commonField.queryIcon"
:size="commonField.smallSize"
@click="handleQuery"
>查询</el-button>
<el-button
:class="commonField.resetClass"
:icon="commonField.resetIcon"
:size="commonField.smallSize"
@click="resetQuery"
>重置</el-button>
</el-form-item>
<div style="float: right">
<el-form-item>
<el-button
:class="commonField.addClass"
:type="commonField.typePrimary"
:icon="commonField.addIcon"
:size="commonField.smallSize"
@click="handleAdd"
>新增</el-button>
</el-form-item>
</div>
</el-form>
</div>
<div style="padding:5px 10px">
<div class="tableTitle">单位管理列表</div>
<el-table v-loading="loading" border :data="sysUnitList">
<el-table-column type="index" label="序号" width="55" />
<el-table-column label="单位类型" prop="unitType" width="100" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ findLabelByValue(scope.row.unitType) }}
</template>
</el-table-column>
<el-table-column label="单位名称" prop="unitName" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.unitName || '-' }}
</template>
</el-table-column>
<el-table-column label="管理员账号" prop="unitNumber" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.unitNumber || '-' }}
</template>
</el-table-column>
<el-table-column label="出口ip" prop="exitId" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.exitId || '-' }}
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" label="创建人" prop="createDate" width="160">
<template slot-scope="scope">
<span>{{ scope.row.creteName || '-' }}</span>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" label="创建时间" prop="createDate" width="160">
<template slot-scope="scope">
<span>{{ scope.row.createdDate }}</span>
</template>
</el-table-column>
<el-table-column width="120" label="状态" prop="flag">
<template slot-scope="scope">
<el-switch
v-model="scope.row.flag"
class="switchDisabledStyle"
inactive-value="0"
active-value="1"
@click.native="handleStatusChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="操作" class-name="small-padding fixed-width" width="100px">
<template slot-scope="scope">
<el-button
:class="commonField.updateClass"
:type="commonField.typeParent"
:size="commonField.size"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
:class="commonField.delClass"
:type="commonField.typeParent"
:size="commonField.size"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.rows"
@pagination="getList"
/>
<!-- 添加或修改单位管理配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="90px">
<el-form-item label="单位类型" prop="unitType">
<el-select v-model="form.unitType" style="width: 100%" clearable placeholder="请选择单位类型">
<el-option
v-for="(item,index) in unitTypeList"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="单位名称" prop="unitName">
<el-input v-model.trim="form.unitName" :maxlength="30" placeholder="请输入单位名称" />
</el-form-item>
<el-form-item label="管理员账号" prop="unitNumber">
<el-select v-model="form.unitNumber" style="width: 100%" clearable placeholder="请选择管理员账号">
<el-option
v-for="(item,index) in userList"
:key="index"
:label="item.name"
:value="item.username"
/>
</el-select>
</el-form-item>
<el-form-item label="出口Ip" prop="exitId">
<el-input v-model.trim="form.exitId" :maxlength="255" placeholder="请输入出口id" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button class="cancelBtn" @click="cancel">取 消</el-button>
<el-button class="submitBtn" type="primary" @click="submitForm">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listSysUnit,
getSysUnit,
delSysUnit,
addSysUnit,
updateSysUnit,
exportSysUnit } from '@/api/sysUnit'
import commonField from '@/utils/commonField'
import { listUser } from '@/api/system/user'
export default {
name: "index",
name: 'SysUnit',
data() {
return {
userList: [],
/**
* @description: 用户类型
* @author: gaoyu
* @param:
* @return:
**/
unitTypeList: [
{
label: '企业',
value: '1'
},
{
label: '院校',
value: '2'
}
],
// 遮罩层
loading: true,
// 总条数
total: 0,
// 单位管理表格数据
sysUnitList: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
// 状态菜单
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
page: 1,
rows: 10,
createdBy: undefined,
createdDate: undefined,
updatedBy: undefined,
updatedDate: undefined,
unitType: undefined,
unitName: undefined,
unitNumber: undefined,
exitId: undefined,
flag: ''
},
// 表单参数
form: {},
// 表单校验
rules: {
}
}
},
created() {
computed: {
commonField() {
return commonField
}
},
mounted() {
created() {
this.getUserList()
this.getList() // 列表查询
},
methods: {
getUserList() {
listUser().then(res => {
this.userList = res.rows
})
},
/** 根据value查label**/
findLabelByValue(value) {
if (value && value !== '' && value !== undefined) {
if (this.unitTypeList.find(item => item.value === value)) {
return this.unitTypeList.find(item => item.value === value).label
}
} else {
return '-'
}
},
/** 查询单位管理列表 */
getList() {
this.loading = true
listSysUnit(this.addDateRange(this.queryParams, this.dateRange)).then(
response => {
this.sysUnitList = response.rows
this.total = response.total
this.loading = false
}
)
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
businessId: undefined,
remarks: undefined,
createdBy: undefined,
createdDate: undefined,
updatedBy: undefined,
updatedDate: undefined,
unitType: undefined,
unitName: undefined,
unitNumber: undefined,
exitId: undefined,
flag: '1'
}
this.resetForm('form')
},
/** 查询按钮操作 */
handleQuery() {
this.queryParams.page = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.queryParams = {
page: 1,
rows: 10,
createdBy: undefined,
createdDate: undefined,
updatedBy: undefined,
updatedDate: undefined,
unitType: undefined,
unitName: undefined,
unitNumber: undefined,
exitId: undefined,
flag: ''
}
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = '添加单位'
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const id = row.businessId
getSysUnit(id).then(response => {
this.form = response.data
this.open = true
this.title = '修改单位'
})
},
// 改变状态
handleStatusChange(row) {
const text = row.flag === '1' ? '启用' : '停用'
this.$confirm('确认操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return updateSysUnit(row)
}).then(() => {
this.$message({
message: text + '成功',
type: 'success'
})
}).catch(function() {
row.flag = row.flag === '0' ? '1' : '0'
})
},
/** 提交按钮 */
submitForm: function() {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.form.businessId !== undefined) {
updateSysUnit(this.form).then(response => {
this.msgSuccess('修改成功')
this.open = false
this.getList()
})
} else {
addSysUnit(this.form).then(response => {
this.msgSuccess('新增成功')
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.businessId
this.$confirm('是否确认操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return delSysUnit(id)
}).then(() => {
this.getList()
this.$message({
message: '删除成功',
type: 'success'
})
}).catch(function() {
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams
this.$confirm('是否确认操作?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return exportSysUnit(queryParams).then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '单位管理信息' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
})
})
}
}
}
</script>
<style lang="scss" scoped>
.app-container {
font-size: 18px;
padding: 0;
<style scoped lang="scss">
.unitManagement_module{
.placeholder {
height: 1.3vh;
background-color: #F4F4F4;
margin-bottom: 10px
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment