修改基础管理中的基础内容

This commit is contained in:
meimei
2025-04-18 14:45:48 +08:00
parent 0a83799b2d
commit f20b865f4d
9 changed files with 70 additions and 16 deletions

View File

@@ -51,14 +51,15 @@ class Firmstoreprojectsone extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['firm'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','name']);
$row->visible(['firm']);
$row->getRelation('firm')->visible(['full_name']);
}
$result = array("total" => $list->total(), "rows" => $list->items());

View File

@@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 店铺二级项目
@@ -51,7 +52,7 @@ class Firmstoreprojectstwo extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['firmstoreprojectsone'])
->with(['firmstoreprojectsone','firm'])
->where($where)
->order($sort, $order)
->paginate($limit);
@@ -60,6 +61,8 @@ class Firmstoreprojectstwo extends Backend
$row->visible(['id','name']);
$row->visible(['firmstoreprojectsone']);
$row->getRelation('firmstoreprojectsone')->visible(['name']);
$row->visible(['firm']);
$row->getRelation('firm')->visible(['full_name']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
@@ -68,5 +71,47 @@ class Firmstoreprojectstwo extends Backend
}
return $this->view->fetch();
}
public function add()
{
if (false === $this->request->isPost()) {
$ids = input('ids');
$oneData['id'] = 0;
$oneData['firm_id'] = 0;
$oneData['firmstore_id'] = 0;
if (!empty($ids)){
$oneData = Db::table('fa_firmstoreprojectsone')->where('id',$ids)->find();
}
$this->view->assign('oneData', $oneData);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
}

View File

@@ -29,7 +29,10 @@ class Firmstoreprojectsone extends Model
];
public function firm()
{
return $this->belongsTo('Firm', 'firm_id', 'id', [], 'LEFT')->setEagerlyType(0);
}

View File

@@ -34,7 +34,10 @@ class Firmstoreprojectstwo extends Model
public function firm()
{
return $this->belongsTo('Firm', 'firm_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function firmstoreprojectsone()

View File

@@ -10,19 +10,19 @@
<label class="control-label col-xs-12 col-sm-2">{:__('Firmstore_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-firmstore_id" min="0" data-rule="required"
disabled
data-source="firmstore/index" class="form-control selectpage"
name="row[firmstore_id]" type="text" value="{:session_admin_firmstore_id()}">
name="row[firmstore_id]" type="text" value="1">
</div>
<span style="color: red">不选择为基础模版</span>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Firm_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-firm_id" min="0" data-rule="required"
disabled
data-source="firm/index" class="form-control selectpage"
name="row[firm_id]" type="text" value="{:session_admin_firm_id()}">
name="row[firm_id]" type="text" value="1">
</div>
<span style="color: red">不选择为基础模版</span>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>

View File

@@ -9,7 +9,7 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Firmstoreprojectsone_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-firmstoreprojectsone_id" min="0" data-rule="required" data-source="firmstoreprojectsone/index" class="form-control selectpage" name="row[firmstoreprojectsone_id]" type="text" value="">
<input id="c-firmstoreprojectsone_id" min="0" data-rule="required" data-source="firmstoreprojectsone/index" class="form-control selectpage" name="row[firmstoreprojectsone_id]" type="text" value="{$oneData.id|htmlentities}">
</div>
</div>
<div class="form-group">
@@ -18,7 +18,7 @@
<input id="c-firmstore_id" min="0" data-rule="required"
disabled
data-source="firmstore/index" class="form-control selectpage"
name="row[firmstore_id]" type="text" value="{:session_admin_firmstore_id()}">
name="row[firmstore_id]" type="text" value="{$oneData.firmstore_id|htmlentities}">
</div>
</div>
<div class="form-group">
@@ -27,7 +27,7 @@
<input id="c-firm_id" min="0" data-rule="required" data-source="firm/index"
disabled
class="form-control selectpage"
name="row[firm_id]" type="text" value="{:session_admin_firm_id()}">
name="row[firm_id]" type="text" value="{$oneData.firm_id|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">

View File

@@ -7,7 +7,7 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('firmstoreprojectstwo/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('firmstoreprojectstwo/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('firmstoreprojectstwo/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('firmstoreprojectstwo/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>

View File

@@ -27,6 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'firm.full_name', title: '企业名称', operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,

View File

@@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'firmstoreprojectsone.name', title: __('Firmstoreprojectsone.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'firm.full_name', title: '企业名称', operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]