* Rewrite for batch edit user page.

This commit is contained in:
wangyidong
2023-07-19 13:36:24 +08:00
parent e01b5660e2
commit 6fd7d0943d
10 changed files with 114 additions and 24 deletions
+6 -1
View File
@@ -29,9 +29,12 @@ $config->company->user->actionList['delete']['data-toggle'] = 'modal';
$config->company->user->dtable = new stdclass();
$config->company->user->dtable->fieldList['id']['name'] = 'id';
$config->company->user->dtable->fieldList['id']['title'] = $lang->idAB;
$config->company->user->dtable->fieldList['id']['type'] = 'id';
$config->company->user->dtable->fieldList['id']['type'] = 'checkID';
$config->company->user->dtable->fieldList['id']['fixed'] = 'left';
$config->company->user->dtable->fieldList['id']['sortType'] = true;
$config->company->user->dtable->fieldList['id']['checkbox'] = true;
$config->company->user->dtable->fieldList['id']['show'] = true;
$config->company->user->dtable->fieldList['id']['group'] = 1;
$config->company->user->dtable->fieldList['realname']['name'] = 'realname';
$config->company->user->dtable->fieldList['realname']['title'] = $lang->user->realname;
@@ -39,6 +42,7 @@ $config->company->user->dtable->fieldList['realname']['type'] = 'text';
$config->company->user->dtable->fieldList['realname']['group'] = '1';
$config->company->user->dtable->fieldList['realname']['fixed'] = 'left';
$config->company->user->dtable->fieldList['realname']['sortType'] = true;
$config->company->user->dtable->fieldList['realname']['group'] = '1';
$config->company->user->dtable->fieldList['account']['name'] = 'account';
$config->company->user->dtable->fieldList['account']['title'] = $lang->user->account;
@@ -86,6 +90,7 @@ else
$config->company->user->dtable->fieldList['email']['name'] = 'email';
$config->company->user->dtable->fieldList['email']['title'] = $lang->user->email;
$config->company->user->dtable->fieldList['email']['type'] = 'text';
$config->company->user->dtable->fieldList['email']['width'] = 200;
$config->company->user->dtable->fieldList['email']['sortType'] = true;
$config->company->user->dtable->fieldList['email']['group'] = '4';
+12
View File
@@ -0,0 +1,12 @@
$(document).off('click', '.batch-btn').on('click', '.batch-btn', function()
{
const $this = $(this);
const dtable = zui.DTable.query($('#userList'));
const checkedList = dtable.$.getChecks();
if(!checkedList.length) return;
const postData = new FormData();
checkedList.forEach((id) => postData.append('users[]', id));
postAndLoadPage($this.data('url'), postData);
});
+7 -6
View File
@@ -53,24 +53,25 @@ sidebar
'modules' => $deptTree,
'activeKey' => $type == 'bydept' ? $param : 0,
'settingLink' => $settingLink,
'closeLink' => $closeLink
'closeLink' => $closeLink,
'showDisplay' => false,
'settingText' => $lang->dept->manage,
)))
);
$footToolbar = common::hasPriv('user', 'batchEdit') ? array(
'items' => array
(
array('text' => $lang->edit, 'className' => 'secondary batch-btn', 'data-url' => createLink('user', 'batchEdit')),
),
'items' => array(array('text' => $lang->edit, 'className' => 'secondary batch-btn', 'data-url' => createLink('user', 'batchEdit'))),
'btnProps' => array('size' => 'sm', 'btnType' => 'secondary')
) : '';
) : null;
if(common::hasPriv('user', 'batchEdit')) $this->config->company->user->dtable->fieldList['id']['type'] = 'checkID';
$tableData = initTableData($users, $this->config->company->user->dtable->fieldList, $this->loadModel('user'));
dtable
(
setID('userList'),
set::cols($this->config->company->user->dtable->fieldList),
set::data($tableData),
set::checkable(common::hasPriv('user', 'batchEdit')),
set::fixedLeftWidth('0.2'),
set::footToolbar($footToolbar),
set::footPager(usePager()),
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
global $lang;
$config->personnel->accessible = new stdClass();
$config->personnel->accessible->search['module'] = 'accessible';
$config->personnel->accessible->search['module'] = 'personnel';
$config->personnel->accessible->search['fields']['realname'] = $lang->personnel->realName;
$config->personnel->accessible->search['fields']['role'] = $lang->personnel->job;
$config->personnel->accessible->search['fields']['account'] = $lang->personnel->userName;
+22
View File
@@ -1,4 +1,5 @@
<?php
global $lang;
$config->user->form = new stdclass();
$config->user->form->batchCreate = common::formConfig('user', 'batchCreate');
$config->user->form->batchCreate['dept'] = array('required' => false, 'type' => 'int', 'default' => 0);
@@ -14,3 +15,24 @@ $config->user->form->batchCreate['email'] = array('required' => false, 'type'
$config->user->form->batchCreate['gender'] = array('required' => false, 'type' => 'string', 'default' => '');
$config->user->form->batchCreate['password'] = array('required' => true, 'type' => 'string', 'default' => '');
$config->user->form->batchCreate['join'] = array('required' => false, 'type' => 'date', 'default' => null);
$config->user->form->batchEdit = array();
$config->user->form->batchEdit['dept'] = array('required' => false, 'type' => 'int', 'width' => '200px', 'name' => 'dept', 'label' => $lang->user->dept, 'control' => 'picker', 'default' => 0, 'ditto' => true);
$config->user->form->batchEdit['account'] = array('required' => true, 'type' => 'string', 'width' => '160px', 'name' => 'account', 'label' => $lang->user->account, 'control' => 'text', 'default' => '', 'filter' => 'trim', 'base' => true);
$config->user->form->batchEdit['realname'] = array('required' => true, 'type' => 'string', 'width' => '150px', 'name' => 'realname', 'label' => $lang->user->realname, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['visions'] = array('required' => true, 'type' => 'string', 'width' => '200px', 'name' => 'visions', 'label' => $lang->user->visions, 'control' => 'picker', 'default' => $config->vision, 'multiple' => true, 'filter' => 'join');
$config->user->form->batchEdit['role'] = array('required' => false, 'type' => 'string', 'width' => '200px', 'name' => 'role', 'label' => $lang->user->role, 'control' => 'picker', 'default' => '', 'ditto' => true, 'items' => $lang->user->roleList);
$config->user->form->batchEdit['type'] = array('required' => false, 'type' => 'string', 'width' => '200px', 'name' => 'type', 'label' => $lang->user->type, 'control' => 'picker', 'default' => 'inside', 'items' => $lang->user->typeList);
$config->user->form->batchEdit['commiter'] = array('required' => false, 'type' => 'string', 'width' => '160px', 'name' => 'commiter', 'label' => $lang->user->commiter, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['email'] = array('required' => false, 'type' => 'string', 'width' => '160px', 'name' => 'email', 'label' => $lang->user->email, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['join'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'join', 'label' => $lang->user->join, 'control' => 'date', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['skype'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'skype', 'label' => $lang->user->skype, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['qq'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'qq', 'label' => $lang->user->qq, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['dingding'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'dingding', 'label' => $lang->user->dingding, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['weixin'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'weixin', 'label' => $lang->user->weixin, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['mobile'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'mobile', 'label' => $lang->user->mobile, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['slack'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'slack', 'label' => $lang->user->slack, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['whatsapp'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'whatsapp', 'label' => $lang->user->whatsapp, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['phone'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'phone', 'label' => $lang->user->phone, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['address'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'address', 'label' => $lang->user->address, 'control' => 'text', 'default' => '', 'filter' => 'trim');
$config->user->form->batchEdit['zipcode'] = array('required' => false, 'type' => 'date', 'width' => '160px', 'name' => 'zipcode', 'label' => $lang->user->zipcode, 'control' => 'text', 'default' => '', 'filter' => 'trim');
+6 -11
View File
@@ -660,19 +660,14 @@ class user extends control
*/
public function batchEdit($deptID = 0)
{
if(isset($_POST['users']))
if(empty($_POST)) return $this->send(array('result' => 'success', 'load' => $this->session->userList ? $this->session->userList : $this->createLink('company', 'browse', "deptID=$deptID")));
if(!empty($_POST['account']))
{
$this->view->users = $this->dao->select('*')->from(TABLE_USER)->where('id')->in($this->post->users)->orderBy('id')->fetchAll('id');
}
elseif($_POST)
{
if($this->post->account) $this->user->batchEdit();
return print(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse', "deptID=$deptID"), 'parent'));
}
else
{
return print(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse', "deptID=$deptID"), 'parent'));
$this->user->batchEdit();
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $this->session->userList ? $this->session->userList : $this->createLink('company', 'browse', "deptID=$deptID")));
}
if(isset($_POST['users'])) $this->view->users = $this->dao->select('*')->from(TABLE_USER)->where('id')->in($this->post->users)->orderBy('id')->fetchAll('id');
$this->lang->user->menu = $this->lang->company->menu;
$this->lang->user->menuOrder = $this->lang->company->menuOrder;
+1 -1
View File
@@ -62,7 +62,7 @@ $(document).ready(function()
$('#verifyPassword').closest('form').find('button[type="submit"]').on('click', function()
{
var password = $('input#verifyPassword').val().trim();
var rand = $('input#verifyRand').val();
var rand = $('input[name=verifyRand]').val();
if(!verifyEncrypted && password) $('input#verifyPassword').val(md5(md5(password) + rand));
verifyEncrypted = true;
});
+3 -3
View File
@@ -685,10 +685,10 @@ class userModel extends model
public function batchEdit()
{
$data = fixer::input('post')->get();
if(empty($_POST['verifyPassword']) or $this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) helper::end(js::alert($this->lang->user->error->verifyPassword));
if(empty($_POST['verifyPassword']) or $this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) return dao::$errors['verifyPassword'] = $this->lang->user->error->verifyPassword;
$oldUsers = $this->dao->select('id, account, email')->from(TABLE_USER)->where('id')->in(array_keys($data->account))->fetchAll('id');
$accountGroup = $this->dao->select('id, account')->from(TABLE_USER)->where('account')->in($data->account)->fetchGroup('account', 'id');
$oldUsers = $this->dao->select('id,account,email')->from(TABLE_USER)->where('id')->in(array_keys($data->account))->fetchAll('id');
$accountGroup = $this->dao->select('id,account')->from(TABLE_USER)->where('account')->in($data->account)->fetchGroup('account', 'id');
$accounts = array();
foreach($data->account as $id => $account)
+1 -1
View File
@@ -27,7 +27,7 @@ foreach(explode(',', $config->user->create->requiredFields) as $field)
formBatchPanel
(
import('/js/md5.js', 'js'),
h::import($config->webRoot . 'js/md5.js', 'js'),
set::headingClass('user-batchcreate-heading'),
set::title($lang->user->batchCreate),
on::change('[data-name="new"]', 'toggleNew'),
+55
View File
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* The batchCreate view file of user module of ZenTaoPMS.
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Mengyi Liu <liumengyi@easycorp.ltd>
* @package user
* @link https://www.zentao.net
*/
namespace zin;
$items = array();
$items['id'] = array('name' => 'id', 'label' => $lang->idAB, 'control' => 'index', 'width' => '60px');
$items = array_merge($items, $config->user->form->batchEdit);
$items['dept']['items'] = $depts;
$items['visions']['items'] = $visionList;
$fnGenerateCustomizedFields = function() use ($showFields, $customFields)
{
global $config;
$showFields = ",{$showFields},";
$fields = array();
$defaultFields = explode(',', $config->user->custom->batchEditFields);
foreach($customFields as $name => $text) $fields[] = array('name' => $name, 'text' => $text, 'show' => str_contains($showFields, ",$name,"), 'default' => in_array($name, $defaultFields));
return $fields;
};
formBatchPanel
(
h::import($config->webRoot . 'js/md5.js', 'js'),
set::customFields(array('items' => $fnGenerateCustomizedFields(), 'urlParams' => 'module=user&section=custom&key=batchEditFields')),
set::title($lang->user->batchEdit),
set::mode('edit'),
set::items($items),
set::data(array_values($users)),
div
(
setClass('form-grid'),
formGroup
(
setClass('flex verify-box'),
set::width('400px'),
set::label($lang->user->verifyPassword),
set::labelClass('w-10 mr-2'),
set::control('password'),
set::name('verifyPassword'),
set::value(''),
set::required(true),
),
),
);
formHidden('verifyRand', $rand);
render();