| | |
| | | <template> |
| | | <div> |
| | | <div class="body" :style="{height:mainHeight+'px'}"> |
| | | <div style="padding: 10px 5px 0 0"> |
| | | <el-form |
| | | ref="form" |
| | | :model="form" |
| | | label-width="80px" |
| | | inline |
| | | style="display: flex;justify-content: space-between" |
| | | > |
| | | <div class="elForm"> |
| | | <el-form-item label="用户编码" style=" display: flex;"> |
| | | <el-input v-model="form.UserCode" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" style=" display: flex;"> |
| | | <el-input v-model="form.UserName" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="所属组织" style=" display: flex;"> |
| | | <el-cascader |
| | | ref="cascader" |
| | | filterable |
| | | popper-class="elCascader" |
| | | :options="StuOrgArr" |
| | | :props="defaultProps" |
| | | @change="cascaderChange" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="工资类型" style=" display: flex;"> |
| | | <el-select v-model="form.wagetype" :popper-append-to-body="false" filterable style="width: 200px" placeholder="请选择"> |
| | | <el-option |
| | | |
| | | v-for="item in wagetypeArr" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="在职状态" style=" display: flex;"> |
| | | <el-select v-model="form.Enable" :popper-append-to-body="false" filterable style="width: 200px" placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in EnableArr" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </div> |
| | | <div style="display: flex;align-items: start;margin-top: 5px;"> |
| | | <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button> |
| | | <el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button> |
| | | </div> |
| | | </el-form> |
| | | </div> |
| | | <el-divider /> |
| | | <div style="margin-left: 10px;display: flex"> |
| | | <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button> |
| | | <el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button> |
| | | </div> |
| | | <el-divider /> |
| | | <div class="elTableDiv"> |
| | | <el-table |
| | | :data="tableData" |
| | | border |
| | | stripe |
| | | :height="tableHeight" |
| | | highlight-current-row |
| | | :style="{width: 100+'%',height:tableHeight+'px'}" |
| | | :header-cell-style="this.$headerCellStyle" |
| | | :cell-style="this.$cellStyle" |
| | | @sort-change="sortChange" |
| | | > |
| | | <!-- <el-table-column--> |
| | | <!-- type="selection"--> |
| | | <!-- width="50"--> |
| | | <!-- />--> |
| | | <el-table-column |
| | | prop="RowNum" |
| | | width="50" |
| | | label="序号" |
| | | /> |
| | | <el-table-column |
| | | prop="usercode" |
| | | label="用户编码" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="username" |
| | | label="用户名称" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="password" |
| | | label="用户密码" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="org_name" |
| | | label="所属组织" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="wagetype" |
| | | label="所属组织" |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <div v-if="row.wagetype==='1'">计时制</div> |
| | | <div v-if="row.wagetype==='2'">计件制</div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="mobile" |
| | | label="联系方式" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="email" |
| | | label="电子邮箱" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="" |
| | | label="在职状态" |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <div v-if="row.enable==='Y'">在职</div> |
| | | <div v-if="row.enable==='N'">离职</div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="lm_user" |
| | | label="创建人员" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="lm_date" |
| | | label="创建时间" |
| | | width="200" |
| | | show-overflow-tooltip |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="is_role" |
| | | label="关联角色" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <i class="el-icon-share" @click="roleClick({row})" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="操作" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <div class="operationClass"> |
| | | <el-button type="text" @click="edit('edit',row)">修改</el-button> |
| | | <el-button type="text" @click="del(row.id)">删除</el-button> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | <!--分页--> |
| | | <pagination |
| | | v-show="total>0" |
| | | :total="total" |
| | | :page.sync="form.page" |
| | | :limit.sync="form.rows" |
| | | align="right" |
| | | layout="prev, pager, next,sizes" |
| | | popper-class="select_bottom" |
| | | @pagination="getUserSearch" |
| | | /> |
| | | </div> |
| | | |
| | | <!-- 用户清单新增、修改--> |
| | | <el-dialog |
| | | :title="operation==='add'?'新增':'修改'" |
| | | :visible.sync="dialogVisible" |
| | | width="50%" |
| | | top="15vh" |
| | | @closed="handleClose" |
| | | @close="handleClose" |
| | | > |
| | | <el-form ref="dialogForm" :rules="dialogFormRules" inline :model="dialogForm" label-width="80px"> |
| | | <el-form-item label="用户编码" prop="UserCode"> |
| | | <el-input v-model="dialogForm.UserCode" :disabled="operation!=='add'" style="width: 220px" /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" prop="UserName"> |
| | | <el-input v-model="dialogForm.UserName" style="width: 220px" /> |
| | | </el-form-item> |
| | | <el-form-item label="用户密码" prop="Password"> |
| | | <el-input v-model="dialogForm.Password" style="width: 220px" /> |
| | | </el-form-item> |
| | | <el-form-item label="在职状态" prop="Enable"> |
| | | <el-select |
| | | v-model="dialogForm.Enable" |
| | | :popper-append-to-body="false" |
| | | filterable |
| | | style="width: 220px" |
| | | placeholder="请选择" |
| | | > |
| | | <el-option |
| | | v-for="item in EnableArr" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="所属组织" prop="StuOrg" style="display: flex;float: left"> |
| | | <el-cascader |
| | | ref="dialogCascader" |
| | | key="cascaderKey" |
| | | filterable |
| | | popper-class="elCascader" |
| | | :options="StuOrgArr" |
| | | :props="defaultProps" |
| | | style="width: 220px;" |
| | | @change="dialogCascaderChange" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="工资类型" prop="wagetype"> |
| | | <el-select |
| | | v-model="dialogForm.wagetype" |
| | | :popper-append-to-body="false" |
| | | filterable |
| | | style="width: 220px" |
| | | placeholder="请选择" |
| | | > |
| | | <el-option |
| | | v-for="item in wagetypeArr" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="联系方式"> |
| | | <el-input v-model="dialogForm.Mobile" style="width: 220px" /> |
| | | </el-form-item> |
| | | <el-form-item label="电子邮箱"> |
| | | <el-input v-model="dialogForm.Email" style="width: 220px" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <div class="footerButton"> |
| | | <el-button @click="dialogVisibleCancel">取 消</el-button> |
| | | <el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button> |
| | | </div> |
| | | </span> |
| | | </el-dialog> |
| | | |
| | | <!-- 关联角色--> |
| | | <el-dialog |
| | | title="关联角色" |
| | | :visible.sync="dialogVisibleRoles" |
| | | width="50%" |
| | | top="15vh" |
| | | class="dialogVisibleRoles" |
| | | @closed="handleCloseRoles" |
| | | @close="handleCloseRoles" |
| | | > |
| | | <!-- @opened="handleOpenedRoles"--> |
| | | |
| | | <div> |
| | | <i class="el-icon-s-comment" style="color:#42b983;" /> 用户名称:{{ dialogFormRoles.username }} |
| | | </div> |
| | | <el-divider /> |
| | | <div> |
| | | <div style="margin-bottom:20px"> |
| | | <i class="el-icon-s-operation" style="color:#42b983;" /> 角色类型集合: |
| | | </div> |
| | | <div class="myCheckboxGroup"> |
| | | <div |
| | | v-for="item in dialogFormRoles.rolesArr" |
| | | :key="item.code" |
| | | :style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}" |
| | | class="myCheckbox" |
| | | @click="myCheckboxClick(item)" |
| | | > |
| | | <input |
| | | class="myCheckboxInput" |
| | | type="checkbox" |
| | | :value="item.code" |
| | | :name="item.name" |
| | | :style="{color:item.isSelected2?'#42b983':'#fff'}" |
| | | @click="myCheckboxInputClick(item)" |
| | | >{{ item.name }} |
| | | <!-- 父子点击事件不影响--> |
| | | <!-- onClick="event.cancelBubble = true"--> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-divider /> |
| | | <div> |
| | | <div style="margin-bottom:20px"> |
| | | <i class="el-icon-s-operation" style="color:#42b983;" /> 角色: |
| | | </div> |
| | | <el-tree |
| | | ref="roleTree" |
| | | :data="dialogFormRoles.roleTree" |
| | | show-checkbox |
| | | node-key="code" |
| | | default-expand-all |
| | | :props="defaultPropsOfRoleTree" |
| | | @check="checkBoxClick" |
| | | /> |
| | | <!-- @check-change="checkChange"--> |
| | | |
| | | </div> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <div class="footerButton"> |
| | | <el-button @click="rolesDialogVisibleCancel">取 消</el-button> |
| | | <el-button type="primary" @click="rolesDialogVisibleConfirm">确 定</el-button> |
| | | </div> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import Pagination from '@/components/Pagination' |
| | | import { |
| | | AddUpdateUser, |
| | | DeleteUser, SaveUserAssoctRole, UserAssociationRole, |
| | | UserOrganization, |
| | | UserSearch |
| | | } from '@/api/jcsz' |
| | | import { getCookie } from '@/utils/auth' |
| | | import $ from 'jquery' |
| | | |
| | | const SER_HZ = /^[\u4e00-\u9fa5]+$/ |
| | | export default { |
| | | name: "yhqd" |
| | | name: 'Zzjg', |
| | | components: { |
| | | Pagination |
| | | }, |
| | | data() { |
| | | const validateName = (rule, value, callback) => { |
| | | if (!value) { |
| | | return callback(new Error('请输入编码')) |
| | | } else { |
| | | if (SER_HZ.test(value)) { |
| | | return callback(new Error('编码不能为中文')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | } |
| | | return { |
| | | mainHeight: 0, |
| | | tableHeight: 0, |
| | | form: { |
| | | UserCode: '', // 用户编码 |
| | | UserName: '', // 用户名称 |
| | | StuOrg: '', // 所属组织 |
| | | wagetype: '', // 工资类型 |
| | | Enable: '', // 在职状态 |
| | | prop: 'lm_date', // 排序字段 |
| | | order: 'desc', // 排序字段 |
| | | page: 1, // 第几页 |
| | | rows: 20 // 每页多少条 |
| | | }, |
| | | StuOrgArr: [], // 所属组织数组 |
| | | defaultProps: { |
| | | checkStrictly: true, |
| | | value: 'code', |
| | | label: 'name', |
| | | children: 'children' |
| | | }, |
| | | EnableArr: [ |
| | | { value: 'Y', label: '在职' }, |
| | | { value: 'N', label: '离职' } |
| | | ], // 在职状态 |
| | | total: 10, |
| | | tableData: [], |
| | | dialogVisible: false, |
| | | dialogForm: { |
| | | id: '', |
| | | UserCode: '', |
| | | UserName: '', |
| | | Password: '', |
| | | Enable: '', |
| | | StuOrg: '', |
| | | Mobile: '', |
| | | Email: '', |
| | | Operator: '', |
| | | OperType: '', |
| | | wagetype: '' |
| | | }, |
| | | wagetypeArr: [ |
| | | { value: '2', label: '计件制' }, |
| | | { value: '1', label: '计时制' } |
| | | ], |
| | | operation: '', |
| | | dialogFormRules: { |
| | | UserCode: [ |
| | | { required: true, validator: validateName, trigger: ['blur', 'change'] } |
| | | ], |
| | | UserName: [ |
| | | { required: true, message: '请输入用户名称', trigger: ['blur', 'change'] } |
| | | ], |
| | | Password: [ |
| | | { required: true, message: '请输入用户密码', trigger: ['blur', 'change'] } |
| | | ], |
| | | Enable: [ |
| | | { required: true, message: '请选择在职状态', trigger: ['blur', 'change'] } |
| | | ], |
| | | StuOrg: [ |
| | | { required: true, message: '请选择所属组织', trigger: ['blur', 'change'] } |
| | | ], |
| | | wagetype: [ |
| | | { required: true, message: '请选择工资类型', trigger: ['blur', 'change'] } |
| | | ] |
| | | }, |
| | | dialogVisibleRoles: false, |
| | | dialogFormRoles: { |
| | | username: '', // 用户名称 |
| | | usercode: '', // 用户编码 |
| | | rolesArr: [], // 角色类型集合 |
| | | rolesArrSelectedArr: [], // 角色类型集合选中 |
| | | roleTree: [], // 角色树 |
| | | roleTreeSelectedArr: [] // 角色树选中 |
| | | }, |
| | | rolesAll: [], // 角色所有 |
| | | defaultPropsOfRoleTree: { |
| | | value: 'code', |
| | | label: 'name', |
| | | children: 'children' |
| | | } |
| | | |
| | | } |
| | | }, |
| | | created() { |
| | | this.getUserSearch() |
| | | this.getUserOrganization() |
| | | }, |
| | | mounted() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | }, |
| | | methods: { |
| | | // 获取用户清单 |
| | | async getUserSearch() { |
| | | const res = await UserSearch(this.form) |
| | | this.tableData = res.data |
| | | this.total = res.count |
| | | }, |
| | | // 获取所属组织 |
| | | async getUserOrganization() { |
| | | const { data: res } = await UserOrganization() |
| | | this.StuOrgArr = res |
| | | }, |
| | | // 导入按钮 |
| | | upload() { |
| | | |
| | | }, |
| | | // 排序改变时 |
| | | sortChange({ column, prop, order }) { |
| | | if (order === 'descending') { |
| | | order = 'desc' |
| | | } else if (order === 'ascending') { |
| | | order = 'asc' |
| | | } else { |
| | | order = 'desc' |
| | | } |
| | | this.form.order = order |
| | | this.form.prop = prop |
| | | this.getUserSearch() |
| | | }, |
| | | // 查询 |
| | | search() { |
| | | this.getUserSearch() |
| | | }, |
| | | // 重置 |
| | | reset() { |
| | | this.form.UserCode = '' |
| | | this.form.UserName = '' |
| | | this.form.StuOrg = '' |
| | | this.form.Enable = '' |
| | | this.form.wagetype = '' |
| | | this.$refs.cascader.checkedValue = ''// 级联选择器的清空 |
| | | this.getUserSearch() |
| | | }, |
| | | // 级联选择器改变事件 |
| | | cascaderChange(val) { |
| | | this.form.StuOrg = val[val.length - 1] |
| | | }, |
| | | dialogCascaderChange(val) { |
| | | this.dialogForm.StuOrg = val[val.length - 1] |
| | | }, |
| | | // 新增按钮 |
| | | add(operation) { |
| | | this.operation = operation |
| | | this.dialogVisible = true |
| | | }, |
| | | // 修改按钮 |
| | | edit(operation, row) { |
| | | this.operation = operation |
| | | this.dialogVisible = true |
| | | console.log(row) |
| | | |
| | | this.$nextTick(() => { |
| | | this.dialogForm.id = row.id |
| | | this.dialogForm.UserCode = row.usercode |
| | | this.dialogForm.UserName = row.username |
| | | this.dialogForm.Password = row.password |
| | | this.dialogForm.Enable = row.enable |
| | | this.dialogForm.StuOrg = row.stu_torgcode |
| | | this.$refs.dialogCascader.checkedValue = row.stu_torgcode |
| | | this.dialogForm.Mobile = row.mobile |
| | | this.dialogForm.Email = row.email |
| | | this.dialogForm.wagetype = row.wagetype |
| | | }) |
| | | }, |
| | | // 删除按钮 |
| | | async del(id) { |
| | | this.$confirm('是否确认删除?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | DeleteUser({ Userid: id }).then(res => { |
| | | if (res.code === '200') { |
| | | this.$message.success('删除成功!') |
| | | this.getUserSearch() |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | this.$message.info('已取消删除') |
| | | }) |
| | | }, |
| | | // 对话框关闭事件 |
| | | handleClose() { |
| | | this.dialogForm.UserCode = '' |
| | | this.dialogForm.UserCode = '' |
| | | this.dialogForm.UserName = '' |
| | | this.dialogForm.Password = '' |
| | | this.dialogForm.Enable = '' |
| | | this.$refs.dialogCascader.checkedValue = '' |
| | | this.dialogForm.StuOrg = '' |
| | | this.dialogForm.Mobile = '' |
| | | this.dialogForm.Email = '' |
| | | this.dialogForm.wagetype = '' |
| | | this.$refs.dialogForm.clearValidate() |
| | | }, |
| | | // 对话框取消 |
| | | dialogVisibleCancel() { |
| | | this.dialogVisible = false |
| | | }, |
| | | // 对话框确认 |
| | | dialogVisibleConfirm() { |
| | | this.$refs.dialogForm.validate(valid => { |
| | | if (valid) { |
| | | const data = { |
| | | id: this.dialogForm.id, |
| | | UserCode: this.dialogForm.UserCode, |
| | | UserName: this.dialogForm.UserName, |
| | | Password: this.dialogForm.Password, |
| | | Enable: this.dialogForm.Enable, |
| | | // StuOrg: this.dialogForm.StuOrg, |
| | | StuOrg: Array.isArray(this.$refs.dialogCascader.checkedValue) ? this.$refs.dialogCascader.checkedValue[this.$refs.dialogCascader.checkedValue.length - 1] : this.$refs.dialogCascader.checkedValue, |
| | | Mobile: this.dialogForm.Mobile, |
| | | Email: this.dialogForm.Email, |
| | | wagetype: this.dialogForm.wagetype, |
| | | OperType: this.operation === 'add' ? 'Add' : 'Update', |
| | | Operator: getCookie('admin') |
| | | } |
| | | AddUpdateUser(data).then(res => { |
| | | if (res.code === '200') { |
| | | this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!') |
| | | this.dialogVisible = false |
| | | this.getUserSearch() |
| | | } else { |
| | | this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!') |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | // 获取页面高度 |
| | | getHeight() { |
| | | this.$nextTick(() => { |
| | | this.mainHeight = window.innerHeight - 250 |
| | | this.tableHeight = this.mainHeight - 100 |
| | | }) |
| | | }, |
| | | // 关联角色点击事件 |
| | | async roleClick({ row }) { |
| | | this.dialogFormRoles.rolesArrSelectedArr = [] |
| | | this.dialogFormRoles.rolesArr = [] |
| | | this.dialogFormRoles.roleTreeSelectedArr = [] |
| | | this.dialogVisibleRoles = true |
| | | this.dialogFormRoles.username = row.username |
| | | this.dialogFormRoles.usercode = row.usercode |
| | | const { data: res } = await UserAssociationRole({ usercode: row.usercode }) |
| | | this.rolesAll = res |
| | | |
| | | const nodeKey = []// 树形回显key |
| | | res.forEach((item, index) => { |
| | | this.dialogFormRoles.rolesArr.push({ |
| | | code: item.code, |
| | | name: item.name, |
| | | flag: item.flag, |
| | | isSelected1: false, |
| | | isSelected2: false |
| | | }) |
| | | if (item.flag === 'Y') { |
| | | this.dialogFormRoles.rolesArr[index].isSelected2 = true |
| | | this.$nextTick(() => { |
| | | // $('input:checkbox').eq(index).attr('checked', true)// 自定义单选框回显 |
| | | $('input:checkbox').eq(index).prop('checked', true)// 自定义单选框回显 |
| | | }) |
| | | this.dialogFormRoles.rolesArrSelectedArr.push(item.name) |
| | | if (item.children && item.children.length > 0) { |
| | | const Data = [] |
| | | item.children.forEach(it => { |
| | | if (it.flag === 'Y') { |
| | | nodeKey.push(it.code) |
| | | Data.push(it.code) |
| | | } |
| | | }) |
| | | this.dialogFormRoles.roleTreeSelectedArr.push({ Code: item.code, Name: item.name, Data: Data }) |
| | | } |
| | | } |
| | | }) |
| | | console.log(this.dialogFormRoles.roleTreeSelectedArr, 11) |
| | | console.log(this.dialogFormRoles.rolesArr, 888) |
| | | |
| | | this.dialogFormRoles.rolesArr[0].isSelected1 = true// 默认选中第一个 |
| | | // this.dialogFormRoles.rolesArr[0].name = '全部' |
| | | |
| | | this.dialogFormRoles.roleTree = this.rolesAll.filter(item => item.code === this.dialogFormRoles.rolesArr[0].code) |
| | | this.dialogFormRoles.roleTree[0].name = '全部' |
| | | // this.dialogFormRoles.rolesArr |
| | | console.log(nodeKey, 1) |
| | | this.$refs.roleTree.setCheckedKeys(nodeKey) |
| | | }, |
| | | // 处理用户关联对话框关闭事件 |
| | | handleCloseRoles() { |
| | | this.$refs.roleTree.setCheckedKeys([]) |
| | | this.dialogFormRoles.rolesArrSelectedArr = [] |
| | | }, |
| | | // 用户关联对话框取消事件 |
| | | rolesDialogVisibleCancel() { |
| | | this.dialogVisibleRoles = false |
| | | }, |
| | | // 用户关联对话框确认事件 |
| | | async rolesDialogVisibleConfirm() { |
| | | console.log(this.dialogFormRoles.roleTreeSelectedArr, 333337) |
| | | const res = await SaveUserAssoctRole(this.dialogFormRoles.roleTreeSelectedArr, this.dialogFormRoles.usercode) |
| | | if (res.code === '200') { |
| | | this.$message.success('保存成功!') |
| | | this.dialogVisibleRoles = false |
| | | } |
| | | }, |
| | | // 树形复选框点击事件 |
| | | checkBoxClick(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) { |
| | | // console.log(obj, checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys, 78787878) |
| | | |
| | | // 找到 checkedFatherCode 父code值 |
| | | // 当halfCheckedKeys不等等零的时候 |
| | | // let checkedFatherCode = halfCheckedKeys.length !== 0 ? halfCheckedKeys[0] : checkedKeys[0] |
| | | let checkedFatherCode = '' // 找到 checkedFatherCode 父code值 |
| | | // if (checkedFatherCode === undefined) { |
| | | // console.log(this.rolesAll, 66666) |
| | | this.rolesAll.forEach((item, index) => { |
| | | if (item.code === obj.code) { |
| | | checkedFatherCode = item.code |
| | | } |
| | | if (item.children && item.children.length > 0) { |
| | | item.children.forEach((it, ind) => { |
| | | if (it.code === obj.code) { |
| | | checkedFatherCode = item.code |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | // } |
| | | console.log(checkedFatherCode, 8) |
| | | |
| | | // 1.第一种情况当树形 半叶 不为零 全叶 不为零 |
| | | if (halfCheckedKeys.length !== 0 && checkedKeys.length !== 0) { |
| | | this.dialogFormRoles.rolesArr.forEach((item, index) => { |
| | | if (item.code === checkedFatherCode) { |
| | | console.log('1.第一种情况当树形 半叶 不为零 全叶 不为零') |
| | | this.dialogFormRoles.rolesArr[index].isSelected2 = true |
| | | this.$nextTick(() => { |
| | | // $('input:checkbox').eq(index).attr('checked', true)// 自定义单选框回显 |
| | | $('input:checkbox').eq(index).prop('checked', true)// 自定义单选框回显 |
| | | }) |
| | | const temp = this.rolesAll.filter(it => it.code === checkedFatherCode)// 过滤出每次选中的大项 |
| | | temp.forEach(it => { |
| | | const a = [] |
| | | it.children.forEach(it => { |
| | | if (it.code === obj.code) { |
| | | a.push(it.code) |
| | | } |
| | | }) |
| | | // console.log(!this.dialogFormRoles.roleTreeSelectedArr.some(i => i.Code === checkedFatherCode)) |
| | | if (!this.dialogFormRoles.roleTreeSelectedArr.some(i => i.Code === checkedFatherCode)) { // 当直接选父code时执行 |
| | | this.dialogFormRoles.roleTreeSelectedArr.push({ |
| | | Code: it.code, |
| | | Name: it.name, |
| | | Data: a |
| | | }) |
| | | } else { |
| | | this.dialogFormRoles.roleTreeSelectedArr.forEach((i, ind) => { // 当选子code时执行 |
| | | if (i.Code === checkedFatherCode) { |
| | | this.dialogFormRoles.roleTreeSelectedArr[ind].Data.forEach((i1, ind2) => { |
| | | if (i1 === a[0]) { |
| | | this.dialogFormRoles.roleTreeSelectedArr[ind].Data.splice(ind2, 1)// 当子code与现在的code相同时执行 |
| | | } else { |
| | | this.dialogFormRoles.roleTreeSelectedArr[ind].Data.push(a[0])// //当子code与现在的code不相同时执行 |
| | | } |
| | | }) |
| | | // this.dialogFormRoles.roleTreeSelectedArr[ind].Data.filter((i1, ind2) => i1 !== a[0])// 过滤掉选中相同的 |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | console.log(this.dialogFormRoles.roleTreeSelectedArr, 11) |
| | | |
| | | // 2.第二种情况当树形 半叶 为零 全叶 为零 |
| | | if (halfCheckedKeys.length === 0 && checkedKeys.length === 0) { |
| | | this.dialogFormRoles.rolesArr.forEach((item, index) => { |
| | | if (item.code === checkedFatherCode) { |
| | | console.log('2.第二种情况当树形 半叶 为零 全叶 为零') |
| | | this.dialogFormRoles.rolesArr[index].isSelected2 = false |
| | | this.$nextTick(() => { |
| | | // console.log($('input:checkbox').eq(1).attr('checked', false), 88888) |
| | | $('input:checkbox').eq(index).prop('checked', false)// 自定义单选框回显 |
| | | }) |
| | | this.dialogFormRoles.roleTreeSelectedArr.forEach((it, ind) => { |
| | | if (it.Code === checkedFatherCode) { |
| | | console.log(it.Code, 9) |
| | | console.log(this.dialogFormRoles.roleTreeSelectedArr.splice(ind, 1), 7) |
| | | } |
| | | }) |
| | | this.dialogFormRoles.rolesArrSelectedArr.forEach((i, i1) => { |
| | | if (i === checkedFatherCode) { |
| | | console.log(this.dialogFormRoles.rolesArrSelectedArr.splice(i1, 1), 8) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | console.log(this.dialogFormRoles.roleTreeSelectedArr, 22) |
| | | |
| | | // 3.第三种种情况当树形 半叶 为零 全叶 不为零 |
| | | if (halfCheckedKeys.length === 0 && checkedKeys.length !== 0) { |
| | | // this.dialogFormRoles.roleTreeSelectedArr = [] |
| | | this.dialogFormRoles.rolesArr.forEach((item, index) => { |
| | | if (item.code === checkedFatherCode) { |
| | | console.log(' 3.第三种种情况当树形 半叶 为零 全叶 不为零') |
| | | this.dialogFormRoles.rolesArr[index].isSelected2 = true |
| | | this.$nextTick(() => { |
| | | // $('input:checkbox').eq(index).attr('checked', true)// 自定义单选框回显 |
| | | $('input:checkbox').eq(index).prop('checked', true)// 自定义单选框回显 |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | const temp = this.rolesAll.filter(it => it.code === checkedFatherCode)// 过滤出每次选中的大项 |
| | | // console.log(!this.dialogFormRoles.roleTreeSelectedArr.some(i => i.Code === checkedFatherCode)) |
| | | if (!this.dialogFormRoles.roleTreeSelectedArr.some(i => i.Code === checkedFatherCode)) { // 当父类为全叶时 |
| | | temp.forEach(it => { |
| | | this.dialogFormRoles.roleTreeSelectedArr.push({ |
| | | Code: it.code, |
| | | Name: it.name, |
| | | Data: it.children.map(i => i.code) |
| | | }) |
| | | }) |
| | | } else { // 当父类由半叶变为全叶时 |
| | | this.dialogFormRoles.roleTreeSelectedArr.forEach((i1, ind) => { |
| | | if (i1.Code === checkedFatherCode) { // i1没找对 |
| | | console.log(i1, this.dialogFormRoles.roleTreeSelectedArr.splice(ind, 1), 8) |
| | | temp.forEach(it => { |
| | | this.dialogFormRoles.roleTreeSelectedArr.push({ |
| | | Code: it.code, |
| | | Name: it.name, |
| | | Data: it.children.map(i => i.code) |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | // myCheckBox点击事件 大盒子点击 |
| | | myCheckboxClick(item) { |
| | | console.log(this.dialogFormRoles.rolesArr, 7) |
| | | this.dialogFormRoles.rolesArr.forEach(it => { |
| | | it.isSelected1 = it.code === item.code |
| | | }) |
| | | this.dialogFormRoles.roleTree = this.rolesAll.filter(it => it.code === item.code) |
| | | this.dialogFormRoles.roleTree[0].name = '全部' |
| | | if (this.dialogFormRoles.roleTree[0].children.length < 1) { |
| | | this.dialogFormRoles.roleTree = '' |
| | | } |
| | | const temp = this.dialogFormRoles.roleTreeSelectedArr.filter(it => it.Code === item.code) |
| | | console.log(temp, 33) |
| | | if (temp.length > 0) { |
| | | this.$refs.roleTree.setCheckedKeys(temp[0].Data)// 树形选中回显 |
| | | } else { |
| | | this.$refs.roleTree.setCheckedKeys([])// 当长度为零时置空 |
| | | } |
| | | }, |
| | | // myCheckBoxInput点击事件 小盒子点击(input) |
| | | myCheckboxInputClick(item) { |
| | | item.isSelected2 = !item.isSelected2 |
| | | this.dialogFormRoles.rolesArrSelectedArr = [...new Set(this.dialogFormRoles.rolesArrSelectedArr)]// 数组去重 |
| | | if (item.isSelected2) { // 从没选中到选中 |
| | | console.log('从没选中到选中') |
| | | this.dialogFormRoles.rolesArr.forEach(it => { |
| | | if (it.code === item.code && item.isSelected2) { |
| | | this.dialogFormRoles.rolesArrSelectedArr.push(it.code) |
| | | } |
| | | }) |
| | | |
| | | const temp = this.rolesAll.filter(it => it.code === item.code)// 过滤出每次选中的大项 |
| | | |
| | | temp.forEach(it => { |
| | | this.dialogFormRoles.roleTreeSelectedArr.push({ |
| | | Code: it.code, |
| | | Name: it.name, |
| | | Data: it.children.map(i => i.code) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (!item.isSelected2) { // 从选中到没选中 |
| | | console.log('从选中到没选中') |
| | | this.dialogFormRoles.rolesArr.forEach((it, ind) => { |
| | | if (it.code === item.code && !item.isSelected2) { |
| | | console.log('进来了') |
| | | console.log(this.dialogFormRoles.rolesArrSelectedArr, 78) |
| | | this.dialogFormRoles.rolesArrSelectedArr.forEach((i, i1) => { |
| | | if (i === it.code) { |
| | | console.log(this.dialogFormRoles.rolesArrSelectedArr.splice(i1, 1), 6664) |
| | | } |
| | | }) |
| | | this.dialogFormRoles.roleTreeSelectedArr.forEach((i, i1) => { |
| | | if (i.Code === it.code) { |
| | | console.log(i1, this.dialogFormRoles.roleTreeSelectedArr.splice(i1, 1), 6665) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.$refs.roleTree.setCheckedKeys(this.dialogFormRoles.rolesArrSelectedArr) |
| | | // this.$refs.roleTree.getCheckedKeys()//只能获取到第一个树形 |
| | | |
| | | this.dialogFormRoles.rolesArrSelectedArr = [...new Set(this.dialogFormRoles.rolesArrSelectedArr)]// 数组去重 |
| | | // 数组中对象相同的去重 |
| | | // this.dialogFormRoles.roleTreeSelectedArr = this.dialogFormRoles.roleTreeSelectedArr.filter((currentValue, currentIndex, selfArr) => { |
| | | // return selfArr.findIndex(item => item.code === currentValue.Code) === currentIndex |
| | | // }) |
| | | console.log(this.dialogFormRoles.rolesArrSelectedArr, 6666) |
| | | console.log(this.dialogFormRoles.roleTreeSelectedArr, 6777) |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | <style lang="scss" scoped> |
| | | $main_color: #42b983; |
| | | ::v-deep .el-button--primary { |
| | | background-color: $main_color !important; |
| | | height: 30px; |
| | | display: flex; |
| | | align-items: center; |
| | | //border: 1px solid $main_color; |
| | | border: none; |
| | | padding: 0 20px; |
| | | } |
| | | ::v-deep .el-button--primary:hover { |
| | | border: none; |
| | | } |
| | | |
| | | ::v-deep .el-button--info { |
| | | //background-color: $main_color !important; |
| | | height: 30px; |
| | | display: flex; |
| | | align-items: center; |
| | | padding: 0 20px; |
| | | } |
| | | |
| | | ::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active { |
| | | background-color: $main_color !important; |
| | | } |
| | | |
| | | ::v-deep .el-dialog__footer { |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | } |
| | | |
| | | .footerButton { |
| | | display: flex; |
| | | justify-content: end; |
| | | } |
| | | |
| | | ::v-deep .el-button--default { |
| | | background-color: #ffffff !important; |
| | | height: 30px; |
| | | display: flex; |
| | | align-items: center; |
| | | padding: 0 20px; |
| | | } |
| | | |
| | | ::v-deep .el-button--default:hover { |
| | | color: #606266; |
| | | } |
| | | |
| | | ::v-deep .el-dialog__body { |
| | | padding: 20px 100px !important; |
| | | } |
| | | |
| | | ::v-deep .el-radio__input.is-checked .el-radio__inner { |
| | | background-color: $main_color; |
| | | border-color: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-radio__input.is-checked + .el-radio__label { |
| | | color: $main_color !important; |
| | | } |
| | | |
| | | ::v-deep .el-checkbox__input.is-checked .el-checkbox__inner { |
| | | border-color: $main_color; |
| | | background-color: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-input__inner { |
| | | height: 30px; |
| | | line-height: 30px; |
| | | } |
| | | |
| | | ::v-deep .el-table .caret-wrapper { |
| | | transform: scale(0.8); |
| | | } |
| | | |
| | | ::v-deep .cell { |
| | | display: flex !important; |
| | | align-items: center !important; |
| | | justify-content: space-between !important; |
| | | } |
| | | |
| | | ::v-deep .el-button--text { |
| | | color: $main_color; |
| | | font-size: 14px; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .operationClass { |
| | | height: 23px; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | } |
| | | |
| | | .el-icon-share { |
| | | color: $main_color; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .el-checkbox.is-bordered.is-checked { |
| | | border-color: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-radio__input.is-checked .el-radio__inner { |
| | | border-color: $main_color; |
| | | background: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner { |
| | | border-color: $main_color; |
| | | background: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-checkbox__input.is-checked + .el-checkbox__label { |
| | | color: $main_color !important; |
| | | } |
| | | |
| | | ::v-deep .el-checkbox.is-bordered + .el-checkbox.is-bordered { |
| | | margin: 10px 30px 0px 0; |
| | | } |
| | | |
| | | ::v-deep .el-radio__input.is-checked + .el-radio__label { |
| | | color: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-radio.is-bordered + .el-radio.is-bordered { |
| | | margin: 10px 30px 0px 0; |
| | | } |
| | | |
| | | .dialogVisibleRoles { |
| | | .myCheckboxGroup { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | |
| | | .myCheckbox { |
| | | border: 1px solid #eee; |
| | | display: flex; |
| | | min-width: 100px; |
| | | padding: 10px; |
| | | margin: 10px 30px 0 0; |
| | | border-radius: 5px; |
| | | cursor: default; |
| | | |
| | | .myCheckboxInput { |
| | | margin: 1px 5px 0 0; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | } |
| | | |
| | | input[type=checkbox] { |
| | | cursor: pointer; |
| | | position: relative; |
| | | width: 14px; |
| | | height: 14px; |
| | | font-size: 14px; |
| | | } |
| | | |
| | | input[type=checkbox]::after { |
| | | position: absolute; |
| | | top: 0; |
| | | color: $main_color; |
| | | width: 14px; |
| | | height: 14px; |
| | | display: inline-block; |
| | | visibility: visible; |
| | | padding-left: 0; |
| | | text-align: center; |
| | | content: ' '; |
| | | border-radius: 3px |
| | | } |
| | | |
| | | input[type=checkbox]:checked::after { |
| | | content: "✓"; |
| | | //content: "√"; |
| | | color: #fff; |
| | | font-size: 12px; |
| | | font-weight: bold; |
| | | background-color: $main_color; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .body ::v-deep .el-divider { |
| | | border: 1px solid #eee; |
| | | width: 99%; |
| | | margin: 10px auto; |
| | | } |
| | | |
| | | .body ::v-deep .el-form-item { |
| | | margin-bottom: 0; |
| | | } |
| | | |
| | | ::v-deep .el-input__inner:focus { |
| | | border-color: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-select .el-input__inner:focus{ |
| | | border-color: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-select-dropdown__item.selected{ |
| | | color: $main_color; |
| | | } |
| | | |
| | | ::v-deep .el-input__inner:focus { |
| | | border-color: #42b983 !important; |
| | | } |
| | | |
| | | //::v-deep .el-cascader:not(.is-disabled):hover .el-input__inner:focus { |
| | | // border-color: #42b983 !important; |
| | | //} |
| | | </style> |
| | | <style lang="scss"> |
| | | .elCascader { |
| | | //.el-cascader-node.in-active-path, .el-cascader-node.is-active, .el-cascader-node.is-selectable.in-checked-path { |
| | | // color: #42b983 ; |
| | | //} |
| | | .el-cascader-node.is-selectable.in-checked-path { |
| | | color: #42b983; |
| | | } |
| | | |
| | | .el-radio__input.is-checked .el-radio__inner { |
| | | background-color: #42b983; |
| | | border-color: #42b983; |
| | | } |
| | | .el-radio__input.is-checked .el-radio__inner:hover { |
| | | border-color: #42b983; |
| | | } |
| | | .el-input__inner{ |
| | | border-color: #42b983 !important; |
| | | } |
| | | |
| | | } |
| | | </style> |