<template>
|
<div>
|
<div class="body" :style="{height:mainHeight+'px'}">
|
<div class="bodyTopButtonGroup" style="justify-content: space-between">
|
|
<el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
|
|
<div style="display: flex">
|
<el-button icon="el-icon-menu" @click="workingTramClick">生产班组</el-button>
|
<el-button icon="el-icon-download" @click="upload">导入</el-button>
|
</div>
|
</div>
|
|
<div class="bodyTopFormGroup">
|
<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"
|
/>
|
<!-- @focus="getUserOrganization"-->
|
|
</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: flex-start;margin-top: 3px">
|
<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>
|
|
<div class="elTableDiv">
|
<el-table
|
:data="tableData"
|
:height="tableHeight+'px'"
|
highlight-current-row
|
:style="{width: 100+'%',height:tableHeight+'px'}"
|
:header-cell-style="this.$headerCellStyle"
|
:row-class-name="tableRowClassName"
|
:cell-style="this.$cellStyle"
|
border
|
@sort-change="sortChange"
|
>
|
<!-- <el-table-column-->
|
<!-- type="selection"-->
|
<!-- width="50"-->
|
<!-- />-->
|
<el-table-column
|
prop="RowNum"
|
width="50"
|
label="序号"
|
fixed
|
/>
|
<el-table-column
|
prop="usercode"
|
label="用户编码"
|
min-width="110"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="username"
|
label="用户名称"
|
min-width="110"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="password"
|
label="用户密码"
|
min-width="110"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="org_name"
|
label="所属组织"
|
min-width="110"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.org_name">{{ row.org_name }}</div>
|
<div v-else>/</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="group_name"
|
label="生产班组"
|
min-width="110"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.group_name">{{ row.group_name }}</div>
|
<div v-else>/</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="wagetype"
|
label="工资类型"
|
sortable="custom"
|
width="110"
|
>
|
<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="联系方式"
|
min-width="110"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.mobile===''">/</div>
|
<div v-else>{{ row.mobile }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="email"
|
label="电子邮箱"
|
sortable="custom"
|
min-width="110"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.email===''">/</div>
|
<div v-else>{{ row.email }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="enable"
|
label="在职状态"
|
width="110"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.enable==='Y'">
|
<svg-icon icon-class="circleYes" style="margin-right: 2px" />
|
在职
|
</div>
|
<div v-if="row.enable==='N'">
|
<svg-icon icon-class="circleNo" style="margin-right: 2px" />
|
离职
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="lm_user"
|
label="创建人员"
|
width="110"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="lm_date"
|
label="创建时间"
|
width="160"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="is_role"
|
label="关联角色"
|
width="110"
|
>
|
<template slot-scope="{row}">
|
<i v-if="row.is_role==='Y'" class="el-icon-share" @click="roleClick({row})" />
|
<i
|
v-if="row.is_role==='N'"
|
class="el-icon-share"
|
style="color: rgb(180 ,181, 185)"
|
@click="roleClick({row})"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
fixed="right"
|
width="120"
|
>
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<el-tooltip class="item" effect="dark" content="编辑" placement="top">
|
<i class="el-icon-edit-outline" @click="edit('edit',row)" />
|
</el-tooltip>
|
<el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
|
<i class="el-icon-delete" @click="del(row.id)" />
|
</el-tooltip>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<!--分页-->
|
<pagination
|
:total="total"
|
:page.sync="form.page"
|
:limit.sync="form.rows"
|
align="right"
|
layout="total ,prev, pager, next,sizes"
|
popper-class="select_bottom"
|
@pagination="getUserSearch"
|
/>
|
</div>
|
|
<!-- 用户清单新增、编辑-->
|
<el-dialog
|
:title="operation==='add'?'新增':'编辑'"
|
:visible.sync="dialogVisible"
|
width="800px"
|
:close-on-click-modal="false"
|
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: 200px" />
|
</el-form-item>
|
<el-form-item label="用户名称" prop="UserName">
|
<el-input v-model="dialogForm.UserName" style="width: 200px" />
|
</el-form-item>
|
<el-form-item label="用户密码" prop="Password">
|
<el-input v-model="dialogForm.Password" style="width: 200px" />
|
</el-form-item>
|
<el-form-item label="在职状态" prop="Enable">
|
<el-select
|
v-model="dialogForm.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>
|
<el-form-item label="所属组织" prop="StuOrg" style="display: flex;float: left">
|
<el-cascader
|
ref="dialogCascader"
|
key="cascaderKey"
|
filterable
|
popper-class="elCascader"
|
:options="StuOrgArr2"
|
:props="defaultProps"
|
style="width: 200px;"
|
@change="dialogCascaderChange"
|
/>
|
</el-form-item>
|
<el-form-item label="所属班组" prop="groupcode">
|
<el-select
|
v-model="dialogForm.groupcode"
|
:popper-append-to-body="false"
|
filterable
|
style="width: 200px"
|
placeholder="请选择"
|
>
|
<el-option
|
v-for="item in usergroupArr"
|
:key="item.group_code"
|
:label="item.group_name"
|
:value="item.group_code"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工资类型" prop="wagetype">
|
<el-select
|
v-model="dialogForm.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="联系方式" prop="Mobile">
|
<el-input v-model="dialogForm.Mobile" style="width: 200px" />
|
</el-form-item>
|
<el-form-item label="电子邮箱" prop="Email">
|
<el-input v-model="dialogForm.Email" style="width: 200px" />
|
</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="800px"
|
:top="isIpad?'3vh':'15vh'"
|
:fullscreen="isIpad"
|
:close-on-click-modal="false"
|
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
|
style="height: 300px"
|
: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>
|
|
<!-- 产组按钮对话框-->
|
<el-dialog
|
title="生产班组"
|
:visible.sync="workingDialogVisible"
|
width="800px"
|
top="15vh"
|
:close-on-click-modal="false"
|
class="workingDialogVisible"
|
@close="handleCloseWorking"
|
>
|
<!-- <div style="margin-bottom: 10px; padding: 10px 0; background-color: #f8f8fa; display: flex">-->
|
<!-- <el-button style="margin-left: 10px;" type="primary" icon="el-icon-circle-plus-outline" @click="addWorking">新增</el-button>-->
|
<!-- <!– <el-button type="primary" icon="el-icon-delete" @click="delSetting">删除</el-button>–>-->
|
<!-- </div>-->
|
|
<div style="margin-bottom: 20px;display: flex">
|
<el-button type="primary" icon="el-icon-circle-plus-outline" @click="addWorking">新增</el-button>
|
<!-- <el-button type="primary" icon="el-icon-delete" @click="delSetting">删除</el-button>-->
|
</div>
|
<el-table
|
ref="workingTableData"
|
:data="workingTableData"
|
border
|
height="377"
|
highlight-current-row
|
:header-cell-style="this.$headerCellStyle"
|
:cell-style="this.$cellStyle"
|
:row-class-name="tableRowClassName"
|
@sort-change="sortChangeOfWorking"
|
>
|
<!-- :style="{width: 100+'%',height:tableHeight-300+'px'}"-->
|
|
<!-- <el-table-column-->
|
<!-- type="selection"-->
|
<!-- width="50"-->
|
<!-- />-->
|
<el-table-column
|
width="50"
|
label="序号"
|
prop="RowNum"
|
/>
|
<el-table-column
|
prop="group_code"
|
label="班组编码"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<el-input v-if="row.isVisible===1" v-model="row.group_code" oninput="value=value.replace(/[^0-9a-zA-Z]/g,'')" placeholder="请输入" />
|
<div v-else> {{ row.group_code }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="group_name"
|
label="班组名称"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<el-input v-if="row.isVisible===1" v-model="row.group_name" placeholder="请输入" />
|
<div v-else> {{ row.group_name }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="description"
|
label="班组描述"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<el-input v-if="row.isVisible===1" v-model="row.description" placeholder="请输入" />
|
<div v-else> {{ row.description }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作">
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<el-button v-if="row.isVisible===0" type="text" @click="delWorking(row)">删除</el-button>
|
<el-button v-if="row.isVisible===1" type="text" @click="saveWorking(row)">保存</el-button>
|
<el-button v-if="row.isVisible===1" type="text" @click="cancelWorking(row)">取消</el-button>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页-->
|
<pagination
|
:total="workingTableDataLength"
|
:page.sync="formWorking.page"
|
:limit.sync="formWorking.rows"
|
align="right"
|
style="margin-top: 10px"
|
layout="total,prev, pager, next,sizes"
|
popper-class="select_bottom"
|
@pagination="getUserGroupSearch"
|
/>
|
<span slot="footer" class="dialog-footer">
|
<div class="footerButton">
|
<el-button @click="WorkingDialogVisibleCancel">返回</el-button>
|
<!-- <el-button type="primary" @click="settingDialogVisibleConfirm">确 定</el-button>-->
|
</div>
|
</span>
|
</el-dialog>
|
|
<!--导入组件-->
|
<import-picker ref="importPickerFunc" class="importPickerClass" :shows.sync="shows" :title="title_value" :colos="colos" :code="code" />
|
|
</div>
|
</template>
|
|
<script>
|
import Pagination from '@/components/Pagination'
|
import ImportPicker from '@/components/ImportPicker'
|
|
import {
|
AddUpdateUser,
|
DeleteUser,
|
SaveUserAssoctRole,
|
UserAssociationRole,
|
UserGroupAdd,
|
UserGroupDelete,
|
UserGroupSearch,
|
UserOrganization,
|
UserSearch
|
} from '@/api/jcsz'
|
import { getCookie } from '@/utils/auth'
|
import $ from 'jquery'
|
import clearAllChildren, { validateCode } from '@/utils/global'
|
import { MesOrderStepReportSelectUserGroup } from '@/api/scgl'
|
|
export default {
|
name: 'YYQD',
|
components: {
|
Pagination, ImportPicker
|
},
|
data() {
|
const validateMobile = (rule, value, callback) => {
|
if (!value) {
|
callback()
|
// return callback(new Error('请输入电话号码'))
|
} else {
|
const mobile = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ // 长号
|
const mobile2 = /^[0-9]{6}$/ // 短号
|
if (mobile.test(value) || mobile2.test(value)) {
|
callback()
|
// return callback(new Error('电话号码不符合规则'))
|
} else {
|
return callback(new Error('电话号码不符合规则'))
|
// callback()
|
}
|
}
|
}
|
const validateEmail = (rule, value, callback) => {
|
if (!value) {
|
callback()
|
// return callback(new Error('请输入电子邮箱'))
|
} else {
|
const email = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$/
|
if (email.test(value)) {
|
callback()
|
} else {
|
return callback(new Error('电子邮箱不符合规则'))
|
}
|
}
|
}
|
return {
|
isIpad: false,
|
mainHeight: 0,
|
tableHeight: 0,
|
form: {
|
UserCode: '', // 用户编码
|
UserName: '', // 用户名称
|
StuOrg: '', // 所属组织
|
wagetype: '', // 工资类型
|
Enable: '', // 在职状态
|
prop: 'lm_date', // 排序字段
|
order: 'desc', // 排序字段
|
page: 1, // 第几页
|
rows: 20 // 每页多少条
|
},
|
StuOrgArr: [], // 所属组织数组
|
StuOrgArr2: [], // 所属组织数组 对话框
|
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: '123456',
|
Enable: 'Y',
|
StuOrg: '',
|
Mobile: '',
|
Email: '',
|
groupcode: '',
|
Operator: '',
|
OperType: '',
|
wagetype: '2'
|
},
|
usergroupArr: [], // 生产班组数组
|
wagetypeArr: [
|
{ value: '2', label: '计件制' },
|
{ value: '1', label: '计时制' }
|
],
|
operation: '',
|
dialogFormRules: {
|
UserCode: [
|
{ required: true, validator: validateCode, 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'] }
|
],
|
groupcode: [
|
{ required: true, message: '请选择所属班组', trigger: ['blur', 'change'] }
|
],
|
Mobile: [
|
{ required: false, validator: validateMobile, trigger: ['blur', 'change'] }
|
],
|
Email: [
|
{ required: false, validator: validateEmail, trigger: ['blur', 'change'] }
|
]
|
|
},
|
dialogVisibleRoles: false,
|
dialogFormRoles: {
|
username: '', // 用户名称
|
usercode: '', // 用户编码
|
rolesArr: [], // 角色类型集合
|
rolesArrSelectedArr: [], // 角色类型集合选中
|
roleTree: [], // 角色树
|
roleTreeSelectedArr: [] // 角色树选中
|
},
|
rolesAll: [], // 角色所有
|
defaultPropsOfRoleTree: {
|
value: 'code',
|
label: 'name',
|
children: 'children'
|
},
|
workingDialogVisible: false,
|
workingTableData: [],
|
workingTableDataLength: 0,
|
formWorking: {
|
rows: 10,
|
page: 1,
|
prop: 'group_code',
|
order: 'desc'
|
},
|
|
title_value: '数据导入 / 用户清单',
|
code: '2',
|
shows: false
|
}
|
},
|
watch: {
|
shows() {
|
if (!this.shows) {
|
this.getUserSearch()
|
}
|
}
|
},
|
created() {
|
this.handleRequest()
|
},
|
|
mounted() {
|
window.addEventListener('resize', this.getHeight)
|
this.getHeight()
|
},
|
methods: {
|
handleRequest() {
|
this.getUserSearch().then(res => {
|
if (res.code === '200') {
|
this.getUserOrganization()
|
}
|
})
|
},
|
|
// 获取用户清单
|
async getUserSearch() {
|
const res = await UserSearch(this.form)
|
this.tableData = res.data
|
this.total = res.count
|
return { code: res.code }
|
},
|
// 获取所属组织
|
async getUserOrganization() {
|
const { data: res } = await UserOrganization()
|
this.StuOrgArr = clearAllChildren(res)
|
},
|
// 获取所属组织对话框
|
async getUserOrganization2() {
|
const { data: res } = await UserOrganization()
|
this.StuOrgArr2 = clearAllChildren(res)
|
},
|
// 导入按钮
|
upload() {
|
this.shows = true
|
this.$refs.importPickerFunc.newDataFunc()
|
},
|
colos() {
|
this.shows = false
|
},
|
// 排序改变时
|
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 = 'Y'
|
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]
|
},
|
// 获取下拉生产班组
|
async getMesOrderStepReportSelectUserGroup() {
|
const { data: res } = await MesOrderStepReportSelectUserGroup()
|
this.usergroupArr = res
|
},
|
// 新增按钮
|
add(operation) {
|
this.operation = operation
|
this.dialogVisible = true
|
this.getUserOrganization2()
|
this.getMesOrderStepReportSelectUserGroup()
|
},
|
// 修改按钮
|
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.groupcode = row.group_code
|
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
|
})
|
this.getMesOrderStepReportSelectUserGroup()
|
this.getUserOrganization2()
|
},
|
// 删除按钮
|
async del(id) {
|
this.$confirm('是否确认删除?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
DeleteUser({ Userid: id }).then(res => {
|
if (res.code === '200') {
|
this.$message.success('删除成功!')
|
if (this.form.page > 1 && this.tableData.length === 1) {
|
this.form.page--
|
}
|
this.getUserSearch()
|
}
|
})
|
}).catch(() => {
|
this.$message.info('已取消删除')
|
})
|
},
|
// 对话框关闭事件
|
handleClose() {
|
this.dialogForm.UserCode = ''
|
this.dialogForm.UserCode = ''
|
this.dialogForm.UserName = ''
|
this.dialogForm.Password = '123456'
|
this.dialogForm.Enable = 'Y'
|
this.$refs.dialogCascader.checkedValue = ''
|
this.dialogForm.StuOrg = ''
|
this.dialogForm.Mobile = ''
|
this.dialogForm.Email = ''
|
this.dialogForm.groupcode = ''
|
this.dialogForm.wagetype = '2'
|
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,
|
groupcode: this.dialogForm.groupcode,
|
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.mainHeight = window.innerHeight - 85
|
this.tableHeight = this.mainHeight - 200
|
if (window.innerHeight < 769) {
|
this.tableHeight = this.tableHeight - 40
|
}
|
this.isIpad = window.innerHeight < 769 && window.innerWidth < 1367
|
})
|
},
|
// 关联角色点击事件
|
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('保存成功!')
|
await this.getUserSearch()
|
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相同时执行
|
this.dialogFormRoles.roleTreeSelectedArr[ind].Data = this.dialogFormRoles.roleTreeSelectedArr[ind].Data.filter(i2 => i2 !== a[0])
|
} 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)
|
this.dialogFormRoles.roleTreeSelectedArr.splice(ind, 1)
|
}
|
})
|
this.dialogFormRoles.rolesArrSelectedArr.forEach((i, i1) => {
|
if (i === checkedFatherCode) {
|
this.dialogFormRoles.rolesArrSelectedArr.splice(i1, 1)
|
}
|
})
|
}
|
})
|
}
|
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没找对
|
this.dialogFormRoles.roleTreeSelectedArr.splice(ind, 1)
|
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) {
|
this.dialogFormRoles.rolesArrSelectedArr.splice(i1, 1)
|
}
|
})
|
this.dialogFormRoles.roleTreeSelectedArr.forEach((i, i1) => {
|
if (i.Code === it.code) {
|
this.dialogFormRoles.roleTreeSelectedArr.splice(i1, 1)
|
}
|
})
|
}
|
})
|
}
|
|
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)
|
},
|
|
/*
|
生产班组模块
|
*/
|
// 生产班组按钮点击
|
workingTramClick() {
|
this.workingDialogVisible = true
|
this.getUserGroupSearch()
|
// 页面加载完后重新渲染表格
|
this.$nextTick(() => {
|
this.$refs.workingTableData.doLayout()
|
})
|
},
|
// 生产班组对话框关闭事件
|
handleCloseWorking() {
|
this.workingTableData.forEach((item, index) => {
|
if (item.isVisible === 1) {
|
this.workingTableData.splice(index, 1)
|
}
|
})
|
this.getMesOrderStepReportSelectUserGroup()
|
},
|
// 生产班组排序
|
sortChangeOfWorking({ 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.getUserGroupSearch()
|
},
|
// 获取生产班组列表
|
async getUserGroupSearch() {
|
const res = await UserGroupSearch(this.formWorking)
|
this.workingTableData = res.data
|
this.workingTableDataLength = res.count
|
this.workingTableData.forEach(item => {
|
item.isVisible = 0
|
})
|
},
|
// 新增
|
addWorking() {
|
let number = Math.random() * Math.random()// 作为删除时的标识符
|
number = number === 0 ? (10 + Math.random()) : number
|
const data = { group_code: '', group_name: '', description: '', isVisible: 1, number: number }
|
this.workingTableData.unshift(data)
|
},
|
// 删除
|
delWorking(row) {
|
this.$confirm('是否确认删除?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
UserGroupDelete({ UserGrupCode: row.group_code }).then(res => {
|
if (res.code === '200') {
|
this.$message.success('删除成功!')
|
if (this.formWorking.page > 1 && this.workingTableData.length === 1) {
|
this.formWorking.page--
|
}
|
this.getUserGroupSearch()
|
}
|
})
|
}).catch(() => {
|
this.$message.info('已取消删除')
|
})
|
},
|
// 保存
|
async saveWorking(row) {
|
if (row.group_code.trim().length < 1) {
|
return this.$message.info('班组编码不能为空!')
|
}
|
if (row.group_name.trim().length < 1) {
|
return this.$message.info('班组名称不能为空!')
|
}
|
// if (row.description.trim().length < 1) {
|
// return this.$message.info('班组描述不能为空!')
|
// }
|
const data = {
|
code: row.group_code,
|
name: row.group_name,
|
flag: row.description
|
}
|
const res = await UserGroupAdd([data])
|
if (res.code === '200') {
|
this.$message.success('保存成功!')
|
await this.getUserGroupSearch()
|
}
|
},
|
// 取消
|
cancelWorking(row) {
|
this.workingTableData.forEach((item, index) => {
|
if (item.isVisible === 1 && item.number === row.number) {
|
this.workingTableData.splice(index, 1)
|
}
|
})
|
},
|
// 生产班组返回按钮
|
WorkingDialogVisibleCancel() {
|
this.workingDialogVisible = false
|
},
|
tableRowClassName({ row, rowIndex }) {
|
// console.log(row, rowIndex, 12)
|
// if (rowIndex === 1) {
|
// return 'warning-row'
|
// } else if (rowIndex === 3) {
|
// return 'success-row'
|
// }
|
return 'custom-row'
|
}
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
$main_color: #42b983;
|
|
.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;
|
}
|
}
|
}
|
|
.workingDialogVisible ::v-deep .el-dialog__body {
|
padding: 20px 20px !important;
|
}
|
</style>
|
|
<!--公共页面样式-->
|
<style lang="scss" scoped>
|
$main_color: #42b983;
|
|
::v-deep .el-button--text{
|
font-size: 14px ;
|
cursor: pointer ;
|
}
|
.el-icon-share ,.el-icon-delete,.el-icon-edit-outline{
|
color: $main_color;
|
cursor: pointer;
|
}
|
.el-icon-edit-outline{
|
margin-right: 15px;
|
}
|
|
::v-deep .el-button--primary, .el-button--default, .el-button--info {
|
height: 34px;
|
display: flex;
|
align-items: center;
|
padding: 0 15px;
|
}
|
|
::v-deep .el-button--primary {
|
//background-color: $main_color !important;
|
}
|
|
::v-deep .el-button--default {
|
background-color: #f8f8fa;
|
border: none;
|
}
|
|
::v-deep .el-input__inner {
|
height: 34px;
|
line-height: 34px;
|
//color: #a7a7a7;
|
}
|
|
::v-deep .el-dialog__body {
|
padding: 20px 100px !important;
|
}
|
|
::v-deep .dialogVisibleRoles .el-dialog__body {
|
padding: 20px 20px !important;
|
}
|
|
::v-deep .importPickerClass .el-dialog__body {
|
padding: 20px 20px !important;
|
}
|
|
::v-deep .el-dialog__footer {
|
display: flex;
|
justify-content: flex-end;
|
}
|
|
::v-deep .el-table .caret-wrapper {
|
transform: scale(0.8);
|
}
|
|
::v-deep .cell {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
|
::v-deep .el-table::before {
|
height: 0;
|
}
|
|
::v-deep .el-table__body-wrapper {
|
background-color: #f8f8fa;
|
}
|
|
::v-deep .el-table__body .el-table__row.hover-row td{
|
background-color: #eaecef ;
|
}
|
|
::v-deep .el-form--inline .el-form-item__label {
|
color: #a7a7a7;
|
}
|
|
.body ::v-deep .el-divider {
|
border: 1px solid #eee;
|
width: 99%;
|
margin: 10px auto;
|
}
|
|
.body ::v-deep .el-form-item {
|
margin-bottom: 0;
|
}
|
|
</style>
|
<style>
|
|
.el-table .custom-row {
|
background: #f8f8fa;
|
}
|
</style>
|