model","marks":[]}]}],"state":{}},{"type":"block","id":"DcD6-1651730680583","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"tBNH-1651730680582","leaves":[{"text":"->where($this->listWhere('enterprise'))","marks":[]}]}],"state":{}},{"type":"block","id":"hX2g-1651730680585","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"qCYV-1651730680584","leaves":[{"text":"->field('id, name')","marks":[]}]}],"state":{}},{"type":"block","id":"oueO-1651730680587","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"xyRd-1651730680586","leaves":[{"text":"->select();","marks":[]}]}],"state":{}},{"type":"block","id":"i5em-1651730680590","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"YMtx-1651730680589","leaves":[{"text":"$arr = [];","marks":[]}]}],"state":{}},{"type":"block","id":"AOmj-1651730680592","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"umvc-1651730680591","leaves":[{"text":"foreach ($list as $v)","marks":[]}]}],"state":{}},{"type":"block","id":"vyKM-1651730680594","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"KKAN-1651730680593","leaves":[{"text":"{","marks":[]}]}],"state":{}},{"type":"block","id":"YRqr-1651730680596","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"WRzf-1651730680595","leaves":[{"text":"$arr[$v['id']] = $v['name'];","marks":[]}]}],"state":{}},{"type":"block","id":"Q07A-1651730680598","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"nNUR-1651730680597","leaves":[{"text":"}","marks":[]}]}],"state":{}},{"type":"block","id":"A4Pz-1651730680600","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"Q7b8-1651730680599","leaves":[{"text":"return json($arr);","marks":[]}]}],"state":{}},{"type":"block","id":"NWoa-1651730680602","name":"paragraph","data":{"style":null,"version":1},"nodes":[{"type":"text","id":"bZ2W-1651730680601","leaves":[{"text":"}","marks":[]}]}],"state":{}},{"type":"block","id":"A7WE-1651730671962","name":"paragraph","data":{},"nodes":[{"type":"text","id":"My3d-1651730671960","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"9FQ7-1651730542124","name":"paragraph","data":{},"nodes":[{"type":"text","id":"XTK4-1651730542122","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"uArA-1651730562242","name":"paragraph","data":{},"nodes":[{"type":"text","id":"ZbbN-1651730562240","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"ILTw-1651730542251","name":"paragraph","data":{},"nodes":[{"type":"text","id":"HQZu-1651730542249","leaves":[{"text":"2 ","marks":[{"type":"bold"}]},{"text":"在index 方法中 利用view 渲染时 写入一个js变量","marks":[{"type":"color","value":"#1a1a1a"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontFamily","value":"Arial"},{"type":"fontSize","value":14},{"type":"bold"}]}]}],"state":{}},{"type":"block","id":"sYqA-1651730551619","name":"paragraph","data":{"style":null},"nodes":[{"type":"text","id":"lkFS-1651730551618","leaves":[{"text":"/**","marks":[]}]}],"state":{}},{"type":"block","id":"wV0W-1651730551995","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"gMnC-1651730551977","leaves":[{"text":" * 查看","marks":[]}]}],"state":{}},{"type":"block","id":"Quyv-1651730551996","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"eUWc-1651730551978","leaves":[{"text":" */","marks":[]}]}],"state":{}},{"type":"block","id":"RmqI-1651730551998","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"7Gif-1651730551979","leaves":[{"text":" public function index()\n {","marks":[]}]}],"state":{}},{"type":"block","id":"b9rc-1651730551999","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"mjAJ-1651730551980","leaves":[{"text":" //设置过滤方法","marks":[]}]}],"state":{}},{"type":"block","id":"leut-1651730552000","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"SVxB-1651730551981","leaves":[{"text":" $this->request->filter(['strip_tags', 'trim']);","marks":[]}]}],"state":{}},{"type":"block","id":"dpMY-1651730552001","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"nVRp-1651730551982","leaves":[{"text":" if ($this->request->isAjax()) {","marks":[]}]}],"state":{}},{"type":"block","id":"oHfQ-1651730552002","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"5G8w-1651730551983","leaves":[{"text":" ......","marks":[]}]}],"state":{}},{"type":"block","id":"UVGS-1651730552003","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"Tm8P-1651730551984","leaves":[{"text":" }","marks":[]}]}],"state":{}},{"type":"block","id":"E7Bt-1651730552005","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"KoxM-1651730551985","leaves":[{"text":" $type_data = [1 => '启用', 0 => '关闭'];","marks":[]}]}],"state":{}},{"type":"block","id":"S9KS-1651730552006","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"BpBC-1651730551986","leaves":[{"text":" $this->assignconfig('type_data', $type_data);","marks":[]}]}],"state":{}},{"type":"block","id":"LpHz-1651730552007","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"ZoLp-1651730551987","leaves":[{"text":" return $this->view->fetch();","marks":[]}]}],"state":{}},{"type":"block","id":"oJAx-1651730552008","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"3pkZ-1651730551988","leaves":[{"text":" }","marks":[]}]}],"state":{}},{"type":"block","id":"sfYc-1651730559495","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"1CUQ-1651730559493","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"0Pur-1651730559657","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"c4XL-1651730559655","leaves":[{"text":"js文件中引入 type_data变量 完事","marks":[]}]}],"state":{}},{"type":"block","id":"NFOI-1651730560024","name":"paragraph","data":{"version":1,"style":null},"nodes":[{"type":"text","id":"9cmA-1651730560018","leaves":[{"text":" {field: 'type_data', title: __('Type_data'), searchList: Config.type_data , formatter: Table.api.formatter.normal,visible: false}","marks":[]}]}],"state":{}}]'>
1 编写一个接口 searchList 返回key => value格式数据
{field: 'enterprise_id', title: __('Enterprise_id'), operate: 'LIKE', searchList: $.getJSON("enterprise/list"), visible: false},
public function list()
{
$list = $this->model
->where($this->listWhere('enterprise'))
->field('id, name')
->select();
$arr = [];
foreach ($list as $v)
{
$arr[$v['id']] = $v['name'];
}
return json($arr);
}
2 在index 方法中 利用view 渲染时 写入一个js变量
/**
* 查看
*/
public function index() {
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
......
}
$type_data = [1 => '启用', 0 => '关闭'];
$this->assignconfig('type_data', $type_data);
return $this->view->fetch();
}
js文件中引入 type_data变量 完事
{field: 'type_data', title: __('Type_data'), searchList: Config.type_data , formatter: Table.api.formatter.normal,visible: false}

点赞(1) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部