| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453 |
- <template>
- <div class="app-container">
- <div class="app-container">
- <div class = "search-bx" >
- <div class="search">
- <el-row :gutter="0">
- <el-col :span="21">
- <el-input v-model="get_table_dataParm.parammaps.ename" placeholder="姓名" style="width: 180px;" class="filter-item" clearable />
- <el-select v-model="get_table_dataParm.parammaps.departmentId" placeholder="集团" class="filter-item" style="width: 120px;" clearable>
- <el-option v-for="(item,index) in departmentList" :key="index" :label="item.name" :value="item.id" />
- </el-select>
- </el-col>
- <el-col :span="3">
- <el-button class="successBorder" @click="form_search">查询</el-button>
- <el-button class="successBorder" @click="form_clear">重置</el-button>
- </el-col>
- </el-row>
- </div>
- <div class="operation">
- <el-row :gutter="0">
- <el-col :span="21">
- <el-button class="success" icon="el-icon-plus" @click="form_add">新增</el-button>
- </el-col>
- <el-col :span="3">
- </el-col>
- </el-row>
- </div>
- </div>
- <div class="table" style="margin-top:100px">
- <el-table v-loading="listLoading" element-loading-text="给我一点时间" :data="list" border fit highlight-current-row style="width: 100%;" :row-style="rowStyle" :cell-style="cellStyle" class="elTable" row-key="id">
- <el-table-column label="序号" align="center" type="index" width="50px">
- <template slot-scope="scope">
- <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="姓名" header-align="center" align="center" width="200px">
- <template slot-scope="scope">
- <span>{{ scope.row.ename }}</span>
- </template>
- </el-table-column>
- <el-table-column label="部门" width="200px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.dname }}</span>
- </template>
- </el-table-column>
- <el-table-column label="电话" width="200px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.telephone }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备注" width="200px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.remark }}</span>
- </template>
- </el-table-column>
- <el-table-column label="顺序" width="100px" header-align="center" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.sort }}</span>
- </template>
- </el-table-column>
- <el-table-column label="启用" min-width="80px" header-align="center" align="center">
- <template slot-scope="scope">
- <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="change_enable(scope.$index, scope.row)" />
- </template>
- </el-table-column>
- <el-table-column label="操作" header-align="center" align="center" width="260" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <el-button type="primary" size="mini" @click="form_edit(row)">
- 编辑
- </el-button>
- <el-button v-if="row.status!='已删'" size="mini" type="danger" @click="handleDelete(row)">
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination v-show="total>=0" :total="total" :page.sync="get_table_dataParm.offset" :limit.sync="get_table_dataParm.pagecount" @pagination="get_table_data" />
- </div>
- <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="40%">
- <el-form ref="dataForm" :rules="rules" :model="deptform" label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
- <el-form-item label="姓名" prop="ename">
- <el-input ref="ename" v-model="deptform.ename" />
- </el-form-item>
- <el-form-item label="部门" prop="parentid">
- <tree-select :disabled="disabled" :height="280" :width="200" size="small" :data="parent" :default-props="defaultProps" clearable :node-key="nodeKey" :checked-keys="defaultCheckedKeys" @popoverHide="popoverHide" />
- </el-form-item>
- <el-form-item label="电话" prop="telephone">
- <el-input ref="telephone" v-model="deptform.telephone" maxlength="11" />
- </el-form-item>
- <el-form-item label="备注" prop="remark">
- <el-input ref="remark" v-model="deptform.remark" />
- </el-form-item>
- <el-form-item label="顺序" prop="sort">
- <el-input ref="sort" v-model="deptform.sort" />
- </el-form-item>
- <el-form-item label="启用" prop="enable">
- <el-switch ref="enable" v-model="deptform.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button class="cancelClose" @click="dialogFormVisible = false;get_table_data()">关闭</el-button>
- <el-button class="success" @click="dialogStatus==='create'?add_dialog_save():form_edit_save()">确认</el-button>
- </div>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import TreeSelect from '@/components/TreeSelect'
- import waves from '@/directive/waves' // waves directive
- import Cookies from 'js-cookie'
- import { isIntegerZero } from '@/utils/validate'
- import { PostDataByName, GetDataByName, transData, failproccess, } from '@/api/common'
- import { MessageBox } from 'element-ui'
- import Pagination from '@/components/Pagination'
- export default {
- name: 'StaffManagement',
- components: { TreeSelect, Pagination },
- directives: { waves },
- filters: {
- menutypeFilter(menutype) {
- const menutypeMap = {
- menu: '',
- button: 'warning'
- }
- return menutypeMap[menutype]
- }
- },
- data() {
- return {
- disabled: false,
- tableKey: 0,
- list: [
- { 'deptname': '公司', 'id': 1, 'parentid': -1, 'remark': '' }
- ],
- parent: [],
- parentmenu: [],
- parentButton: [],
- departmentList: [],
- requestParam: {
- name: 'insertEmployees',
- parammaps: {}
- },
- deptform: {
- id: '',
- ename: '',
- remark: '',
- sort: '',
- parentid: '0',
- telephone: "",
- enable: '1'
- },
- get_table_dataParm: {
- name: 'getEmployees',
- page: 1,
- offset: 1,
- pagecount: parseInt(Cookies.get('pagecount')),
- returntype: 'Map',
- parammaps: {
- ename: "",
- departmentId: "",
- }
- },
- listLoading: true,
- tableKey: 0,
- list: [],
- total: 0,
- getRecuListParm: { name: 'getDepartmentCascade' },
- getRecuListBParm: { name: 'getMenuListBRecu',
- idname: 'id',
- parammaps: { id: 0 }
- },
- rules: {
- ename: [{ type: 'string', required: true, message: '姓名必填', trigger: 'change' }],
- parentid: [{ required: true, message: '部门名称必填', trigger: 'change' }],
- telephone: [{ required: true, message: '电话不能为空'},
- { min: 11, max: 11, message: '必填11个字符', trigger: 'blur' }],
- sort: [{ validator: isIntegerZero, trigger: 'blur' }]
- },
- dialogFormVisible: false,
- dialogStatus: '',
- textMap: {
- update: '编辑',
- create: '新增'
- },
- rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
- cellStyle: { padding: 0 + 'px' },
- defaultProps: {
- children: 'children',
- label: 'title'
- },
- nodeKey: 'id',
- defaultCheckedKeys: []
- }
- },
- created() {
- this.get_table_data()
- this.get_select_list()
- },
- methods: {
- popoverHide(checkedIds, checkedData) {
- this.deptform.parentid = checkedIds
- },
- form_search() {
- console.log('点击了查询')
- this.get_table_dataParm.offset = 1
- this.get_table_data()
- },
- form_clear() {
- console.log('点击了重置')
- this.get_table_dataParm.parammaps.departmentId = ''
- this.get_table_dataParm.parammaps.ename = ''
- this.get_table_dataParm.offset = 1
- this.get_table_data()
- },
- get_table_data() {
- this.listLoading = true
- GetDataByName(this.get_table_dataParm).then(response => {
- if (response.data.list !== null) {
- console.log(this.list, '-----------------')
- for (var i = 0; i < response.data.list.length; i++) {
- response.data.list[i].enable = parseInt(response.data.list[i].enable)
- }
- this.list = response.data.list
- this.pageNum = response.data.pageNum
- this.pageSize = response.data.pageSize
- this.total = response.data.total
- } else {
- this.list = []
- }
- setTimeout(() => {
- this.listLoading = false
- }, 0.5 * 1000)
- })
- },
- get_select_list() {
- GetDataByName(this.getRecuListParm).then(response => {
- if (response.data.list !== null) {
- this.parentmenu = transData(response.data.list, 'id', 'parentid', 'children')
- }
- })
- GetDataByName({ name: 'getDepartmentsSelect', offset: 0, pagecount: 0, parammaps: {} }).then(response => {
- console.log("部门下拉框", response)
- this.departmentList = response.data.list
- })
- },
- refreshDownList() {
- for (var val of this.parentmenu) {
- this.parent = []
- this.parent.push({ id: val.id, title: val.title, parentid: val.parentid })
- }
- },
- resetRequestParam() {
- this.deptform.parentid = '0'
- this.deptform.departmentid = '0'
- this.deptform.ename = ''
- this.deptform.remark = ''
- this.deptform.sort = '0'
- this.deptform.telephone = ''
- this.deptform.id = ''
- this.deptform.enable = 1
- },
- form_add() {
- this.resetRequestParam()
- this.dialogStatus = 'create'
- this.parent = this.parentmenu
- this.dialogFormVisible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].clearValidate()
- })
- },
- add_dialog_save() {
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- this.requestParam.name = 'insertEmployees'
- if (this.deptform.parentid === '') this.deptform.parentid = '0'
- this.requestParam.parammaps = {
- id: '',
- ename: this.deptform.ename,
- telephone: this.deptform.telephone,
- remark: this.deptform.remark,
- sort: this.deptform.sort,
- departmentId: this.deptform.parentid,
- enable: this.deptform.enable
- }
- PostDataByName(this.requestParam).then((response) => {
- console.log('新增保存发送参数', this.requestParam)
- if (response.msg !== 'fail') {
- this.get_table_data()
- this.dialogFormVisible = false
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- } else {
- this.$notify({ title: '失败', message: '保存失败', type: 'error', duration: 2000 })
- }
- })
- }
- })
- },
- form_edit(row) {
- this.parent = this.parentmenu
- console.log('row=====>', row)
- this.defaultCheckedKeys = [row.departmentid]
- console.log(this.defaultCheckedKeys)
- this.deptform.departmentid = row.departmentid
- this.deptform.parentid = row.departmentid
- this.deptform.ename = row.ename
- this.deptform.remark = row.remark
- this.deptform.sort = row.sort
- this.deptform.telephone = row.telephone
- this.deptform.id = row.id
- this.deptform.enable = row.enable
- this.dialogStatus = 'update'
- this.dialogFormVisible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].clearValidate()
- })
- },
- form_edit_save() {
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- this.requestParam.name = 'updateEmployees'
- this.requestParam.parammaps = {
- id: this.deptform.id,
- ename: this.deptform.ename,
- telephone: this.deptform.telephone,
- remark: this.deptform.remark,
- sort: this.deptform.sort,
- departmentId: this.deptform.parentid,
- enable: this.deptform.enable
- }
- console.log(this.requestParam)
- PostDataByName(this.requestParam).then((response) => {
- console.log('编辑保存发送参数', this.requestParam)
- if (response.msg !== 'fail') {
- this.get_table_data()
- this.dialogFormVisible = false
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- } else {
- this.$notify({ title: '失败', message: '保存失败', type: 'error', duration: 2000 })
- }
- })
- }
- })
- },
- change_enable(index, row) {
- this.requestParam.name = 'updateEmployees'
- this.requestParam.parammaps = {
- id: row.id,
- ename: row.ename,
- telephone: row.telephone,
- remark: row.remark,
- sort: row.sort,
- departmentId: row.departmentid,
- enable: row.enable
- }
- PostDataByName(this.requestParam).then((response) => {
- console.log('编辑保存发送参数', this.requestParam)
- if (response.msg !== 'fail') {
- this.get_table_data()
- this.dialogFormVisible = false
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- } else {
- this.$notify({ title: '失败', message: '保存失败', type: 'error', duration: 2000 })
- }
- })
- },
- handleDelete(row) {
- MessageBox.confirm('确认删除此信息?', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.requestParam.name = 'delEmployees'
- this.requestParam.parammaps = {
- id: row.id,
- }
- PostDataByName(this.requestParam).then(() => {
- this.get_table_data()
- this.dialogFormVisible = false
- this.$notify({
- title: '成功',
- message: '删除成功',
- type: 'success',
- duration: 2000
- })
- })
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .search {
- padding-top: 10px;
- clear: both;
- }
- .table {
- margin-top: 10px;
- }
- </style>
|