activitiModel.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <div id="activitiModel" class="plg-tab-container">
  2. <div style="display: none;">
  3. <button type="button" class="layui-btn layui-btn-sm" id="test3"><i class="layui-icon"></i>上传文件</button>
  4. </div>
  5. <div id="activitiModel-table" class="grid-container-full"></div>
  6. <form id="form1" style="display: none;margin-top: 10px;">
  7. <input id="id" name="id" type="hidden" />
  8. <div class="layui-form-item">
  9. <label class="layui-form-label">模型名称</label>
  10. <div class="layui-input-block">
  11. <input type="text" id="name" name="name" lay-verify="required" placeholder="必填" autocomplete="off" class="layui-input">
  12. </div>
  13. </div>
  14. <div class="layui-form-item">
  15. <label class="layui-form-label">key值</label>
  16. <div class="layui-input-block">
  17. <input type="text" id="key" name="key" lay-verify="required" placeholder="必填" autocomplete="off" class="layui-input">
  18. </div>
  19. </div>
  20. <div class="layui-form-item">
  21. <label class="layui-form-label">类目</label>
  22. <div class="layui-input-block">
  23. <input type="text" id="category" name="category" lay-verify="required" placeholder="必填" autocomplete="off" class="layui-input">
  24. </div>
  25. </div>
  26. <div class="layui-form-item">
  27. <label class="layui-form-label">描述</label>
  28. <div class="layui-input-block">
  29. <input type="text" id="desc" name="desc" lay-verify="required" placeholder="选填" autocomplete="off" class="layui-input">
  30. </div>
  31. </div>
  32. </form>
  33. </div>
  34. <script type="text/javascript">
  35. (function($){
  36. var PopupsData = {
  37. toolbar: [
  38. {type: "settings", labelAlign:'left', labelWidth: 65},
  39. {type: "input", name: 'serviceName', label: '服务名称:',offsetLeft:5,placeholder:'请输入服务名称', width:300},{type: "newcolumn"},
  40. {type:"button", name:"searchBtn", value:"查询"}
  41. ],
  42. columns:[
  43. {id:"id",name:"id",type:'ro',width:"50",hidden:true},
  44. {id:"serviceName",name:"服务名",type:'ed',width:"200"},
  45. {id:"authNumber",name:"权限编号",type:'ed',width:"200"},
  46. {id:"source",name:"资源",type:'ed',width:"100"},
  47. {id:"method",name:"提交方式",type:'ed',width:"100"}
  48. ],
  49. multiselect:false,
  50. imagePath:"../../prologui/assets/PlgGrid",
  51. url:"/api/service-authorization/resource/list",//数据接口
  52. type:"get",//数据提交方式,默认为get
  53. pagebar:{
  54. type:'simple' //full simple min
  55. },
  56. params:{ pageSize:8, pageNum:1},//查询提交参数,分页参数默认为pageNum,pageSize
  57. page:true, //是否启用分页
  58. beforeLoad:function(t){
  59. t.params.pageSize=2;
  60. },
  61. pageNum: "pageNum",//设置分页参数页码key值,默认为pageNum
  62. totalCount:"totalCount" //总记录数字段,默认totalCount
  63. };
  64. var parent= $("#activitiModel");
  65. var form=parent.find("#form1")
  66. var $ = layui.jquery,
  67. upload = layui.upload;
  68. var opts = {
  69. skin: "terrace",
  70. columns: [
  71. {id: "id",name: "id",type: 'txt',hidden: true},
  72. {
  73. id: "name",
  74. name: "模型名称",
  75. type: 'ro',
  76. width: 150
  77. },
  78. {
  79. id: "key",
  80. name: "key值",
  81. type: 'ro',
  82. width: 150
  83. },
  84. {
  85. id: "category",
  86. name: "类目",
  87. type: 'ro',
  88. width: 120
  89. },
  90. {
  91. id: "createTime",
  92. name: "创建时间",
  93. type: 'ro',
  94. width: 120
  95. },
  96. {
  97. id: "span",
  98. name: "dd",
  99. type: 'selectTable',
  100. table:PopupsData,
  101. fieldText:"serviceName",
  102. fieldValue:["serviceName","source"],
  103. width: '*'
  104. }
  105. // ,
  106. // {
  107. // id: "editorSourceValueId",
  108. // name: "editorSourceValueId",
  109. // type: 'txt',
  110. // hidden: true
  111. // }
  112. // ,
  113. // {
  114. // id: "",
  115. // name: "操作",
  116. // type: 'ro',
  117. // width: 160,
  118. // render: function(v, d) {
  119. // return '<a href="javascript:void(0);" style="color: dodgerblue;" onclick="delActivitiModel(\'' + d["id"] + '\')">删除</a>'
  120. // + ' | <a href="javascript:void(0);" style="color: dodgerblue;" onclick="deployActivitiModel(\'' + d["id"] + '\')">部署</a>';
  121. // }
  122. // }
  123. ],
  124. imagePath: "/prologui/assets/PlgGrid",
  125. url: "/api/service-activiti/model/model", //数据接口
  126. type: "get", //数据提交方式,默认为get
  127. params: {
  128. pageNum: 1,
  129. pageSize: 10,
  130. modelName: null
  131. }, //查询提交参数,分页参数默认为pageNum,pageSize
  132. multiselect: false, //是否支持多选
  133. page: true, //是否启用分页
  134. toolbar:[
  135. {type:"button", name:"addBtn", value:"<i class='layui-icon layui-icon-add-1 layui-anim-scale'></i>添加"},{type: "newcolumn"},
  136. // {type:"button", name:"updateBtn", value:"<i class='layui-icon layui-icon-edit'></i>修改"},{type: "newcolumn"},
  137. {type:"button", name:"upload", className: "normal", value:"<i class='layui-icon layui-icon-upload-circle'></i>上传"},{type: "newcolumn"},
  138. {type:"button", name:"deployBtn", className: "normal", value:"<i class='layui-icon layui-icon-engine'></i>部署"},{type: "newcolumn"},
  139. {type:"button", name:"deleteBtn", className: "danger", value:"<i class='layui-icon layui-icon-delete'></i>删除"},{type: "newcolumn"},
  140. // {type:"button", name:"download", value:"<i class='layui-icon layui-icon-download-circle'></i>下载"},{type: "newcolumn"},
  141. {type: "input", name: 'modelName', label: '模型名称:', placeholder:'请输入模型名称', offsetLeft:20},{type: "newcolumn"}
  142. ,{type:"button", name:"searchBtn", value:"查询"},{type: "newcolumn"}
  143. ],
  144. formData:[
  145. {type:"settings",inputWidth :300,width:400,labelWidth:80,position:"label-left",labelAlign:"left"},
  146. {type: "hidden", name:"id", value:""},
  147. {type: "input", name: 'name', label: '名称:',validate:"NotEmpty", required: true, placeholder:'请输入名称', editable:false},
  148. {type:"input", name:"key", label:"模型key:",validate:"NotEmpty", required: true, placeholder:'请输入模型key'},
  149. {type:"input", name:"category", label:"分类:",validate:"NotEmpty", required: true, placeholder:'请输入模型类型'},
  150. {type:"input", name:"desc", label:"描述:", rows:3}
  151. ],
  152. totalCount: "totalCount" //总记录数字段,默认totalCount
  153.   
  154. };
  155. var activitiModel = new PlgGrid(opts);
  156. activitiModel.renderTo("activitiModel-table");
  157. activitiModel.loadData();
  158. //activitiModel.getGrid().enableEditEvents(true,false,false);
  159. activitiModel.attachToolBarEvent("onButtonClick", function(name){
  160. if(name == "addBtn"){
  161. //addActivitiModel();
  162. activitiModel.showDialog(0,"添加",430,350,{url:"/api/service-activiti/model",type:"post"});
  163. }else if(name == "deleteBtn"){
  164. delActivitiModel();
  165. }else if(name == "deployBtn"){
  166. deployActivitiModel();
  167. }else if(name == "updateBtn"){
  168. updateModel();
  169. }else if(name == "searchBtn"){
  170. search();
  171. }else if(name == "upload"){
  172. $("#test3").click();
  173. }else if(name == "download"){
  174. download();
  175. }
  176. });
  177. function download(){
  178. var modelId = activitiModel.getSelectedRowId();
  179. if(!modelId){
  180. layer.msg("请选择一条数据");
  181. return;
  182. }
  183. window.location.href = "/api/service-activiti/activiti/resource?modelId="+modelId;
  184. // $.ajax({
  185. // url:"/api/service-activiti/activiti/resource?modelId="+modelId,
  186. // type:"get",
  187. // success:function(res){
  188. // layer.msg("成功");
  189. // },
  190. // error:function(e){
  191. // layer.msg("error");
  192. // }
  193. // });
  194. }
  195. function updateModel(){
  196. layer.open({
  197. title: '修改模型'
  198. ,content: '开发中'
  199. });
  200. }
  201. function search(){
  202. var modelName = $("input[name='modelName']").val();
  203. var am = activitiModel.getParams();
  204. am.modelName = modelName;
  205. activitiModel.reload();
  206. }
  207. //上传bpmn文件
  208. upload.render({
  209. elem: '#test3'
  210. ,url: '/api/service-activiti/model/upload'
  211. ,accept: 'file' //普通文件
  212. ,data: {
  213. modelId: function(){
  214. return activitiModel.getSelectedRowId();
  215. }
  216. }
  217. ,before:function(){
  218. }
  219. ,done: function(res){
  220. alert(res.message);
  221. //console.log(res);
  222. }
  223. });
  224. function deployActivitiModel(){
  225. var modelId = activitiModel.getSelectedRowId();
  226. if(!modelId){
  227. layer.msg("请选择一条数据");
  228. return;
  229. }
  230. layer.confirm('确定部署?', {
  231. btn: ['确定', '取消'],
  232. }, function(index, layero) {
  233. //按钮【按钮一】的回调
  234. $.ajax({
  235. type: 'POST',
  236. url: "/api/service-activiti/model/deploy",
  237. data: {
  238. modelId:modelId
  239. },
  240. async: false,
  241. success: function(data) {
  242. activitiModel.reload();
  243. alert(data.message);
  244. }
  245. });
  246. layer.close(index)
  247. });
  248. }
  249. function delActivitiModel() {
  250. var modelId = activitiModel.getSelectedRowId();
  251. if(!modelId){
  252. layer.msg("请选择一条数据");
  253. return;
  254. }
  255. layer.confirm('确定删除?', {
  256. btn: ['确定', '取消'],
  257. }, function(index, layero) {
  258. //按钮【按钮一】的回调
  259. $.ajax({
  260. type: 'GET',
  261. url: "/api/service-activiti/model/model/" + modelId,
  262. data: {
  263. },
  264. async: false,
  265. success: function(data) {
  266. // activitiModel.reload();
  267. activitiModel.reload();
  268. // alert(data.message);
  269. }
  270. });
  271. layer.close(index)
  272. });
  273. };
  274. function addActivitiModel() {
  275. $("#id").val("");
  276. $("#name").val("");
  277. $("#description").val("");
  278. var index = layer.open({
  279. type: 1,
  280. title: '新增页',
  281. area: ['1000px', '550px'],
  282. shade: 0.5,
  283. maxmin: true,
  284. content: form,
  285. id: 'add1',
  286. closeBtn: 1,
  287. btn: ['确定', '关闭'],
  288. yes: function(index, layero) {
  289. var d =form.serialize();
  290. $.ajax({
  291. type: 'post',
  292. async: false,
  293. url: "/api/service-activiti/model",
  294. data: d,
  295. dataType: "json",
  296. success: function(data) {
  297. if(data.success == false) {
  298. alert("操作失败")
  299. } else {
  300. // alert(data.message);
  301. // activitiModel.reload();
  302. activitiModel.reload();
  303. form.hide();
  304. layer.closeAll();
  305. }
  306. }
  307. });
  308. },
  309. zIndex: layer.zIndex,
  310. end: function() {
  311. form.hide();
  312. layer.closeAll();
  313. }
  314. });
  315. }
  316. })($)
  317. </script>