<template>
  <div id="app">
    <BpmnDesignAntd
      ref="BpmnDesignAntd"
      :design="controlForm"
      :penal="penal"
    >
    <!-- 多实例集合属性插槽 -->
      <template #collection="{collection}">
        <a-input @change="aaa" :value="collection"></a-input>
      </template>
    </BpmnDesignAntd>
  </div>
</template>

<script>
import translations from "@/translations";
// 自定义渲染（隐藏了 label 标签）
import CustomRenderer from "@/modules/custom-renderer";
import xmlObj2json from "./utils/xml2json";
// import {BpmnDesignAntd}  from "../package/index.js";
// Vue.use(BpmnDesignAntd);
export default {
  name: "App",
  components: {
    // BpmnDesignAntd
  },
  data() {
    return {
      xmlString: '',
      modeler: null,
      reloadIndex: 0,
      controlDrawerVisible: false,
      translationsSelf: translations,
      controlForm: {
        processId: "",
        processName: "",
        simulation: true,
        labelEditing: false,
        labelVisible: false,
        prefix: "activiti",
        headerButtonSize: "small",
        // additionalModel: []
        // additionalModel: [CustomContentPadProvider, CustomPaletteProvider]
      },
      penal:{
        assignee:[
          { username: 'admin', realname: '管理员' },
          { username: 'xys', realname: 'xys' }
        ]
      },
      addis: {}
    };
  },
  methods: {
    initModeler(modeler) {
      setTimeout(() => {
        this.modeler = modeler;
      }, 10);
    },
    reloadProcessDesigner() {
      this.controlForm.additionalModel = [];
      for (let key in this.addis) {
        if (this.addis[key]) {
          this.controlForm.additionalModel.push(this.addis[key]);
        }
      }
      this.reloadIndex += 1;
      this.modeler = null; // 避免 panel 异常
    },
    changeLabelEditingStatus(status) {
      this.addis.labelEditing = status ? { labelEditingProvider: ["value", ""] } : false;
      this.reloadProcessDesigner();
    },
    changeLabelVisibleStatus(status) {
      this.addis.customRenderer = status ? CustomRenderer : false;
      this.reloadProcessDesigner();
    },
    elementClick(element) {
      console.log('app',element)
      // this.element = element;
      // console.log(xmlObj2json(this.xmlString));
      // console.log(this.modeler);
      // if (element.type === "bpmn:UserTask") {
      //   const moddle = window.bpmnInstances.moddle;
      //   const modeling = window.bpmnInstances.modeling;
      //   const child1 = moddle.create("flowable:ChildField", {
      //     id: "child1",
      //     name: "1",
      //     readable: true
      //   });
      //   const child2 = moddle.create("flowable:ChildField", {
      //     id: "child2",
      //     name: "2",
      //     type: "string",
      //     required: true
      //   });
      //   const formProperty = moddle.create("flowable:FormProperty", {
      //     children: [child1, child2]
      //     // children: []
      //   });
      //   const extensionElements = moddle.create("bpmn:ExtensionElements", {
      //     values: [formProperty]
      //   });
      //   modeling.updateProperties(element, {
      //     extensionElements
      //   });
      // }
    },
    save(data){
      console.log('----',data)
    },
    aaa(){
      this.$refs.BpmnDesignAntd.updateLoop('collection', '${testUser.resolveUsersForTask(execution,"admin")}')
    }
  }
};
</script>

<style lang="less">
body {
  overflow: hidden;
  margin: 0;
  box-sizing: border-box;
}
#app {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: inline-grid;
  grid-template-columns: auto max-content;
}
.demo-control-bar {
  position: fixed;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  .open-control-dialog {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 32px;
    background: rgba(64, 158, 255, 1);
    color: #ffffff;
    cursor: pointer;
  }
}
.control-form {
  .el-radio {
    width: 100%;
    line-height: 32px;
  }
}
body,
body * {
  /* 滚动条 */
  &::-webkit-scrollbar-track-piece {
    background-color: #fff; /*滚动条的背景颜色*/
    -webkit-border-radius: 0; /*滚动条的圆角宽度*/
  }
  &::-webkit-scrollbar {
    width: 10px; /*滚动条的宽度*/
    height: 8px; /*滚动条的高度*/
  }
  &::-webkit-scrollbar-thumb:vertical {
    /*垂直滚动条的样式*/
    height: 50px;
    background-color: rgba(153, 153, 153, 0.5);
    -webkit-border-radius: 4px;
    outline: 2px solid #fff;
    outline-offset: -2px;
    border: 2px solid #fff;
  }
  &::-webkit-scrollbar-thumb {
    /*滚动条的hover样式*/
    background-color: rgba(159, 159, 159, 0.3);
    -webkit-border-radius: 4px;
  }
  &::-webkit-scrollbar-thumb:hover {
    /*滚动条的hover样式*/
    background-color: rgba(159, 159, 159, 0.5);
    -webkit-border-radius: 4px;
  }
}
</style>
