ConditionCell.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Created by Jacky.gao on 2016/9/19.
  3. */
  4. import {MsgBox} from 'flowdesigner';
  5. import Cell from './Cell.js';
  6. export default class ConditionCell extends Cell{
  7. constructor(row,col,cellData){
  8. super(row,col,cellData);
  9. this.type="condition";
  10. }
  11. initCell(cellData){
  12. const _this=this;
  13. const container=$(`<div></div>`);
  14. this.td.append(container);
  15. const conditionContainer=$('<span><span style="color:#999">无</span></span>');
  16. container.append(conditionContainer);
  17. const configCondition=$(`<span class="attribute-operation" style="color:#3c763d;margin-left: 5px"><i class="glyphicon glyphicon-cog" style="cursor: pointer" title="配置条件"></i></span>`);
  18. container.append(configCondition);
  19. if(cellData){
  20. this.cellCondition=new urule.CellCondition("<div/>");
  21. this.cellCondition.initData(cellData.joint);
  22. conditionContainer.empty();
  23. conditionContainer.append(this.cellCondition.getDisplayContainer());
  24. }
  25. configCondition.click(function () {
  26. const dialogContent=$("<div/>");
  27. if(!_this.cellCondition){
  28. _this.cellCondition=new urule.CellCondition("<div/>");
  29. }
  30. _this.cellCondition.renderTo(dialogContent);
  31. const caption="配置条件";
  32. MsgBox.showDialog(caption,dialogContent,[],[{
  33. name:'hide.bs.modal',
  34. callback:function(){
  35. conditionContainer.empty();
  36. conditionContainer.append(_this.cellCondition.getDisplayContainer());
  37. }
  38. }],true);
  39. });
  40. if(this.row.rowType && this.row.rowType==='condition'){
  41. const _this=this;
  42. const del=$(`<span class="attribute-operation" style="color: #03A9F4;margin-left: 3px"><i class="glyphicon glyphicon-trash" style="cursor: pointer" title="删除当前行"></i></span>`);
  43. container.append(del);
  44. del.click(function () {
  45. bootbox.confirm("真的要删除?",function (result) {
  46. if(!result)return;
  47. _this.row.remove();
  48. });
  49. });
  50. }
  51. }
  52. }