You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
567 lines
16 KiB
567 lines
16 KiB
<template>
|
|
<div class="app-container">
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-card class="box-card">
|
|
<div class="filter-container">
|
|
<el-form>
|
|
<el-form-item>
|
|
<el-input
|
|
v-model="listQuery.typeCode"
|
|
placeholder="请输入类型代码"
|
|
clearable
|
|
style="width: 200px"
|
|
@keyup.enter.native="handleFilter"
|
|
/>
|
|
<el-input
|
|
v-model="listQuery.typeName"
|
|
placeholder="请输入类型名称"
|
|
clearable
|
|
style="width: 200px"
|
|
@keyup.enter.native="handleFilter"
|
|
/>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-search"
|
|
@click="handleFilter"
|
|
>
|
|
查询
|
|
</el-button>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-edit"
|
|
@click="showCreate"
|
|
>
|
|
添加
|
|
</el-button>
|
|
<el-button
|
|
type="danger"
|
|
icon="el-icon-delete"
|
|
@click="deleteDicType"
|
|
>
|
|
删除
|
|
</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
<el-table
|
|
ref="list"
|
|
:data="list"
|
|
border
|
|
height="700"
|
|
fit
|
|
highlight-current-row
|
|
stripe
|
|
@row-click="onRowClick"
|
|
@selection-change="handleSelectionChange"
|
|
>
|
|
<el-table-column type="selection" width="40" />
|
|
<el-table-column
|
|
align="center"
|
|
type="index"
|
|
label="序号"
|
|
width="50"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="字典类型代码"
|
|
prop="typeCode"
|
|
width="160"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="字典类型名称"
|
|
prop="typeName"
|
|
width="100"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="字典类型释义"
|
|
prop="typeNotes"
|
|
width="160"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="排序序号"
|
|
prop="sort"
|
|
min-width="10"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="操作"
|
|
prop=""
|
|
min-width="20"
|
|
fixed="right"
|
|
>
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
type="primary"
|
|
size="medium"
|
|
title="修改"
|
|
@click="showUpdate(scope.$index)"
|
|
>
|
|
修改
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination
|
|
v-show="total > 0"
|
|
:total="total"
|
|
:page-num.sync="listQuery.pageNum"
|
|
:page-row.sync="listQuery.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
</el-card>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-card class="box-card">
|
|
<div slot="header" class="clearfix">
|
|
<span>字典详情</span>
|
|
<el-button type="primary" icon="el-icon-edit" style="float: right;margin-left:10px" @click="subshowCreate">
|
|
添加
|
|
</el-button>
|
|
<el-button
|
|
type="danger"
|
|
icon="el-icon-delete"
|
|
style="float: right;"
|
|
@click="subdeleteDicType"
|
|
>
|
|
删除
|
|
</el-button>
|
|
</div>
|
|
<el-table
|
|
ref="list"
|
|
:data="sublist"
|
|
border
|
|
fit
|
|
height="700"
|
|
highlight-current-row
|
|
stripe
|
|
@selection-change="handleSelectionChange"
|
|
>
|
|
<el-table-column type="selection" width="40" />
|
|
<el-table-column
|
|
align="center"
|
|
type="index"
|
|
label="序号"
|
|
width="50"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="字典代码"
|
|
prop="code"
|
|
min-width="20"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="字典名称"
|
|
prop="name"
|
|
min-width="40"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="字典值"
|
|
prop="value"
|
|
min-width="20"
|
|
/>
|
|
<el-table-column align="center" label="字典说明" prop="notes" width="150" />
|
|
<el-table-column
|
|
align="center"
|
|
label="排序序号"
|
|
prop="sort"
|
|
min-width="15"
|
|
/>
|
|
<el-table-column
|
|
align="center"
|
|
label="操作"
|
|
prop=""
|
|
min-width="20"
|
|
fixed="right"
|
|
>
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
type="primary"
|
|
size="medium"
|
|
title="修改"
|
|
@click="subshowUpdate(scope.$index)"
|
|
>
|
|
修改
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination v-if="subtotal>0" :total="subtotal" :page-num.sync="sublistQuery.pageNum" :page-row.sync="sublistQuery.pageSize" @pagination="getsubList" />
|
|
</el-card>
|
|
</el-col>
|
|
</el-row>
|
|
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
|
<el-form
|
|
ref="tempDicType"
|
|
:model="tempDicType"
|
|
class="small-space"
|
|
label-position="left"
|
|
label-width="120px"
|
|
style="width: 300px; margin-left: 50px"
|
|
>
|
|
<el-form-item label="字典类型代码" prop="typeCode" required>
|
|
<el-input v-model="tempDicType.typeCode" type="text" />
|
|
</el-form-item>
|
|
<el-form-item label="字典类型名称" prop="typeName" required>
|
|
<el-input v-model="tempDicType.typeName" type="text" />
|
|
</el-form-item>
|
|
<el-form-item label="字典类型释义" prop="typeNotes">
|
|
<el-input v-model="tempDicType.typeNotes" :rows="3" type="textarea" />
|
|
</el-form-item>
|
|
<el-form-item label="排序序号" prop="sort" required>
|
|
<el-input-number v-model="tempDicType.sort" :min="1" :max="100" />
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button @click="dialogFormVisible = false">
|
|
取 消
|
|
</el-button>
|
|
<el-button
|
|
v-if="dialogStatus === 'create'"
|
|
type="success"
|
|
@click="createDicType"
|
|
>
|
|
创 建
|
|
</el-button>
|
|
<el-button v-else type="primary" @click="updateDicType">
|
|
修 改
|
|
</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
<el-dialog :title="textMap[dialogStatus]" :visible.sync="secondDialogFormVisible">
|
|
<el-form ref="tempDicData" :model="tempDicData" class="small-space" label-position="left" label-width="120px" style="width: 300px; margin-left:50px;">
|
|
<el-form-item label="字典类型" prop="typeId" required>
|
|
<el-select v-model="tempDicData.typeId" filterable placeholder="请选择字典类型" clearable>
|
|
<el-option v-for="item in dicTypeList" :key="item.value" :label="item.label" :value="item.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="字典代码" prop="code" required>
|
|
<el-input v-model="tempDicData.code" type="text" />
|
|
</el-form-item>
|
|
<el-form-item label="字典名称" prop="name" required>
|
|
<el-input v-model="tempDicData.name" type="text" />
|
|
</el-form-item>
|
|
<el-form-item label="字典值" prop="value" required>
|
|
<el-input v-model="tempDicData.value" type="text" />
|
|
</el-form-item>
|
|
<el-form-item label="字典说明" prop="notes">
|
|
<el-input v-model="tempDicData.notes" :rows="3" type="textarea" />
|
|
</el-form-item>
|
|
<el-form-item label="所属父类" prop="parentId">
|
|
<el-select v-model="tempDicData.parentId" filterable placeholder="请选择所属父类" clearable>
|
|
<el-option v-for="item in dicDataList" :key="item.value" :label="item.label" :value="item.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="排序序号" prop="sort" required>
|
|
<el-input-number v-model="tempDicData.sort" :min="1" :max="100" />
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button @click="dialogFormVisible = false">
|
|
取 消
|
|
</el-button>
|
|
<el-button v-if="dialogStatus==='create'" type="success" @click="subcreateDicData">
|
|
创 建
|
|
</el-button>
|
|
<el-button v-else type="primary" @click="subupdateDicData">
|
|
修 改
|
|
</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import Pagination from '@/components/Pagination'
|
|
import Utils from '../../utils/contact.js'
|
|
export default {
|
|
name: 'DicTypeList',
|
|
components: { Pagination },
|
|
data() {
|
|
return {
|
|
total: 0, // 分页组件--数据总条数
|
|
list: [], // 表格的数据
|
|
sublist: [],
|
|
listQuery: {
|
|
pageNum: 1, // 页码
|
|
pageSize: 10
|
|
},
|
|
sublistQuery: {
|
|
pageNum: 1, // 页码
|
|
pageSize: 10,
|
|
typeId: ''
|
|
},
|
|
dialogStatus: 'create',
|
|
dialogFormVisible: false,
|
|
secondDialogFormVisible: false,
|
|
textMap: {
|
|
update: '编辑',
|
|
create: '新建字典类型'
|
|
},
|
|
tempDicType: {},
|
|
multipleSelection: [],
|
|
dicTypeList: [],
|
|
dicDataList: [],
|
|
subtotal: 0,
|
|
tempDicData: {
|
|
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
this.getList()
|
|
this.getDicType()
|
|
this.getAllDicData()
|
|
},
|
|
methods: {
|
|
getList() {
|
|
this.api({
|
|
url: '/dicType/list',
|
|
method: 'get',
|
|
params: this.listQuery
|
|
}).then((data) => {
|
|
this.list = data.list
|
|
this.total = data.total
|
|
})
|
|
},
|
|
getAllDicData() {
|
|
this.api({
|
|
url: '/dicData/getAllDicData',
|
|
method: 'get'
|
|
}).then(data => {
|
|
this.dicDataList = data
|
|
})
|
|
},
|
|
getsubList() {
|
|
this.api({
|
|
url: '/dicData/list',
|
|
method: 'get',
|
|
params: this.sublistQuery
|
|
}).then((data) => {
|
|
this.sublist = data.list
|
|
this.subtotal = data.total
|
|
this.spanArr = []
|
|
this.getSpanArr(this.list)
|
|
})
|
|
},
|
|
handleFilter() {
|
|
// 查询事件
|
|
this.listQuery.pageNum = 1
|
|
this.getList()
|
|
},
|
|
onRowClick(row) {
|
|
this.$refs.list.toggleRowSelection(row)
|
|
this.sublistQuery.typeId = row.id
|
|
this.getsubList()
|
|
},
|
|
handleSelectionChange: function(val) {
|
|
this.multipleSelection = val
|
|
},
|
|
showCreate() {
|
|
this.tempDicType = {}
|
|
this.dialogStatus = 'create'
|
|
this.dialogFormVisible = true
|
|
},
|
|
showUpdate($index) {
|
|
this.tempDicType = this.list[$index]
|
|
this.dialogStatus = 'update'
|
|
this.dialogFormVisible = true
|
|
},
|
|
createDicType() {
|
|
this.$refs['tempDicType'].validate((valid) => {
|
|
if (valid) {
|
|
this.api({
|
|
url: '/dicType',
|
|
method: 'post',
|
|
data: this.tempDicType
|
|
}).then(() => {
|
|
this.$message({ message: '添加成功。', type: 'success' })
|
|
this.getList()
|
|
this.dialogFormVisible = false
|
|
})
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
|
|
updateDicType() {
|
|
this.$refs['tempDicType'].validate((valid) => {
|
|
if (valid) {
|
|
this.api({
|
|
url: '/dicType',
|
|
method: 'put',
|
|
data: this.tempDicType
|
|
}).then(() => {
|
|
this.$message({ message: '更新成功。', type: 'success' })
|
|
this.getList()
|
|
this.dialogFormVisible = false
|
|
})
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
getDicType() {
|
|
this.api({
|
|
url: '/dicType/all',
|
|
method: 'get'
|
|
}).then(data => {
|
|
this.dicTypeList = data
|
|
})
|
|
},
|
|
getDicTypeName(row, column, cellValue) {
|
|
for (let i = 0; i < this.dicTypeList.length; i++) {
|
|
if (this.dicTypeList[i].value === cellValue.toString()) {
|
|
return this.dicTypeList[i].label
|
|
}
|
|
}
|
|
},
|
|
deleteDicType() {
|
|
if (this.multipleSelection.length === 0) {
|
|
this.$message({
|
|
type: 'error',
|
|
message: '请选中需要删除的数据!'
|
|
})
|
|
return false
|
|
} else {
|
|
this.$confirm('确定删除当前选中记录?', '提示', {
|
|
confirmButtonText: '确定',
|
|
showCancelButton: true,
|
|
type: 'warning'
|
|
}).then(() => {
|
|
const pks = []
|
|
const qs = require('qs')
|
|
this.multipleSelection.forEach((dicType) => {
|
|
pks.push(dicType.id)
|
|
})
|
|
console.log(pks)
|
|
this.api({
|
|
url: '/dicType',
|
|
method: 'delete',
|
|
params: {
|
|
ids: pks
|
|
},
|
|
paramsSerializer: function(params) {
|
|
return qs.stringify(params, { indices: false })
|
|
}
|
|
}).then(() => {
|
|
this.$message({ message: '删除成功。', type: 'success' })
|
|
this.getList()
|
|
Utils.$emit('dic-data-list')
|
|
})
|
|
})
|
|
}
|
|
},
|
|
subshowCreate() {
|
|
this.tempDicData = {}
|
|
this.getAllDicData()
|
|
this.dialogStatus = 'create'
|
|
this.secondDialogFormVisible = true
|
|
},
|
|
subshowUpdate($index) {
|
|
this.tempDicData = this.sublist[$index]
|
|
this.getAllDicData()
|
|
this.tempDicData.parentId = this.sublist[$index].typeId
|
|
this.dialogStatus = 'update'
|
|
this.secondDialogFormVisible = true
|
|
},
|
|
subcreateDicData() {
|
|
console.log(this.tempDicData)
|
|
this.$refs['tempDicData'].validate(valid => {
|
|
if (valid) {
|
|
this.api({
|
|
url: '/dicData',
|
|
method: 'post',
|
|
data: this.tempDicData
|
|
}).then(() => {
|
|
this.$message({ message: '添加成功。', type: 'success' })
|
|
this.getsubList()
|
|
this.secondDialogFormVisible = false
|
|
})
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
subupdateDicData() {
|
|
this.$refs['tempDicData'].validate(valid => {
|
|
if (valid) {
|
|
this.api({
|
|
url: '/dicData',
|
|
method: 'put',
|
|
data: this.tempDicData
|
|
}).then(() => {
|
|
this.$message({ message: '更新成功。', type: 'success' })
|
|
this.getList()
|
|
this.secondDialogFormVisible = false
|
|
})
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
subdeleteDicType() {
|
|
if (this.multipleSelection.length === 0) {
|
|
this.$message({
|
|
type: 'error',
|
|
message: '请选中需要删除的数据!'
|
|
})
|
|
return false
|
|
} else {
|
|
this.$confirm('确定删除当前选中记录?', '提示', {
|
|
confirmButtonText: '确定',
|
|
showCancelButton: true,
|
|
type: 'warning'
|
|
}).then(() => {
|
|
const pks = []
|
|
const qs = require('qs')
|
|
this.multipleSelection.forEach(dicData => {
|
|
pks.push(dicData.id)
|
|
})
|
|
this.api({
|
|
url: '/dicData',
|
|
method: 'delete',
|
|
params: {
|
|
ids: pks
|
|
},
|
|
paramsSerializer: function(params) {
|
|
return qs.stringify(params, { indices: false })
|
|
}
|
|
}).then(() => {
|
|
this.$message({ message: '删除成功。', type: 'success' })
|
|
this.getsubList()
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped>
|
|
.text {
|
|
font-size: 14px;
|
|
}
|
|
|
|
.item {
|
|
margin-bottom: 18px;
|
|
}
|
|
|
|
.clearfix:before,
|
|
.clearfix:after {
|
|
display: table;
|
|
content: "";
|
|
}
|
|
.clearfix:after {
|
|
clear: both;
|
|
}
|
|
|
|
.box-card {
|
|
width: 98%;
|
|
overflow-y: scroll;
|
|
}
|
|
</style>
|
|
|