123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- define(function (require) {
- return function (context) {
- var $grid1, $grid2, $dlg, $form;
- var tabIndex = 0, tabSelect = 1;
- var search = [{
- queryProperties: ''
- }, {
- queryProperties: ''
- }];
- // 输入搜索文本后点击回车按钮查询列表
- function enterQueryGrid1(e) {
- if (e.keyCode === 13) {
- var tmp = $(this).val();
- $form.formSet({queryProperties: tmp});
- queryGrid1();
- queryGrid2();
- }
- }
- //左侧列表
- function queryGrid1() {
- $grid1.jqGrid("clearGridData");
- var obj = $form.formGet();
- obj.roleId = context.roleId;
- $grid1.reload({
- url: api('/hr/userRole/querySys'),
- mtype: 'POST',
- queryParams: obj
- });
- if ($grid2 != undefined) {
- $grid2.jqGrid("clearGridData");
- }
- }
- //右侧列表
- function queryGrid2() {
- $grid2.jqGrid("clearGridData");
- var obj = $form.formGet();
- obj.roleId = context.roleId;
- $grid2.reload({
- url: api('/sys/sysRole/querySysRoleNot'),
- mtype: 'POST',
- queryParams: obj
- });
- }
- return {
- xtype: 'dialog',
- dialogId: 'dialogHrUserRole',
- title: '分配角色人员',
- width: '100%',
- height: '100%',
- onOpen: function () {
- $dlg = $(this);
- if (context.isEdit) {
- }
- },
- north: {
- height: 90,
- split: true,
- border: false,
- items: [
- {
- xtype: 'toolbar', title: '', items: [
- {
- text: '查询', iconCls: 'fa fa-search', onClick: function () {
- if (tabIndex == 0) {
- queryGrid1();
- } else if (tabIndex == 1) {
- queryGrid2();
- }
- }
- }, {
- text: '重置', iconCls: 'fa fa-refresh', onClick: function () {
- $form.formClear();
- if (tabIndex == 0) {
- queryGrid1();
- } else if (tabIndex == 1) {
- queryGrid2();
- }
- }
- }, {
- text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () {
- $dlg.window('close');
- }
- }
- ]
- }, {
- xtype: 'form',
- onRender: function () {
- $form = $(this);
- },
- items: [[
- {name: 'roleId', label: '当前角色 》', labelWidth: 'auto', value: context.roleName, readonly: true},
- {
- xtype: 'textbox',
- label: '检索条件',
- name: 'queryProperties',
- prompt: '姓名/用户名/手机号/部门',
- labelWidth: 'auto', events: {keydown: enterQueryGrid1}
- },
- {
- xtype: 'yvselect', label: '是否分配角色', name: 'hasRole', labelWidth: 'auto', width: 220,
- data: [{"id": '', "text": '全部'}, {"id": '0', "text": '未分配'}, {"id": '1', "text": '已分配'}], value: '',
- onChange: function () {
- if (tabIndex == 0) {
- queryGrid1();
- } else if (tabIndex == 1) {
- queryGrid2();
- }
- }
- },
- ]]
- }
- ]
- },
- center: {
- items: {
- xtype: 'tabs',
- onRender: function () {
- var $tabs = $(this);
- $tabs.tabs('select', tabSelect);
- },
- //切换tabs事件
- onSelect: function (title, index) { //得到第几个grid被选中
- var obj = $form.formGet();
- search[0].queryProperties = obj.queryProperties;
- search[1].queryProperties = obj.queryProperties;
- var _data = search[index];
- $form.formSet({
- queryProperties: _data.queryProperties
- });
- tabIndex = index;
- },
- items:
- [
- {
- title: '已选择',
- lazy: true,
- items: {
- onRender: function () {
- $grid1 = $(this);
- queryGrid1(); //初始化数据
- },
- xtype: 'grid',
- pagination: true,
- toolbar: {
- xtype: 'toolbar',
- title: '已选择的人员',
- items: [
- {
- text: '移除人员', iconCls: 'fa fa-times', onClick: function () {
- var row = $grid1.rowData();
- if (!row) {
- $.yvan.msg('请先选择一行数据');
- return;
- }
- if (row.hurId == undefined || row.hurId == null) {
- $.yvan.msg('请先选择一行数据');
- return;
- }
- $.yvan.confirm('确定移除 [' + row.name + ']吗?', {
- yes: function () {
- $.yvan.ajax({
- url: api('/hr/userRole/delete'),
- method: 'post',
- data: {
- hurId: row.hurId,
- roleName: context.roleName,
- userId:row.userId,
- roleId:row.roleId,
- },
- success: function () {
- $.yvan.msg('操作成功');
- $grid1.reload();
- if ($grid2 != undefined && $grid2 != null) {
- $grid2.reload();
- }
- context.confirm();
- }
- });
- }
- });
- }
- }
- ]
- },
- columns: [[
- {field: 'hurId', title: '选择', hidden: true},
- {field: 'sysId', title: '用户ID', hidden: true},
- {field: 'userId', title: '用户ID', hidden: true},
- {field: 'roleId', title: '用户ID', hidden: true},
- {field: 'name', title: '姓名'},
- {field: 'gender', title: '性别', align: 'center', formatter: $.fn.fmatter.genderSrc},
- {field: 'account', title: '用户名'},
- {field: 'mobile', title: '手机号'},
- {field: 'deptName', title: '所属部门'},
- {field: 'roleName', title: '拥有角色'},
- {field: 'timeCreate', title: '加入时间', align: 'center', formatter: 'ts'},
- ]],
- }
- },
- {
- title: '待选择',
- lazy: true,
- items: {
- onRender: function () {
- $grid2 = $(this);
- queryGrid2(); //初始化数据
- },
- xtype: 'grid',
- toolbar: {
- xtype: 'toolbar',
- title: '待选择的人员', items: [
- {
- text: '新增人员', iconCls: 'fa fa-plus-circle', onClick: function () {
- var row = $grid2.rowData();
- if (!row) {
- $.yvan.msg('请先选择一行数据');
- return;
- }
- if (row.userId == undefined || row.userId == null) {
- $.yvan.msg('请先选择一行数据');
- return;
- }
- var obj = $form.formGet();
- if (obj.farmId == "" || obj.farmId == 0) {
- $.yvan.msg('请先选择加入的库区');
- return;
- }
- $.yvan.ajax({
- url: api('/hr/userRole/insert'),
- method: 'post',
- data: {
- userId: row.userId,
- roleId: context.roleId,
- sysId: obj.sysId,
- name:row.name,
- roleName:row.roleNames,
- mobile:row.mobile,
- deptNames:row.deptNames,
- jobcard:row.jobcard,
- gender:row.gender,
- xtRoleName:context.roleName,
- },
- success: function () {
- $.yvan.msg('操作成功');
- $grid1.reload();
- $grid2.reload();
- context.confirm();
- }
- });
- }
- }
- ]
- },
- columns: [[
- {field: 'userId', title: '用户ID', hidden: true},
- {field: 'name', title: '姓名'},
- {field: 'gender', title: '性别', align: 'center', formatter: $.fn.fmatter.genderSrc},
- {field: 'gender', title: '性别', hidden: true},
- {field: 'account', title: '用户名'},
- {field: 'mobile', title: '手机号'},
- {field: 'deptNames', title: '所属部门'},
- {field: 'roleNames', title: '拥有角色'},
- {field: 'jobcard', title: '职工号', hidden: true},
- {field: 'userCreate', title: '新增人', hidden: true},
- {field: 'timeCreate', title: '新增时间', hidden: true},
- ]]
- }
- }
- ]
- }
- }
- };
- };
- }
- );
|