插件基类方法介绍
插件机制
后端代码编写
进阶
前端代码编写
插件数据类型
为了帮助插件更方便的调用其他插件的接口,系统内置插件数据类型机制。以下举例说明。
例如,打印机插件为了方便其他插件选择打印机ID,可以添加一个打印机ID数据类型。点餐插件在设计插件数据结构时,可以设置一个字段类型为打印机ID。其具体效果为,当用户使用该功能需要设置打印机ID时,直接点击选择打印机ID,系统自动调起打印机插件的打印机选择页面选择打印机,然后返回打印机ID。
以上功能需要依赖插件开发工具实现(设置数据类型和添加数据类型)。如果不使用插件开发工具,需要使用此接口的。可以手动书写打印机ID选择接口代码和打印机选择页面代码。以下分别示例。
打印机ID选择接口(接口调用方)。
<div class="form-group" > <label class="col-xs-12 col-sm-3 col-md-2 control-label">打印机ID</label> <div class="col-sm-9 col-xs-12"> <div class="input-group"> <input type="text" class="form-control" ng-model="pagedata.item.pid"/> <span class="input-group-btn"> <button class="btn btn-default" type="button" ng-click="modal_func (pagedata.item,'pid','get_printer','','printer')">选择打印机 </button> </span> </div> </div> </div>
该段代码的作用为,调用打印机选择接口获得打印机ID,存入pagedata.item.pid。其中,核心函数为modal_func()。其主要参数如下。
| data | 接收数据对象 |
| to | 接收数据下标 |
| action | 数据选择接口的方法名 |
| html | 数据选择页面html(相对地址),可不填 |
| plugin | 数据选择接口所属插件,不填默认当前插件 |
打印机选择页面。
<div class="panel panel-info" ng-if="modaldata.op=='list'">
<div class="panel-heading">筛选</div>
<div class="panel-body">
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 left-label">打印机名称</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="title" class="form-control"
ng-model="modaldata.params.nickname"/>
<div class="help-block"></div>
</div>
</div>
<div class="form-group" ng-include="sys_html('common/modal_find',true)"></div>
</div>
</div>
<div class="clearfix table-responsive" ng-if="modaldata.op=='list'">
<form method="post" class="form-horizontal jinyun-form" id="form1">
<table class="table jinyun-table table-hover vertical-middle">
<thead class="navbar-inner">
<tr>
<th>打印机名称</th>
<th>操作</th>
</tr>
</thead>
<tr ng-repeat="item in modaldata.list" >
<td>{{item.title}}</td>
<td>
<a href="javascript:;" ng-click="modal_result(item.id)">选取</a>
</td>
</tr>
</form>
</table>
<div ng-include="sys_html('common/modal_page',true)"></div>
</div>该页面的核心函数为,modal_result,其作用为将选择的数据赋值给modal_func函数指定的参数,然后关闭数据选择页面。该函数接收一项参数,即选择结果。本例中为打印机ID。
页面控制文件比较简单,此处不再举例。
返回
条结果""