Skip to content

Commit

Permalink
同步更改的内容
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Feb 1, 2018
1 parent 1a69092 commit 327e28f
Show file tree
Hide file tree
Showing 40 changed files with 1,185 additions and 902 deletions.
31 changes: 26 additions & 5 deletions docs/AutoComplete.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<?php

namespace plugins\admin\docs {
namespace MiaoxingDoc\Admin {

/**
* @property \Miaoxing\Admin\Service\adminNav $adminNav 后台导航
*
* @property \Miaoxing\Admin\Service\AdminLog $adminLog 后台管理日志
* @method \Miaoxing\Admin\Service\AdminLog|\Miaoxing\Admin\Service\AdminLog[] adminLog() 后台管理日志
* @method \Miaoxing\Admin\Service\AdminLog|\Miaoxing\Admin\Service\AdminLog[] adminLog()
*
* @property \Miaoxing\Admin\Service\AdminNav $adminNav 后台导航
*
* @property \Miaoxing\Admin\Service\CsvExporter $csvExporter Csv格式数据导出服务
*
* @property \Miaoxing\Admin\Service\SexConst $sexConst 性别常量服务
*
* @property \Miaoxing\Admin\Service\YesNoConst $yesNoConst 是否常量服务
*/
class AutoComplete
{
Expand All @@ -16,9 +22,24 @@ class AutoComplete
namespace {

/**
* @return \plugins\admin\docs\AutoComplete
* @return MiaoxingDoc\Admin\AutoComplete
*/
function wei()
{
}

/** @var Miaoxing\Admin\Service\AdminLog $adminLog */
$adminLog = wei()->adminLog;

/** @var Miaoxing\Admin\Service\AdminNav $adminNav */
$adminNav = wei()->adminNav;

/** @var Miaoxing\Admin\Service\CsvExporter $csvExporter */
$csvExporter = wei()->csvExporter;

/** @var Miaoxing\Admin\Service\SexConst $sexConst */
$sexConst = wei()->sexConst;

/** @var Miaoxing\Admin\Service\YesNoConst $yesNoConst */
$yesNoConst = wei()->yesNoConst;
}
65 changes: 65 additions & 0 deletions modules/containers/admin/admins/form.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react';
import {Button} from 'react-bootstrap';
import {Page, PageHeader, FormItem, Form, FormAction, Options, ImageUpload} from 'components';

const loader = Promise.all([
import('jquery-populate'),
import('jquery-form'),
import('jquery-validation-mx')
]);

class AdminForm extends React.Component {
componentDidMount() {
loader.then(() => {
$('.js-admin-form')
.populate(wei.user)
.ajaxForm({
url: $.url('admin/admins/' + (wei.user.id ? 'update' : 'create')),
dataType: 'json',
beforeSubmit: (arr, $form) => $form.valid(),
success: (ret) => {
$.msg(ret, () => {
if (ret.code === 1) {
window.location = $.url('admin/admins');
}
});
}
})
.validate();
});
}

render() {
return (
<Page>
<PageHeader>
<Button href={$.url('admin/admins')}>返回列表</Button>
</PageHeader>
<Form horizontal className="js-admin-form" method="post">
<FormItem label="用户名" name="username" required={!wei.user.id}
control={wei.user.id && <p className="form-control-static">{wei.user.username}</p>} />

<FormItem label="用户组" name="groupId" required>
<Options data={wei.groups} labelKey="name" valueKey="id"/>
</FormItem>

<FormItem label="头像" name="headImg" control={<ImageUpload name="headImg"/>}
help="支持.jpg .jpeg .bmp .gif .png格式照片"/>

<FormItem label="昵称" name="nickName"/>

<FormItem label="密码" name="password" type="password" required={!wei.user.id}
help={wei.user.id && '不修改密码请留空'}/>

<FormItem label="重复密码" name="passwordAgain" type="password" required={!wei.user.id}/>

<input type="hidden" id="id" name="id"/>

<FormAction url={$.url('admin/admins')}/>
</Form>
</Page>
)
}
}

export default AdminForm;
111 changes: 111 additions & 0 deletions modules/containers/admin/admins/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {Button} from 'react-bootstrap';
import {Page, PageHeader, DataTable, SearchForm, SearchItem} from 'components';
import rp from 'require-promise';
import 'jquery-update-event';

const loader = Promise.all([
rp('template'),
import('query-url'),
import('datatables-net-mx')
]);

class AdminIndex extends React.Component {
componentDidMount() {
loader.then(() => {
// FIXME
template.helper('$', $);

var $table = $('.js-admin-table').dataTable({
searchEl: '.js-admin-form',
searchEvent: 'update',
ajax: {
url: $.queryUrl2('admin/admins.json')
},
order: [],
columns: [
{
title: '用户名',
data: 'username'
},
{
title: '昵称',
data: 'nickName'
},
{
title: '邮箱',
data: 'email'
},
{
title: '分组',
data: 'group.name'
},
{
title: '创建时间',
data: 'createTime'
},
{
title: `<span class="js-tips-hover table-header-tips" data-content="禁用后,用户将无法登录"
data-container="body" data-placement="bottom" data-trigger="hover">
启用 <i class="fa fa-question-circle light-grey bigger-130"></i>
</span>`,
data: 'enable',
render: function (data, type, full) {
return template.render('checkbox-col-tpl', {
id: full.id,
name: 'enable',
value: data
});
}
},
{
title: '操作',
data: 'id',
createdCell: (td, val) => {
ReactDOM.render(<span>
<a href={$.url('admin/admins/%s/edit', val)}>编辑</a>
{' '}
{wei.isInstalledCan && <a href={$.url('admin/users/%s/roles/assign', val)}>分配角色</a>}
</span>, td);
}
}
]
});

$('.js-tips-hover').popover();

// 切换状态
$table.on('click', '.js-toggle-status', function () {
const $this = $(this);
var data = {};
data['id'] = $this.data('id');
data[$this.attr('name')] = +!$this.data('value');
$.post($.url('admin/admins/enable'), data, function (result) {
$.msg(result);
$table.reload();
}, 'json');
});
});
}

render() {
return (
<Page>
<PageHeader>
<Button bsStyle="success" href={$.url('admin/admins/new')}>添加管理员</Button>
</PageHeader>
<SearchForm className="js-admin-form">
<SearchItem label="用户名" name="username" />

<SearchItem label="昵称" name="nickName" />

<SearchItem label="邮箱" name="email" />
</SearchForm>
<DataTable className="js-admin-table" />
</Page>
)
}
}

export default AdminIndex;
Loading

0 comments on commit 327e28f

Please sign in to comment.