123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- <div id="activitiModel" class="plg-tab-container">
- <div style="display: none;">
- <button type="button" class="layui-btn layui-btn-sm" id="test3"><i class="layui-icon"></i>上传文件</button>
- </div>
- <div id="activitiModel-table" class="grid-container-full"></div>
- <form id="form1" style="display: none;margin-top: 10px;">
- <input id="id" name="id" type="hidden" />
- <div class="layui-form-item">
- <label class="layui-form-label">模型名称</label>
- <div class="layui-input-block">
- <input type="text" id="name" name="name" lay-verify="required" placeholder="必填" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">key值</label>
- <div class="layui-input-block">
- <input type="text" id="key" name="key" lay-verify="required" placeholder="必填" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">类目</label>
- <div class="layui-input-block">
- <input type="text" id="category" name="category" lay-verify="required" placeholder="必填" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">描述</label>
- <div class="layui-input-block">
- <input type="text" id="desc" name="desc" lay-verify="required" placeholder="选填" autocomplete="off" class="layui-input">
- </div>
- </div>
- </form>
- </div>
- <script type="text/javascript">
- (function($){
-
- var PopupsData = {
- toolbar: [
- {type: "settings", labelAlign:'left', labelWidth: 65},
- {type: "input", name: 'serviceName', label: '服务名称:',offsetLeft:5,placeholder:'请输入服务名称', width:300},{type: "newcolumn"},
- {type:"button", name:"searchBtn", value:"查询"}
- ],
- columns:[
- {id:"id",name:"id",type:'ro',width:"50",hidden:true},
- {id:"serviceName",name:"服务名",type:'ed',width:"200"},
- {id:"authNumber",name:"权限编号",type:'ed',width:"200"},
- {id:"source",name:"资源",type:'ed',width:"100"},
- {id:"method",name:"提交方式",type:'ed',width:"100"}
- ],
- multiselect:false,
- imagePath:"../../prologui/assets/PlgGrid",
- url:"/api/service-authorization/resource/list",//数据接口
- type:"get",//数据提交方式,默认为get
- pagebar:{
- type:'simple' //full simple min
- },
- params:{ pageSize:8, pageNum:1},//查询提交参数,分页参数默认为pageNum,pageSize
- page:true, //是否启用分页
- beforeLoad:function(t){
- t.params.pageSize=2;
- },
- pageNum: "pageNum",//设置分页参数页码key值,默认为pageNum
- totalCount:"totalCount" //总记录数字段,默认totalCount
- };
- var parent= $("#activitiModel");
- var form=parent.find("#form1")
- var $ = layui.jquery,
- upload = layui.upload;
- var opts = {
- skin: "terrace",
- columns: [
- {id: "id",name: "id",type: 'txt',hidden: true},
- {
- id: "name",
- name: "模型名称",
- type: 'ro',
- width: 150
- },
- {
- id: "key",
- name: "key值",
- type: 'ro',
- width: 150
- },
- {
- id: "category",
- name: "类目",
- type: 'ro',
- width: 120
- },
- {
- id: "createTime",
- name: "创建时间",
- type: 'ro',
- width: 120
- },
- {
- id: "span",
- name: "dd",
- type: 'selectTable',
- table:PopupsData,
- fieldText:"serviceName",
- fieldValue:["serviceName","source"],
- width: '*'
- }
- // ,
- // {
- // id: "editorSourceValueId",
- // name: "editorSourceValueId",
- // type: 'txt',
- // hidden: true
- // }
- // ,
- // {
- // id: "",
- // name: "操作",
- // type: 'ro',
- // width: 160,
- // render: function(v, d) {
- // return '<a href="javascript:void(0);" style="color: dodgerblue;" onclick="delActivitiModel(\'' + d["id"] + '\')">删除</a>'
- // + ' | <a href="javascript:void(0);" style="color: dodgerblue;" onclick="deployActivitiModel(\'' + d["id"] + '\')">部署</a>';
- // }
- // }
- ],
- imagePath: "/prologui/assets/PlgGrid",
- url: "/api/service-activiti/model/model", //数据接口
- type: "get", //数据提交方式,默认为get
- params: {
- pageNum: 1,
- pageSize: 10,
- modelName: null
- }, //查询提交参数,分页参数默认为pageNum,pageSize
- multiselect: false, //是否支持多选
- page: true, //是否启用分页
- toolbar:[
- {type:"button", name:"addBtn", value:"<i class='layui-icon layui-icon-add-1 layui-anim-scale'></i>添加"},{type: "newcolumn"},
- // {type:"button", name:"updateBtn", value:"<i class='layui-icon layui-icon-edit'></i>修改"},{type: "newcolumn"},
- {type:"button", name:"upload", className: "normal", value:"<i class='layui-icon layui-icon-upload-circle'></i>上传"},{type: "newcolumn"},
- {type:"button", name:"deployBtn", className: "normal", value:"<i class='layui-icon layui-icon-engine'></i>部署"},{type: "newcolumn"},
- {type:"button", name:"deleteBtn", className: "danger", value:"<i class='layui-icon layui-icon-delete'></i>删除"},{type: "newcolumn"},
- // {type:"button", name:"download", value:"<i class='layui-icon layui-icon-download-circle'></i>下载"},{type: "newcolumn"},
- {type: "input", name: 'modelName', label: '模型名称:', placeholder:'请输入模型名称', offsetLeft:20},{type: "newcolumn"}
- ,{type:"button", name:"searchBtn", value:"查询"},{type: "newcolumn"}
- ],
- formData:[
- {type:"settings",inputWidth :300,width:400,labelWidth:80,position:"label-left",labelAlign:"left"},
- {type: "hidden", name:"id", value:""},
- {type: "input", name: 'name', label: '名称:',validate:"NotEmpty", required: true, placeholder:'请输入名称', editable:false},
- {type:"input", name:"key", label:"模型key:",validate:"NotEmpty", required: true, placeholder:'请输入模型key'},
- {type:"input", name:"category", label:"分类:",validate:"NotEmpty", required: true, placeholder:'请输入模型类型'},
- {type:"input", name:"desc", label:"描述:", rows:3}
- ],
- totalCount: "totalCount" //总记录数字段,默认totalCount
-
- };
- var activitiModel = new PlgGrid(opts);
- activitiModel.renderTo("activitiModel-table");
- activitiModel.loadData();
- //activitiModel.getGrid().enableEditEvents(true,false,false);
- activitiModel.attachToolBarEvent("onButtonClick", function(name){
- if(name == "addBtn"){
- //addActivitiModel();
- activitiModel.showDialog(0,"添加",430,350,{url:"/api/service-activiti/model",type:"post"});
- }else if(name == "deleteBtn"){
- delActivitiModel();
- }else if(name == "deployBtn"){
- deployActivitiModel();
- }else if(name == "updateBtn"){
- updateModel();
- }else if(name == "searchBtn"){
- search();
- }else if(name == "upload"){
- $("#test3").click();
- }else if(name == "download"){
- download();
- }
- });
- function download(){
- var modelId = activitiModel.getSelectedRowId();
- if(!modelId){
- layer.msg("请选择一条数据");
- return;
- }
-
- window.location.href = "/api/service-activiti/activiti/resource?modelId="+modelId;
- // $.ajax({
- // url:"/api/service-activiti/activiti/resource?modelId="+modelId,
- // type:"get",
- // success:function(res){
- // layer.msg("成功");
- // },
- // error:function(e){
- // layer.msg("error");
- // }
- // });
- }
- function updateModel(){
- layer.open({
- title: '修改模型'
- ,content: '开发中'
- });
- }
-
- function search(){
- var modelName = $("input[name='modelName']").val();
- var am = activitiModel.getParams();
- am.modelName = modelName;
- activitiModel.reload();
-
- }
-
- //上传bpmn文件
- upload.render({
- elem: '#test3'
- ,url: '/api/service-activiti/model/upload'
- ,accept: 'file' //普通文件
- ,data: {
- modelId: function(){
- return activitiModel.getSelectedRowId();
- }
- }
- ,before:function(){
-
- }
- ,done: function(res){
- alert(res.message);
- //console.log(res);
- }
- });
-
- function deployActivitiModel(){
- var modelId = activitiModel.getSelectedRowId();
- if(!modelId){
- layer.msg("请选择一条数据");
- return;
- }
- layer.confirm('确定部署?', {
- btn: ['确定', '取消'],
- }, function(index, layero) {
- //按钮【按钮一】的回调
- $.ajax({
- type: 'POST',
- url: "/api/service-activiti/model/deploy",
- data: {
- modelId:modelId
- },
- async: false,
- success: function(data) {
- activitiModel.reload();
- alert(data.message);
- }
- });
- layer.close(index)
- });
- }
- function delActivitiModel() {
- var modelId = activitiModel.getSelectedRowId();
- if(!modelId){
- layer.msg("请选择一条数据");
- return;
- }
- layer.confirm('确定删除?', {
- btn: ['确定', '取消'],
- }, function(index, layero) {
- //按钮【按钮一】的回调
- $.ajax({
- type: 'GET',
- url: "/api/service-activiti/model/model/" + modelId,
- data: {
- },
- async: false,
- success: function(data) {
- // activitiModel.reload();
- activitiModel.reload();
- // alert(data.message);
- }
- });
- layer.close(index)
- });
- };
- function addActivitiModel() {
- $("#id").val("");
- $("#name").val("");
- $("#description").val("");
- var index = layer.open({
- type: 1,
- title: '新增页',
- area: ['1000px', '550px'],
- shade: 0.5,
- maxmin: true,
- content: form,
- id: 'add1',
- closeBtn: 1,
- btn: ['确定', '关闭'],
- yes: function(index, layero) {
- var d =form.serialize();
- $.ajax({
- type: 'post',
- async: false,
- url: "/api/service-activiti/model",
- data: d,
- dataType: "json",
- success: function(data) {
- if(data.success == false) {
- alert("操作失败")
- } else {
- // alert(data.message);
- // activitiModel.reload();
- activitiModel.reload();
- form.hide();
- layer.closeAll();
- }
- }
- });
- },
- zIndex: layer.zIndex,
- end: function() {
- form.hide();
- layer.closeAll();
- }
- });
- }
- })($)
- </script>
|