创建版本
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
|
||||
use Gdoo\Model\Models\Bill;
|
||||
use Gdoo\Model\Models\Model;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class BillController extends DefaultController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$header = [
|
||||
'master_name' => '单据',
|
||||
'simple_search_form' => 1,
|
||||
'table' => 'model_bill',
|
||||
'master_table' => 'model_bill',
|
||||
'create_btn' => 1,
|
||||
];
|
||||
|
||||
$search = search_form([
|
||||
'advanced' => '',
|
||||
], [
|
||||
['form_type' => 'text', 'name' => '名称', 'field' => 'model_bill.name', 'value' => '', 'options' => []],
|
||||
], 'model');
|
||||
|
||||
$header['cols'] = [
|
||||
'checkbox' => [
|
||||
'width' => 40,
|
||||
'suppressSizeToFit' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'editable' => false,
|
||||
'resizable' => false,
|
||||
'filter' => false,
|
||||
'checkboxSelection' => true,
|
||||
'headerCheckboxSelection' => true,
|
||||
],
|
||||
'sequence_sn' => [
|
||||
'width' => 60,
|
||||
'headerName' => '序号',
|
||||
'suppressSizeToFit' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'resizable' => false,
|
||||
'editable' => false,
|
||||
'type' => 'sn',
|
||||
'filter' => false,
|
||||
],
|
||||
'name' => [
|
||||
'field' => 'name',
|
||||
'headerName' => '名称',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-left',
|
||||
'form_type' => 'text',
|
||||
'width' => 100,
|
||||
],
|
||||
'code' => [
|
||||
'field' => 'code',
|
||||
'headerName' => '编码',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 100,
|
||||
],
|
||||
'uri' => [
|
||||
'field' => 'uri',
|
||||
'headerName' => '路径',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-left',
|
||||
'form_type' => 'text',
|
||||
'width' => 140,
|
||||
],
|
||||
'model_name' => [
|
||||
'field' => 'model_name',
|
||||
'headerName' => '主模型',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 120,
|
||||
],
|
||||
'audit_type_name' => [
|
||||
'field' => 'audit_type_name',
|
||||
'headerName' => '审核类型',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 80,
|
||||
],
|
||||
'sn_rule' => [
|
||||
'field' => 'sn_rule',
|
||||
'headerName' => '编号规则',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 80,
|
||||
],
|
||||
'updated_dt' => [
|
||||
'field' => 'updated_dt',
|
||||
'headerName' => '操作时间',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 80,
|
||||
],
|
||||
'id' => [
|
||||
'field' => 'id',
|
||||
'headerName' => 'ID',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 40,
|
||||
],
|
||||
'actions' => [
|
||||
'headerName' => '',
|
||||
'cellRenderer' => 'actionCellRenderer',
|
||||
'options' => [[
|
||||
'name' => '视图',
|
||||
'action' => 'view',
|
||||
'display' => 1,
|
||||
],[
|
||||
'name' => '流程',
|
||||
'action' => 'flow',
|
||||
'display' => 1,
|
||||
],[
|
||||
'name' => '权限',
|
||||
'action' => 'permission',
|
||||
'display' => 1,
|
||||
],[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]],
|
||||
'width' => 160,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressSizeToFit' => true,
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'editable' => false,
|
||||
'resizable' => false,
|
||||
'filter' => false,
|
||||
],
|
||||
];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
$model = Bill::leftJoin('model', 'model.id', '=', 'model_bill.model_id')
|
||||
->selectRaw('model_bill.*,model_bill.id as master_id, model.[table] as model_table,model.name as model_name')
|
||||
->orderBy('model_bill.id', 'desc')
|
||||
->where('model_bill.type', 0)
|
||||
->setBy($header);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
|
||||
$rows->transform(function($row) {
|
||||
$row['updated_dt'] = format_datetime($row['updated_at']);
|
||||
|
||||
if ($row['audit_type'] == 0) {
|
||||
$row['audit_type_name'] = '无';
|
||||
}
|
||||
elseif($row['audit_type'] == 1) {
|
||||
$row['audit_type_name'] = '固定流程';
|
||||
}
|
||||
elseif($row['audit_type'] == 2) {
|
||||
$row['audit_type_name'] = '自由流程';
|
||||
}
|
||||
elseif($row['audit_type'] == 3) {
|
||||
$row['audit_type_name'] = '审核';
|
||||
}
|
||||
$row['sn_rule'] = $row['sn_prefix'].$row['sn_rule'].($row['sn_length'] > 0 ? $row['sn_length'] : '');
|
||||
$row['model_name'] = $row['model_name'].'('.$row['model_table'].')';
|
||||
return $row;
|
||||
});
|
||||
return $rows;
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['search_form'] = $search;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
// 配置权限
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'code' => 'required|unique:model_bill,code,'.$gets['id'],
|
||||
];
|
||||
$v = Validator::make($gets, $rules);
|
||||
|
||||
if ($v->fails()) {
|
||||
return $this->json($v->errors()->first());
|
||||
}
|
||||
|
||||
// 单据设置为0
|
||||
$gets['type'] = 0;
|
||||
|
||||
$bill = Bill::findOrNew($gets['id']);
|
||||
$bill->fill($gets);
|
||||
$bill->save();
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
$bill_id = Request::get('id');
|
||||
$bill = Bill::find($bill_id);
|
||||
$models = Model::where('parent_id', 0)->get();
|
||||
|
||||
return $this->render([
|
||||
'bill' => $bill,
|
||||
'models' => $models,
|
||||
'bill_id' => $bill_id,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
public function storeAction()
|
||||
{
|
||||
return $this->editAction();
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$ids = (array)Request::get('id');
|
||||
if (count($ids) > 0) {
|
||||
Bill::whereIn('id', $ids)->delete();
|
||||
/*
|
||||
Step::whereIn('bill_id', $ids)->delete();
|
||||
Run::whereIn('bill_id', $ids)->delete();
|
||||
RunLog::whereIn('bill_id', $ids)->delete();
|
||||
RunStep::whereIn('bill_id', $ids)->delete();
|
||||
Template::whereIn('bill_id', $ids)->delete();
|
||||
*/
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use App\Support\Module;
|
||||
|
||||
use Gdoo\Model\Models\Model;
|
||||
use Gdoo\Model\Models\Field;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Model\Services\FlowService;
|
||||
use Gdoo\Model\Services\FieldService;
|
||||
use Gdoo\Model\Services\ModuleService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
use Gdoo\System\Models\Option;
|
||||
|
||||
class FieldController extends DefaultController
|
||||
{
|
||||
public $permission = ['getColumns', 'getEnums'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$model_id = Request::get('model_id');
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$sorts = Request::get('sort');
|
||||
$i = 0;
|
||||
foreach ($sorts as $id) {
|
||||
Field::where('id', $id)->update(['sort' => $i]);
|
||||
$i ++;
|
||||
}
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
$master = Model::with(['fields' => function ($q) {
|
||||
$q->orderBy('sort', 'asc')
|
||||
->orderBy('id', 'asc');
|
||||
}])->find($model_id);
|
||||
|
||||
$sublist = Model::with(['fields' => function ($q) {
|
||||
$q->orderBy('sort', 'asc')
|
||||
->orderBy('id', 'asc');
|
||||
}])->where('parent_id', $master->id)->get();
|
||||
|
||||
$models = DB::table('model')->where('parent_id', 0)->orderBy('lft', 'asc')->get();
|
||||
$model = Model::find($model_id);
|
||||
|
||||
$sets = $models->keyBy('table');
|
||||
|
||||
return $this->display([
|
||||
'master' => $master,
|
||||
'sublist' => $sublist,
|
||||
'model_id' => $model_id,
|
||||
'model' => $model,
|
||||
'models' => $models,
|
||||
'sets' => $sets,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
$model_id = (int)Request::get('model_id');
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
$row = Field::find($id);
|
||||
$model = Model::find($model_id);
|
||||
|
||||
$templates = [];
|
||||
|
||||
switch ($this->dbType) {
|
||||
case 'sqlsrv':
|
||||
$templates = [
|
||||
'BIGINT' => ['type' => 'bigint', 'length' => '', 'default' => 'NULL'],
|
||||
'INT' => ['type' => 'int', 'length' => '', 'default' => 'NULL'],
|
||||
'MEDIUMINT' => ['type' => 'int', 'length' => '', 'default' => 'NULL'],
|
||||
'SMALLINT' => ['type' => 'smallint', 'length' => '', 'default' => 'NULL'],
|
||||
'TINYINT' => ['type' => 'tinyint', 'length' => '', 'default' => 'NULL', ],
|
||||
'DECIMAL' => ['type' => 'decimal', 'length' => '20,2', 'default' => 'NULL'],
|
||||
'DATE' => ['type' => 'date', 'length' => '', 'default' => 'NULL'],
|
||||
'DATETIME' => ['type' => 'datetime', 'length' => '', 'default' => 'NULL'],
|
||||
'NCHAR' => ['type' => 'nchar', 'length' => '50', 'default' => 'NULL'],
|
||||
'NVARCHAR' => ['type' => 'nvarchar', 'length' => '255', 'default' => 'NULL'],
|
||||
'NVARCHAR(MAX)' => ['type' => 'nvarchar(max)', 'length' => '', 'default' => 'NULL'],
|
||||
'VARCHAR' => ['type' => 'nvarchar', 'length' => '255', 'default' => 'NULL'],
|
||||
'TEXT' => ['type' => 'nvarchar(max)', 'length' => '', 'default' => 'NULL']
|
||||
];
|
||||
break;
|
||||
case 'mysql':
|
||||
$templates = [
|
||||
'BIGINT' => ['type' => 'bigint', 'length' => '20', 'default' => 'NULL'],
|
||||
'INT' => ['type' => 'integer', 'length' => '11', 'default' => 'NULL'],
|
||||
'SMALLINT' => ['type' => 'smallint', 'length' => '5', 'default' => 'NULL'],
|
||||
'TINYINT' => ['type' => 'smallint', 'length' => '3', 'default' => 'NULL'],
|
||||
'DECIMAL' => ['type' => 'decimal', 'length' => '20,2', 'default' => 'NULL'],
|
||||
'DATE' => ['type' => 'date', 'length' => '', 'default' => 'NULL'],
|
||||
'DATETIME' => ['type' => 'datetime', 'length' => '', 'default' => 'NULL'],
|
||||
'TIME' => ['type' => 'time', 'length' => '', 'default' => 'NULL'],
|
||||
'CHAR' => ['type' => 'char', 'length' => '50', 'default' => 'NULL'],
|
||||
'VARCHAR' => ['type' => 'varchar', 'length' => '255', 'default' => 'NULL'],
|
||||
'TEXT' => ['type' => 'text', 'length' => '', 'default' => 'NULL']
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
$gets = Request::all();
|
||||
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'field' => 'required|unique:model_field,field,'.$id.',id,model_id,'.$model_id,
|
||||
'form_type' => 'required',
|
||||
];
|
||||
|
||||
if ($gets['validate']) {
|
||||
$gets['validate'] = join('|', $gets['validate']);
|
||||
}
|
||||
|
||||
$v = Validator::make($gets, $rules);
|
||||
if ($v->fails()) {
|
||||
return $this->json(join('<br>',$v->errors()->all()));
|
||||
}
|
||||
|
||||
if (trim($gets['type'])) {
|
||||
$type = $templates[$gets['type']]['type'];
|
||||
$table = $model->getAttribute('table');
|
||||
$sql = [];
|
||||
|
||||
try {
|
||||
$columns = DB::select('select column_name as column_name from information_schema.columns where table_name=?', [$table]);
|
||||
$columns = array_by($columns, 'column_name');
|
||||
|
||||
switch ($this->dbType) {
|
||||
case 'sqlsrv':
|
||||
if ($gets['id'] > 0 && isset($columns[$row['field']])) {
|
||||
|
||||
// 修改字段名
|
||||
if ($row['field'] != $gets['field']) {
|
||||
$sql[] = "EXEC sp_rename '{$table}.{$row['field']}', '{$gets['field']}', 'column'";
|
||||
|
||||
// 删除旧索引
|
||||
if ($row['index']) {
|
||||
if ($row['index'] == 'PRIMARY') {
|
||||
$index = "pk_{$table}_{$row['field']}";
|
||||
} else {
|
||||
$index = "idx_{$table}_{$row['field']}";
|
||||
}
|
||||
$sql[] = "if exists (select 1 from sys.indexes where object_id = object_id(N'{$table}') and name = '{$index}')
|
||||
begin
|
||||
drop index {$index} on {$table}
|
||||
end";
|
||||
}
|
||||
|
||||
// 添加新索引
|
||||
if ($gets['index']) {
|
||||
if ($gets['index'] == 'INDEX') {
|
||||
$sql[] = "create INDEX idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
} else if($gets['index'] == 'UNIQUE') {
|
||||
$sql[] = "create UNIQUE INDEX idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
} else if($gets['index'] == 'PRIMARY') {
|
||||
$sql[] = "create PRIMARY KEY INDEX pk_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改字段类型
|
||||
if ($row['type'] != $gets['type'] || $row['not_null'] != $gets['not_null'] || $row['length'] != $gets['length']) {
|
||||
$not_null = $gets['not_null'] == 1 ? 'not null' : 'null';
|
||||
$type = $gets['length'] == '' ? $type : $type.'('.$gets['length'].')';
|
||||
$sql[] = "alter table {$table} alter column {$gets['field']} {$type} $not_null";
|
||||
}
|
||||
|
||||
// 默认值
|
||||
if ($row['default'] != $gets['default']) {
|
||||
|
||||
// 删除旧默认值
|
||||
$sql[] = "if exists (select 1 from sysobjects as t where id = (select cdefault from syscolumns where id = object_id(N'{$table}') and name = 'df_{$table}_{$gets['field']}'))
|
||||
begin
|
||||
alter table $table drop constraint df_{$table}_{$gets['field']}
|
||||
end";
|
||||
|
||||
$default = trim($gets['default']);
|
||||
if ($gets['default'] == 'NULL') {
|
||||
$default = 'NULL';
|
||||
} else if($gets['default'] == 'Empty String') {
|
||||
$default = "''";
|
||||
}
|
||||
if ($default != '') {
|
||||
$sql[] = "alter table $table add constraint df_{$table}_{$gets['field']} default {$default} for {$gets['field']} with values";
|
||||
}
|
||||
}
|
||||
|
||||
// 修改字段注释
|
||||
if ($row['name'] != $gets['name']) {
|
||||
$sql[] = "EXECUTE sp_updateextendedproperty 'MS_Description', '{$gets['name']}', 'user', 'dbo', 'table', '{$table}', 'column', '{$gets['field']}'";
|
||||
}
|
||||
|
||||
} else {
|
||||
// 字段不存在
|
||||
if (!isset($columns[$gets['field']])) {
|
||||
|
||||
$not_null = $gets['not_null'] == 1 ? 'not null' : 'null';
|
||||
$type = $gets['length'] == '' ? $type : $type.'('.$gets['length'].')';
|
||||
|
||||
// 添加字段
|
||||
$sql[] = "alter table {$table} add {$gets['field']} {$type} $not_null";
|
||||
// 添加字段索引
|
||||
if ($gets['index']) {
|
||||
if ($gets['index'] == 'INDEX') {
|
||||
$sql[] = "create INDEX idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
} else if($gets['index'] == 'UNIQUE') {
|
||||
$sql[] = "create UNIQUE INDEX idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
}
|
||||
else if($gets['index'] == 'PRIMARY') {
|
||||
$sql[] = "create PRIMARY KEY INDEX pk_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
}
|
||||
}
|
||||
|
||||
$default = trim($gets['default']);
|
||||
if ($default == '') {
|
||||
$default = '';
|
||||
} else if ($default == 'NULL') {
|
||||
$default = 'NULL';
|
||||
} else if($gets['default'] == 'Empty String') {
|
||||
$default = "''";
|
||||
}
|
||||
if ($default != '') {
|
||||
$sql[] = "alter table $table add constraint df_{$table}_{$gets['field']} default {$gets['default']} for {$gets['field']} with values";
|
||||
}
|
||||
|
||||
$sql[] = "EXECUTE sp_addextendedproperty 'MS_Description', '{$gets['name']}', 'user', 'dbo', 'table', '{$table}', 'column', '{$gets['field']}'";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'mysql':
|
||||
$type = $gets['type'].($gets['length'] == '' ? '' : '('.$gets['length'].')');
|
||||
$not_null = $gets['not_null'] == 1 ? 'not null' : 'null';
|
||||
|
||||
// 处理默认值
|
||||
$default = trim($gets['default']);
|
||||
if ($default == '' || $default == 'NULL') {
|
||||
$default = 'default NULL';
|
||||
} else if($default == 'Empty String') {
|
||||
$default = "default ''";
|
||||
} else {
|
||||
$default = "default '{$default}'";
|
||||
}
|
||||
// 处理注释
|
||||
$comment = "COMMENT '{$gets['name']}'";
|
||||
// 字段位置
|
||||
$after = '';
|
||||
|
||||
if ($gets['id'] > 0 && isset($columns[$row['field']])) {
|
||||
|
||||
// 修改字段数据
|
||||
if ($row['field'] != $gets['field'] || $row['type'] != $gets['type'] || $row['not_null'] != $gets['not_null'] || $row['length'] != $gets['length']) {
|
||||
$sql[] = "alter table {$table} change `{$row['field']}` `{$gets['field']}` $type $not_null $default $comment $after";
|
||||
}
|
||||
|
||||
// 修改字段名
|
||||
if ($row['field'] != $gets['field']) {
|
||||
// 删除旧索引
|
||||
if ($row['index']) {
|
||||
if ($row['index'] == 'PRIMARY') {
|
||||
$index = "pk_{$table}_{$row['field']}";
|
||||
} else {
|
||||
$index = "idx_{$table}_{$row['field']}";
|
||||
}
|
||||
$sql[] = "drop index {$index} on {$table}";
|
||||
}
|
||||
|
||||
// 添加新索引
|
||||
if ($gets['index']) {
|
||||
if ($gets['index'] == 'INDEX') {
|
||||
$sql[] = "alter table {$table} add index idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
} else if($gets['index'] == 'UNIQUE') {
|
||||
$sql[] = "alter table {$table} add unique idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
} else if($gets['index'] == 'PRIMARY') {
|
||||
$sql[] = "alter table {$table} add primary key pk_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 字段不存在
|
||||
if (!isset($columns[$gets['field']])) {
|
||||
// 添加字段
|
||||
$sql[] = "alter table {$table} add `{$gets['field']}` $type $not_null $default $comment $after";
|
||||
|
||||
// 添加新索引
|
||||
if ($gets['index']) {
|
||||
if ($gets['index'] == 'INDEX') {
|
||||
$sql[] = "alter table {$table} add index idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
} else if($gets['index'] == 'UNIQUE') {
|
||||
$sql[] = "alter table {$table} add unique idx_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
} else if($gets['index'] == 'PRIMARY') {
|
||||
$sql[] = "alter table {$table} add primary key pk_{$table}_{$gets['field']} on $table({$gets['field']})";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// 操作数据表
|
||||
foreach ($sql as $_sql) {
|
||||
DB::statement($_sql);
|
||||
}
|
||||
|
||||
} catch(\Exception $e) {
|
||||
return $this->json($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 写入模型数据
|
||||
$gets['setting'] = json_encode($gets['setting'], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$model = Field::findOrNew((int)$gets['id']);
|
||||
$model->fill($gets);
|
||||
$model->save();
|
||||
|
||||
return $this->json('恭喜你,操作成功。', url('index', ['model_id' => $gets['model_id']]));
|
||||
}
|
||||
|
||||
if ($row['validate']) {
|
||||
$row['validate'] = explode('|', $row['validate']);
|
||||
}
|
||||
|
||||
if ($model['parent_id'] > 0) {
|
||||
// 获取子表目录
|
||||
$_model = DB::table('model')->where('id', $model['parent_id'])->first();
|
||||
$_models = DB::table('model')->where('parent_id', $_model['id'])->get();
|
||||
} else {
|
||||
// 获取子表目录
|
||||
$_model = DB::table('model')->where('id', $model['id'])->first();
|
||||
$_models = DB::table('model')->where('parent_id', $_model['id'])->get();
|
||||
}
|
||||
|
||||
$models[] = $_model;
|
||||
foreach ($_models as $_model) {
|
||||
$models[] = $_model;
|
||||
}
|
||||
|
||||
$row['model_id'] = $model_id;
|
||||
|
||||
$setting = json_decode($row['setting'], true);
|
||||
$row['setting'] = $setting;
|
||||
|
||||
$types = [];
|
||||
$dialogs = ModuleService::dialogs();
|
||||
foreach ($dialogs as $table => $dialog) {
|
||||
$types[] = ['table' => $table, 'name' => $dialog['name']];
|
||||
}
|
||||
|
||||
$_types = DB::table('model')->orderBy('lft')->get()->keyBy('id');
|
||||
$types = [];
|
||||
foreach ($_types as $type) {
|
||||
if ($type['parent_id']) {
|
||||
$name = $_types[$type['parent_id']]['name'].'->'.$type['name'];
|
||||
} else {
|
||||
$name = $type['name'];
|
||||
}
|
||||
$types[] = ['table' => $type['table'], 'name' => $name];
|
||||
}
|
||||
|
||||
$fields = DB::table('model_field')->where('model_id', $model_id)->get(['field', 'name']);
|
||||
|
||||
$regulars = FlowService::regulars();
|
||||
return $this->render([
|
||||
'types' => $types,
|
||||
'fields' => $fields,
|
||||
'row' => $row,
|
||||
'model' => $model,
|
||||
'models' => $models,
|
||||
'model_id' => $model_id,
|
||||
'regulars' => $regulars,
|
||||
'templates' => $templates,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段类型
|
||||
*/
|
||||
public function typeAction()
|
||||
{
|
||||
$type = Request::get('type');
|
||||
$model_id = Request::get('model_id');
|
||||
if ($type) {
|
||||
return FieldService::{'form_'.$type}([], $model_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段关联对象
|
||||
*/
|
||||
public function getColumnsAction()
|
||||
{
|
||||
$table = Request::get('table');
|
||||
|
||||
$flow = DB::table('model')->where('table', $table)->first();
|
||||
$fields = DB::table('model_field')->where('model_id', $flow['id'])->get();
|
||||
$rows = [];
|
||||
foreach($fields as $field) {
|
||||
if ($field['data_type'] && $field['data_field']) {
|
||||
$f = $field['data_type'].'.'.$field['data_field'];
|
||||
$rows[] = ['field' => $f, 'key' => $field['field'].'.'.$field['data_link'].':'.$f, 'name' => $field['name']];
|
||||
} else {
|
||||
$rows[] = ['field' => $field['field'], 'key' => $field['field'], 'name' => $field['name']];
|
||||
}
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
public function getEnumsAction()
|
||||
{
|
||||
$enums = Option::where('parent_id', 0)->orderBy('sort', 'asc')->orderBy('id', 'asc')->get();
|
||||
return response()->json($enums);
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$model_id = Request::get('model_id');
|
||||
$id = Request::get('id');
|
||||
$id = is_array($id) ? $id : [$id];
|
||||
Field::whereIn('id', $id)->delete();
|
||||
return $this->json('恭喜你,操作成功。', url('index', ['model_id' => $model_id]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Form;
|
||||
use Gdoo\Model\Grid;
|
||||
|
||||
use Gdoo\Model\Models\Model;
|
||||
use Gdoo\Model\Models\Field;
|
||||
use Gdoo\Model\Models\Step;
|
||||
use Gdoo\Model\Models\Run;
|
||||
use Gdoo\Model\Models\RunLog;
|
||||
use Gdoo\Model\Models\RunStep;
|
||||
use Gdoo\Model\Models\Template;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class ModelController extends DefaultController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$header = [
|
||||
'master_name' => '模型',
|
||||
'simple_search_form' => 1,
|
||||
'table' => 'model',
|
||||
'master_table' => 'model',
|
||||
'create_btn' => 1,
|
||||
];
|
||||
|
||||
$search = search_form([
|
||||
'advanced' => '',
|
||||
], [
|
||||
['form_type' => 'text', 'name' => '名称', 'field' => 'model.name', 'value' => '', 'options' => []],
|
||||
], 'model');
|
||||
|
||||
$header['cols'] = [
|
||||
'checkbox' => [
|
||||
'width' => 40,
|
||||
'suppressSizeToFit' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'editable' => false,
|
||||
'resizable' => false,
|
||||
'filter' => false,
|
||||
'checkboxSelection' => true,
|
||||
'headerCheckboxSelection' => true,
|
||||
],
|
||||
'sequence_sn' => [
|
||||
'width' => 60,
|
||||
'headerName' => '序号',
|
||||
'suppressSizeToFit' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'resizable' => false,
|
||||
'editable' => false,
|
||||
'type' => 'sn',
|
||||
'filter' => false,
|
||||
],
|
||||
'text' => [
|
||||
'field' => 'text',
|
||||
'headerName' => '名称',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-left',
|
||||
'form_type' => 'text',
|
||||
'width' => 100,
|
||||
],
|
||||
'user' => [
|
||||
'field' => 'table',
|
||||
'headerName' => '表名',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-left',
|
||||
'form_type' => 'text',
|
||||
'width' => 0,
|
||||
],
|
||||
'relation' => [
|
||||
'field' => 'relation',
|
||||
'headerName' => '关联外键',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 80,
|
||||
],
|
||||
'updated_dt' => [
|
||||
'field' => 'updated_dt',
|
||||
'headerName' => '操作时间',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 80,
|
||||
],
|
||||
'id' => [
|
||||
'field' => 'id',
|
||||
'headerName' => 'ID',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 40,
|
||||
],
|
||||
'actions' => [
|
||||
'headerName' => '',
|
||||
'cellRenderer' => 'actionCellRenderer',
|
||||
'options' => [[
|
||||
'name' => '字段',
|
||||
'action' => 'field',
|
||||
'display' => 1,
|
||||
],[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]],
|
||||
'width' => 100,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressSizeToFit' => true,
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'editable' => false,
|
||||
'resizable' => false,
|
||||
'filter' => false,
|
||||
],
|
||||
];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = Model::setBy($header);
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
$model->orderBy('lft', 'asc');
|
||||
$model->selectRaw('*, id as master_id');
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
|
||||
$rows->transform(function($row) {
|
||||
$row['updated_dt'] = format_datetime($row['updated_at']);
|
||||
return $row;
|
||||
});
|
||||
|
||||
$items = $rows->items();
|
||||
array_nest($items);
|
||||
$rows->items($items);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['search_form'] = $search;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
// 配置权限
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'table' => 'required|unique:model,table,'.$gets['id'],
|
||||
];
|
||||
$v = Validator::make($gets, $rules);
|
||||
|
||||
if ($v->fails()) {
|
||||
return $this->json($v->errors()->first());
|
||||
}
|
||||
|
||||
$model = Model::findOrNew($gets['id']);
|
||||
$model->fill($gets);
|
||||
$model->save();
|
||||
$model->treeRebuild();
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
$model_id = Request::get('id');
|
||||
$model = Model::find($model_id);
|
||||
$models = Model::where('parent_id', 0)->get();
|
||||
|
||||
return $this->render([
|
||||
'model' => $model,
|
||||
'models' => $models,
|
||||
'model_id' => $model_id,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
public function storeAction()
|
||||
{
|
||||
return $this->editAction();
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$ids = (array)Request::get('id');
|
||||
if (count($ids) > 0) {
|
||||
Model::whereIn('id', $ids)->delete();
|
||||
Field::whereIn('model_id', $ids)->delete();
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Form;
|
||||
use Gdoo\Model\Grid;
|
||||
|
||||
use Gdoo\Model\Models\Module;
|
||||
use Gdoo\Model\Services\ModuleService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class ModuleController extends DefaultController
|
||||
{
|
||||
public $permission = ['test', 'refresh'];
|
||||
|
||||
/**
|
||||
* 邮件设置
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$header = [
|
||||
'master_name' => '模块',
|
||||
'simple_search_form' => 1,
|
||||
'table' => 'model_module',
|
||||
'master_table' => 'model_module',
|
||||
'create_btn' => 0,
|
||||
];
|
||||
|
||||
$search = search_form([
|
||||
'advanced' => '',
|
||||
], [
|
||||
['form_type' => 'text', 'name' => '模块名称', 'field' => 'model_module.name', 'value' => '', 'options' => []],
|
||||
], 'model');
|
||||
|
||||
$query = $search['query'];
|
||||
|
||||
$header['cols'] = [
|
||||
'checkbox' => [
|
||||
'width' => 40,
|
||||
'suppressSizeToFit' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'editable' => false,
|
||||
'resizable' => false,
|
||||
'filter' => false,
|
||||
'checkboxSelection' => true,
|
||||
'headerCheckboxSelection' => true,
|
||||
],
|
||||
'sequence_sn' => [
|
||||
'width' => 60,
|
||||
'headerName' => '序号',
|
||||
'suppressSizeToFit' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'resizable' => false,
|
||||
'editable' => false,
|
||||
'type' => 'sn',
|
||||
'filter' => false,
|
||||
],
|
||||
'name' => [
|
||||
'field' => 'name',
|
||||
'headerName' => '模块名称',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-',
|
||||
'form_type' => 'text',
|
||||
'width' => 0,
|
||||
],
|
||||
'status_name' => [
|
||||
'field' => 'status_name',
|
||||
'headerName' => '状态',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'width' => 120,
|
||||
],
|
||||
'id' => [
|
||||
'field' => 'id',
|
||||
'headerName' => 'ID',
|
||||
'sortable' => true,
|
||||
'suppressMenu' => true,
|
||||
'cellClass' => 'text-center',
|
||||
'form_type' => 'text',
|
||||
'width' => 40,
|
||||
],
|
||||
'actions' => [
|
||||
'headerName' => '',
|
||||
'cellRenderer' => 'actionCellRenderer',
|
||||
'options' => [[
|
||||
'name' => '安装',
|
||||
'action' => 'install',
|
||||
'display' => 0,
|
||||
],[
|
||||
'name' => '升级',
|
||||
'action' => 'upgrade',
|
||||
'display' => 0,
|
||||
]],
|
||||
'width' => 80,
|
||||
'cellClass' => 'text-center',
|
||||
'suppressSizeToFit' => true,
|
||||
'suppressMenu' => true,
|
||||
'sortable' => false,
|
||||
'editable' => false,
|
||||
'resizable' => false,
|
||||
'filter' => false,
|
||||
],
|
||||
];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
$model->selectRaw('*, id as master_id');
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$rows->transform(function($row) {
|
||||
if ($row['status'] == 1) {
|
||||
$row['status_name'] = '已安装';
|
||||
} else {
|
||||
$row['status_name'] = '未安装';
|
||||
}
|
||||
return $row;
|
||||
});
|
||||
return $rows->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['left_buttons'] = [
|
||||
['name' => '更新', 'color' => 'default', 'icon' => 'fa-refresh', 'action' => 'refresh', 'display' => 1],
|
||||
['name' => '安装', 'color' => 'default', 'icon' => 'fa-cloud-download', 'action' => 'install', 'display' => 1],
|
||||
['name' => '打包', 'color' => 'default', 'icon' => 'fa-cube', 'action' => 'package', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['search_form'] = $search;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
// 配置权限
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建邮箱帐号
|
||||
public function createAction()
|
||||
{
|
||||
return $this->editAction();
|
||||
}
|
||||
|
||||
// 编辑邮箱帐号
|
||||
public function editAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$row = DB::table('mail')->where('id', $id)->first();
|
||||
return $this->render([
|
||||
'row' => $row,
|
||||
], 'edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public function storeAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'smtp' => 'required',
|
||||
'user' => 'required',
|
||||
'password' => 'required',
|
||||
'port' => 'required',
|
||||
];
|
||||
$v = Validator::make($gets, $rules);
|
||||
if ($v->fails()) {
|
||||
return $this->json(join('<br>', $v->errors()->all()));
|
||||
|
||||
}
|
||||
if ($gets['id']) {
|
||||
DB::table('mail')->where('id', $gets['id'])->update($gets);
|
||||
} else {
|
||||
DB::table('mail')->insert($gets);
|
||||
}
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$id = Request::get('id');
|
||||
Module::whereIn('id', $id)->delete();
|
||||
return $this->json('删除成功。', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模块列表
|
||||
*/
|
||||
public function refreshAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$modules = ModuleService::details();
|
||||
foreach($modules as $module => $row) {
|
||||
$model = Module::firstOrNew(['module' => $module]);
|
||||
$model->name = $row['name'];
|
||||
$model->module = $module;
|
||||
$model->save();
|
||||
}
|
||||
return $this->json('模块刷新完成。', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Models\Bill;
|
||||
use Gdoo\Model\Models\Model;
|
||||
use Gdoo\Model\Models\Field;
|
||||
use Gdoo\Model\Models\Permission;
|
||||
|
||||
use Gdoo\Model\Services\FlowService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class PermissionController extends DefaultController
|
||||
{
|
||||
public $permission = ['index','create','delete'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$sorts = Request::get('sort');
|
||||
$i = 0;
|
||||
foreach ($sorts as $sort) {
|
||||
Permission::where('id', $sort)->update(['sort' => $i]);
|
||||
$i ++;
|
||||
}
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
$bill_id = Request::get('bill_id');
|
||||
$rows = Permission::where('bill_id', $bill_id)
|
||||
->orderBy('sort', 'asc')
|
||||
->get();
|
||||
|
||||
return $this->display([
|
||||
'bill_id' => $bill_id,
|
||||
'rows' => $rows,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
];
|
||||
$v = Validator::make($gets, $rules);
|
||||
|
||||
$gets['data'] = json_encode($gets['data']);
|
||||
$gets['type'] = join(',', (array)$gets['type']);
|
||||
|
||||
if ($v->fails()) {
|
||||
return $this->back()->withErrors($v)->withInput();
|
||||
}
|
||||
|
||||
if ($gets['id']) {
|
||||
Permission::where('id', $gets['id'])->update($gets);
|
||||
} else {
|
||||
Permission::insert($gets);
|
||||
}
|
||||
|
||||
return $this->success('index', ['bill_id' => $gets['bill_id']], '恭喜你,操作成功。');
|
||||
}
|
||||
|
||||
$id = Request::get('id');
|
||||
$bill_id = Request::get('bill_id');
|
||||
$bill = Bill::find($bill_id);
|
||||
$permission = Permission::find($id);
|
||||
|
||||
$permission['data'] = json_decode($permission['data'], true);
|
||||
|
||||
$master = Model::with([
|
||||
'fields' => function ($q) {
|
||||
$q->orderBy('sort', 'asc')
|
||||
->orderBy('id', 'asc');
|
||||
}])
|
||||
->where('id', $bill->model_id)
|
||||
->first();
|
||||
|
||||
$sublist = Model::with(['fields' => function ($q) {
|
||||
$q->orderBy('sort', 'asc')
|
||||
->orderBy('id', 'asc');
|
||||
}])->where('parent_id', $master->id)->get();
|
||||
|
||||
$permission['bill_id'] = $bill->id;
|
||||
$permission['type'] = explode(',', $permission['type']);
|
||||
|
||||
$models = DB::table('model')->where('parent_id', 0)->orderBy('lft', 'asc')->get();
|
||||
$regulars = FlowService::regulars();
|
||||
|
||||
return $this->display([
|
||||
'permission' => $permission,
|
||||
'regulars' => $regulars,
|
||||
'bill_id' => $bill->id,
|
||||
'models' => $models,
|
||||
'master' => $master,
|
||||
'sublist' => $sublist,
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
if ($id > 0) {
|
||||
Permission::where('id', $id)->delete();
|
||||
return $this->success('index', '恭喜你,操作成功。');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Models\Bill;
|
||||
use Gdoo\Model\Models\Step;
|
||||
use Gdoo\Model\Models\Model;
|
||||
use Gdoo\Model\Models\Field;
|
||||
use Gdoo\Model\Models\Permission;
|
||||
|
||||
use Gdoo\Model\Services\StepService;
|
||||
use Gdoo\Model\Services\FlowService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class StepController extends DefaultController
|
||||
{
|
||||
public $permission = ['condition', 'steps', 'index2', 'save', 'add', 'show'];
|
||||
|
||||
/**
|
||||
* 步骤列表
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
// 更新排序
|
||||
if (Request::method() == 'POST') {
|
||||
$sorts = Request::get('sort');
|
||||
StepService::setSort($sorts);
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
$bill_id = Request::get('bill_id');
|
||||
$bill = Bill::find($bill_id);
|
||||
$rows = Step::where('bill_id', $bill_id)->orderBy('sort', 'asc')->get()->keyBy('id');
|
||||
|
||||
if ($bill->audit_type == 1) {
|
||||
// 开始结果
|
||||
$count = Step::where('bill_id', $bill_id)->whereIn('type', ['start', 'end'])->count();
|
||||
if ($count == 0) {
|
||||
Step::insert([
|
||||
'bill_id' => $bill_id,
|
||||
'name' => '开始',
|
||||
'sort' => 0,
|
||||
'type' => 'start',
|
||||
]);
|
||||
Step::insert([
|
||||
'bill_id' => $bill_id,
|
||||
'name' => '结束',
|
||||
'sort' => 255,
|
||||
'type' => 'end',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
'bill_id' => $bill_id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤列表
|
||||
*/
|
||||
public function index2Action()
|
||||
{
|
||||
// 更新排序
|
||||
if (Request::method() == 'POST') {
|
||||
$bill_id = Request::get('bill_id');
|
||||
$rows = Step::where('bill_id', $bill_id)->orderBy('sort', 'asc')->get()->keyBy('id')->toArray();
|
||||
$top = 100;
|
||||
$left = 0;
|
||||
foreach ($rows as &$row) {
|
||||
$row['top'] = $row['posY'];
|
||||
$row['left'] = $row['posX'];
|
||||
/*
|
||||
if ($row['type'] == 1) {
|
||||
} else {
|
||||
$left = $left + 40;
|
||||
$row['top'] = $top;
|
||||
}
|
||||
$row['left'] = $row['left'] + $left;
|
||||
if ($row['join']) {
|
||||
$joins = explode(',', $row['join']);
|
||||
$_top = count($joins) * 45;
|
||||
$_left = $left;
|
||||
foreach ($joins as $join) {
|
||||
$rows[$join]['top'] = $_top;
|
||||
$rows[$join]['left'] = $_left;
|
||||
$_top = $_top + 65;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
$bill_id = Request::get('bill_id');
|
||||
$bill = Bill::find($bill_id);
|
||||
$rows = Step::where('bill_id', $bill_id)->orderBy('sort', 'asc')->get()->keyBy('id');
|
||||
|
||||
if ($bill->audit_type == 1) {
|
||||
// 开始结果
|
||||
$count = Step::where('bill_id', $bill_id)->whereIn('type', ['start', 'end'])->count();
|
||||
if ($count == 0) {
|
||||
Step::insert([
|
||||
'bill_id' => $bill->id,
|
||||
'name' => '开始',
|
||||
'sort' => 0,
|
||||
'type' => 'start',
|
||||
]);
|
||||
Step::insert([
|
||||
'bill_id' => $bill->id,
|
||||
'name' => '结束',
|
||||
'sort' => 255,
|
||||
'type' => 'end',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
'bill' => $bill,
|
||||
'bill_id' => $bill_id,
|
||||
]);
|
||||
}
|
||||
|
||||
// 添加步骤和克隆步骤
|
||||
public function addAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
// 是克隆步骤
|
||||
if ($gets['id'] > 0) {
|
||||
$step = DB::table('model_step')->where('id', $gets['id'])->first();
|
||||
unset($step['id'], $step['join']);
|
||||
}
|
||||
$count = DB::table('model_step')->where('bill_id', $gets['bill_id'])->count();
|
||||
$step['bill_id'] = $gets['bill_id'];
|
||||
$step['name'] = '新建节点';
|
||||
DB::table('model_step')->insert($step);
|
||||
return $this->json('节点添加成功', true);
|
||||
}
|
||||
}
|
||||
|
||||
// 查看步骤信息
|
||||
public function showAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
$row = DB::table('model_step')->where('id', $gets['id'])->first();
|
||||
return $this->json($row, true);
|
||||
}
|
||||
|
||||
// 保存步骤
|
||||
public function saveAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
$_join = [];
|
||||
foreach ($gets['join'] as $join) {
|
||||
$_join[$join['id']][] = $join['target'];
|
||||
}
|
||||
foreach ($gets['position'] as $position) {
|
||||
$position['join'] = join(',', (array)$_join[$position['id']]);
|
||||
$position['posX'] = (int)$position['posX'];
|
||||
$position['posY'] = (int)$position['posY'];
|
||||
DB::table('model_step')->where('id', $position['id'])->update($position);
|
||||
}
|
||||
return $this->json('节点添加成功', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点条件
|
||||
*/
|
||||
public function conditionAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
$bill_id = Request::get('bill_id');
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
$step = Step::find($id);
|
||||
$step->condition = json_encode($gets['condition'], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$step->save();
|
||||
return $this->json('恭喜你,流程步骤操作成功。', url('step/index', ['bill_id'=>$bill_id]));
|
||||
}
|
||||
|
||||
$row = Step::findOrNew($id);
|
||||
|
||||
if (empty($row->join)) {
|
||||
return '很抱歉,此进程没有下一步节点。';
|
||||
}
|
||||
|
||||
$join = explode(',', $row->join);
|
||||
$condition = json_decode($row->condition, true);
|
||||
|
||||
$bill = Bill::find($bill_id);
|
||||
$steps = Step::where('bill_id', $bill_id)->whereIn('id', $join)->orderBy('sort', 'ASC')->get();
|
||||
$model = Model::with('fields', 'children.fields')->where('id', $bill->model_id)->first();
|
||||
|
||||
$fields = [
|
||||
['name' => '[创建人ID]', 'field' => '[start_user_id]', 'auto' => 1],
|
||||
['name' => '[创建人角色ID]', 'field' => '[start_role_id]', 'auto' => 1],
|
||||
['name' => '[创建人部门ID]', 'field' => '[start_department_id]', 'auto' => 1],
|
||||
['name' => '[创建人姓名]', 'field' => '[start_user]', 'auto' => 1],
|
||||
['name' => '[创建人职位]', 'field' => '[start_position]', 'auto' => 1],
|
||||
['name' => '[创建人组]', 'field' => '[start_group]', 'auto' => 1],
|
||||
['name' => '[创建人角色]', 'field' => '[start_role]', 'auto' => 1],
|
||||
['name' => '[创建人部门]', 'field' => '[start_department]', 'auto' => 1],
|
||||
['name' => '[经办人姓名]', 'field' => '[edit_user]', 'auto' => 1],
|
||||
['name' => '[经办人ID]', 'field' => '[edit_user_id]', 'auto' => 1],
|
||||
['name' => '[经办人角色ID]', 'field' => '[edit_role_id]', 'auto' => 1],
|
||||
['name' => '[经办人部门ID]', 'field' => '[edit_department_id]', 'auto' => 1],
|
||||
['name' => '[经办人职位]', 'field' => '[edit_position]', 'auto' => 1],
|
||||
['name' => '[经办人群组]', 'field' => '[edit_group]', 'auto' => 1],
|
||||
['name' => '[经办人角色]', 'field' => '[edit_role]', 'auto' => 1],
|
||||
['name' => '[经办人部门]', 'field' => '[edit_department]', 'auto' => 1],
|
||||
];
|
||||
|
||||
$fields = array_merge($fields, $model->fields->toArray());
|
||||
$columns[$model->table] = [
|
||||
'master' => 1,
|
||||
'name' => $model['name'],
|
||||
'data' => $fields
|
||||
];
|
||||
|
||||
foreach ($model->children as $children) {
|
||||
$columns[$children->table] = [
|
||||
'master' => 0,
|
||||
'name' => $children['name'],
|
||||
'data' => $children->fields->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render([
|
||||
'model' => $model,
|
||||
'condition' => $condition,
|
||||
'columns' => $columns,
|
||||
'steps' => $steps,
|
||||
'row' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建步骤
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
$bill_id = Request::get('bill_id');
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
|
||||
$gets['field'] = json_encode($gets['field']);
|
||||
$gets['notify'] = json_encode($gets['notify']);
|
||||
$gets['select_org'] = (int)$gets['select_org'];
|
||||
$gets['type_value'] = (string)$gets['type_value'][$gets['type']];
|
||||
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
);
|
||||
$v = Validator::make($gets, $rules);
|
||||
|
||||
if ($v->fails()) {
|
||||
return $this->back()->withErrors($v)->withInput();
|
||||
}
|
||||
|
||||
$flow = Step::findOrNew($gets['id']);
|
||||
$flow->fill($gets);
|
||||
$flow->save();
|
||||
|
||||
return $this->json('恭喜你,步骤操作成功。', true);
|
||||
}
|
||||
|
||||
$row = Step::findOrNew($id);
|
||||
|
||||
$row->condition = json_decode($row->condition, true);
|
||||
$row->field = json_decode($row->field, true);
|
||||
$row->notify = json_decode($row->notify, true);
|
||||
|
||||
$bill = Bill::find($bill_id);
|
||||
$steps = Step::where('bill_id', $bill_id)->orderBy('sort', 'ASC')->get();
|
||||
$permissions = Permission::where('bill_id', $bill_id)->orderBy('id', 'ASC')->get();
|
||||
|
||||
$model = Model::with('fields', 'children.fields')->where('id', $bill->model_id)->first();
|
||||
$columns[$model->table]['master'] = 1;
|
||||
$columns[$model->table]['fields'] = $model->fields;
|
||||
|
||||
foreach ($model->children as $children) {
|
||||
$columns[$children->table]['master'] = 0;
|
||||
$columns[$children->table]['fields'] = $children->fields;
|
||||
}
|
||||
|
||||
$regulars = FlowService::regulars();
|
||||
return $this->render([
|
||||
'bill' => $bill,
|
||||
'model' => $model,
|
||||
'columns' => $columns,
|
||||
'permissions' => $permissions,
|
||||
'regulars' => $regulars,
|
||||
'steps' => $steps,
|
||||
'row' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程移交
|
||||
*/
|
||||
public function moveAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
$bill_id = Request::get('bill_id');
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
|
||||
$gets['condition'] = json_encode($gets['condition']);
|
||||
$gets['field'] = json_encode($gets['field']);
|
||||
$gets['notify'] = json_encode($gets['notify']);
|
||||
|
||||
$gets['type_value'] = (string)$gets['type_value'][$gets['type']];
|
||||
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'sn' => 'required|numeric|min:1',
|
||||
);
|
||||
$v = Validator::make($gets, $rules);
|
||||
|
||||
if ($v->fails()) {
|
||||
return $this->back()->withErrors($v)->withInput();
|
||||
}
|
||||
|
||||
$flow = Step::findOrNew($gets['id']);
|
||||
$flow->fill($gets);
|
||||
$flow->save();
|
||||
|
||||
return $this->success('index', ['bill_id'=>$bill_id], '恭喜你,流程步骤操作成功。');
|
||||
}
|
||||
|
||||
$row = Step::findOrNew($id);
|
||||
|
||||
$row->join = explode(',', $row->join);
|
||||
$row->condition = json_decode($row->condition, true);
|
||||
$row->field = json_decode($row->field, true);
|
||||
$row->notify = json_decode($row->notify, true);
|
||||
|
||||
$bill = Bill::find($bill_id);
|
||||
$steps = Step::where('bill_id', $bill_id)->orderBy('sort', 'ASC')->get();
|
||||
|
||||
$permissions = Permission::where('bill_id', $bill_id)->orderBy('id', 'ASC')->get();
|
||||
|
||||
$model = Model::with('fields', 'children.fields')->where('id', $bill->model_id)->first();
|
||||
$columns[$model->table]['master'] = 1;
|
||||
$columns[$model->table]['fields'] = $model->fields;
|
||||
|
||||
foreach ($model->children as $children) {
|
||||
$columns[$children->table]['master'] = 0;
|
||||
$columns[$children->table]['fields'] = $children->fields;
|
||||
}
|
||||
|
||||
return $this->render([
|
||||
'model' => $model,
|
||||
'columns' => $columns,
|
||||
'permissions' => $permissions,
|
||||
'steps' => $steps,
|
||||
'row' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
public function stepsAction()
|
||||
{
|
||||
$table = Request::get('table');
|
||||
$model = Model::where('table', $table)->first();
|
||||
|
||||
$rows = Step::where('model_id', $model->id)
|
||||
->where('type', '!=', 'end')
|
||||
->orderBy('sort', 'asc')
|
||||
->get(['id', 'name']);
|
||||
return json_encode($rows);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除步骤
|
||||
*/
|
||||
public function deleteAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
if ($id > 0) {
|
||||
$step = Step::find($id);
|
||||
Step::where('id', $id)->delete();
|
||||
StepService::setFieldSort($step->bill_id);
|
||||
return $this->json('恭喜你,流程步骤删除成功。', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Models\Model;
|
||||
use Gdoo\Model\Models\Field;
|
||||
use Gdoo\Model\Models\Template;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
use Gdoo\Model\Services\ModelService;
|
||||
use Gdoo\Model\Services\ModuleService;
|
||||
|
||||
class TemplateController extends DefaultController
|
||||
{
|
||||
public $permission = ['create', 'create2', 'create3'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$sorts = Request::get('sort');
|
||||
$i = 0;
|
||||
foreach ($sorts as $sort) {
|
||||
Template::where('id', $sort)->update(['sort' => $i]);
|
||||
$i ++;
|
||||
}
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
$bill_id = Request::get('bill_id');
|
||||
$rows = Template::where('bill_id', $bill_id)
|
||||
->orderBy('sort', 'asc')
|
||||
->get();
|
||||
|
||||
$models = DB::table('model')->where('parent_id', 0)->orderBy('lft', 'asc')->get();
|
||||
$model = Model::find($bill_id);
|
||||
|
||||
return $this->display([
|
||||
'rows' => $rows,
|
||||
'bill_id' => $bill_id,
|
||||
'models' => $models,
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
];
|
||||
$v = Validator::make($gets, $rules);
|
||||
|
||||
if ($v->fails()) {
|
||||
return $this->back()->withErrors($v)->withInput();
|
||||
}
|
||||
|
||||
$gets['type'] = join(',', (array)$gets['type']);
|
||||
$gets['client'] = join(',', (array)$gets['client']);
|
||||
$gets['tpl'] = json_encode($gets['columns'], JSON_UNESCAPED_UNICODE);
|
||||
unset($gets['columns']);
|
||||
|
||||
$model = Template::findOrNew($gets['id']);
|
||||
$model->fill($gets);
|
||||
$model->save();
|
||||
return $this->json('恭喜你,操作成功。', url('create', ['bill_id' => $gets['bill_id'], 'id' => $gets['id']]));
|
||||
}
|
||||
|
||||
$bill_id = Request::get('bill_id');
|
||||
$bill = DB::table('model_bill')->find($bill_id);
|
||||
|
||||
// 主模型
|
||||
$master_model = null;
|
||||
|
||||
// 获取全部模型
|
||||
$models = ModelService::getModelAllFields($bill['model_id']);
|
||||
$lists = [];
|
||||
foreach ($models as $model) {
|
||||
if ($model['parent_id'] == 0) {
|
||||
$master_model = $model;
|
||||
}
|
||||
foreach ($model['fields'] as $field) {
|
||||
$field['table'] = $model['table'];
|
||||
$lists[$field['id']] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
$template = DB::table('model_template')->find($gets['id']);
|
||||
$tpl = $template['tpl'];
|
||||
$views = json_decode($tpl, true);
|
||||
|
||||
foreach ((array)$views as $i => $view) {
|
||||
$v1 = $view['fields'];
|
||||
foreach ($v1 as $j => $sublist) {
|
||||
$_fields = $sublist['fields'];
|
||||
if ($_fields) {
|
||||
foreach ($_fields as $k => $_field) {
|
||||
if (empty($_field['table'])) {
|
||||
$list = $lists[$_field['id']];
|
||||
$_field['table'] = $list['table'];
|
||||
unset($_field['id']);
|
||||
} else {
|
||||
$list = $models[$_field['table']]['fields'][$_field['field']];
|
||||
}
|
||||
if ($list) {
|
||||
$_field['name'] = $list['name'];
|
||||
}
|
||||
$_fields[$k] = $_field;
|
||||
|
||||
unset($models[$_field['table']]['fields'][$_field['field']]);
|
||||
}
|
||||
$v1[$j]['fields'] = $_fields;
|
||||
} else {
|
||||
if (empty($sublist['table'])) {
|
||||
$list = $lists[$sublist['id']];
|
||||
$sublist['table'] = $list['table'];
|
||||
unset($sublist['id']);
|
||||
} else {
|
||||
$sublist['table'] = $master_model['table'];
|
||||
$list = $models[$master_model['table']]['fields'][$sublist['field']];
|
||||
}
|
||||
if ($list) {
|
||||
$sublist['name'] = $list['name'];
|
||||
$sublist['field'] = $list['field'];
|
||||
}
|
||||
$v1[$j] = $sublist;
|
||||
unset($models[$sublist['table']]['fields'][$sublist['field']]);
|
||||
}
|
||||
}
|
||||
$views[$i]['fields'] = $v1;
|
||||
}
|
||||
|
||||
$template['type'] = explode(',', $template['type']);
|
||||
$template['client'] = explode(',', $template['client']);
|
||||
|
||||
return $this->display([
|
||||
'views' => $views,
|
||||
'template' => $template,
|
||||
'model' => $model,
|
||||
'master_model' => $master_model,
|
||||
'bill_id' => $bill_id,
|
||||
'models' => $models,
|
||||
]);
|
||||
}
|
||||
|
||||
public function create2Action()
|
||||
{
|
||||
$gets = Request::all();
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
$gets['code'] = $gets['table'].$gets['code'];
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'code' => 'required',
|
||||
];
|
||||
$v = Validator::make($gets, $rules);
|
||||
|
||||
if ($v->fails()) {
|
||||
return $this->back()->withErrors($v)->withInput();
|
||||
}
|
||||
|
||||
$gets['type'] = join(',', (array)$gets['type']);
|
||||
$gets['client'] = join(',', (array)$gets['client']);
|
||||
$gets['tpl'] = json_encode($gets['columns'], JSON_UNESCAPED_UNICODE);
|
||||
unset($gets['columns']);
|
||||
|
||||
$model = Template::findOrNew($gets['id']);
|
||||
$model->fill($gets);
|
||||
$model->save();
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
$bill_id = Request::get('bill_id');
|
||||
$bill = DB::table('model_bill')->find($bill_id);
|
||||
$template = DB::table('model_template')->find($gets['id']);
|
||||
|
||||
$leftFields = [];
|
||||
$rightFields = [];
|
||||
$views = (array)json_decode($template['tpl'], true);
|
||||
|
||||
// 获取所有模型
|
||||
$models = array_by(ModelService::getModels($bill['model_id']), 'id');
|
||||
foreach ($views as $view) {
|
||||
if (empty($view['table'])) {
|
||||
$view['table'] = $models[$view['model_id']]['table'];
|
||||
}
|
||||
unset($view['model_id']);
|
||||
unset($view['id']);
|
||||
$rightFields[$view['table'].'.'.$view['field']] = $view;
|
||||
}
|
||||
|
||||
$model = DB::table('model')->find($bill['model_id']);
|
||||
$_fields = DB::table('model_field')->where('model_id', $model['id'])->orderBy('sort', 'asc')->get();
|
||||
foreach ($_fields as $field) {
|
||||
$field_key = $model['table'].'.'.$field['field'];
|
||||
$rightField = $rightFields[$field_key];
|
||||
if ($rightField) {
|
||||
$rightField['name'] = $field['name'];
|
||||
$rightField['table'] = $model['table'];
|
||||
$rightField['field'] = $field['field'];
|
||||
$rightFields[$field_key] = $rightField;
|
||||
continue;
|
||||
}
|
||||
$leftFields[] = ['table' => $model['table'], 'field' => $field['field'], 'name' => $field['name']];
|
||||
}
|
||||
|
||||
// 子模型
|
||||
$childrens = DB::table('model')->where('parent_id', $model['id'])->get();
|
||||
foreach ($childrens as $children) {
|
||||
$_fields = DB::table('model_field')->where('model_id', $children['id'])->orderBy('sort', 'asc')->get();
|
||||
foreach ($_fields as $field) {
|
||||
$field_key = $children['table'].'.'.$field['field'];
|
||||
$rightField = $rightFields[$field_key];
|
||||
if ($rightField) {
|
||||
$rightField['table'] = $children['table'];
|
||||
$rightField['field'] = $field['field'];
|
||||
$rightField['name'] = '['.$children['name'].']'.$field['name'];
|
||||
$rightFields[$field_key] = $rightField;
|
||||
continue;
|
||||
}
|
||||
$leftFields[] = ['table' => $children['table'], 'field' => $field['field'], 'name' => '['.$children['name'].']'.$field['name']];
|
||||
}
|
||||
}
|
||||
|
||||
$rightFields = array_values($rightFields);
|
||||
|
||||
$models = DB::table('model')->where('parent_id', 0)->orderBy('lft', 'asc')->get();
|
||||
$template['leftFields'] = $leftFields;
|
||||
$template['rightFields'] = $rightFields;
|
||||
unset($template['tpl']);
|
||||
$template['type'] = explode(',', $template['type']);
|
||||
$template['client'] = explode(',', $template['client']);
|
||||
$template['code'] = str_replace($model['table'].'_', '', $template['code']);
|
||||
|
||||
return $this->display([
|
||||
'template' => $template,
|
||||
'model' => $model,
|
||||
'bill_id' => $bill_id,
|
||||
'models' => $models,
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
if ($id > 0) {
|
||||
DB::table('model_template')->where('id', $id)->delete();
|
||||
return $this->success('index', '恭喜你,操作成功。');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php namespace Gdoo\Model\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
use Auth;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class TodoController extends DefaultController
|
||||
{
|
||||
public $permission = ['widget'];
|
||||
|
||||
/**
|
||||
* 流程待办
|
||||
*/
|
||||
public function widgetAction(Request $request)
|
||||
{
|
||||
if ($request->method() == 'POST') {
|
||||
$bill_id = $request->get('bill_id');
|
||||
$model = DB::table('model_run_log')
|
||||
->leftJoin('model_run', 'model_run.id', '=', 'model_run_log.run_id')
|
||||
->leftJoin('model_bill', 'model_bill.id', '=', 'model_run.bill_id')
|
||||
->leftJoin('user as run_log_user', 'run_log_user.id', '=', 'model_run_log.created_id')
|
||||
->leftJoin('customer', 'customer.id', '=', DB::raw("model_run.partner_id and model_run.partner_type = 'customer'"))
|
||||
->leftJoin('supplier', 'supplier.id', '=', DB::raw("model_run.partner_id and model_run.partner_type = 'supplier'"))
|
||||
->where('model_run_log.updated_id', 0)
|
||||
->where('model_run_log.user_id', auth()->id())
|
||||
->orderBy('model_run.id', 'desc')
|
||||
->selectRaw("
|
||||
model_run_log.*,
|
||||
model_run.name,
|
||||
model_run.sn,
|
||||
model_run.remark,
|
||||
model_run.bill_id,
|
||||
model_run_log.[option],
|
||||
run_log_user.name as user_name,
|
||||
model_run_log.created_at,
|
||||
model_run.data_id,
|
||||
model_bill.uri as bill_uri,
|
||||
CASE WHEN partner_type = 'customer' THEN customer.name ELSE supplier.name END AS partner_name
|
||||
");
|
||||
|
||||
if ($bill_id > 0) {
|
||||
$model->where('model_run.bill_id', $bill_id);
|
||||
}
|
||||
|
||||
$rows = $model->get();
|
||||
|
||||
$rows->transform(function ($row) {
|
||||
$row['url'] = $row['bill_uri'].'/show';
|
||||
return $row;
|
||||
});
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
$selects = DB::table('model_bill')->where('audit_type', 1)->get();
|
||||
return $this->render([
|
||||
'selects' => $selects,
|
||||
]);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Bill extends BaseModel
|
||||
{
|
||||
protected $table = 'model_bill';
|
||||
|
||||
public function fields()
|
||||
{
|
||||
return $this->hasMany('Gdoo\Model\Models\Field');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany('Gdoo\Model\Models\Model', 'parent_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Field extends BaseModel
|
||||
{
|
||||
protected $table = 'model_field';
|
||||
|
||||
public function model()
|
||||
{
|
||||
return $this->belongsTo(Model::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Model extends BaseModel
|
||||
{
|
||||
protected $table = 'model';
|
||||
|
||||
public function fields()
|
||||
{
|
||||
return $this->hasMany('Gdoo\Model\Models\Field');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany('Gdoo\Model\Models\Model', 'parent_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Module extends BaseModel
|
||||
{
|
||||
protected $table = 'model_module';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Permission extends BaseModel
|
||||
{
|
||||
protected $table = 'model_permission';
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Run extends BaseModel
|
||||
{
|
||||
protected $table = 'model_run';
|
||||
|
||||
public function model()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Model\Models\Model');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class RunLog extends BaseModel
|
||||
{
|
||||
protected $table = 'model_run_log';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class RunStep extends BaseModel
|
||||
{
|
||||
protected $table = 'model_run_step';
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Step extends BaseModel
|
||||
{
|
||||
protected $table = 'model_step';
|
||||
|
||||
public function model()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Model\Models\Model');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Model\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Template extends BaseModel
|
||||
{
|
||||
protected $table = 'model_template';
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
<?php namespace Gdoo\Model\Services;
|
||||
|
||||
class FlowService
|
||||
{
|
||||
public static function regulars()
|
||||
{
|
||||
return [
|
||||
'required' => '必填',
|
||||
'numeric' => '数字',
|
||||
'numeric_than:0' => '数字大于0',
|
||||
'alpha' => '字母',
|
||||
'date' => '日期',
|
||||
'alpha_num' => '数字+字母',
|
||||
'email' => '邮箱',
|
||||
'active_url' => '链接',
|
||||
'unique' => '唯一',
|
||||
'regex:/^[0-9]{5,20}$/' => 'QQ',
|
||||
'regex:/^(1)[0-9]{10}$/' => '手机',
|
||||
'regex:/^[0-9-]{6,13}$/' => '电话',
|
||||
'regex:/^[0-9]{6}$/' => '邮编',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php namespace Gdoo\Model\Services;
|
||||
|
||||
use DB;
|
||||
use Gdoo\Model\Models\Model;
|
||||
|
||||
class ModelService
|
||||
{
|
||||
public static function getModelAllFields($model_id) {
|
||||
$res = [];
|
||||
$model = DB::table('model')->find($model_id);
|
||||
$fields = DB::table('model_field')
|
||||
->where('model_id', $model['id'])
|
||||
->orderBy('sort', 'asc')
|
||||
->get()->keyBy('field')->toArray();
|
||||
$model['fields'] = $fields;
|
||||
$res[$model['table']] = $model;
|
||||
|
||||
// 子模型
|
||||
$childrens = DB::table('model')->where('parent_id', $model['id'])->get();
|
||||
foreach ($childrens as $children) {
|
||||
$fields = DB::table('model_field')
|
||||
->where('model_id', $children['id'])
|
||||
->orderBy('sort', 'asc')
|
||||
->get()->keyBy('field')->toArray();
|
||||
$children['fields'] = $fields;
|
||||
$res[$children['table']] = $children;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function getModels($model_id) {
|
||||
$master = static::getModel($model_id);
|
||||
$models = Model::with(['fields' => function ($q) {
|
||||
$q->orderBy('sort', 'asc')->orderBy('id', 'asc');
|
||||
}])->where('parent_id', $master->id)
|
||||
->get();
|
||||
|
||||
$res = [$master];
|
||||
foreach($models as $model) {
|
||||
$res[] = $model;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function getModel($model_id) {
|
||||
$master = Model::with(['fields' => function ($q) {
|
||||
$q->orderBy('sort', 'asc')
|
||||
->orderBy('id', 'asc');
|
||||
}])->find($model_id);
|
||||
|
||||
return $master;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php namespace Gdoo\Model\Services;
|
||||
|
||||
use App\Support\Hook;
|
||||
|
||||
class ModuleService
|
||||
{
|
||||
public static $modules;
|
||||
|
||||
public static $details = [];
|
||||
|
||||
public static $dialogs = [];
|
||||
|
||||
public static $widgets = [];
|
||||
|
||||
public static $badges = [];
|
||||
|
||||
public static function details()
|
||||
{
|
||||
return static::$details;
|
||||
}
|
||||
|
||||
public static function all()
|
||||
{
|
||||
if (static::$modules) {
|
||||
return static::$modules;
|
||||
}
|
||||
|
||||
$path = base_path().'/app/Gdoo';
|
||||
|
||||
if (is_dir($path)) {
|
||||
$folders = new \DirectoryIterator($path);
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
if (!$folder->isDot() && $folder->isDir()) {
|
||||
$folder = $folder->getFileName();
|
||||
$file = $path.'/'.$folder.'/config.php';
|
||||
|
||||
if (is_file($file)) {
|
||||
static::$modules[$folder] = $path.'/'.$folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return static::$modules;
|
||||
}
|
||||
|
||||
public static function allWithDetails()
|
||||
{
|
||||
$modules = static::all();
|
||||
$json = [];
|
||||
foreach ($modules as $key => $module) {
|
||||
$file = $module.'/config.php';
|
||||
|
||||
if (is_file($file)) {
|
||||
$content = include($file);
|
||||
$content['path'] = $module;
|
||||
|
||||
if (not_empty($content['listens'])) {
|
||||
foreach ($content['listens'] as $k => $v) {
|
||||
Hook::listen($k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
if (not_empty($content['widgets'])) {
|
||||
static::$widgets = static::$widgets + $content['widgets'];
|
||||
}
|
||||
|
||||
if (not_empty($content['badges'])) {
|
||||
static::$badges = static::$badges + $content['badges'];
|
||||
}
|
||||
|
||||
// 获取对话框
|
||||
if (not_empty($content['dialogs'])) {
|
||||
static::$dialogs = static::$dialogs + $content['dialogs'];
|
||||
}
|
||||
|
||||
$json[lcfirst($key)] = $content;
|
||||
}
|
||||
}
|
||||
static::$details = $json;
|
||||
return $json;
|
||||
}
|
||||
|
||||
public static function widgets($key = null)
|
||||
{
|
||||
if ($key) {
|
||||
return static::$widgets[$key];
|
||||
}
|
||||
return static::$widgets;
|
||||
}
|
||||
|
||||
public static function dialogs($key = null)
|
||||
{
|
||||
if ($key) {
|
||||
return static::$dialogs[$key];
|
||||
}
|
||||
return static::$dialogs;
|
||||
}
|
||||
|
||||
public static function badges($key = null)
|
||||
{
|
||||
if ($key) {
|
||||
return static::$badges[$key];
|
||||
}
|
||||
return static::$badges;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,614 @@
|
||||
<?php namespace Gdoo\Model\Services;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
|
||||
use App\Support\Hook;
|
||||
|
||||
use Gdoo\Model\Models\Step;
|
||||
|
||||
class StepService
|
||||
{
|
||||
/**
|
||||
* 获取下一步审核节点和抄送节点
|
||||
*/
|
||||
public static function getNextSteps($steps, $parent_id, $params) {
|
||||
static $ret;
|
||||
foreach ($steps as $step) {
|
||||
if ($step['join']) {
|
||||
// 获取自己的下级
|
||||
$join = explode(',', $step['join']);
|
||||
foreach ($join as $step_next_id) {
|
||||
|
||||
if ($step['step_id'] == $parent_id) {
|
||||
|
||||
$step_next = $steps[$step_next_id];
|
||||
$step_id = $step_next['step_id'];
|
||||
|
||||
$step_next['run_step_id'] = $step_next['id'];
|
||||
$step_next['id'] = $step_id;
|
||||
$step_next['parent_id'] = $parent_id;
|
||||
|
||||
// 多条路径形成的bug(多个审核节点接连到相同节点时会出现)
|
||||
if (isset($ret[$step_next['step_id']])) {
|
||||
$step_id = $step_id.'.'.$parent_id;
|
||||
}
|
||||
|
||||
// 检查条件(不满足就跳过,不管是知会还是审核)
|
||||
if (static::checkCondition($step, [$step_next], $params)) {
|
||||
|
||||
$step_user = static::getStepUser($step_next, $params);
|
||||
$step_next = $step_user['step'];
|
||||
$continue = $step_user['continue'];
|
||||
$ret[$step_id] = $step_next;
|
||||
|
||||
// 节点是审核节点时不再获取下一个节点
|
||||
if ($step['option'] == 1) {
|
||||
if ($continue) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
static::getNextSteps($steps, $step_next_id, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一步审核节点和抄送节点
|
||||
*/
|
||||
public static function getBackSteps($steps, $parent_id, $params) {
|
||||
static $ret;
|
||||
foreach ($steps as $step) {
|
||||
if ($step['join']) {
|
||||
// 获取自己的下级
|
||||
$join = explode(',', $step['join']);
|
||||
|
||||
foreach ($join as $step_next_id) {
|
||||
if ($step_next_id == $parent_id) {
|
||||
|
||||
$step_next = $steps[$parent_id];
|
||||
$step_id = $step['step_id'];
|
||||
$step['run_step_id'] = $step['id'];
|
||||
$step['id'] = $step_id;
|
||||
$step['parent_id'] = $parent_id;
|
||||
|
||||
// 检查条件
|
||||
if (static::checkCondition($step, [$step_next], $params)) {
|
||||
|
||||
$step_user = static::getStepUser($step, $params);
|
||||
$step = $step_user['step'];
|
||||
$continue = $step_user['continue'];
|
||||
$ret[$step_id] = $step;
|
||||
|
||||
// 节点是审核节点时不再获取下一个节点
|
||||
if ($step['option'] == 1) {
|
||||
if ($continue) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
static::getBackSteps($steps, $step_id, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配节点相关人员
|
||||
*/
|
||||
public static function getStepUser($step, $params) {
|
||||
$master = $params['master'];
|
||||
$table = $master['table'];
|
||||
$id = $master['id'];
|
||||
$data = $params[$table];
|
||||
$user_ids = static::getUser($params, $step, $master['auth'], $table, $data, $id);
|
||||
$step['user_ids'] = DB::table('user')->whereIn('id', (array)$user_ids)->where('status', 1)->pluck('id')->toArray();
|
||||
|
||||
$continue = true;
|
||||
|
||||
$nouser = intval($step['nouser']);
|
||||
|
||||
// 找不到匹配的办理人
|
||||
if (empty($step['user_ids'])) {
|
||||
if ($nouser == 0) {
|
||||
$step['select_org'] = 1;
|
||||
} else if ($nouser == 1) {
|
||||
// 不跳过节点继续寻找下一个节点
|
||||
$continue = false;
|
||||
$step['hide'] = true;
|
||||
} else if ($nouser == 2) {
|
||||
$step['user_ids'] = [$step['nouser_user_id']];
|
||||
}
|
||||
}
|
||||
return ['step' => $step, 'continue' => $continue];
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件测试
|
||||
*/
|
||||
public static function testCondition($a, $b, $t) {
|
||||
if($t == '==') {
|
||||
return $a == $b;
|
||||
}
|
||||
if($t == '<>') {
|
||||
return $a <> $b;
|
||||
}
|
||||
if($t == '>') {
|
||||
return $a > $b;
|
||||
}
|
||||
if($t == '<') {
|
||||
return $a < $b;
|
||||
}
|
||||
if($t == '>=') {
|
||||
return $a >= $b;
|
||||
}
|
||||
if($t == '<=') {
|
||||
return $a <= $b;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查转入条件
|
||||
*/
|
||||
public static function checkCondition($run_step, $next_steps, $gets)
|
||||
{
|
||||
$form_data = static::formDataCondition($gets);
|
||||
|
||||
$step_condition = false;
|
||||
$null_condition = 0;
|
||||
|
||||
$next_steps_count = count($next_steps);
|
||||
if ($next_steps_count > 0) {
|
||||
// 流程转交条件检查
|
||||
$conditions = json_decode($run_step['condition'], true);
|
||||
|
||||
foreach ($next_steps as $step) {
|
||||
$condition = $conditions[$step['step_id']];
|
||||
|
||||
if (empty($condition)) {
|
||||
$null_condition ++;
|
||||
continue;
|
||||
}
|
||||
$test = static::testCheckCondition($form_data, $condition, $gets);
|
||||
// 条件满足记录步骤数组
|
||||
if ($test) {
|
||||
$step_condition = true;
|
||||
}
|
||||
}
|
||||
// 有一种情况,多个转入步骤都是空条件, 或单转入步骤条件为空
|
||||
if ($next_steps_count == $null_condition) {
|
||||
$step_condition = true;
|
||||
}
|
||||
}
|
||||
return $step_condition;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 检查条件的表单字段
|
||||
*/
|
||||
public static function formDataCondition($gets)
|
||||
{
|
||||
$master = $gets['master'];
|
||||
|
||||
// 获取单据创建者ID
|
||||
if ($master['created_id'] > 0) {
|
||||
$created_id = $master['created_id'];
|
||||
} else {
|
||||
$created_id = Auth::id();
|
||||
}
|
||||
|
||||
// 创建人
|
||||
$start_user = static::getMacroUser($created_id);
|
||||
|
||||
// 经办人
|
||||
$current_user = static::getMacroUser(Auth::id());
|
||||
|
||||
$form_data = [];
|
||||
$form_data['[start_user_id]'] = $start_user['user_id'];
|
||||
$form_data['[start_role_id]'] = $start_user['role_id'];
|
||||
$form_data['[start_department_id]'] = $start_user['department_id'];
|
||||
|
||||
$form_data['[start_user]'] = $start_user['user_name'];
|
||||
$form_data['[start_position]'] = $start_user['position_name'];
|
||||
$form_data['[start_group]'] = $start_user['group_name'];
|
||||
$form_data['[start_role]'] = $start_user['role_name'];
|
||||
$form_data['[start_department]'] = $start_user['department_name'];
|
||||
|
||||
$form_data['[edit_user_id]'] = $current_user['user_id'];
|
||||
$form_data['[edit_role_id]'] = $current_user['role_id'];
|
||||
$form_data['[edit_department_id]'] = $current_user['department_id'];
|
||||
|
||||
$form_data['[edit_user]'] = $current_user['user_name'];
|
||||
$form_data['[edit_position]'] = $current_user['position_name'];
|
||||
$form_data['[edit_group]'] = $current_user['group_name'];
|
||||
$form_data['[edit_role]'] = $current_user['role_name'];
|
||||
$form_data['[edit_department]'] = $current_user['department_name'];
|
||||
|
||||
// $form_data['[步骤号]'] = $post['setp_id'];
|
||||
// $form_data['[流程设计步骤号]'] = $gets['step_number'];
|
||||
|
||||
// $form_data['[公共附件名称]'] = $post['attachment'];
|
||||
// $form_data['[公共附件个数]'] = $post['attachment'];
|
||||
|
||||
return $form_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试检查条件
|
||||
*/
|
||||
public static function testCheckCondition($form_data, $conditions, $gets)
|
||||
{
|
||||
// 存在条件
|
||||
$wheres = [];
|
||||
foreach ($conditions as $condition) {
|
||||
$f = $condition['f'];
|
||||
$c = $condition['c'];
|
||||
$v = $condition['v'];
|
||||
$t = $condition['t'];
|
||||
|
||||
if (isset($form_data[$f])) {
|
||||
$condition['f'] = "\$form_data['".$f."']";
|
||||
} else {
|
||||
// 分割字段名称
|
||||
list($p, $k) = explode('.', $f);
|
||||
|
||||
// 多行子表
|
||||
$lines = $gets['models'];
|
||||
|
||||
// 子表处理
|
||||
if(isset($lines[$p])) {
|
||||
$rows = $gets[$p]['rows'];
|
||||
if ($t) {
|
||||
$_test = false;
|
||||
// 总数
|
||||
if ($t == 'count') {
|
||||
$count = count($rows);
|
||||
if (static::testCondition($count, $v, $c)) {
|
||||
$_test = true;
|
||||
}
|
||||
}
|
||||
// 总和
|
||||
if ($t == 'sum') {
|
||||
$_sum = 0;
|
||||
foreach ($rows as $row) {
|
||||
$_sum += $row[$k];
|
||||
}
|
||||
if (static::testCondition($_sum, $v, $c)) {
|
||||
$_test = true;
|
||||
}
|
||||
}
|
||||
$condition['c'] = '';
|
||||
$condition['v'] = '';
|
||||
if($_test) {
|
||||
$condition['f'] = 'true';
|
||||
} else {
|
||||
$condition['f'] = 'false';
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
// 把变量名称作为字符串赋值
|
||||
$condition['f'] = "\$gets['".$p."']['".$k."']";
|
||||
}
|
||||
}
|
||||
unset($condition['t']);
|
||||
$wheres[] = join(' ', $condition);
|
||||
}
|
||||
|
||||
// 检查条件
|
||||
$where = join(' ', $wheres);
|
||||
$test = eval("return $where;");
|
||||
return $test;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查转入条件
|
||||
*/
|
||||
public static function runCheckCondition($run_step, $next_steps, $gets)
|
||||
{
|
||||
$form_data = static::formDataCondition($gets);
|
||||
|
||||
$steps = [];
|
||||
|
||||
$next_steps_count = count($next_steps);
|
||||
if ($next_steps_count > 0) {
|
||||
// 流程转交条件检查
|
||||
$conditions = json_decode($run_step['condition'], true);
|
||||
|
||||
foreach ($next_steps as $step) {
|
||||
$condition = $conditions[$step['step_id']];
|
||||
if (empty($condition)) {
|
||||
$steps[] = $step;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 组合条件
|
||||
$test = static::testCheckCondition($form_data, $condition, $gets);
|
||||
|
||||
// 条件满足记录步骤数组
|
||||
if ($test) {
|
||||
$steps[] = $step;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $steps;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getFlowStep($steps, $step, $gets, &$ret) {
|
||||
$ids = array_filter(explode(',', $step['join']));
|
||||
$next_steps = [];
|
||||
foreach($ids as $id) {
|
||||
if (isset($steps[$id])) {
|
||||
$next_steps[] = $steps[$id];
|
||||
}
|
||||
}
|
||||
$rows = static::runCheckCondition($step, $next_steps, $gets);
|
||||
foreach($rows as $row) {
|
||||
$ret[$row['step_id']] = $row;
|
||||
static::getFlowStep($steps, $row, $gets, $ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程字段的数据
|
||||
*/
|
||||
public static function getFlowField($run_id, $row, $flow, $steps, $step, $view, $view_step_id, $action, $permission)
|
||||
{
|
||||
$run_step = $steps[$view_step_id];
|
||||
if(empty($run_step)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$write = $permission['flow_step'][$view_step_id];
|
||||
$remark = $run_step['run_remark'];
|
||||
|
||||
$by = '';
|
||||
$line = ' ';
|
||||
if ($run_step['run_updated_id'] > 0) {
|
||||
$updated_by = get_user($run_step['run_updated_id'], 'name', false);
|
||||
$by = $updated_by.' '.format_datetime($run_step['run_updated_at']);
|
||||
}
|
||||
|
||||
if ($action == 'show' || $action == 'print') {
|
||||
if ($run_step['run_updated_at'] > 0) {
|
||||
if ($remark == '') {
|
||||
$remark = '同意';
|
||||
}
|
||||
} else {
|
||||
if ($write['w'] == 1) {
|
||||
$remark = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'show') {
|
||||
return '<div id="flow_step_'.$view_step_id.'">'.$remark.$line.$by.'</div>';
|
||||
} elseif ($action == 'print') {
|
||||
return $remark.$line.$by;
|
||||
} else {
|
||||
if ($write['w'] == 1) {
|
||||
$required = '';
|
||||
if (in_array('required', (array)$write['v'])) {
|
||||
$required = 'input-required';
|
||||
}
|
||||
return '<textarea class="form-control input-sm '.$required.'" autocomplete="off" id="step_remark_'.$view_step_id.'" name="step_remark['.$view_step_id.']">'.$remark.'</textarea>';
|
||||
} else {
|
||||
return '<textarea class="form-control input-sm" autocomplete="off" id="flow_step_'.$view_step_id.'" disabled="disabled" readonly="readonly">'.$remark.$line.$by.'</textarea>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程日志
|
||||
*/
|
||||
public static function getFlowLog($run_id, $data, $model)
|
||||
{
|
||||
$steps = DB::table('flow_run_step')
|
||||
->whereNotIn('type', ['end'])
|
||||
->where('run_id', $run_id)
|
||||
->orderBy('sort', 'asc')
|
||||
->get();
|
||||
|
||||
// 设置主表数据
|
||||
$gets['master'] = $data;
|
||||
$gets[$model['table']] = $data;
|
||||
|
||||
$step = $steps[0];
|
||||
$ret = [];
|
||||
$ret[$step['step_id']] = $step;
|
||||
$steps = array_by($steps, 'step_id');
|
||||
static::getFlowStep($steps, $step, $gets, $ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程日志
|
||||
*/
|
||||
public static function getFlowLogTpl($run_id, $data, $model, $html)
|
||||
{
|
||||
$steps = static::getFlowLog($run_id, $data, $model);
|
||||
foreach($steps as $log) {
|
||||
if ($log['option'] == 1) {
|
||||
$remark = $log['remark'];
|
||||
if ($remark == '') {
|
||||
if ($log['run_status'] == 'next' || $log['run_status'] == 'end') {
|
||||
$remark = '同意';
|
||||
}
|
||||
}
|
||||
$updated_by = get_user($log['updated_id'], 'name', false);
|
||||
$html .= '<div class="row"><div class="col-sm-12 control-text">'.$log['name'].': '.$remark.' '.$updated_by.' '.format_datetime($log['updated_at']).'</div></div>';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
public static function getMacroUser($user_id)
|
||||
{
|
||||
if (empty($user_id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DB::table('user')
|
||||
->LeftJoin('role', 'role.id', '=', 'user.role_id')
|
||||
->LeftJoin('user_group', 'user_group.id', '=', 'user.group_id')
|
||||
->LeftJoin('department', 'department.id', '=', 'user.department_id')
|
||||
->LeftJoin('user_position', 'user_position.id', '=', 'user.position_id')
|
||||
|
||||
->where('user.id', $user_id)
|
||||
->first([
|
||||
'user.id as user_id',
|
||||
'user.group_id',
|
||||
'user.department_id',
|
||||
'user.role_id',
|
||||
'user.position_id',
|
||||
'user_position.name as position_name',
|
||||
'user.name as user_name',
|
||||
'role.name as role_name',
|
||||
'department.name as department_name',
|
||||
'user_group.name as group_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public static function setSort($sorts)
|
||||
{
|
||||
$i = 0;
|
||||
foreach ($sorts as $id) {
|
||||
if ($id > 0) {
|
||||
$step = Step::find($id);
|
||||
if ($step['type'] == 'start') {
|
||||
continue;
|
||||
}
|
||||
$step->sort = $i;
|
||||
$i++;
|
||||
$step->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function setFieldSort($model_id)
|
||||
{
|
||||
$rows = Step::where('bill_id', $model_id)
|
||||
->where('type', '!=', 'end')
|
||||
->orderBy('sort', 'asc')
|
||||
->get();
|
||||
|
||||
$j = 0;
|
||||
foreach ($rows as $row) {
|
||||
$row->sort = $j;
|
||||
$j++;
|
||||
$row->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getUser($gets, $step, $auth, $table, $data, $id)
|
||||
{
|
||||
$user_ids = [];
|
||||
switch ($step['type']) {
|
||||
// 指定办理人
|
||||
case 'user':
|
||||
$user_ids = explode(',', $step['type_value']);
|
||||
break;
|
||||
// 负责人
|
||||
case 'owner':
|
||||
$user_ids = [$auth->owner_id];
|
||||
break;
|
||||
// 指定角色办理人
|
||||
case 'role':
|
||||
$roles = explode(',', $step['type_value']);
|
||||
$user_ids = DB::table('user')->whereIn('role_id', $roles)->pluck('id')->toArray();
|
||||
break;
|
||||
// 单据创建者
|
||||
case 'created_id':
|
||||
case 'start':
|
||||
$row = DB::table($table)->find($id);
|
||||
$user_ids = [$row['created_id']];
|
||||
break;
|
||||
// 直属领导
|
||||
case 'leader':
|
||||
$user_ids = [$auth->leader_id];
|
||||
break;
|
||||
// 部门主管
|
||||
case 'manager':
|
||||
$user_ids = [$auth->department->manager];
|
||||
break;
|
||||
// 主表字段值
|
||||
case 'field':
|
||||
// 字段是供应商
|
||||
if ($step['type_value'] == 'supplier_id') {
|
||||
$supplier = DB::table('supplier')->find($data['supplier_id']);
|
||||
$user_ids = [$supplier['user_id']];
|
||||
// 字段是客户
|
||||
} else if ($step['type_value'] == 'customer_id') {
|
||||
$customer = DB::table('customer')->find($data['customer_id']);
|
||||
$user_ids = [$customer['user_id']];
|
||||
} else {
|
||||
$user_ids = [$data[$step['type_value']]];
|
||||
}
|
||||
break;
|
||||
// 销售团队(1级)
|
||||
case 'region1':
|
||||
$customer_id = $data['customer_id'];
|
||||
if ($customer_id > 0) {
|
||||
$customer = DB::table('customer')->find($customer_id);
|
||||
$region3 = DB::table('customer_region')->find($customer['region_id']);
|
||||
$region2 = DB::table('customer_region')->find($region3['parent_id']);
|
||||
$region1 = DB::table('customer_region')->find($region2['parent_id']);
|
||||
$user_ids = [$region1['owner_user_id']];
|
||||
}
|
||||
break;
|
||||
// 销售团队(2级)
|
||||
case 'region2':
|
||||
$customer_id = $data['customer_id'];
|
||||
if ($customer_id > 0) {
|
||||
$customer = DB::table('customer')->find($customer_id);
|
||||
$region3 = DB::table('customer_region')->find($customer['region_id']);
|
||||
$region2 = DB::table('customer_region')->find($region3['parent_id']);
|
||||
$user_ids = [$region2['owner_user_id']];
|
||||
}
|
||||
$region_id = $data['region_id'];
|
||||
if ($region_id > 0) {
|
||||
$region3 = DB::table('customer_region')->find($region_id);
|
||||
$region2 = DB::table('customer_region')->find($region3['parent_id']);
|
||||
$user_ids = [$region2['owner_user_id']];
|
||||
}
|
||||
break;
|
||||
// 销售团队(3级)
|
||||
case 'region3':
|
||||
$customer_id = $data['customer_id'];
|
||||
if ($customer_id > 0) {
|
||||
$customer = DB::table('customer')->find($customer_id);
|
||||
$region3 = DB::table('customer_region')->find($customer['region_id']);
|
||||
$user_ids = [$region3['owner_user_id']];
|
||||
}
|
||||
break;
|
||||
// 自定义
|
||||
case 'custom':
|
||||
// 过滤数据
|
||||
$_data = Hook::fire($table . '.onSetpUser', ['gets' => $gets, 'step' => $step, 'auth' => $auth, 'table'=> $table, 'data'=> $data, 'user_ids' => $user_ids]);
|
||||
extract($_data);
|
||||
break;
|
||||
}
|
||||
return $user_ids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
return [
|
||||
"name" => "模型管理",
|
||||
"version" => "1.0",
|
||||
"description" => "模型管理",
|
||||
"icons" => [
|
||||
16 => "images/16.png",
|
||||
48 => "images/48.png",
|
||||
128 => "images/128.png"
|
||||
],
|
||||
'widgets' => [
|
||||
'widget_model_todo' => [
|
||||
'name' => '待办事项',
|
||||
'type' => 1,
|
||||
'url' => 'model/todo/widget',
|
||||
'more_url' => 'model/todo/index',
|
||||
],
|
||||
],
|
||||
"controllers" => [
|
||||
"bill" => [
|
||||
"name" => "单据",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"model" => [
|
||||
"name" => "模型",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"template" => [
|
||||
"name" => "视图",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"field" => [
|
||||
"name" => "字段",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"type" => [
|
||||
"name" => "类型"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"step" => [
|
||||
"name" => "步骤",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"save" => [
|
||||
"name" => "保存"
|
||||
],
|
||||
"condition" => [
|
||||
"name" => "条件"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"move" => [
|
||||
"name" => "移交"
|
||||
]
|
||||
]
|
||||
],
|
||||
"module" => [
|
||||
"name" => "模块",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"save" => [
|
||||
"name" => "保存"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,74 @@
|
||||
<form method="post" id="model_bill" name="model_bill">
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td align="right" width="10%">单据名称</th>
|
||||
<td><input type="text" id="name" name="name" value="{{$bill->name}}" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">单据编码</th>
|
||||
<td><input type="text" id="code" name="code" value="{{$bill->code}}" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">单据路径</th>
|
||||
<td><input type="text" id="uri" name="uri" value="{{$bill->uri}}" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">模型主表</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="model_id" id="model_id">
|
||||
<option value="0"> - </option>
|
||||
@foreach($models as $_model)
|
||||
<option value="{{$_model->id}}" @if($_model->id == $bill->model_id) selected @endif>{{$_model->name}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">编号前缀</th>
|
||||
<td><input type="text" id="sn_prefix" name="sn_prefix" value="{{$bill->sn_prefix}}" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">编号规则</th>
|
||||
<td><input type="text" id="sn_rule" name="sn_rule" value="{{$bill->sn_rule}}" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">编号长度</th>
|
||||
<td><input type="text" id="sn_length" name="sn_length" value="{{$bill->sn_length}}" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td align="right">审核类型</td>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['audit_type'] == 0) checked @endif value="0" name="audit_type"> 无 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['audit_type'] == 1) checked @endif value="1" name="audit_type"> 固定流程 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['audit_type'] == 2) checked @endif value="2" name="audit_type"> 自由流程 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['audit_type'] == 3) checked @endif value="3" name="audit_type"> 审核 </label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">表单模式</td>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['form_type'] == 0) checked @endif value="0" name="form_type"> ERP </label>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['form_type'] == 1) checked @endif value="1" name="form_type"> OA </label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">支持回收站</td>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['is_trash'] == 0) checked @endif value="0" name="is_trash"> 否 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($bill['is_trash'] == 1) checked @endif value="1" name="is_trash"> 是 </label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<input type="hidden" name="id" value="{{$bill->id}}">
|
||||
</form>
|
||||
@@ -0,0 +1,107 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'dialog';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
action.view = function(data) {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var url = app.url('model/template/index', {bill_id: data.master_id});
|
||||
var index = layer.open({
|
||||
skin: 'layui-layer-frame',
|
||||
scrollbar: false,
|
||||
closeBtn: 2,
|
||||
title: data.master_name + '[视图]',
|
||||
type: 2,
|
||||
move: false,
|
||||
area: ['100%', '100%'],
|
||||
content: url,
|
||||
});
|
||||
}
|
||||
action.flow = function(data) {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
top.addTab('model/step/index2?bill_id=' + data.master_id, 'flow_step_index2', '单据流程');
|
||||
}
|
||||
action.permission = function(data) {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var url = app.url('model/permission/index', {bill_id: data.master_id});
|
||||
var index = layer.open({
|
||||
skin: 'layui-layer-frame',
|
||||
scrollbar: false,
|
||||
closeBtn: 2,
|
||||
title: data.master_name + '[权限]',
|
||||
type: 2,
|
||||
move: false,
|
||||
area: ['100%', '100%'],
|
||||
content: url,
|
||||
});
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.edit(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 自定义行按钮渲染
|
||||
options.actionCellBeforeRender = function(html, act, data) {
|
||||
if (act.action == 'flow') {
|
||||
if (data.audit_type == 1) {
|
||||
return html;
|
||||
}
|
||||
return '';
|
||||
} else {
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,311 @@
|
||||
<form class="form-horizontal form-controller" method="post" action="{{url()}}" id="flow-field" name="flow_field">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-3 control-label" for="model_id"><span style="color:red;">*</span> 模型名</div>
|
||||
<div class="col-sm-9 control-text b-t">
|
||||
<select class="form-control input-sm" name="model_id" id="model_id">
|
||||
@foreach($models as $v)
|
||||
<option value="{{$v['id']}}" @if($row['model_id'] == $v['id']) selected @endif>{{$v['name']}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="name">
|
||||
<span style="color:red;">*</span>
|
||||
字段别名
|
||||
<a class="hinted" href="javascript:;" title="例如客户名称"><i class="fa fa-question-circle"></i></a>
|
||||
</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<input class="form-control input-sm" type="text" name="name" value="{{$row['name']}}" id="name" onblur="app.pinyin('name','field');" required="required" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="field"><span style="color:red;">*</span>
|
||||
字段名
|
||||
<a class="hinted" href="javascript:;" title="只能由英文字母、数字和下划线组成,并且仅能字母开头"><i class="fa fa-question-circle"></i></a>
|
||||
</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<input class="form-control input-sm" type="text" id="field" name="field" value="{{$row['field']}}" required="required" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="form_type"><span style="color:red;">*</span> 编辑类别</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" name="form_type" id="form_type" required="required">
|
||||
<option value=""> - </option>
|
||||
{{:$titles = Gdoo\Model\Services\FieldService::title()}}
|
||||
@foreach($titles as $id => $title)
|
||||
<option value="{{$id}}" @if($row['form_type'] == $id) selected @endif>{{$title}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="content" class="b-t">
|
||||
@if($row['id'])
|
||||
{{Gdoo\Model\Services\FieldService::{'form_'.$row['form_type']}($row['setting'], $row['model_id'])}}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="data_format">格式数据</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" name="data_format">
|
||||
<option value=""> - </option>
|
||||
<option value="text" @if($row['data_format'] == 'text') selected @endif>文本</option>
|
||||
<option value="number" @if($row['data_format'] == 'number') selected @endif>数字</option>
|
||||
<option value="money" @if($row['data_format'] == 'money') selected @endif>金额</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@verbatim
|
||||
<div id="app">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="data_type">绑定数据</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" v-model="data_type" name="data_type" id="data_type" @change="changeDataType">
|
||||
<option value=""> - </option>
|
||||
<option v-for="item in dataType" :value="item.table">{{item.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="data_type">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="data_field">映射字段</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" v-model="data_field" name="data_field" id="data_field">
|
||||
<option value=""> - </option>
|
||||
<option v-for="item in dataField" :value="item.key">{{item.name}}({{item.field}})</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="data_link">关联字段</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" v-model="data_link" name="data_link" id="data_link">
|
||||
<option value=""> - </option>
|
||||
<option v-for="item in dataLink" :value="item.field">{{item.name}}({{item.field}})</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="data_relation">关联关系</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" v-model="data_relation" name="data_relation" id="data_relation">
|
||||
<option value=""> - </option>
|
||||
<option v-for="item in dataRelation" :value="item.field">{{item.name}}({{item.field}})</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endverbatim
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="type">
|
||||
字段类型
|
||||
<a class="hinted" href="javascript:;" title="注意修改类型可能导致数据丢失,如果不建立字段请留空"><i class="fa fa-question-circle"></i></a>
|
||||
</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" name="type" onchange="setlength(this.value)" id="type">
|
||||
<option value="">-</option>
|
||||
@foreach($templates as $type => $template)
|
||||
<option value="{{$type}}" @if($row['type'] == $type) selected @endif>{{$type}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="length">
|
||||
字段长度
|
||||
<a class="hinted" href="javascript:;" title="注意长度值不能超界"><i class="fa fa-question-circle"></i></a>
|
||||
</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<input class="form-control input-sm" type="text" id="length" name="length" value="{{$row['length']}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="length">不是NULL</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" name="not_null">
|
||||
<option value="0" @if($row['not_null'] == '0') selected @endif>否</option>
|
||||
<option value="1" @if($row['not_null'] == '1') selected @endif>是</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="length">字段默认值</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
选择 <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" id="default-menu">
|
||||
<li><a href="javascript:;"> </a></li>
|
||||
<li><a href="javascript:;">NULL</a></li>
|
||||
<li><a href="javascript:;">Empty String</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<input type="text" id="default" class="form-control input-sm" name="default" value="{{$row['default']}}" @if($row['default'] == 'NULL' || $row['default'] == 'Empty String') readonly="readonly" @endif />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="index">
|
||||
字段索引
|
||||
<a class="hinted" href="javascript:;" title="注意必须理解索引的概念"><i class="fa fa-question-circle"></i></a>
|
||||
</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<select class="form-control input-sm" name="index">
|
||||
<option value=""> - </option>
|
||||
<option value="INDEX" @if($row['index'] == 'INDEX') selected @endif>普通</option>
|
||||
<option value="UNIQUE" @if($row['index'] == 'UNIQUE') selected @endif>唯一</option>
|
||||
<option value="PRIMARY" @if($row['index'] == 'PRIMARY') selected @endif>主键</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="tips">
|
||||
编辑提示
|
||||
<a class="hinted" href="javascript:;" title="显示在字段别名下方作为表单输入提示"><i class="fa fa-question-circle"></i></a>
|
||||
</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<input class="form-control input-sm" type="text" name="tips" value="{{$row['tips']}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="is_index">列表显示</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_index'] == '0') checked @endif value="0" name="is_index">否</label>
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_index'] == '1') checked @endif value="1" name="is_index">是</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="is_search">列表搜索</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_search'] == '0') checked @endif value="0" name="is_search">否</label>
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_search'] == '1') checked @endif value="1" name="is_search">是</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="is_sort">字段菜单</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_menu'] == '0') checked @endif value="0" name="is_menu">否</label>
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_menu'] == '1') checked @endif value="1" name="is_menu">是</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="is_sort">列表排序</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_sort'] == '0') checked @endif value="0" name="is_sort">否</label>
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_sort'] == '1') checked @endif value="1" name="is_sort">是</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label" for="is_import">允许导入</label>
|
||||
<div class="col-sm-9 control-text">
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_import'] == '0') checked @endif value="0" name="is_import">否</label>
|
||||
<label class="radio-inline"><input type="radio" @if($row['is_import'] == '1') checked @endif value="1" name="is_import">是</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input name="id" type="hidden" value="{{$row['id']}}">
|
||||
<input name="parent_id" type="hidden" value="{{$parent_id}}">
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var types = JSON.parse('<?php echo json_encode($types, JSON_UNESCAPED_UNICODE); ?>') || {};
|
||||
var fields = JSON.parse('<?php echo json_encode($fields, JSON_UNESCAPED_UNICODE); ?>') || {};
|
||||
|
||||
var model_id = '{{$row["model_id"]}}';
|
||||
var data_link = '{{$row["data_link"]}}';
|
||||
var data_type = '{{$row["data_type"]}}';
|
||||
var data_field = '{{$row["data_field"]}}';
|
||||
|
||||
const vueData = {
|
||||
data() {
|
||||
return {
|
||||
data_relation: '',
|
||||
dataLink: fields,
|
||||
dataField: [],
|
||||
dataRelation: [
|
||||
{field: 'one2one', name: '一对一'},
|
||||
{field: 'one2many', name: '一对多'},
|
||||
{field: 'many2many', name: '多对多'}
|
||||
],
|
||||
dataType: types,
|
||||
data_link: data_link,
|
||||
data_type: data_type,
|
||||
data_field: data_field,
|
||||
}
|
||||
},mounted() {
|
||||
this.changeDataType();
|
||||
$('#form_type').off('change').on('change', function() {
|
||||
var loading = layer.msg('数据提交中...', {
|
||||
icon: 16,
|
||||
shade: 0.1,
|
||||
time: 1000 * 30
|
||||
});
|
||||
$.get("{{url('type')}}?type=" + this.value + '&model_id=' + model_id, function(data) {
|
||||
$("#content").html(data);
|
||||
}).complete(function() {
|
||||
layer.close(loading);
|
||||
});
|
||||
});
|
||||
$('#default-menu').on('click', 'a', function() {
|
||||
let value = $(this).text();
|
||||
$('#default').val(value);
|
||||
defaultReadonly(value);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
changeDataType: function() {
|
||||
var me = this;
|
||||
$.getJSON(url('model/field/getColumns'), {table: me.data_type}, function(res) {
|
||||
me.dataField = res.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Vue.createApp(vueData).mount('#app');
|
||||
|
||||
function setlength(value) {
|
||||
var types = {{json_encode($templates)}};
|
||||
if (value) {
|
||||
var type = types[value];
|
||||
$('#length').val(types[value]['length']);
|
||||
$('#default').val(types[value]['default']);
|
||||
defaultReadonly(types[value]['default']);
|
||||
}
|
||||
}
|
||||
|
||||
function defaultReadonly(value) {
|
||||
if (value == 'NULL' || value == 'Empty String') {
|
||||
$('#default').prop('readonly', true);
|
||||
} else {
|
||||
$('#default').prop('readonly', false);
|
||||
}
|
||||
}
|
||||
|
||||
ajaxSubmit('flow-field');
|
||||
</script>
|
||||
@@ -0,0 +1,102 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm">
|
||||
<a class="btn btn-info btn-sm" data-toggle="field-edit" data-model_id="{{$model_id}}" href="javascript:;"><i class="icon icon-plus"></i> 新建</a>
|
||||
</div>
|
||||
|
||||
<div class="wrapper-sm b-t">
|
||||
<form method="post" id="myform" name="myform">
|
||||
|
||||
<table class="table table-bordered m-b-none table-hover b-t" id="table-sortable" url="{{url()}}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">字段别名</th>
|
||||
<th align="left">字段名</th>
|
||||
<th align="center">数据绑定</th>
|
||||
<th align="center">数据关联</th>
|
||||
<th align="center">字段类型</th>
|
||||
<th align="center">字段索引</th>
|
||||
<th align="center">表单类型</th>
|
||||
<th align="center">ID</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($master->fields as $row)
|
||||
<tr id="{{$row['id']}}">
|
||||
<td align="left" class="move">{{$row['name']}}</td>
|
||||
<td align="left">{{$row['field']}}</td>
|
||||
<td align="center">
|
||||
@if($row['data_type'])
|
||||
{{$sets[$row['data_type']]['name']}}({{$row['data_field']}})
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
{{$row['data_link']}}
|
||||
</td>
|
||||
<td align="center">@if($row['type']) {{$row['type']}}({{$row['length']}}) @endif</td>
|
||||
<td align="center">{{$row['index']}}</td>
|
||||
<td align="center">{{$row['form_type']}}</td>
|
||||
<td align="center">{{$row['id']}}</td>
|
||||
<td align="center">
|
||||
<a class="option" data-toggle="field-edit" data-id="{{$row['id']}}" data-parent_id="{{$model_id}}" data-model_id="{{$row['model_id']}}" href="javascript:;">编辑</a>
|
||||
@if($row['system'] == 0)
|
||||
<a class="option" href="javascript:app.confirm('{{url('delete',['id'=>$row['id'],'model_id'=>$model_id])}}','确定要删除吗?');">删除</a>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
@foreach($sublist as $rows)
|
||||
@foreach($rows->fields as $row)
|
||||
<tr id="{{$row['id']}}">
|
||||
<td align="left" class="move"><span class="label label-primary">{{$rows->name}}</span> {{$row['name']}}</td>
|
||||
<td align="left">{{$row['field']}}</td>
|
||||
<td align="center">
|
||||
@if($row['data_type'])
|
||||
{{$sets[$row['data_type']]['name']}}({{$row['data_field']}})
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">{{$row['data_link']}}</td>
|
||||
<td align="center">@if($row['type']) {{$row['type']}}({{$row['length']}}) @endif</td>
|
||||
<td align="center">{{$row['index']}}</td>
|
||||
<td align="center">{{$row['form_type']}}</td>
|
||||
<td align="center">{{$row['id']}}</td>
|
||||
<td align="center">
|
||||
<a class="option" data-toggle="field-edit" data-id="{{$row['id']}}" data-parent_id="{{$model_id}}" data-model_id="{{$row['model_id']}}">编辑</a>
|
||||
@if($row['system'] == 0)
|
||||
<a class="option" href="javascript:app.confirm('{{url('delete',['model_id'=>$model_id,'id'=>$row['id']])}}','确定要删除吗?');">删除</a>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('[data-toggle="field-edit"]').on('click', function() {
|
||||
var data = $(this).data();
|
||||
formDialog({
|
||||
title: '字段管理',
|
||||
url: app.url('model/field/create', data),
|
||||
storeUrl: app.url('model/field/create'),
|
||||
id: 'flow-field',
|
||||
dialogClass:'modal-md',
|
||||
success: function(res) {
|
||||
toastrSuccess(res.data);
|
||||
$(this).dialog("close");
|
||||
location.reload();
|
||||
},
|
||||
error: function(res) {
|
||||
toastrError(res.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,71 @@
|
||||
<form method="post" id="model" name="model">
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td align="right" width="10%">模型名称</th>
|
||||
<td><input type="text" id="name" name="name" value="{{$model->name}}" onblur="app.pinyin('name','table');" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">父节模型</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="parent_id" id="parent_id">
|
||||
<option value="0"> - </option>
|
||||
@foreach($models as $_model)
|
||||
<option value="{{$_model->id}}" @if($_model->id == $model->parent_id) selected @endif>{{$_model->name}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">模型类型</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="type" id="type">
|
||||
<option value="0" @if($model->type == 0) selected @endif> - </option>
|
||||
<option value="1" @if($model->type == 1) selected @endif>多行子表</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">关联外键</td>
|
||||
<td><input type="text" id="relation" name="relation" value="{{$model->relation}}" class="form-control input-sm"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">数据表名</td>
|
||||
<td><input type="text" id="table" name="table" value="{{$model->table}}" class="form-control input-sm" @if($row->id > 0) readonly @endif></td>
|
||||
</tr>
|
||||
|
||||
<!--
|
||||
<tr>
|
||||
<td align="right">审核类型</td>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" @if($model['audit_type'] == 0) checked @endif value="0" name="audit_type"> 无 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($model['audit_type'] == 1) checked @endif value="1" name="audit_type"> 固定流程 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($model['audit_type'] == 2) checked @endif value="2" name="audit_type"> 自由流程 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($model['audit_type'] == 3) checked @endif value="3" name="audit_type"> 审核 </label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">支持回收站</td>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" @if($model['is_trash'] == 0) checked @endif value="0" name="is_trash"> 否 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($model['is_trash'] == 1) checked @endif value="1" name="is_trash"> 是 </label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">数据排序</td>
|
||||
<td>
|
||||
<label class="radio-inline"><input type="radio" @if($model['is_sort'] == 0) checked @endif value="1" name="is_sort"> 否 </label>
|
||||
<label class="radio-inline"><input type="radio" @if($model['is_sort'] == 1) checked @endif value="0" name="is_sort"> 是 </label>
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
|
||||
</table>
|
||||
<input type="hidden" name="id" value="{{$model->id}}">
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,92 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'dialog';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
action.field = function(data) {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var url = app.url('model/field/index', {model_id: data.master_id});
|
||||
var index = layer.open({
|
||||
skin: 'layui-layer-frame',
|
||||
scrollbar: false,
|
||||
closeBtn: 2,
|
||||
title: data.master_name + '[字段]',
|
||||
type: 2,
|
||||
move: false,
|
||||
area: ['100%', '100%'],
|
||||
content: url,
|
||||
});
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
config.cols[0]['hide'] = true;
|
||||
config.cols[1]['hide'] = true;
|
||||
config.cols[2]['hide'] = true;
|
||||
options.autoGroupColumnDef = {
|
||||
headerName: '名称',
|
||||
width: 120,
|
||||
cellRendererParams: {
|
||||
checkbox: true,
|
||||
suppressCount: true,
|
||||
}
|
||||
};
|
||||
options.treeData = true;
|
||||
options.groupDefaultExpanded = -1;
|
||||
options.getDataPath = function(data) {
|
||||
return data.tree_path;
|
||||
};
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.edit(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,60 @@
|
||||
<form method="post" class="form-horizontal" action="{{url('store')}}" id="mail" name="mail">
|
||||
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td align="right" width="10%">名称</td>
|
||||
<td align="left">
|
||||
<input class="form-control input-sm" type="text" name="name" value="{{$row['name']}}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">邮箱帐号</td>
|
||||
<td align="left">
|
||||
<input class="form-control input-sm" type="text" name="user" value="{{$row['user']}}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">邮箱密码</td>
|
||||
<td align="left">
|
||||
<input class="form-control input-sm" type="text" name="password" value="{{$row['password']}}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">SMTP服务器</td>
|
||||
<td align="left">
|
||||
<input class="form-control input-sm" type="text" name="smtp" value="{{$row['smtp']}}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">服务器端口</td>
|
||||
<td align="left">
|
||||
<input class="form-control input-sm" type="text" name="port" value="{{$row['port']}}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">连接方式</td>
|
||||
<td align="left">
|
||||
<select class="form-control input-sm" name="secure" id="secure">
|
||||
<option value="" @if($row['secure'] == '') selected @endif>默认</option>
|
||||
<option value="ssl" @if($row['secure'] == 'ssl') selected @endif>ssl</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">状态</td>
|
||||
<td align="left">
|
||||
<select class="form-control input-sm" name="status" id="status">
|
||||
<option value="1" @if($row['status'] == '1') selected @endif>启用</option>
|
||||
<option value="0" @if($row['status'] == '0') selected @endif>停用</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">排序</td>
|
||||
<td align="left">
|
||||
<input class="form-control input-sm" type="text" name="sort" value="{{$row['sort']}}">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="id" value="{{$row['id']}}">
|
||||
</form>
|
||||
@@ -0,0 +1,100 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'dialog';
|
||||
|
||||
action.refresh = function() {
|
||||
var me = this;
|
||||
var loading = layer.msg('模块更新中...', {
|
||||
icon: 16, shade: 0.1, time: 1000 * 120
|
||||
});
|
||||
$.post(app.url('model/module/refresh'), function(res) {
|
||||
if (res.status) {
|
||||
options.remoteData({page: 1});
|
||||
toastrSuccess(res.data);
|
||||
} else {
|
||||
toastrError(res.data);
|
||||
}
|
||||
},'json').complete(function() {
|
||||
layer.close(loading);
|
||||
});
|
||||
}
|
||||
|
||||
action.test = function() {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var rows = grid.api.getSelectedRows();
|
||||
if (rows.length == 1) {
|
||||
formDialog({
|
||||
title: '测试邮件',
|
||||
url: app.url('system/mail/test', {id: rows[0].id}),
|
||||
storeUrl: app.url('system/mail/test'),
|
||||
id: 'mail_test',
|
||||
dialogClass:'modal-sm',
|
||||
success: function(res) {
|
||||
toastrSuccess(res.data);
|
||||
$(this).dialog("close");
|
||||
},
|
||||
error: function(res) {
|
||||
toastrError(res.data);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastrError('只能选择一条数据。');
|
||||
}
|
||||
}
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.show(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,147 @@
|
||||
<div class="panel">
|
||||
|
||||
<form method="post" action="{{url()}}" id="myform" name="myform">
|
||||
|
||||
<div class="wrapper-sm b-b">
|
||||
<a class="btn btn-default btn-sm" href="{{url('index',['bill_id'=>$bill_id])}}"><i class="fa fa-reply"></i> 返回</a>
|
||||
<button type="submit" class="btn btn-sm btn-success"><i class="fa fa-check"></i> 提交</button>
|
||||
</div>
|
||||
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td align="right" width="10%">权限名称<span class="red">*</span></td>
|
||||
<td width="20%">
|
||||
<input type="text" id="name" name="name" value="{{$permission['name']}}" class="form-control input-sm input-inline">
|
||||
</td>
|
||||
<td align="right" width="10%">权限类型 <span class="red">*</span></td>
|
||||
<td width="20%">
|
||||
<select multiple="multiple" class="input-select2 form-control input-sm input-inline" name="type[]">
|
||||
<option value="create" @if(in_array('create', $permission['type'])) selected @endif>新增</option>
|
||||
<option value="edit" @if(in_array('edit', $permission['type'])) selected @endif>编辑</option>
|
||||
</select>
|
||||
</td>
|
||||
<td align="right" width="10%">权限范围 <span class="red">*</span></td>
|
||||
<td width="20%">
|
||||
{{App\Support\Dialog::search($permission, 'id=receive_id&name=receive_name&multi=1')}}
|
||||
</td>
|
||||
<td align="right"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<table class="table table-bordered table-form">
|
||||
<tr>
|
||||
<td>名称</td>
|
||||
<td>字段</td>
|
||||
<td>字段可写</td>
|
||||
<td>字段保密</td>
|
||||
<td>验证规则</td>
|
||||
</tr>
|
||||
|
||||
@foreach($master['fields'] as $field)
|
||||
<tr>
|
||||
<td>
|
||||
{{$field->name}}
|
||||
</td>
|
||||
<td>
|
||||
{{$master->table}}.{{$field->field}}
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" @if($permission['data'][$master->table][$field->field]['w'] == 1) checked @endif class="field-edit" data-key="{{$master->table}}_{{$field->field}}" id="{{$master->table}}_{{$field->field}}_edit" name="data[{{$master->table}}][{{$field->field}}][w]" value="1">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" @if($permission['data'][$master->table][$field->field]['s'] == 1) checked @endif class="field-secret" data-key="{{$master->table}}_{{$field->field}}" id="{{$master->table}}_{{$field->field}}_secret" name="data[{{$master->table}}][{{$field->field}}][s]" value="1">
|
||||
</td>
|
||||
<td>
|
||||
<select multiple data-placeholder="选择验证规则" class="form-control input-sm input-inline input-select2" style="width:200px;" name="data[{{$master->table}}][{{$field->field}}][v][]">
|
||||
<option value=""></option>
|
||||
@foreach($regulars as $key => $regular)
|
||||
<option @if(in_array($key, (array)$permission['data'][$master->table][$field->field]['v'])) selected @endif value="{{$key}}">{{$regular}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@if($field['form_type'] == 'auto' || $field['form_type'] == 'sn' || $field['form_type'] == 'date')
|
||||
<label title="锁定将不允许修改字段的值">
|
||||
<input type="checkbox" value="1" @if($permission['data'][$master->table][$field->field]['m'] == 1) checked @endif name="data[{{$master->table}}][{{$field->field}}][m]"> 锁定
|
||||
</label>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
|
||||
@foreach($sublist as $submodel)
|
||||
<tr>
|
||||
<td>
|
||||
<span class="label label-success">{{$submodel['name']}}</span> 权限
|
||||
</td>
|
||||
<td>
|
||||
{{$submodel->table}}@option
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<select multiple data-placeholder="选择验证规则" class="form-control input-sm input-inline input-select2" name="data[{{$submodel->table}}][{{$field->field}}][v][]">
|
||||
<option value=""></option>
|
||||
<option @if(in_array('required', (array)$permission['data'][$submodel->table]['@option']['v'])) selected @endif value="required">必填</option>
|
||||
</select>
|
||||
<label class="inline-checkbox"><input type="checkbox" @if($permission['data'][$submodel->table]['@option']['w'] == 1) checked @endif name="data[{{$submodel->table}}][@option][w]" value="1"> 增</label>
|
||||
|
||||
<label class="inline-checkbox"><input type="checkbox" @if($permission['data'][$submodel->table]['@option']['d'] == 1) checked @endif name="data[{{$submodel->table}}][@option][d]" value="1"> 删</label>
|
||||
</td>
|
||||
</tr>
|
||||
@foreach($submodel['fields'] as $field)
|
||||
<tr>
|
||||
<td>
|
||||
<span class="label label-primary">{{$submodel['name']}}</span>
|
||||
{{$field['name']}}
|
||||
</td>
|
||||
<td>
|
||||
{{$submodel->table}}.{{$field->field}}
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" @if($permission['data'][$submodel->table][$field->field]['w'] == 1) checked @endif class="field-edit" data-key="{{$submodel->table}}_{{$field->field}}" id="{{$submodel->table}}_{{$field->field}}_edit" name="data[{{$submodel->table}}][{{$field->field}}][w]" value="1">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" @if($permission['data'][$submodel->table][$field->field]['s'] == 1) checked @endif class="field-secret" data-key="{{$submodel->table}}_{{$field->field}}" id="{{$submodel->table}}_{{$field->field}}_secret" name="data[{{$submodel->table}}][{{$field->field}}][s]" value="1">
|
||||
</td>
|
||||
<td>
|
||||
@if($field['form_type'] == 'auto' || $field['form_type'] == 'date')
|
||||
<label title="锁定将不允许修改宏控件的值">
|
||||
<input type="checkbox" value="1" @if($permission['data'][$submodel->table][$field->field]['m'] == 1) checked @endif name="data[{{$submodel->table}}][{{$field->field}}][m]"> 锁定
|
||||
</label>
|
||||
@else
|
||||
<select multiple data-placeholder="选择验证规则" class="form-control input-sm input-inline input-select2" name="data[{{$submodel->table}}][{{$field->field}}][v][]">
|
||||
<option value=""></option>
|
||||
@foreach($regulars as $key => $regular)
|
||||
<option @if(in_array($key, (array)$permission['data'][$submodel->table][$field->field]['v'])) selected @endif value="{{$key}}">{{$regular}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
@endforeach
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<table class="table table-form m-b-none">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="id" value="{{$permission['id']}}">
|
||||
<input type="hidden" name="bill_id" value="{{$bill_id}}">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,41 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm">
|
||||
<a class="btn btn-info btn-sm" href="{{url('create',['bill_id'=>$bill_id])}}"><i class="icon icon-plus"></i> 新建</a>
|
||||
</div>
|
||||
|
||||
<div class="wrapper-sm b-t">
|
||||
<form method="post" action="{{url()}}" id="myform" name="myform">
|
||||
|
||||
<table class="table table-bordered table-hover m-b-none b-t" id="table-sortable" url="{{url()}}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">权限名称</th>
|
||||
<th align="center">权限类型</th>
|
||||
<th align="center">权限范围</th>
|
||||
<th align="center">ID</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($rows)
|
||||
@foreach($rows as $row)
|
||||
<tr id="{{$row['id']}}">
|
||||
<td align="left" class="move">{{$row['name']}}</td>
|
||||
<td align="center">{{$row['type']}}</td>
|
||||
<td align="center">{{$row['receive_name']}}</td>
|
||||
<td align="center">{{$row['id']}}</td>
|
||||
<td align="center">
|
||||
<a class="option" href="{{url('create',['bill_id'=>$row['bill_id'],'id'=>$row['id']])}}">编辑</a>
|
||||
@if($row['system'] == 0)
|
||||
<a class="option" onclick="app.confirm('{{url('delete',['id'=>$row['id']])}}','确定要删除吗?');" href="javascript:;">删除</a>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,52 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center">序号</th>
|
||||
<th align="left">步骤</th>
|
||||
<th align="left">办理内容</th>
|
||||
<th align="center">办理人</th>
|
||||
<th align="center">办理类型</th>
|
||||
<th align="center">办理效率</th>
|
||||
<th align="center">办理时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach($rows as $i => $row)
|
||||
<tr>
|
||||
<td align="center">
|
||||
{{$i + 1}}
|
||||
</td>
|
||||
<td align="left">
|
||||
{{$steps[$row['step_number']]['name']}}
|
||||
</td>
|
||||
<td align="left">
|
||||
{{$row[description]}}
|
||||
</td>
|
||||
<td align="center">
|
||||
{{$row[created_by]}}
|
||||
</td>
|
||||
<td align="center">
|
||||
@if($row[step_status] == 'back')
|
||||
退回
|
||||
@else
|
||||
审批
|
||||
@endif
|
||||
</td>
|
||||
<td align="center">
|
||||
<?php
|
||||
$start = $row['created_at'];
|
||||
if ($i) {
|
||||
$s = Carbon\Carbon::createFromTimeStamp($start);
|
||||
$e = Carbon\Carbon::createFromTimeStamp($end);
|
||||
echo $s->diffInHours($e).'小时';
|
||||
} else {
|
||||
echo '无';
|
||||
}
|
||||
$end = $start;
|
||||
?>
|
||||
</td>
|
||||
<td align="center">
|
||||
@datetime($row[created_at])
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@@ -0,0 +1,72 @@
|
||||
<form class="form-horizontal" name="myturn" id="myturn" method="post">
|
||||
|
||||
<table class="table table-form">
|
||||
|
||||
<tr>
|
||||
<td align="right">办理类型</td>
|
||||
<td align="left">
|
||||
<label class="i-checks i-checks-sm"><input type="radio" class="process-step" name="step_status" value="next"><i></i>审批</label>
|
||||
@if($step->back == 1 && $step->number > 1)
|
||||
|
||||
|
||||
<label class="i-checks i-checks-sm"><input type="radio" class="process-step" name="step_status" value="back"><i></i>退回</label>
|
||||
@endif
|
||||
|
||||
|
||||
<label class="i-checks i-checks-sm"><input type="radio" class="process-step" name="step_status" value="reject"><i></i>拒绝</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right" width="20%">选择进程</td>
|
||||
<td align="left" width="80%">
|
||||
<div id="process-step"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">审批备注</td>
|
||||
<td align="left">
|
||||
<textarea class="form-control" rows="3" id="description" name="description"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">提醒类型</td>
|
||||
<td align="left">
|
||||
<label class="i-checks i-checks-sm"><input type="checkbox" name="notify_sms" value="{{$notify['sms']}}" @if($notify['sms'])checked="checked" @endif><i></i>短信</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">提醒内容</td>
|
||||
<td align="left">
|
||||
<input type="text" class="form-control input-sm" name="notify_text" value="{{$notify['text']}}" readonly="readonly">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<input type="hidden" name="key" value="{{$key}}">
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('.process-step').on('click', function() {
|
||||
if(this.value == 'reject') {
|
||||
$('#process-step').html('无');
|
||||
} else {
|
||||
var myform = $('#myform, #myturn').serialize();
|
||||
var query = $.param({type: this.value, model_id:'{{$step->model_id}}', step_sn:'{{$step->sn}}'});
|
||||
$.post('{{url("step")}}?' + query, myform, function(res) {
|
||||
$('#process-step').html(res);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function get_step_user()
|
||||
{
|
||||
var myform = $('#myform,#myturn').serialize();
|
||||
$.get('{{url("user")}}', myform, function(res) {
|
||||
$('#process-user').html(res.data);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,145 @@
|
||||
<form method="post" action="<?php echo url(); ?>" id="conditionform" name="conditionform">
|
||||
|
||||
<?php
|
||||
if (sizeof($steps)):
|
||||
foreach ($steps as $step):
|
||||
?>
|
||||
<div class="panel">
|
||||
<table id="Condition<?php echo $step->id; ?>Ctrl" class="table table-form table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7" align="left">转入: <?php echo $step->name; ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="center">左括号</th>
|
||||
<th align="center">字段</th>
|
||||
<th align="center">条件</th>
|
||||
<th>值</th>
|
||||
<th>函数</th>
|
||||
<th align="center">右括号</th>
|
||||
<th align="center">逻辑</th>
|
||||
<th align="center">
|
||||
<a @click="create();" class="btn btn-xs btn-default"><i class="icon icon-plus"></i></a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item,index) in items">
|
||||
<td>
|
||||
<select :name="'condition[<?php echo $step->id; ?>]['+index+'][l]'" v-model="item.l" class="input-sm form-control">
|
||||
<option value=""></option>
|
||||
<option value="(">(</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select :name="'condition[<?php echo $step->id; ?>]['+index+'][f]'" v-model="item.f" class="input-sm form-control">
|
||||
<option value=""></option>
|
||||
<?php
|
||||
foreach ($columns as $table => $column):
|
||||
foreach ($column['data'] as $field):
|
||||
?>
|
||||
<?php if ($field['auto'] == 1): ?>
|
||||
<option value="<?php echo $field['field']; ?>"><?php echo $field['name']; ?></option>
|
||||
<?php else: ?>
|
||||
<option value="<?php echo $table; ?>.<?php echo $field['field']; ?>">
|
||||
<?php if ($column['master'] == 0): ?>[<?php echo $column['name']; ?>]<?php endif; ?>
|
||||
<?php echo $field['name']; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endforeach;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select :name="'condition[<?php echo $step->id; ?>]['+index+'][c]'" v-model="item.c" class="input-sm form-control">
|
||||
<option value=""></option>
|
||||
<option value="==">等于</option>
|
||||
<option value="<>">不等于</option>
|
||||
<option value=">">大于</option>
|
||||
<option value="<">小于</option>
|
||||
<option value=">=">大于等于</option>
|
||||
<option value="<=">小于等于</option>
|
||||
<!--
|
||||
<option value="like">包含</option>
|
||||
<option value="not like">不包含</option>
|
||||
-->
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input :name="'condition[<?php echo $step->id; ?>]['+index+'][v]'" v-model="item.v" class="input-sm form-control">
|
||||
</td>
|
||||
<td>
|
||||
<select :name="'condition[<?php echo $step->id; ?>]['+index+'][t]'" v-model="item.t" class="input-sm form-control">
|
||||
<option value=""></option>
|
||||
<option value="sum">SUM(合计)</option>
|
||||
<option value="count">COUNT(行数)</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select :name="'condition[<?php echo $step->id; ?>]['+index+'][r]'" v-model="item.r" class="input-sm form-control">
|
||||
<option value=""></option>
|
||||
<option value=")">)</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select :name="'condition[<?php echo $step->id; ?>]['+index+'][i]'" v-model="item.i" class="input-sm form-control">
|
||||
<option value=""></option>
|
||||
<option value="and">and</option>
|
||||
<option value="or">or</option>
|
||||
</select>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a @click="remove(index);" data-condition="delete" class="btn btn-xs btn-default"><i class="icon icon-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
<?php foreach ($steps as $step): ?>
|
||||
var conditionCtrl = {
|
||||
data() {
|
||||
return {
|
||||
items: <?php echo json_encode((array)$condition[$step->id]); ?>
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
create: function() {
|
||||
var item = {};
|
||||
this.items.push(item);
|
||||
},
|
||||
remove: function(index) {
|
||||
this.items.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
Vue.createApp(conditionCtrl).mount('#Condition<?php echo $step->id; ?>Ctrl');
|
||||
|
||||
<?php endforeach; ?>
|
||||
$('#myform').submit(function () {
|
||||
var url = $(this).attr('action');
|
||||
var data = $(this).serialize();
|
||||
$.post(url, data, function (res) {
|
||||
if (res.status) {
|
||||
toastrSuccess(res.data);
|
||||
} else {
|
||||
toastrError(res.data);
|
||||
}
|
||||
}, 'json');
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $row->id; ?>">
|
||||
<input type="hidden" name="model_id" value="<?php echo $model->id; ?>">
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,173 @@
|
||||
<form method="post" action="{{url()}}" id="mystep" name="mystep">
|
||||
|
||||
<div class="panel">
|
||||
<table class="table table-form">
|
||||
<tr>
|
||||
<td align="right" width="10%">节点名称<span class="red">*</span></td>
|
||||
<td>
|
||||
<input type="text" id="name" name="name" value="{{$row->name}}" class="form-control input-sm">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@if($row->type != 'start')
|
||||
<tr>
|
||||
<td align="right">执行目标</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="type" id="type">
|
||||
<!--
|
||||
<option value="start" @if($row->type == 'start') selected @endif>开始</option>
|
||||
-->
|
||||
<option value=""> - </option>
|
||||
<option value="leader" @if($row->type == 'leader') selected @endif>直属领导</option>
|
||||
<option value="manager" @if($row->type == 'manager') selected @endif>部门主管</option>
|
||||
|
||||
<option value="team1" @if($row->type == 'team1') selected @endif>销售组1级</option>
|
||||
<option value="team2" @if($row->type == 'team2') selected @endif>销售组2级</option>
|
||||
<option value="team3" @if($row->type == 'team3') selected @endif>销售组3级</option>
|
||||
<option value="team4" @if($row->type == 'team4') selected @endif>销售组4级</option>
|
||||
<option value="team5" @if($row->type == 'team5') selected @endif>销售组5级</option>
|
||||
<option value="team6" @if($row->type == 'team6') selected @endif>销售组6级</option>
|
||||
<option value="team7" @if($row->type == 'team7') selected @endif>销售组7级</option>
|
||||
<option value="team8" @if($row->type == 'team8') selected @endif>销售组8级</option>
|
||||
<option value="team9" @if($row->type == 'team9') selected @endif>销售组9级</option>
|
||||
<option value="team10" @if($row->type == 'team10') selected @endif>销售组10级</option>
|
||||
|
||||
<option value="user" @if($row->type == 'user') selected @endif>指定办理人</option>
|
||||
<option value="role" @if($row->type == 'role') selected @endif>指定角色</option>
|
||||
<option value="created_id" @if($row->type == 'created_id') selected @endif>单据创建人ID</option>
|
||||
<option value="field" @if($row->type == 'field') selected @endif>指定字段</option>
|
||||
<option value="position" @if($row->type == 'position') selected @endif>职位</option>
|
||||
<option value="custom" @if($row->type == 'custom') selected @endif>自定义</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">执行规则</td>
|
||||
<td>
|
||||
<?php $type_value = ($row->type == 'field' ? '' : $row->type_value); ?>
|
||||
<span id="type_user" class="type" style="display:none;">
|
||||
{{App\Support\Dialog::user('user','type_value[user]', $type_value, 1, 0)}}
|
||||
</span>
|
||||
|
||||
<span id="type_role" class="type" style="display:none;">
|
||||
{{App\Support\Dialog::user('role','type_value[role]', $type_value, 1, 0)}}
|
||||
</span>
|
||||
|
||||
<span id="type_field" class="type" style="display:none;">
|
||||
<select class="form-control input-sm" name="type_value[field]">
|
||||
@if($columns[$model->table]['fields'])
|
||||
@foreach($columns[$model->table]['fields'] as $column)
|
||||
<option value="{{$column->field}}" @if($row->type_value == $column->field) selected @endif>{{$column->name}}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
</span>
|
||||
|
||||
<label class="checkbox-inline m-t-xs">
|
||||
<input name="select_org" type="checkbox" value="1" @if($row->select_org == 1) checked @endif>允许选择组织中人员
|
||||
</label>
|
||||
|
||||
<div class="m-t-xs">
|
||||
匹配不到人:
|
||||
<select class="form-control input-sm input-inline" name="nouser" id="nouser">
|
||||
<option value="0" @if($row->nouser == 0) selected @endif>由上节点选择执行人</option>
|
||||
<option value="1" @if($row->nouser == 1) selected @endif>自动跳过</option>
|
||||
<option value="2" @if($row->nouser == 2) selected @endif>转给指定人</option>
|
||||
</select>
|
||||
<span class="nouser" id="nouser_2" style="display:none;">
|
||||
<span class="form-inline">
|
||||
{{App\Support\Dialog::user('user','nouser_user_id', $row->nouser_user_id, 0, 0)}}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@endif
|
||||
|
||||
<tr>
|
||||
<td align="right">执行模式</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="run_mode" id="run_mode">
|
||||
<option value="1" @if($row->run_mode == 1) selected @endif>单人执行</option>
|
||||
<option value="2" @if($row->run_mode == 2) selected @endif>多人执行</option>
|
||||
<option value="3" @if($row->run_mode == 3) selected @endif>全体执行</option>
|
||||
<option value="4" @if($row->run_mode == 4) selected @endif>竞争执行</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">节点类型</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="option" id="option">
|
||||
<option value="1" @if($row->option == 1) selected @endif>审核</option>
|
||||
<option value="0" @if($row->option == 0) selected @endif>知会</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">表单权限</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="permission_id" id="permission_id">
|
||||
<option value=""> - </option>
|
||||
@foreach($permissions as $permission)
|
||||
<option value="{{$permission['id']}}" @if($row->permission_id == $permission['id']) selected @endif>{{$permission['name']}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">节点提醒</td>
|
||||
<td>
|
||||
<label class="checkbox-inline">
|
||||
<input name="notify[sms]" type="checkbox" id="notify-sms" value="1" @if($row->notify['sms'] == 1) checked @endif>短信
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@if($row->type != 'start')
|
||||
<tr>
|
||||
<td align="right">节点退回</td>
|
||||
<td>
|
||||
<select class="form-control input-sm" name="back" id="back">
|
||||
<option value="0" @if($row->back == '0') selected @endif>无</option>
|
||||
<option value="1" @if($row->back == '1') selected @endif>上一步</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="{{$row->id}}">
|
||||
<input type="hidden" name="bill_id" value="{{$bill->id}}">
|
||||
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
userType('{{$row->type}}');
|
||||
nouserType('{{$row->nouser}}');
|
||||
$('#type').on('change', function() {
|
||||
userType(this.value);
|
||||
});
|
||||
$('#nouser').on('change', function() {
|
||||
nouserType(this.value);
|
||||
});
|
||||
});
|
||||
|
||||
function nouserType(value) {
|
||||
value = value || '';
|
||||
$('.nouser').hide();
|
||||
$('#nouser_' + value).show();
|
||||
}
|
||||
|
||||
function userType(type) {
|
||||
type = type || '';
|
||||
$('.type').hide().prop('disabled', true);
|
||||
$('#type_' + type).show().prop('disabled', false);
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,49 @@
|
||||
<div class="panel">
|
||||
|
||||
@include('query')
|
||||
|
||||
<table class="table table-hover b-t" id="table-sortable" url="{{url()}}">
|
||||
<tr>
|
||||
<th align="left">节点名称</th>
|
||||
<th align="left">转入节点</th>
|
||||
<th align="center">执行目标</th>
|
||||
<th align="center">节点类型</th>
|
||||
<th align="center">节点颜色</th>
|
||||
<th align="center">ID</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
@foreach($rows as $row)
|
||||
<tr id="{{$row->id}}">
|
||||
<td align="left" @if($row->type != "end" && $row->type != "start") class="move" @endif>
|
||||
@if($row->sn > 1)
|
||||
<span class="badge badge-bg">{{$row->sn}}</span>
|
||||
@endif
|
||||
{{$row->name}}
|
||||
</td>
|
||||
<td align="left">
|
||||
<?php $joins = explode(',', $row->join); ?>
|
||||
@foreach($joins as $id)
|
||||
{{$rows[$id]['name']}}
|
||||
@endforeach
|
||||
</td>
|
||||
<td align="center">{{$row->type}}</td>
|
||||
|
||||
<td align="center">@if($row->option == 1) 审核 @else 知会 @endif</td>
|
||||
|
||||
<td align="center"><span class="label label-{{$row->color}}">{{$row->color}}</span></td>
|
||||
<td align="center">{{$row->id}}</td>
|
||||
<td align="center">
|
||||
@if($row->type != 'end')
|
||||
<?php $condition = json_decode($row->condition, true); ?>
|
||||
<a class="option" href="{{url('condition',['model_id'=>$model->id,'id'=>$row->id])}}">条件({{count($condition)}})</a>
|
||||
<a class="option" href="{{url('create',['model_id'=>$model->id,'id'=>$row->id])}}">编辑</a>
|
||||
@endif
|
||||
@if($row->sn > 1)
|
||||
<a class="option" onclick="app.confirm('{{url('delete',['id'=>$row->id])}}','确定要删除吗?');" href="javascript:;">删除</a>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,454 @@
|
||||
<script src="{{$asset_url}}/vendor/jquery.plumb.min.js" type="text/javascript"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var intervalTimer = null;
|
||||
var nowStepId = null;
|
||||
var normalStepSelector = ".wf-step:not(.wf-step-end)";
|
||||
// var normalStepSelector = ".wf-step:not(.wf-step-start,.wf-step-end)";
|
||||
|
||||
// 判断连接器是否指向了自己
|
||||
var isConnectToSelf = function(param) {
|
||||
return param.sourceId === param.targetId
|
||||
},
|
||||
isFromStartToEnd = function(param) {
|
||||
return param.sourceId === "step_1" && param.targetId === "step_0"
|
||||
},
|
||||
// 判断连接步骤是否重复
|
||||
stepIsRepeat = function(param){
|
||||
// 获取同一scope下的链接器,判断当前链接是否有重复
|
||||
var cnts = jsPlumb.getConnections(param.scope);
|
||||
if(cnts.length > 0) {
|
||||
for(var i = 0, len = cnts.length; i < len; i++) {
|
||||
// 如果有链接器 sourceId 及 targetId 都相等,那大概也许可能就相等了。
|
||||
if(param.sourceId === cnts[i].sourceId && param.targetId === cnts[i].targetId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 连接前的事件
|
||||
var beforeDropHandler = function(param) {
|
||||
|
||||
if (isConnectToSelf(param)) {
|
||||
toastrError('连接点不能是自己。');
|
||||
return false;
|
||||
}
|
||||
// 连接步骤是否重复
|
||||
if (stepIsRepeat(param)) {
|
||||
toastrError('连接点已经存在。');
|
||||
return false;
|
||||
}
|
||||
// 连接步骤是结束
|
||||
if (isFromStartToEnd(param)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
// 获取步骤图
|
||||
workStep.init();
|
||||
|
||||
$('#graph').contextmenu({'target':'#graph-menu'});
|
||||
|
||||
// 阻止非空白处的右键事件,不出现菜单
|
||||
//$container.on("contextmenu", "*", function(evt) {
|
||||
//evt.stopPropagation();
|
||||
//});
|
||||
|
||||
// 点击或双击事件,这里进行了一个单击事件延迟,因为同时绑定了双击事件
|
||||
$("#rows").on('click', 'div', function() {
|
||||
clearTimeout(intervalTimer);
|
||||
intervalTimer = setTimeout(function() {
|
||||
workStep.click();
|
||||
},300);
|
||||
|
||||
}).on('dblclick', 'div', function(e) {
|
||||
nowStepId = $(e.target).attr('step_id');
|
||||
clearTimeout(intervalTimer);
|
||||
workStep.dblClick('base');
|
||||
});
|
||||
});
|
||||
|
||||
var workStep = {
|
||||
|
||||
init:function() {
|
||||
|
||||
jsPlumb.reset();
|
||||
|
||||
jsPlumb.bind("beforeDrop", beforeDropHandler);
|
||||
|
||||
$.post("{{url('index2')}}",{model_id:'{{$model_id}}'},function(res)
|
||||
{
|
||||
$('#rows').empty();
|
||||
var nLastStepId = 0;
|
||||
|
||||
if(res.status == true) {
|
||||
jsPlumb.importDefaults({
|
||||
DragOptions:{cursor:'pointer'},
|
||||
ConnectionOverlays:[
|
||||
["Arrow",{location:1,id:"arrow",width:10,length:8}]
|
||||
],
|
||||
Anchor:'Continuous',
|
||||
Endpoint :"Blank",
|
||||
EndpointStyle:{radius:3,strokeStyle:'#1e8151'},
|
||||
HoverPaintStyle:{radius:3,strokeStyle:'#999'},
|
||||
ConnectorZIndex:5,
|
||||
HoverPaintStyle:workStep.connectorHoverStyle
|
||||
});
|
||||
|
||||
if(!$.support.leadingWhitespace) {
|
||||
// ie9以下,用VML画图
|
||||
jsPlumb.setRenderMode(jsPlumb.VML);
|
||||
} else {
|
||||
// 其他浏览器用SVG
|
||||
jsPlumb.setRenderMode(jsPlumb.SVG);
|
||||
}
|
||||
|
||||
// 第一次循环,生成页面元素div
|
||||
var left = 20;
|
||||
var top = 20;
|
||||
|
||||
var rows = res.data;
|
||||
var setd = {};
|
||||
|
||||
$.each(rows, function(id, row) {
|
||||
var title = '<span class="ep">' + (row.option == 1 ? '审核' : '知会') + '</span> ' + row.name;
|
||||
if (row.type == 'start') {
|
||||
title = '<span class="ep"><i class="icon icon-play"></i></span> ' + row.name;
|
||||
} else if(row.type == 'end') {
|
||||
title = '<span class="ep"><i class="icon icon-stop"></i></span> ' + row.name;
|
||||
}
|
||||
|
||||
var css = 'wf-step';
|
||||
if (row.type == 'start') {
|
||||
css = 'wf-step wf-step-start';
|
||||
} else if(row.type == 'end') {
|
||||
css = 'wf-step wf-step-end';
|
||||
}
|
||||
|
||||
var nodeDiv = document.createElement('div');
|
||||
var $node = $(nodeDiv);
|
||||
|
||||
$node.attr("id", "step_" + row.id)
|
||||
.attr("join", row.join)
|
||||
.attr("step_id", row.id)
|
||||
.css({"left":row.left+'px',"top":row.top+'px',"cursor":"move"})
|
||||
.addClass(css)
|
||||
.html(title);
|
||||
|
||||
/*
|
||||
$(normalStepSelector).on('mousedown', function(e) {
|
||||
|
||||
//if(row.number > 0) {
|
||||
nowStepId = $(e.target).attr('step_id');
|
||||
// $(this).contextmenu({'target':'#step-menu'});
|
||||
//}
|
||||
//e.stopPropagation();
|
||||
});
|
||||
*/
|
||||
|
||||
$("#rows").append($node);
|
||||
|
||||
// 索引变量
|
||||
nLastStepId++;
|
||||
|
||||
});
|
||||
|
||||
// 绑定右键操作菜单
|
||||
$(normalStepSelector).on('mousedown', function(e) {
|
||||
nowStepId = $(e.target).attr('step_id');
|
||||
$(this).contextmenu({'target':'#step-menu'});
|
||||
// e.stopPropagation();
|
||||
});
|
||||
|
||||
// 使之可拖动
|
||||
jsPlumb.draggable($(".wf-step"));
|
||||
|
||||
$(".ep").each(function(i,e) {
|
||||
var p = $(e).parent();
|
||||
jsPlumb.makeSource($(e), {
|
||||
parent:p,
|
||||
anchor:"Continuous",
|
||||
endpoint:"Blank",
|
||||
paintStyle:{
|
||||
strokeStyle:"#3399cc",
|
||||
fillStyle:"transparent",
|
||||
radius:2,
|
||||
lineWidth:2
|
||||
},
|
||||
// stub 线条弯曲角度 gap 距离节点位置 cornerRadius 线条圆角
|
||||
connector:["Flowchart",{stub:[10, 30], gap:0, cornerRadius:3, alwaysRespectStubs:true}],
|
||||
connectorStyle:workStep.connectorPaintStyle,
|
||||
hoverPaintStyle:workStep.endpointHoverStyle,
|
||||
connectorHoverStyle:workStep.connectorHoverStyle,
|
||||
dragOptions:{},
|
||||
maxConnections:-1
|
||||
});
|
||||
});
|
||||
|
||||
// 绑定删除确认操作
|
||||
jsPlumb.bind("click", function(e) {
|
||||
jsPlumb.detach(e);
|
||||
});
|
||||
|
||||
// 连接关联的步骤
|
||||
$('.wf-step').each(function(i) {
|
||||
var id = $(this).attr('id');
|
||||
var join = $(this).attr('join') || '';
|
||||
var joinArray = join.split(",");
|
||||
$.each(joinArray,function(j, n) {
|
||||
if(n > 0) {
|
||||
jsPlumb.connect({source:id, target:"step_"+n});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
jsPlumb.makeTarget($('.wf-step'), {
|
||||
dropOptions: {hoverClass:"dragHover", activeClass:"active"},
|
||||
anchor: "Continuous",
|
||||
maxConnections: 5
|
||||
});
|
||||
}
|
||||
},'json');
|
||||
},
|
||||
connectorPaintStyle:{
|
||||
lineWidth:2,
|
||||
strokeStyle:"#3399cc",
|
||||
joinstyle:"round",
|
||||
outlineColor:"white",
|
||||
dashstyle:"0",
|
||||
outlineWidth:2
|
||||
},
|
||||
connectorHoverStyle:{
|
||||
lineWidth:2,
|
||||
strokeStyle:"#999999",
|
||||
outlineWidth:2,
|
||||
dashstyle:"4 1",
|
||||
outlineColor:"white"
|
||||
},
|
||||
endpointHoverStyle:{
|
||||
strokeStyle:"#216477"
|
||||
},
|
||||
// 清空所有连接
|
||||
clear:function() {
|
||||
jsPlumb.detachEveryConnection();
|
||||
jsPlumb.deleteEveryEndpoint();
|
||||
},
|
||||
// 单击事件
|
||||
click:function() {
|
||||
if (nowStepId > 0) {
|
||||
$('#tree').hide();
|
||||
$.post('{{url("show")}}',{id:nowStepId, model_id:'{{$model_id}}'}, function(res) {
|
||||
$('#tree').html(res.data).show();
|
||||
})
|
||||
}
|
||||
},
|
||||
// 删除步骤
|
||||
deleted:function() {
|
||||
$.messager.confirm('操作警告','确认要删除该步骤吗?',function(btn) {
|
||||
if (btn) {
|
||||
$.post('{{url("delete")}}',{id:nowStepId, model_id:'{{$model_id}}'}, function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('操作成功');
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
// 克隆步骤
|
||||
clone:function() {
|
||||
$.messager.confirm('操作警告','确认要克隆该步骤吗?',function(btn) {
|
||||
if (btn) {
|
||||
$.post('{{url("add")}}',{id:nowStepId,model_id:'{{$model_id}}'},function(data) {
|
||||
if(data.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('操作成功');
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
});
|
||||
},
|
||||
dblClick:function(tab) {
|
||||
if (nowStepId > 0) {
|
||||
if(tab == 'base') {
|
||||
$.dialog({
|
||||
title:'基本设置',
|
||||
url:'{{url("create")}}?model_id={{$model_id}}&id='+nowStepId+'&tab='+tab,
|
||||
dialogClass: 'modal-lg',
|
||||
buttons:[{
|
||||
class: 'btn-info',
|
||||
text:'<i class="fa fa-check-circle"></i> 提交',
|
||||
click: function() {
|
||||
var formData = $('#mystep').serialize();
|
||||
$.post('{{url("create")}}', formData, function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('保存当前视图成功');
|
||||
}
|
||||
},'json');
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text:'<i class="fa fa-times"></i> 取消',
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
if (tab == 'condition') {
|
||||
$.dialog({
|
||||
title:'条件设置',
|
||||
url:'{{url("condition")}}?model_id={{$model_id}}&id='+nowStepId+'&tab='+tab,
|
||||
dialogClass: 'modal-lg',
|
||||
buttons:[{
|
||||
class: 'btn-info',
|
||||
text:'<i class="fa fa-check-circle"></i> 提交',
|
||||
click: function() {
|
||||
var formData = $('#conditionform').serialize();
|
||||
$.post('{{url("condition")}}', formData, function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('保存当前视图成功');
|
||||
}
|
||||
},'json');
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text:'<i class="fa fa-times"></i> 取消',
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
add:function() {
|
||||
$.post('{{url("add")}}',{model_id:'{{$model_id}}'},function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('操作成功');
|
||||
}
|
||||
},'json');
|
||||
},
|
||||
save:function() {
|
||||
var join = [],position = [];
|
||||
var rows = jsPlumb.getConnections();
|
||||
|
||||
if (rows.length == 0) {
|
||||
toastrError('请先建立连接');
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var sourceId = rows[i].sourceId.substring(5);
|
||||
var targetId = rows[i].targetId.substring(5);
|
||||
join[i] = {id:sourceId,target:targetId};
|
||||
}
|
||||
|
||||
$('#rows div').each(function(i) {
|
||||
if(this.id.substring(0,5) == 'step_') {
|
||||
var stepId = this.id.substring(5);
|
||||
var left = $(this).css('left');
|
||||
var top = $(this).css('top');
|
||||
position[i] = {'id':stepId,'posX':left,'posY':top};
|
||||
}
|
||||
});
|
||||
|
||||
$.post('{{url("save")}}', {join:join,position:position,model_id:'{{$model_id}}'},function(result) {
|
||||
if(result.status) {
|
||||
toastrSuccess('保存当前视图成功');
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content-body {
|
||||
margin: 0;
|
||||
}
|
||||
.col-sm-10 {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.col-sm-2 {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="panel">
|
||||
|
||||
<div class="panel-header">
|
||||
<a class="btn btn-sm btn-info" onclick="workStep.add();" href="javascript:;">新建步骤</a>
|
||||
<a class="btn btn-sm btn-default" onclick="workStep.init();" href="javascript:;">重新加载</a>
|
||||
<a href="javascript:;" onclick="workStep.clear();" class="btn btn-sm btn-default"><i class="fa fa-ban"></i> 清空连接</a>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="m-t-sm">
|
||||
<div class="col-sm-10 m-b">
|
||||
<div class="graph" id="graph" data-toggle="context" data-target="#graph-menu">
|
||||
<div id="rows"></div>
|
||||
</div>
|
||||
|
||||
<div id="graph-menu">
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.add();" href="javascript:;">新建步骤</a></li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.save();" href="javascript:;">保存视图</a></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.init();" href="javascript:;">重新加载</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="step-menu">
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('base');" href="javascript:;">基本设置</a></li>
|
||||
<!--
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('handle');" href="javascript:;">经办权限</a></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('field');" href="javascript:;">表单字段</a></li>
|
||||
-->
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('condition');" href="javascript:;">条件设置</a></li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.clone();" href="javascript:;">克隆该步骤</a></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.deleted();" href="javascript:;">删除该步骤</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">基本信息</div>
|
||||
<div class="panel-body">
|
||||
<div id="tree"></div>
|
||||
</div>
|
||||
<div class="panel-heading b-t">表单字段</div>
|
||||
<div class="panel-body">
|
||||
<div id="tree"></div>
|
||||
</div>
|
||||
<div class="panel-heading b-t">办理人员</div>
|
||||
<div class="panel-body">
|
||||
<div id="tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="m-b">
|
||||
<a href="javascript:;" onclick="workStep.save();" class="btn btn-lg btn-block btn-info"><i class="fa fa-random"></i> 保存连接和视图</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,441 @@
|
||||
<script src="{{$asset_url}}/vendor/jquery.plumb.min.js" type="text/javascript"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var intervalTimer = null;
|
||||
var nowStepId = null;
|
||||
var normalStepSelector = ".wf-step:not(.wf-step-end)";
|
||||
// var normalStepSelector = ".wf-step:not(.wf-step-start,.wf-step-end)";
|
||||
|
||||
// 判断连接器是否指向了自己
|
||||
var isConnectToSelf = function(param) {
|
||||
return param.sourceId === param.targetId
|
||||
},
|
||||
isFromStartToEnd = function(param) {
|
||||
return param.sourceId === "step_1" && param.targetId === "step_0"
|
||||
},
|
||||
// 判断连接步骤是否重复
|
||||
stepIsRepeat = function(param){
|
||||
// 获取同一scope下的链接器,判断当前链接是否有重复
|
||||
var cnts = jsPlumb.getConnections(param.scope);
|
||||
if(cnts.length > 0) {
|
||||
for(var i = 0, len = cnts.length; i < len; i++) {
|
||||
// 如果有链接器 sourceId 及 targetId 都相等,那大概也许可能就相等了。
|
||||
if(param.sourceId === cnts[i].sourceId && param.targetId === cnts[i].targetId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 连接前的事件
|
||||
var beforeDropHandler = function(param) {
|
||||
|
||||
if(isConnectToSelf(param)) {
|
||||
toastrError('连接点不能是自己。');
|
||||
return false;
|
||||
}
|
||||
// 连接步骤是否重复
|
||||
if(stepIsRepeat(param)) {
|
||||
toastrError('连接点已经存在。');
|
||||
return false;
|
||||
}
|
||||
// 连接步骤是结束
|
||||
if(isFromStartToEnd(param)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
// 获取步骤图
|
||||
workStep.init();
|
||||
|
||||
$('#graph').contextmenu({'target':'#graph-menu'});
|
||||
|
||||
// 阻止非空白处的右键事件,不出现菜单
|
||||
//$container.on("contextmenu", "*", function(evt) {
|
||||
//evt.stopPropagation();
|
||||
//});
|
||||
|
||||
// 点击或双击事件,这里进行了一个单击事件延迟,因为同时绑定了双击事件
|
||||
$("#rows").on('click', 'div', function() {
|
||||
clearTimeout(intervalTimer);
|
||||
intervalTimer = setTimeout(function() {
|
||||
workStep.click();
|
||||
},300);
|
||||
|
||||
}).on('dblclick', 'div', function(e) {
|
||||
nowStepId = $(e.target).attr('step_id');
|
||||
clearTimeout(intervalTimer);
|
||||
workStep.dblClick('base');
|
||||
});
|
||||
});
|
||||
|
||||
var workStep = {
|
||||
|
||||
init:function() {
|
||||
|
||||
jsPlumb.reset();
|
||||
|
||||
jsPlumb.bind("beforeDrop", beforeDropHandler);
|
||||
|
||||
$.post("{{url('index2')}}",{bill_id:'{{$bill_id}}'},function(res)
|
||||
{
|
||||
$('#rows').empty();
|
||||
var nLastStepId = 0;
|
||||
|
||||
if(res.status == true) {
|
||||
jsPlumb.importDefaults({
|
||||
DragOptions:{cursor:'pointer'},
|
||||
ConnectionOverlays:[
|
||||
["Arrow",{location:1,id:"arrow",width:10,length:8}]
|
||||
],
|
||||
Anchor:'Continuous',
|
||||
Endpoint :"Blank",
|
||||
EndpointStyle:{radius:3,strokeStyle:'#1e8151'},
|
||||
HoverPaintStyle:{radius:3,strokeStyle:'#999'},
|
||||
ConnectorZIndex:5,
|
||||
HoverPaintStyle:workStep.connectorHoverStyle
|
||||
});
|
||||
|
||||
if(!$.support.leadingWhitespace) {
|
||||
// ie9以下,用VML画图
|
||||
jsPlumb.setRenderMode(jsPlumb.VML);
|
||||
} else {
|
||||
// 其他浏览器用SVG
|
||||
jsPlumb.setRenderMode(jsPlumb.SVG);
|
||||
}
|
||||
|
||||
// 第一次循环,生成页面元素div
|
||||
var left = 20;
|
||||
var top = 20;
|
||||
|
||||
var rows = res.data;
|
||||
var setd = {};
|
||||
|
||||
$.each(rows, function(id, row) {
|
||||
var title = '<span class="ep">' + (row.option == 1 ? '审核' : '知会') + '</span> ' + row.name;
|
||||
if (row.type == 'start') {
|
||||
title = '<span class="ep"><i class="icon icon-play"></i></span> ' + row.name;
|
||||
} else if(row.type == 'end') {
|
||||
title = '<span class="ep"><i class="icon icon-stop"></i></span> ' + row.name;
|
||||
}
|
||||
|
||||
var css = 'wf-step';
|
||||
if (row.type == 'start') {
|
||||
css = 'wf-step wf-step-start';
|
||||
} else if(row.type == 'end') {
|
||||
css = 'wf-step wf-step-end';
|
||||
}
|
||||
|
||||
var nodeDiv = document.createElement('div');
|
||||
var $node = $(nodeDiv);
|
||||
|
||||
$node.attr("id", "step_" + row.id)
|
||||
.attr("join", row.join)
|
||||
.attr("step_id", row.id)
|
||||
.css({"left":row.left+'px',"top":row.top+'px',"cursor":"move"})
|
||||
.addClass(css)
|
||||
.html(title);
|
||||
|
||||
/*
|
||||
$(normalStepSelector).on('mousedown', function(e) {
|
||||
|
||||
//if(row.number > 0) {
|
||||
nowStepId = $(e.target).attr('step_id');
|
||||
// $(this).contextmenu({'target':'#step-menu'});
|
||||
//}
|
||||
//e.stopPropagation();
|
||||
});
|
||||
*/
|
||||
|
||||
$("#rows").append($node);
|
||||
|
||||
// 索引变量
|
||||
nLastStepId++;
|
||||
|
||||
});
|
||||
|
||||
// 绑定右键操作菜单
|
||||
$(normalStepSelector).on('mousedown', function(e) {
|
||||
nowStepId = $(e.target).attr('step_id');
|
||||
$(this).contextmenu({'target':'#step-menu'});
|
||||
// e.stopPropagation();
|
||||
});
|
||||
|
||||
// 使之可拖动
|
||||
jsPlumb.draggable($(".wf-step"));
|
||||
|
||||
$(".ep").each(function(i,e) {
|
||||
var p = $(e).parent();
|
||||
jsPlumb.makeSource($(e), {
|
||||
parent:p,
|
||||
anchor:"Continuous",
|
||||
endpoint:"Blank",
|
||||
paintStyle:{
|
||||
strokeStyle:"#3399cc",
|
||||
fillStyle:"transparent",
|
||||
radius:2,
|
||||
lineWidth:2
|
||||
},
|
||||
// stub 线条弯曲角度 gap 距离节点位置 cornerRadius 线条圆角
|
||||
connector:["Flowchart",{stub:[10, 30], gap:0, cornerRadius:3, alwaysRespectStubs:true}],
|
||||
connectorStyle:workStep.connectorPaintStyle,
|
||||
hoverPaintStyle:workStep.endpointHoverStyle,
|
||||
connectorHoverStyle:workStep.connectorHoverStyle,
|
||||
dragOptions:{},
|
||||
maxConnections:-1
|
||||
});
|
||||
});
|
||||
|
||||
// 绑定删除确认操作
|
||||
jsPlumb.bind("click", function(e) {
|
||||
jsPlumb.detach(e);
|
||||
});
|
||||
|
||||
// 连接关联的步骤
|
||||
$('.wf-step').each(function(i) {
|
||||
var id = $(this).attr('id');
|
||||
var join = $(this).attr('join') || '';
|
||||
var joinArray = join.split(",");
|
||||
$.each(joinArray,function(j, n) {
|
||||
if(n > 0) {
|
||||
jsPlumb.connect({source:id, target:"step_"+n});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
jsPlumb.makeTarget($('.wf-step'), {
|
||||
dropOptions: {hoverClass:"dragHover", activeClass:"active"},
|
||||
anchor: "Continuous",
|
||||
maxConnections: 5
|
||||
});
|
||||
}
|
||||
},'json');
|
||||
},
|
||||
connectorPaintStyle:{
|
||||
lineWidth:2,
|
||||
strokeStyle:"#3399cc",
|
||||
joinstyle:"round",
|
||||
outlineColor:"white",
|
||||
dashstyle:"0",
|
||||
outlineWidth:2
|
||||
},
|
||||
connectorHoverStyle:{
|
||||
lineWidth:2,
|
||||
strokeStyle:"#999999",
|
||||
outlineWidth:2,
|
||||
dashstyle:"4 1",
|
||||
outlineColor:"white"
|
||||
},
|
||||
endpointHoverStyle:{
|
||||
strokeStyle:"#216477"
|
||||
},
|
||||
// 清空所有连接
|
||||
clear:function() {
|
||||
jsPlumb.detachEveryConnection();
|
||||
jsPlumb.deleteEveryEndpoint();
|
||||
},
|
||||
// 单击事件
|
||||
click:function() {
|
||||
if (nowStepId > 0) {
|
||||
$('#tree').hide();
|
||||
$.post('{{url("show")}}',{id:nowStepId, bill_id:'{{$bill_id}}'}, function(res) {
|
||||
$('#tree').html(res.data).show();
|
||||
})
|
||||
}
|
||||
},
|
||||
// 删除步骤
|
||||
deleted:function() {
|
||||
$.messager.confirm('操作警告','确认要删除该步骤吗?',function(btn) {
|
||||
if (btn) {
|
||||
$.post('{{url("delete")}}',{id:nowStepId, bill_id:'{{$bill_id}}'}, function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('操作成功');
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
// 克隆步骤
|
||||
clone:function() {
|
||||
$.messager.confirm('操作警告','确认要克隆该步骤吗?',function(btn) {
|
||||
if (btn) {
|
||||
$.post('{{url("add")}}',{id:nowStepId,bill_id:'{{$bill_id}}'},function(data) {
|
||||
if(data.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('操作成功');
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
});
|
||||
},
|
||||
dblClick:function(tab) {
|
||||
if (nowStepId > 0) {
|
||||
if(tab == 'base') {
|
||||
$.dialog({
|
||||
title:'基本设置',
|
||||
url:'{{url("create")}}?bill_id={{$bill_id}}&id='+nowStepId+'&tab='+tab,
|
||||
dialogClass: 'modal-lg',
|
||||
buttons:[{
|
||||
class: 'btn-info',
|
||||
text:'<i class="fa fa-check-circle"></i> 提交',
|
||||
click: function() {
|
||||
var formData = $('#mystep').serialize();
|
||||
$.post('{{url("create")}}', formData, function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('保存当前视图成功');
|
||||
}
|
||||
},'json');
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text:'<i class="fa fa-times"></i> 取消',
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
if (tab == 'condition') {
|
||||
$.dialog({
|
||||
title:'条件设置',
|
||||
url:'{{url("condition")}}?bill_id={{$bill_id}}&id='+nowStepId+'&tab='+tab,
|
||||
dialogClass: 'modal-lg',
|
||||
buttons:[{
|
||||
class: 'btn-info',
|
||||
text:'<i class="fa fa-check-circle"></i> 提交',
|
||||
click: function() {
|
||||
var formData = $('#conditionform').serialize();
|
||||
$.post('{{url("condition")}}', formData, function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('保存当前视图成功');
|
||||
}
|
||||
},'json');
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text:'<i class="fa fa-times"></i> 取消',
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
add:function() {
|
||||
$.post('{{url("add")}}',{bill_id:'{{$bill_id}}'},function(res) {
|
||||
if (res.status) {
|
||||
workStep.init();
|
||||
toastrSuccess('操作成功');
|
||||
}
|
||||
},'json');
|
||||
},
|
||||
save:function() {
|
||||
var join = [],position = [];
|
||||
var rows = jsPlumb.getConnections();
|
||||
|
||||
if(rows.length == 0) {
|
||||
toastrError('请先建立连接');
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var sourceId = rows[i].sourceId.substring(5);
|
||||
var targetId = rows[i].targetId.substring(5);
|
||||
join[i] = {id:sourceId,target:targetId};
|
||||
}
|
||||
|
||||
$('#rows div').each(function(i) {
|
||||
if(this.id.substring(0,5) == 'step_') {
|
||||
var stepId = this.id.substring(5);
|
||||
var left = $(this).css('left');
|
||||
var top = $(this).css('top');
|
||||
position[i] = {'id':stepId,'posX':left,'posY':top};
|
||||
}
|
||||
});
|
||||
|
||||
$.post('{{url("save")}}', {join:join,position:position,bill_id:'{{$bill_id}}'},function(result) {
|
||||
if(result.status) {
|
||||
toastrSuccess('保存当前视图成功');
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
html { overflow: hidden; }
|
||||
.form-panel-body {
|
||||
overflow: hidden;
|
||||
}
|
||||
.graph-box {
|
||||
overflow: auto;
|
||||
width: 100vw;
|
||||
height: calc(100vh - 48px);
|
||||
}
|
||||
.content-body {
|
||||
margin: 0;
|
||||
}
|
||||
.font-thin {
|
||||
padding: 10px;
|
||||
padding-bottom: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="form-panel">
|
||||
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right m-r-sm">
|
||||
<a class="btn btn-sm btn-info" onclick="workStep.add();" href="javascript:;">新建步骤</a>
|
||||
<a class="btn btn-sm btn-default" onclick="workStep.init();" href="javascript:;">重新加载</a>
|
||||
<a href="javascript:;" onclick="workStep.clear();" class="btn btn-sm btn-default"><i class="fa fa-ban"></i> 清空连接</a>
|
||||
<a href="javascript:;" onclick="workStep.save();" class="btn btn-sm btn-info"><i class="fa fa-random"></i> 保存连接和视图</a>
|
||||
<a class="btn btn-sm btn-default" data-toggle="closetab" data-id="flow_step_index2"><i class="fa fa-sign-out"></i> 退出</a>
|
||||
</div>
|
||||
<div class="font-thin">
|
||||
<i class="fa fa-file-text-o"></i> {{$bill['name']}}流程
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-panel-body">
|
||||
<div class="wrapper-xs graph-box">
|
||||
<div class="graph" id="graph" data-toggle="context" data-target="#graph-menu">
|
||||
<div id="rows"></div>
|
||||
</div>
|
||||
<div id="graph-menu">
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.add();" href="javascript:;">新建步骤</a></li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.save();" href="javascript:;">保存视图</a></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.init();" href="javascript:;">重新加载</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="step-menu">
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('base');" href="javascript:;">基本设置</a></li>
|
||||
<!--
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('handle');" href="javascript:;">经办权限</a></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('field');" href="javascript:;">表单字段</a></li>
|
||||
-->
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.dblClick('condition');" href="javascript:;">条件设置</a></li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.clone();" href="javascript:;">克隆该步骤</a></li>
|
||||
<li role="presentation"><a role="menuitem" onclick="workStep.deleted();" href="javascript:;">删除该步骤</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,41 @@
|
||||
<div class="panel">
|
||||
<form class="form-horizontal" method="post" action="{{url()}}" id="moveform" name="moveform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-form">
|
||||
<tr>
|
||||
<td align="right">工作步骤</td>
|
||||
<td align="left">
|
||||
<select id="batch_status" class="form-control input-sm">
|
||||
<option value=""> - </option>
|
||||
<option value="0">未发放</option>
|
||||
<option value="1">已发放</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" width="15%">主办人</td>
|
||||
<td align="left">
|
||||
{{App\Support\Dialog::user('user','user_id', '', 0, 0)}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">工作状态</td>
|
||||
<td align="left">
|
||||
<select id="batch_status" class="form-control input-sm">
|
||||
<option value="0">未办理</option>
|
||||
<option value="1">已办理</option>
|
||||
<option value="2">全部</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">描述</td>
|
||||
<td align="left">
|
||||
<textarea class="form-control" id="batch_description"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="id" value="{{$row->id}}">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,961 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm">
|
||||
<a class="btn btn-default btn-sm" href="{{url('index',['bill_id'=>$bill_id])}}"><i class="fa fa-reply"></i> 返回</a>
|
||||
<a id="add-form-group" class="btn btn-sm btn-info">
|
||||
<i class="fa fa-plus"></i>
|
||||
添加表单组
|
||||
</a>
|
||||
<!--
|
||||
<a onclick="preview()" class="btn btn-default">预览</a>
|
||||
-->
|
||||
<a onclick="submit()" class="btn btn-sm btn-success">
|
||||
<i class="fa fa-check"></i> 提交
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wrapper-sm b-t">
|
||||
|
||||
<div class="col-sm-2 col-left m-b-xs">
|
||||
<div class="panel b-a panel-default tabs-box">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#1" data-toggle="tab">字段列表</a></li>
|
||||
<li class=""><a href="#2" data-toggle="tab">组件列表</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="1">
|
||||
<ul class="list-group">
|
||||
<!-- 多行子表 -->
|
||||
@foreach($models as $model)
|
||||
@if($model['parent_id'])
|
||||
<div class="list-group-item fld field" data-col="12" data-hidden="0" data-readonly="0" data-title="" data-role_name="{{$model['role_name']}}" data-role_id="{{$model['role_id']}}" data-type="{{$model['type']}}" data-table="" data-field="{{$model['table']}}">
|
||||
<div class="title">
|
||||
<b>{{$model['name']}}</b>
|
||||
</div>
|
||||
<i class="move fa fa-w fa-arrows"></i>
|
||||
<i class="fa fa-w fa-remove" title="删除"></i>
|
||||
<div class="desc-sublist"></div>
|
||||
</div>
|
||||
@endif
|
||||
@foreach($model['fields'] as $field)
|
||||
<div class="list-group-item fld field" data-col="12" data-hidden="0" data-readonly="0" data-title="" data-role_name="{{$field['role_name']}}" data-role_id="{{$field['role_id']}}" data-type="@if($model['parent_id'] == 0) 0 @else {{$field['type']}} @endif" data-table="{{$model['table']}}" data-field="{{$field['field']}}">
|
||||
<div class="title">
|
||||
@if($model['parent_id'] > 0)
|
||||
<span class="model-title">[{{$model['name']}}]</span>
|
||||
@endif
|
||||
{{$field['name']}}
|
||||
</div>
|
||||
<i class="move fa fa-w fa-arrows"></i>
|
||||
<i class="remove fa fa-w fa-remove" title="删除"></i>
|
||||
@if($model['parent_id'] == 0)
|
||||
<div class="desc"></div>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@endforeach
|
||||
<div class="list-group-item fld field" data-col="12" data-hidden="0" data-readonly="0" data-role_name="" data-role_id="" data-id="0" data-type="0" data-field="{flowlog}">
|
||||
<div class="title">流程记录</div>
|
||||
<i class="move fa fa-w fa-arrows"></i>
|
||||
<i class="remove fa fa-w fa-remove" title="删除"></i>
|
||||
<div class="desc"></div>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-pane" id="2">
|
||||
<ul class="list-group">
|
||||
<div class="list-group-item fld field" data-col="12" data-hidden="0" data-readonly="0" data-role_name="" data-role_id="" data-id="0" data-type="0" data-custom="1" data-field="{flowlog}">
|
||||
<div class="title">流程记录</div>
|
||||
<i class="move fa fa-w fa-arrows"></i>
|
||||
<i class="remove fa fa-w fa-remove" title="删除"></i>
|
||||
<div class="desc"></div>
|
||||
</div>
|
||||
<div class="list-group-item fld field" data-col="12" data-title="单行文本" data-hidden="0" data-readonly="0" data-role_name="" data-role_id="" data-id="0" data-type="0" data-custom="1" data-field="{text}">
|
||||
<div class="title">单行文本</div>
|
||||
<i class="move fa fa-w fa-arrows"></i>
|
||||
<i class="remove fa fa-w fa-remove" title="删除"></i>
|
||||
<div class="desc"></div>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-8">
|
||||
<div class="droppedFieldsBox" id="droppedFieldsBox"></div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 col-right">
|
||||
<div class="panel b-a panel-default tabs-box">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#11" data-toggle="tab">字段属性</a></li>
|
||||
<li class=""><a href="#22" data-toggle="tab">模板属性</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="11">
|
||||
<div class="panel-body field-attr" id="fieldAttribute">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">占用行比例</label>
|
||||
<div class="form-text">
|
||||
<select class="form-control input-sm" id="set_col" onchange="setCol(this.value)" required="required">
|
||||
<option value="12">12</option>
|
||||
<option value="11">11</option>
|
||||
<option value="10">10</option>
|
||||
<option value="9">9</option>
|
||||
<option value="8">8</option>
|
||||
<option value="7">7</option>
|
||||
<option value="6">6</option>
|
||||
<option value="5">5</option>
|
||||
<option value="4">4</option>
|
||||
<option value="3">3</option>
|
||||
<option value="2">2</option>
|
||||
<option value="1">1</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_readonly">字段只读</label>
|
||||
<div class="form-text">
|
||||
<select class="form-control input-sm" id="set_readonly" onchange="setField('readonly', this.value)" required="required">
|
||||
<option value="0">否</option>
|
||||
<option value="1">是</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_hide_title">标题</label>
|
||||
<div class="form-text">
|
||||
<input class="form-control input-sm" id="set_title" onblur="setField('title', this.value)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_content">内容</label>
|
||||
<div class="form-text">
|
||||
<input class="form-control input-sm" id="set_content" onblur="setField('content', this.value)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_hide_title">标题隐藏</label>
|
||||
<div class="form-text">
|
||||
<select class="form-control input-sm" id="set_hide_title" onchange="setField('hide_title', this.value)" required="required">
|
||||
<option value="0">否</option>
|
||||
<option value="1">是</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_readonly">字段宽度</label>
|
||||
<div class="form-text">
|
||||
<input class="form-control input-sm" id="set_width" onchange="setField('width', this.value)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_hidden">字段可见</label>
|
||||
<div class="form-text">
|
||||
<select class="form-control input-sm" id="set_hidden" onchange="setField('hidden', this.value)" required="required">
|
||||
<option value="0">是</option>
|
||||
<option value="1">否</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_hidden">字段隐藏</label>
|
||||
<div class="form-text">
|
||||
<div class="select-group input-group" style="width:100%;"><input class="form-control input-inline input-sm" style="cursor:pointer;" readonly="readonly" data-multi="1" data-name="role_name" data-title="角色" data-url="user/role/dialog" data-id="role_id" data-toggle="dialog-view" id="role_name" />
|
||||
<div class="input-group-btn">
|
||||
<a data-toggle="dialog-clear" data-id="role_id" class="btn btn-sm btn-default"><i class="fa fa-times"></i></a>
|
||||
</div>
|
||||
<input type="hidden" id="role_id">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="22">
|
||||
<div class="panel-body field-attr">
|
||||
<form method="post" id="myform" name="myform">
|
||||
<div class="form-group">
|
||||
<label for="set_col">视图名称 <span class="red">*</span></label>
|
||||
<div class="form-text">
|
||||
<input type="text" id="name" name="name" value="{{$template['name']}}" class="form-control input-sm">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">视图编码 <span class="red">*</span></label>
|
||||
<div class="form-text">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" style="display:inline-block;overflow:hidden;white-space:nowrap;width:100px;text-overflow:ellipsis;">{{$master_model['table']}}_</span>
|
||||
<input type="text" id="code" name="code" value="{{$template['code']}}" class="form-control input-sm">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">视图类型 <span class="red">*</span></label>
|
||||
<div class="form-text">
|
||||
<select multiple="multiple" class="input-select2 form-control input-sm" id="type" name="type[]" data-width="100%">
|
||||
<option value="create" @if(in_array('create', $template['type'])) selected @endif>新增</option>
|
||||
<option value="edit" @if(in_array('edit', $template['type'])) selected @endif>编辑</option>
|
||||
<option value="show" @if(in_array('show', $template['type'])) selected @endif>显示</option>
|
||||
<option value="print" @if(in_array('print', $template['type'])) selected @endif>打印</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">权限范围</label>
|
||||
<div class="form-text">
|
||||
{{App\Support\Dialog::search($template, 'id=receive_id&name=receive_name&multi=1')}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">打印方式</label>
|
||||
<div class="form-text">
|
||||
<select class="input-select2 form-control input-sm" id="print_type" name="print_type" data-width="100%">
|
||||
<option value=""> </option>
|
||||
<option value="html" @if($template['print_type'] == 'html') selected @endif>html</option>
|
||||
<option value="stiReport" @if($template['print_type'] == 'stiReport') selected @endif>StiReport</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">客户端</label>
|
||||
<div class="form-text">
|
||||
<select multiple="multiple" class="input-select2 form-control input-sm" id="client" name="client[]" data-width="100%">
|
||||
<option value="web" @if(in_array('web', $template['client'])) selected @endif>web</option>
|
||||
<option value="app" @if(in_array('app', $template['client'])) selected @endif>app</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">宽度</label>
|
||||
<div class="form-text">
|
||||
<input type="text" id="width" name="width" value="{{$template['width']}}" class="form-control input-sm">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="bill_id" id="bill_id" value="{{$bill_id}}">
|
||||
<input type="hidden" name="id" id="template_id" value="{{$template['id']}}">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@verbatim
|
||||
@endverbatim
|
||||
|
||||
<style>
|
||||
@media (min-width: 768px) {
|
||||
.col-sm-8 {
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.col-left {
|
||||
padding-left: 0;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.col-right {
|
||||
padding-left: 5px;
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-heading .panel-title {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.panel-heading .fa {
|
||||
vertical-align: middle;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.panel-heading .fa:hover {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.title {
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.desc {
|
||||
display: none;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.list-group-item {
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
}
|
||||
.list-group-item:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.list-group {
|
||||
position: relative;
|
||||
height: 500px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.list-group .fa {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.list-group .field:hover {
|
||||
background-color: #eee;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.droppedFields > .remove {
|
||||
display: none;
|
||||
}
|
||||
.droppedFields .active > .remove {
|
||||
background-color: #ddd;
|
||||
display: block;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
padding-left: 4px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.droppedFields .active > .remove:hover {
|
||||
background-color: #ff0000;
|
||||
}
|
||||
|
||||
.droppedFields .title {
|
||||
padding: 8px;
|
||||
padding-left: 29px;
|
||||
}
|
||||
|
||||
.droppedFields .model-title {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.droppedFields > .move {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.droppedFields .active > .move {
|
||||
cursor: move;
|
||||
background-color: #23b7e5;
|
||||
display: block;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 5px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
padding-left: 4px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.droppedFields .field {
|
||||
border-top: #ddd solid 1px;
|
||||
border-bottom: #ddd solid 1px;
|
||||
border-right: #ddd solid 1px;
|
||||
border-left: #ddd solid 1px;
|
||||
background-color: #fff;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: -1px;
|
||||
white-space: nowrap;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.droppedFields .field {
|
||||
position: relative;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.droppedFields > .field:hover {
|
||||
border: 1px dashed #f6c483;
|
||||
}
|
||||
|
||||
.droppedFields > .field.active {
|
||||
border: 1px dashed #23b7e5;
|
||||
}
|
||||
|
||||
.droppedFields .fa {
|
||||
cursor: pointer;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.droppedFields > .field.active .fa {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
.droppedFields .desc {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.droppedFields .desc-sublist {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
min-height: 30px;
|
||||
border-top: #ddd solid 1px;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.droppedFields .desc-sublist .fld {
|
||||
white-space: normal;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.droppedFields {
|
||||
min-height: 60px;
|
||||
background-color: #fff;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.highlightDroppable {
|
||||
border: 1px dashed #f6c483;
|
||||
background: #fffdfa;
|
||||
text-align: center;
|
||||
color: #ccc;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: -1px;
|
||||
position: relative;
|
||||
margin: 1px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.field-attr .form-group label {
|
||||
width: 70px;
|
||||
float: left;
|
||||
vertical-align: middle;
|
||||
text-align: right;
|
||||
font-weight: normal;
|
||||
line-height: 28px;
|
||||
}
|
||||
.field-attr .form-group .form-text {
|
||||
margin-left: 80px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<!--
|
||||
@verbatim
|
||||
<div id="app">
|
||||
<div class="dragDemo">
|
||||
<draggable class="list-group"
|
||||
element="div"
|
||||
v-model="listLeft"
|
||||
:move="onMove"
|
||||
group="people"
|
||||
@start="isDragging=true"
|
||||
@end="isDragging=false">
|
||||
<div v-for="(item, key) in listLeft" :key="key">
|
||||
{{item.name}}-{{item.value}}
|
||||
</div>
|
||||
</draggable>
|
||||
<draggable class="list-group"
|
||||
element="div"
|
||||
v-model="listLeft1"
|
||||
:move="onMove"
|
||||
group="people"
|
||||
@start="isDragging=true"
|
||||
@end="isDragging=false">
|
||||
<div v-for="(item, key) in listLeft1" :key="key">
|
||||
{{item.name}}-{{item.value}}
|
||||
</div>
|
||||
</draggable>
|
||||
<draggable class="list-group"
|
||||
element="div"
|
||||
v-model="listRight"
|
||||
:move="onMove"
|
||||
group="people"
|
||||
@start="isDragging=true"
|
||||
@end="isDragging=false">
|
||||
<div v-for="(item,key) in listRight" :key="key">
|
||||
{{item.name}}-{{item.value}}
|
||||
</div>
|
||||
</draggable>
|
||||
</div>
|
||||
</div>
|
||||
@endverbatim
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
isDragging:false,
|
||||
listLeft:[{
|
||||
name:'数据一',
|
||||
value:'1'
|
||||
}, {
|
||||
name:'数据二',
|
||||
value:'2'
|
||||
}, {
|
||||
name:'数据三',
|
||||
value:'3'
|
||||
}, {
|
||||
name:'数据四',
|
||||
value:'4'
|
||||
}, {
|
||||
name:'数据五',
|
||||
value:'5'
|
||||
}],
|
||||
listLeft1:[{
|
||||
name:'布局',
|
||||
value:'1'
|
||||
}, {
|
||||
name:'数据二',
|
||||
value:'2'
|
||||
}],
|
||||
listRight:[]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onMove({relatedContext, draggedContext}) {
|
||||
const relatedElement = relatedContext.element;
|
||||
const draggedElement = draggedContext.element;
|
||||
return (
|
||||
(!relatedElement || !relatedElement.fixed) && !draggedElement.fixed
|
||||
);
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dragDemo {
|
||||
margin-top:50px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
color: #555;
|
||||
}
|
||||
.dragDemo .list-group {
|
||||
width: 300px;
|
||||
border: 1px solid #ddd;
|
||||
text-align: center;
|
||||
margin-right: 50px;
|
||||
}
|
||||
.dragDemo .list-group > div {
|
||||
padding:10px;
|
||||
border-bottom:1px dashed #ddd;
|
||||
}
|
||||
.dragDemo .list-group > div img {
|
||||
width:25px;
|
||||
height:25px;
|
||||
vertical-align: middle;
|
||||
padding-right:10px;
|
||||
}
|
||||
</style>
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
var fields = JSON.parse('{{$template["tpl"]}}');
|
||||
|
||||
var activeField = null;
|
||||
|
||||
var droppedFieldsBox = null;
|
||||
|
||||
function setCol(v) {
|
||||
activeField.attr('data-col', v);
|
||||
activeField.css({ width: 'calc(' + (v / 12 * 100) + '% - 2px'});
|
||||
}
|
||||
|
||||
function setField(f, v) {
|
||||
if (f == 'title') {
|
||||
activeField.find('.title').text(v);
|
||||
}
|
||||
activeField.attr('data-' + f, v);
|
||||
}
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('role_id', {
|
||||
onSelect(row) {
|
||||
var role_id = $('#role_id').val();
|
||||
var role_name = $('#role_id_text').val();
|
||||
setField('role_id', role_id);
|
||||
setField('role_name', role_name);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
var sortableOptions = {
|
||||
opacity: 0.4,
|
||||
delay: 50,
|
||||
cursor: "move",
|
||||
handle: ".move",
|
||||
placeholder: "highlightDroppable ui-corner-all",
|
||||
forcePlaceholderSize: true,
|
||||
connectWith: '.droppedFields,.desc-sublist',
|
||||
stop: function (event, ui) {
|
||||
var type = ui.item.hasClass('component');
|
||||
if (type == undefined) {
|
||||
ui.item.attr('component', 1);
|
||||
ui.item.css({width:'100%'});
|
||||
}
|
||||
ui.item.trigger("click");
|
||||
|
||||
if(ui.item.data('type') == 1) {
|
||||
droppedFieldsBox.find('.desc-sublist:not(.ui-sortable)').sortable(sortableOptions);
|
||||
}
|
||||
|
||||
},
|
||||
start: function (event, ui) {
|
||||
ui.item.removeClass('list-group-item');
|
||||
var h = $(this).find(".highlightDroppable");
|
||||
h.outerWidth(ui.item[0].style.width);
|
||||
h.outerHeight(ui.item[0].style.height);
|
||||
h.html('拖放控件到这里');
|
||||
}, out: function (event, ui) {
|
||||
}
|
||||
}
|
||||
|
||||
function editDialog(options) {
|
||||
var defaultOptions = {
|
||||
title: '',
|
||||
html: '<div class="panel-body"><div class="form-group"><label>名字</label><input type="text" class="form-control input-sm" id="group_title"></div><div class="form-group"><label>类型</label><select class="form-control input-sm" id="group_type"><option value="panel">panel</option><option value="tabs">tabs</option></select></div><div class="form-group"><label>边框</label><select class="form-control input-sm" id="group_border"><option value="1">有</option><option value="0">无</option></select></div></div>',
|
||||
buttons: [{
|
||||
class: 'btn-default',
|
||||
text: '<i class="fa fa-remove"></i> 取消',
|
||||
click: function () {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},{
|
||||
class: 'btn-info',
|
||||
text: '<i class="fa fa-check"></i> 提交',
|
||||
click: function () {
|
||||
if(typeof options.onSubmit === 'function') {
|
||||
options.onSubmit.call(this);
|
||||
}
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
options = $.extend(defaultOptions, options);
|
||||
$.dialog(options);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
droppedFieldsBox = $('#droppedFieldsBox');
|
||||
|
||||
// 添加表单组
|
||||
$("#add-form-group").on('click', function() {
|
||||
editDialog({
|
||||
title: '添加表单组',
|
||||
onSubmit: function() {
|
||||
var title = $(this).find('#group_title').val();
|
||||
var type = $(this).find('group_type').val();
|
||||
var border = $(this).find('#group_border').val();
|
||||
|
||||
var size = $('.droppedFields').size() + 1;
|
||||
|
||||
droppedFieldsBox.append('<div class="panel b-a"><div class="panel-heading b-b"><span class="pull-right"><i class="fa fa-fw fa-pencil"></i><i class="fa fa-fw fa-remove"></i></span><span class="label bg-light panel-type">' + type + '</span> <span class="panel-title">' + title + '</span></div><div data-type="' + type + '" data-border="'+border+'" data-title="' + title + '" data-column="' + size + '" id="selected-column-' + size + '" class="droppedFields"></div></div>');
|
||||
$('.droppedFields:not(.ui-sortable)').sortable(sortableOptions);
|
||||
(this).dialog('close');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 编辑表单组
|
||||
droppedFieldsBox.on('click', '.panel-heading .fa-pencil', function() {
|
||||
|
||||
var heading = $(this).closest('.panel');
|
||||
var dropped = heading.find('.droppedFields');
|
||||
|
||||
editDialog({
|
||||
title: '编辑表单组',
|
||||
onShow: function() {
|
||||
var me = this;
|
||||
me.html(me.options['html']);
|
||||
$(this).find('#group_title').val(dropped.attr('data-title'));
|
||||
$(this).find('#group_type').val(dropped.attr('data-type'));
|
||||
$(this).find('#group_border').val(dropped.attr('data-border'));
|
||||
},
|
||||
onSubmit: function() {
|
||||
var title = $(this).find('#group_title').val();
|
||||
var type = $(this).find('group_type').val();
|
||||
var border = $(this).find('#group_border').val();
|
||||
dropped.attr('data-title', title);
|
||||
dropped.attr('data-type', type);
|
||||
dropped.attr('data-border', border);
|
||||
|
||||
heading.find('.panel-title').text(title);
|
||||
heading.find('.panel-type').text(type);
|
||||
heading.find('.panel-border').text(border);
|
||||
|
||||
$(this).dialog('close');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 删除表单组
|
||||
droppedFieldsBox.on('click', '.panel-heading .fa-remove', function() {
|
||||
$(this).closest('.panel').remove();
|
||||
});
|
||||
|
||||
// 删除字段
|
||||
droppedFieldsBox.on('click', '.droppedFields .fa-remove', function() {
|
||||
$(this).closest('.field').remove();
|
||||
});
|
||||
|
||||
// 点击字段
|
||||
droppedFieldsBox.on('click', '.droppedFields .field', function(e) {
|
||||
|
||||
e.stopPropagation();
|
||||
|
||||
var me = $(this);
|
||||
activeField = me;
|
||||
|
||||
$(document).find('.droppedFields .field').removeClass('active');
|
||||
me.addClass('active');
|
||||
var data = me.data();
|
||||
|
||||
for (const key in data) {
|
||||
if (key == 'sortableItem') {
|
||||
continue;
|
||||
}
|
||||
var v = me.attr('data-' + key) || '';
|
||||
var $attr = $('#fieldAttribute');
|
||||
$attr.find('#set_' + key).val(v);
|
||||
if (key == 'role_name') {
|
||||
$attr.find('#role_id_text').val(v || '');
|
||||
} else {
|
||||
$attr.find('#' + key).val(v || '');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('.fld').draggable({
|
||||
connectToSortable: '.droppedFields',
|
||||
helper: "clone",
|
||||
revert: "invalid",
|
||||
start: function (event, ui) {
|
||||
var width = ui.helper.parent().outerWidth();
|
||||
ui.helper.outerWidth(width);
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化字段
|
||||
$.each(fields, function(k, form_group) {
|
||||
|
||||
var type = form_group.type;
|
||||
var size = form_group.column;
|
||||
var title = form_group.title;
|
||||
var border = form_group.border;
|
||||
var _fields = Array();
|
||||
|
||||
form_group.fields = form_group.fields || [];
|
||||
|
||||
$.each(form_group.fields, function(k, v) {
|
||||
var w = 'calc(' + (v.col / 12 * 100) + '% - 2px)';
|
||||
if (v.type == 0) {
|
||||
_fields.push('<div class="fld field" ' + attrJoin(v) + ' style="display:inline-block;width: ' + w + ';" title="'+ v.name +'"><div class="title">' + v.name + '</div><div class="desc"></div><i class="move fa fa-w fa-arrows"></i><i class="remove fa fa-w fa-remove" title="删除"></i></div>');
|
||||
} else {
|
||||
var _subs = [];
|
||||
v.fields = v.fields || [];
|
||||
$.each(v.fields, function(k, vv) {
|
||||
_subs.push('<div class="fld field" ' + attrJoin(vv, true) + ' title="'+ vv.name +'"><div class="title">' + vv.name + '</div><i class="move fa fa-w fa-arrows"></i><i class="remove fa fa-w fa-remove" title="删除"></i></div>');
|
||||
});
|
||||
_fields.push('<div class="fld field" ' + attrJoin(v) + ' style="display:inline-block;width: ' + w + ';" title="'+ v.name +'"><div class="title"> ' + v.name + '</div><i class="move fa fa-w fa-arrows"></i><i class="remove fa fa-w fa-remove" title="删除"></i><div class="desc-sublist">' + _subs.join('') + '</div></div>');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
droppedFieldsBox.append('<div class="panel b-a"><div class="panel-heading b-b"><span class="pull-right"><i class="fa fa-fw fa-pencil"></i><i class="fa fa-fw fa-remove"></i></span><span class="label bg-light panel-type">panel</span> <span class="panel-title">' + title + '</span></div><div data-type="' + type + '" data-border="'+border+'" data-title="' + title + '" data-column="' + size + '" id="selected-column-' + size + '" class="droppedFields">' + _fields.join('') + '</div></div>');
|
||||
|
||||
});
|
||||
|
||||
$('.droppedFields:not(.ui-sortable)').sortable(sortableOptions);
|
||||
droppedFieldsBox.find('.desc-sublist:not(.ui-sortable)').sortable(sortableOptions);
|
||||
|
||||
$('.droppedFieldsBox').sortable({
|
||||
handle: '.panel-heading',
|
||||
opacity: 0.6,
|
||||
delay: 50,
|
||||
cursor: 'move',
|
||||
start: function (event, ui) {
|
||||
},
|
||||
update: function(event, ui) {
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function attrJoin(data, subfld) {
|
||||
var fields = ['col', 'css', 'table', 'field', 'content', 'hidden', 'custom', 'title', 'readonly', 'type', 'width', 'hide_title', 'role_id', 'role_name'];
|
||||
var attr = [];
|
||||
for (let i = 0; i < fields.length; i++) {
|
||||
var field = fields[i];
|
||||
if (subfld == true && field == 'type') {
|
||||
continue;
|
||||
}
|
||||
|
||||
var v = data[field];
|
||||
if (field == 'hidden' || field == 'readonly' || field == 'type' || field == 'hide_title' || field == 'custom') {
|
||||
v = v == undefined ? 0 : v;
|
||||
}
|
||||
|
||||
if (field == 'content' || field == 'role_id' || field == 'role_name' || field == 'title') {
|
||||
v = v == undefined ? '' : v;
|
||||
}
|
||||
|
||||
if (field == 'width') {
|
||||
v = setInt(v);
|
||||
}
|
||||
attr.push('data-' + field + '="' + v + '"');
|
||||
}
|
||||
return attr.join(' ');
|
||||
}
|
||||
|
||||
function setInt(v) {
|
||||
var v = parseInt(v);
|
||||
return v > 0 ? v : '';
|
||||
}
|
||||
|
||||
function preview() {
|
||||
|
||||
console.log(getColumns());
|
||||
return;
|
||||
|
||||
var dialogContent, i, j;
|
||||
if (columns.length > 0) {
|
||||
var divWidth = 100 / columns.length;
|
||||
dialogContent = "<div>";
|
||||
for (i = 0; i < columns.length; i++) {
|
||||
dialogContent += "<div style='float:left;width=" + divWidth + "%;'>";
|
||||
dialogContent += "<ul><li><b>Column " + (i + 1) + "</b></li>";
|
||||
for (j = 0; j < columns[i].length; j++) {
|
||||
var obj = columns[i][j];
|
||||
dialogContent += "<li>" + obj.label + "</li>";
|
||||
}
|
||||
dialogContent += "</ul></div>";
|
||||
}
|
||||
dialogContent += "</div>";
|
||||
} else {
|
||||
dialogContent = '<div>Nothing to preview</div>';
|
||||
}
|
||||
|
||||
$(dialogContent).dialog({
|
||||
modal: true,
|
||||
width: 500,
|
||||
height: 400,
|
||||
buttons: {
|
||||
Ok: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getColumns() {
|
||||
var res = [];
|
||||
$.each($(".droppedFields"), function(i, v) {
|
||||
|
||||
var groupTitle = $(v).attr('data-title');
|
||||
var groupType = $(v).attr('data-type');
|
||||
var groupBorder = $(v).attr('data-border');
|
||||
var groupColumn = $(v).attr('data-column');
|
||||
|
||||
var fields = $(v).children('.field');
|
||||
|
||||
var columns = [];
|
||||
|
||||
if (fields.length > 0) {
|
||||
|
||||
$.each(fields, function(k, v) {
|
||||
|
||||
var me = $(v);
|
||||
var type = me.data('type');
|
||||
|
||||
var _column = getColumn(me);
|
||||
|
||||
if(type == 1) {
|
||||
|
||||
var _fields = $(v).children('.desc-sublist').children('.field');
|
||||
|
||||
if (_fields.length > 0) {
|
||||
var __column = [];
|
||||
$.each(_fields, function(k, _v) {
|
||||
var _me = $(_v);
|
||||
__column.push(getColumn(_me));
|
||||
});
|
||||
_column.fields = __column;
|
||||
}
|
||||
}
|
||||
|
||||
columns.push(_column);
|
||||
|
||||
});
|
||||
res.push({title:groupTitle, border: groupBorder, type: groupType, column:groupColumn, fields:columns});
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
function getColumn(me) {
|
||||
var column = {};
|
||||
column.field = me.attr('data-field');
|
||||
column.css = me.attr('data-css');
|
||||
column.hidden = me.attr('data-hidden');
|
||||
column.width = me.attr('data-width');
|
||||
column.readonly = me.attr('data-readonly');
|
||||
column.hide_title = me.attr('data-hide_title');
|
||||
column.type = me.attr('data-type');
|
||||
column.table = me.attr('data-table');
|
||||
column.title = me.attr('data-title');
|
||||
column.role_id = me.attr('data-role_id');
|
||||
column.role_name = me.attr('data-role_name');
|
||||
column.custom = me.attr('data-custom');
|
||||
column.col = me.attr('data-col');
|
||||
column.content = me.attr('data-content');
|
||||
column.name = me.children(".title").text().trim();
|
||||
return column;
|
||||
}
|
||||
|
||||
function submit() {
|
||||
var columns = getColumns();
|
||||
var data = $('#myform').serialize() + '&' + $.param({columns: columns});
|
||||
$.post('{{url()}}', data, function (res) {
|
||||
if (res.status) {
|
||||
toastrSuccess(res.data);
|
||||
location.href = res.url;
|
||||
} else {
|
||||
toastrError(res.data);
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,365 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm">
|
||||
|
||||
<a class="btn btn-default btn-sm" href="{{url('index',['bill_id'=>$bill_id])}}"><i class="fa fa-reply"></i> 返回</a>
|
||||
<a onclick="submit()" class="btn btn-sm btn-success">
|
||||
<i class="fa fa-check"></i> 提交
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wrapper-sm b-t">
|
||||
|
||||
@verbatim
|
||||
<div id="app">
|
||||
|
||||
<div class="col-sm-2 m-b">
|
||||
<div class="panel b-a panel-default">
|
||||
<div class="panel-heading">
|
||||
<div>字段列表</div>
|
||||
</div>
|
||||
<draggable class="list-group"
|
||||
v-model="listLeft"
|
||||
item-key="name"
|
||||
group="people"
|
||||
:sort="false"
|
||||
@start="isDragging=true"
|
||||
@end="isDragging=false">
|
||||
<template #item="{element}">
|
||||
<a class="list-group-item">
|
||||
{{element.name}}
|
||||
</a>
|
||||
</template>
|
||||
</draggable>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2 m-b">
|
||||
<div class="panel b-a panel-default">
|
||||
<div class="panel-heading">
|
||||
<div>字段列表</div>
|
||||
</div>
|
||||
|
||||
<draggable class="list-group"
|
||||
v-model="listRight"
|
||||
item-key="name"
|
||||
group="people"
|
||||
@start="isDragging=true"
|
||||
@end="isDragging=false">
|
||||
<template #item="{element, index}">
|
||||
<a class="list-group-item" @click="clickItem(index, element)">
|
||||
{{element.name}}
|
||||
</a>
|
||||
</template>
|
||||
</draggable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endverbatim
|
||||
|
||||
<div class="col-sm-2 m-b">
|
||||
<div class="panel b-a panel-default">
|
||||
<div class="panel-heading">
|
||||
<div>字段列表</div>
|
||||
</div>
|
||||
|
||||
<form method="post" id="myform" name="myform">
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label>视图名称 <span class="red">*</span></label>
|
||||
<input type="text" id="name" name="name" value="{{$template['name']}}" class="form-control input-sm">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="set_col">视图编码 <span class="red">*</span></label>
|
||||
<div class="form-text">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{{$model['table']}}_</span>
|
||||
<input type="text" id="code" name="code" value="{{$template['code']}}" class="form-control input-sm">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>视图类型</label>
|
||||
<select multiple="multiple" class="input-select2 form-control input-sm" id="type" name="type[]" data-width="100%">
|
||||
<option value="list" @if(in_array('list', $template['type'])) selected @endif>列表</option>
|
||||
<option value="dialog" @if(in_array('dialog', $template['type'])) selected @endif>对话框</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>权限范围 <span class="red">*</span></label>
|
||||
{{App\Support\Dialog::search($template, 'id=receive_id&name=receive_name&multi=1')}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>客户端 <span class="red">*</span></label>
|
||||
<select multiple="multiple" class="input-select2 form-control input-sm" data-width="100%" id="client" name="client[]">
|
||||
<option value="web" @if(in_array('web', $template['client'])) selected @endif>web</option>
|
||||
<option value="app" @if(in_array('app', $template['client'])) selected @endif>app</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="bill_id" id="bill_id" value="{{$bill_id}}">
|
||||
<input type="hidden" name="id" id="id" value="{{$template['id']}}">
|
||||
<input type="hidden" name="table" id="table" value="{{$model['table']}}_">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 m-b">
|
||||
<div class="panel b-a panel-default">
|
||||
<div class="panel-heading">
|
||||
<div>字段属性</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label for="set_hidden">字段隐藏</label>
|
||||
<div class="select-group input-group" style="width:100%;">
|
||||
<input class="form-control input-inline input-sm" style="cursor:pointer;" readonly="readonly" data-multi="1" data-name="role_name" data-title="角色" data-url="user/role/dialog" data-id="role_id" data-toggle="dialog-view" id="role_id_text" />
|
||||
<div class="input-group-btn">
|
||||
<a data-toggle="dialog-clear" data-id="role_id" class="btn btn-sm btn-default"><i class="fa fa-times"></i></a>
|
||||
</div>
|
||||
<input type="hidden" id="role_id">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.col-sm-2 {
|
||||
padding: 0;
|
||||
padding-right: 10px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var template = JSON.parse('{{json_encode($template, JSON_UNESCAPED_UNICODE)}}');
|
||||
var rightIndex = -1;
|
||||
var vueData = {
|
||||
components: {
|
||||
draggable: GdooVueComponents.draggable,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isDragging: false,
|
||||
listLeft: template.leftFields,
|
||||
listRight: template.rightFields
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickItem(index, item) {
|
||||
rightIndex = index;
|
||||
$('#role_id').val(item.role_id || '');
|
||||
$('#role_id_text').val(item.role_name || '');
|
||||
}
|
||||
}
|
||||
}
|
||||
var vm = Vue.createApp(vueData).mount('#app');
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('role_id', {
|
||||
clear() {
|
||||
vm.listRight[rightIndex]['role_id'] = '';
|
||||
vm.listRight[rightIndex]['role_name'] = '';
|
||||
},
|
||||
onSelect(row) {
|
||||
var role_id = $('#role_id').val();
|
||||
var role_name = $('#role_id_text').val();
|
||||
if (rightIndex >= 0) {
|
||||
vm.listRight[rightIndex]['role_id'] = role_id;
|
||||
vm.listRight[rightIndex]['role_name'] = role_name;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
function submit() {
|
||||
var data = vm.listRight;
|
||||
var data = $('#myform').serialize() + '&' + $.param({columns: data});
|
||||
$.post('{{url()}}', data, function (res) {
|
||||
if (res.status) {
|
||||
toastrSuccess(res.data);
|
||||
location.reload();
|
||||
} else {
|
||||
toastrError(res.data);
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.col-sm-8 {
|
||||
padding-left: 0px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-heading .panel-title {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.panel-heading .fa {
|
||||
vertical-align: middle;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.panel-heading .fa:hover {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.desc {
|
||||
display: none;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.field {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.droppedFields .title > .fa {
|
||||
display: none;
|
||||
float: right;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.droppedFields .active .title > .fa {
|
||||
display: none;
|
||||
float: right;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.droppedFields .title:hover > .fa {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.list-group {
|
||||
position: relative;
|
||||
height: 500px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.list-group .fa {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.list-group .field:hover {
|
||||
background-color: #eee;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.droppedFields .field {
|
||||
cursor: move;
|
||||
border-top: #ddd solid 1px;
|
||||
border-bottom: #ddd solid 1px;
|
||||
border-right: #ddd solid 1px;
|
||||
border-left: #ddd solid 1px;
|
||||
background-color: #fff;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: -1px;
|
||||
white-space: nowrap;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.title {
|
||||
padding: 10px;
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.droppedFields .title {
|
||||
background-color: #eee;
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
.droppedFields .desc-sublist .title {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.droppedFields .active > .title {
|
||||
background-color: #0e90d2;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.droppedFields .fa {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.droppedFields .desc {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.droppedFields .desc-sublist {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
min-height: 30px;
|
||||
border-top: #ddd solid 1px;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.droppedFields .subfld {
|
||||
white-space: normal;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.droppedFields {
|
||||
min-height: 60px;
|
||||
background-color: #fff;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.highlightDroppable {
|
||||
padding: 10px;
|
||||
border: 1px dashed #f6c483;
|
||||
background: #fffdfa;
|
||||
text-align: center;
|
||||
color: #ccc;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: -1px;
|
||||
position: relative;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.desc-sublist .highlightDroppable {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.dragDemo {
|
||||
margin-top:50px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
color: #555;
|
||||
}
|
||||
.dragDemo .list-group {
|
||||
width: 300px;
|
||||
border: 1px solid #ddd;
|
||||
text-align: center;
|
||||
margin-right: 50px;
|
||||
}
|
||||
.dragDemo .list-group > div {
|
||||
padding:10px;
|
||||
border-bottom:1px dashed #ddd;
|
||||
}
|
||||
.dragDemo .list-group > div img {
|
||||
width:25px;
|
||||
height:25px;
|
||||
vertical-align: middle;
|
||||
padding-right:10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,48 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper-sm">
|
||||
<a class="btn btn-info btn-sm" href="{{url('create',['bill_id'=>$bill_id])}}"><i class="icon icon-plus"></i> 新建表单</a>
|
||||
<a class="btn btn-info btn-sm" href="{{url('create2',['bill_id'=>$bill_id])}}"><i class="icon icon-plus"></i> 新建列表</a>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{url()}}" id="myform" name="myform">
|
||||
|
||||
<div class="wrapper-sm b-t">
|
||||
<table class="table table-bordered table-hover m-b-none b-t" id="table-sortable" url="{{url()}}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">视图名称</th>
|
||||
<th align="center">视图类型</th>
|
||||
<th align="center">客户端</th>
|
||||
<th align="center">权限范围</th>
|
||||
<th align="center">ID</th>
|
||||
<th align="center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($rows)
|
||||
@foreach($rows as $row)
|
||||
<tr id="{{$row['id']}}">
|
||||
<td align="left" class="move">{{$row['name']}}</td>
|
||||
<td align="center">{{$row['type']}}</td>
|
||||
<td align="center">{{$row['client']}}</td>
|
||||
<td align="center">{{$row['receive_name']}}</td>
|
||||
<td align="center">{{$row['id']}}</td>
|
||||
<td align="center">
|
||||
@if($row['type'] == 'list')
|
||||
<a class="option" href="{{url('create2',['bill_id'=>$bill_id,'id'=>$row['id']])}}">编辑</a>
|
||||
@else
|
||||
<a class="option" href="{{url('create',['bill_id'=>$bill_id,'id'=>$row['id']])}}">编辑</a>
|
||||
@endif
|
||||
@if($row['system'] == 0)
|
||||
<a class="option" onclick="app.confirm('{{url('delete',['bill_id'=>$bill_id,'id'=>$row['id']])}}','确定要删除吗?');" href="javascript:;">删除</a>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,102 @@
|
||||
<div class="todo-select b-b">
|
||||
<select id="todo-select" class="form-control input-xs input-inline">
|
||||
<option value="0">全部单据</option>
|
||||
@foreach($selects as $select)
|
||||
<option value="{{$select['id']}}">{{$select['name']}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="todo-grid-box">
|
||||
<div class="list-jqgrid" id="todo-grid-controller">
|
||||
<div id="todo-grid" class="ag-theme-balham" style="width:100%;height:200px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var gridDiv = document.querySelector("#todo-grid");
|
||||
var options = new agGridOptions();
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = {};
|
||||
options.rowMultiSelectWithClick = false;
|
||||
|
||||
function option(params) {
|
||||
if (params.data) {
|
||||
if (params.data.option == 1) {
|
||||
return '审核';
|
||||
} else {
|
||||
return '知会';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
options.components['link'] = function(params) {
|
||||
if (params.node.rowPinned) {
|
||||
return params.value;
|
||||
}
|
||||
var data = params.data;
|
||||
var key = data.url.replace(/\//g,'_');
|
||||
return '<a href="javascript:;" data-toggle="todo-grid" data-key="'+ key +'" data-url="' + data.url + '?id=' + data.data_id + '" data-name="'+ data.name + '" data-action="link">打开</a>';
|
||||
};
|
||||
|
||||
options.columnDefs = [
|
||||
{suppressMenu: true, type:'sn', cellClass:'text-center', headerName: '序号', width: 60},
|
||||
{suppressMenu: true, field: 'sn', cellClass:'text-center', headerName: '单据编号', minWidth: 160},
|
||||
{suppressMenu: true, field: 'name', cellClass:'text-center', headerName: '单据类型', width: 160},
|
||||
{suppressMenu: true, field: 'option', cellClass:'text-center', cellRenderer: option, headerName: '通知类型', width: 160},
|
||||
{suppressMenu: true, field: 'partner_name', cellClass:'text-center', headerName: '往来单位', width: 160},
|
||||
{suppressMenu: true, field: 'run_name', cellClass:'text-center', headerName: '状态', width: 160},
|
||||
{suppressMenu: true, field: 'user_name', cellClass:'text-center', headerName: '转交人', width: 160},
|
||||
{suppressMenu: true, type: 'datetime', cellClass:'text-center', field: 'created_at', headerName: '转交时间', width: 160},
|
||||
//{suppressMenu: true, field: 'id', cellClass:'text-center', headerName: 'ID', width: 80},
|
||||
{suppressMenu: true, field: 'link', cellClass:'text-center', sortable: false, cellRenderer: 'link', headerName: '', width: 60},
|
||||
];
|
||||
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
var data = params.data;
|
||||
if (data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (data.data_id > 0) {
|
||||
var key = data.url.replace(/\//g,'_');
|
||||
top.addTab(data.url + '?id=' + data.data_id, key, data.name);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
window.todoGrid = options;
|
||||
|
||||
// 读取数据
|
||||
options.remoteData();
|
||||
|
||||
gdoo.widgets['model_todo_widget'] = options;
|
||||
|
||||
var panel = $('#todo-grid-controller');
|
||||
panel.on('click', '[data-toggle="todo-grid"]', function() {
|
||||
var data = $(this).data();
|
||||
if (data.action == 'link') {
|
||||
top.addTab(data.url, data.key, data.name);
|
||||
}
|
||||
});
|
||||
|
||||
$('#todo-select').on('change', function() {
|
||||
var bill_id = $(this).val();
|
||||
options.remoteData({bill_id: bill_id, page: 1});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.todo-grid-box {
|
||||
padding: 0 10px 10px 10px;
|
||||
}
|
||||
.todo-select {
|
||||
padding: 5px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user