This commit is contained in:
2024-08-02 12:56:30 +08:00
parent 57afa3062c
commit fad602b71f
4 changed files with 51 additions and 58 deletions

View File

@@ -34,4 +34,39 @@ class Hdrquestionnairequestion extends Backend
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['hdrdepartment'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','question','fit_sex','create_time']);
$row->visible(['hdrdepartment']);
$row->getRelation('hdrdepartment')->visible(['name']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
}

View File

@@ -1,13 +1,14 @@
<?php
return [
'Id' => 'ID',
'Hdrdepartment_id' => '所属科室',
'Question' => '问卷问题',
'Fit_sex' => '适合对象',
'Fit_sex all' => '全部',
'Fit_sex gg' => '男',
'Fit_sex mm' => '女',
'Create_time' => '创建时间',
'Update_time' => '更新时间'
'Id' => 'ID',
'Hdrdepartment_id' => '所属科室',
'Question' => '问卷问题',
'Fit_sex' => '适合对象',
'Fit_sex all' => '全部',
'Fit_sex gg' => '男',
'Fit_sex mm' => '女',
'Create_time' => '创建时间',
'Update_time' => '更新时间',
'Hdrdepartment.name' => '科室名称'
];

View File

@@ -46,4 +46,8 @@ class Hdrquestionnairequestion extends Model
public function hdrdepartment()
{
return $this->belongsTo('Hdrdepartment', 'hdrdepartment_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}

View File

@@ -26,58 +26,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'hdrdepartment_id', title: __('Hdrdepartment_id')},
{field: 'question', title: __('Question'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'fit_sex', title: __('Fit_sex'), searchList: {"all":__('Fit_sex all'),"gg":__('Fit_sex gg'),"mm":__('Fit_sex mm')}, formatter: Table.api.formatter.normal},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
buttons: [
{
name: 'addasw',
text: __('添加答案'),
title: __('添加答案'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'hdrquestionnaireanswer/add',
callback: function (data) {
// Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
return true;
}
},
// {
// name: 'ajax',
// text: __('发送Ajax'),
// title: __('发送Ajax'),
// classname: 'btn btn-xs btn-success btn-magic btn-ajax',
// icon: 'fa fa-magic',
// url: 'example/bootstraptable/detail',
// confirm: '确认发送',
// success: function (data, ret) {
// Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
// //如果需要阻止成功提示则必须使用return false;
// //return false;
// },
// error: function (data, ret) {
// console.log(data, ret);
// Layer.alert(ret.msg);
// return false;
// }
// },
// {
// name: 'addtabs',
// text: __('新选项卡中打开'),
// title: __('新选项卡中打开'),
// classname: 'btn btn-xs btn-warning btn-addtabs',
// icon: 'fa fa-folder-o',
// url: 'example/bootstraptable/detail'
// }
]
}
{field: 'hdrdepartment.name', title: __('Hdrdepartment.name'), 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}
]
]
});