<template>
  <div class="app-container" style="position: relative">
    <div class="fd-nav-content">
      <section class="dingflow-design">
        <div class="zoom">
          <div :class="'zoom-out' + (nowVal == 50 ? ' disabled' : '')" @click="zoomSize(1)"></div>
          <span>{{ nowVal }}%</span>
          <div :class="'zoom-in' + (nowVal == 300 ? ' disabled' : '')" @click="zoomSize(2)"></div>
        </div>
        <div v-loading="loading" class="box-scale" id="box-scale"
          :style="'transform: scale(' + nowVal / 100 + '); transform-origin: 50% 0px 0px;'">
          <nodeWrap :nodeConfig.sync="state.formConfig.auditConfig" :flowPermission.sync="flowPermission"
            :isTried.sync="isTried" :isDetail="state.disabled" :tableId="tableId"
            @nodeClick="val => $emit('nodeClick', val)">
          </nodeWrap>
          <div class="end-node">
            <div class="end-node-circle"></div>
            <div class="end-node-text">{{ $t('flow_end') }}</div>
          </div>
        </div>
      </section>
    </div>
  </div>
</template>
<script>
import NodeWrap from './nodeWrap.vue'
import { getAllDict } from '@/api/workflowManagement'
import { useGlobalPinia } from '@/pinia/global'
const { lang } = useGlobalPinia()

export default {
  inject: ['state'],
  provide() {
    return {
      optionTypeMap: this.optionTypeMap,
      signTypeMap: this.signTypeMap,
      compareMap: this.compareMap,
      nodePropertyMap: this.nodePropertyMap,
      businessColumnMap: this.businessColumnMap
    }
  },
  components: { NodeWrap },
  data() {
    return {
      isTried: false,
      tipList: [],
      tipVisible: false,
      nowVal: 100,
      processConfig: {},
      workFlowDef: {},
      flowPermission: [],
      tableId: '',
      form: {
        companyId: null,
        auditFlow: '1',
      },
      loading: false,
      saving: false,
      optionTypeMap: {},
      signTypeMap: {},
      compareMap: {},
      nodePropertyMap: {},
      businessColumnMap: {}
    }
  },
  mounted() {
    this.getDictMap('30_002', this.optionTypeMap)
    this.getDictMap('30_003', this.nodePropertyMap)
    this.getDictMap('30_004', this.signTypeMap)
    this.getDictMap('30_007', this.compareMap)
    this.state.formConfig.columnConfig
      .filter(item => item.control === 'input-number')
      .forEach(item => this.businessColumnMap[item.propAlias] = item[`label${lang}`])
  },
  methods: {
    getDictMap(dictKey, obj) {
      getAllDict({
        i_sch_field: "ALL",
        i_sch_dict_type: dictKey
      }).then(res => {
        res.dataList.forEach(({ label, value }) => obj[value] = label)
      })
    },
    zoomSize(type) {
      if (type == 1) {
        if (this.nowVal == 50) {
          return
        }
        this.nowVal -= 10
      } else {
        if (this.nowVal == 300) {
          return
        }
        this.nowVal += 10
      }
    },
  },
}
</script>
<style scoped>
.app-container {
  min-height: calc(100vh - 180px);
}

.error-modal-list {
  width: 455px;
}

.fd-nav-container {
  display: inline-block;
  position: relative;
}

.fd-nav-container .ghost-bar {
  position: absolute;
  width: 150px;
  height: 100%;
  left: 0;
  background: #1583f2;
  -webkit-transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.fd-nav-container .ghost-bar:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  margin-left: -5px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 5px 6px;
  border-color: transparent transparent #f6f6f6;
}

.fd-nav-item {
  position: relative;
  cursor: pointer;
  display: inline-block;
  line-height: 60px;
  width: 150px;
  text-align: center;
  white-space: nowrap;
}

.fd-nav-item .order-num {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  border: 1px solid #fff;
  border-radius: 50%;
  margin-right: 6px;
  -webkit-transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.fd-nav-item.active .order-num {
  color: #1583f2;
  background: #fff;
}

.fd-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 997;
  width: 100%;
  height: 60px;
  font-size: 14px;
  color: #fff;
  background: #3296fa;
  display: flex;
  align-items: center;
}

.fd-nav>* {
  flex: 1;
  width: 100%;
}

.fd-nav .fd-nav-left {
  display: -webkit-box;
  display: flex;
  align-items: center;
}

.fd-nav .fd-nav-center {
  flex: none;
  width: 600px;
  text-align: center;
}

.fd-nav .fd-nav-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
}

.fd-nav .fd-nav-back {
  display: inline-block;
  width: 60px;
  height: 60px;
  font-size: 22px;
  border-right: 1px solid #1583f2;
  text-align: center;
  cursor: pointer;
}

.fd-nav .fd-nav-back:hover {
  background: #5af;
}

.fd-nav .fd-nav-back:active {
  background: #1583f2;
}

.fd-nav .fd-nav-back .anticon {
  line-height: 60px;
}

.fd-nav .fd-nav-title {
  width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 15px;
}

.fd-nav a {
  color: #fff;
  margin-left: 12px;
}

.fd-nav .button-publish {
  min-width: 80px;
  margin-right: 15px;
  color: #3296fa;
  border-color: #fff;
}

.fd-nav .button-publish.ant-btn:focus,
.fd-nav .button-publish.ant-btn:hover {
  color: #3296fa;
  border-color: #fff;
  box-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.3);
}

.fd-nav .button-publish.ant-btn:active {
  color: #3296fa;
  background: #d6eaff;
  box-shadow: none;
}

.fd-nav .button-preview {
  min-width: 80px;
  margin-right: 8px;
  color: #fff;
  border-color: #fff;
  background: transparent;
}

.fd-nav .button-preview.ant-btn:focus,
.fd-nav .button-preview.ant-btn:hover {
  color: #fff;
  border-color: #fff;
  background: #59acfc;
}

.fd-nav .button-preview.ant-btn:active {
  color: #fff;
  border-color: #fff;
  background: #2186ef;
}

.fd-nav-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 30px;
}

.ant-btn {
  line-height: 1.5;
  display: inline-block;
  font-weight: 400;
  text-align: center;
  touch-action: manipulation;
  cursor: pointer;
  background-image: none;
  border: 1px solid transparent;
  white-space: nowrap;
  padding: 0 15px;
  font-size: 14px;
  border-radius: 4px;
  height: 32px;
  user-select: none;
  transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  position: relative;
  color: rgba(0, 0, 0, 0.65);
  background-color: #fff;
  border-color: #d9d9d9;
}

.ant-btn>.anticon {
  line-height: 1;
}

.ant-btn,
.ant-btn:active,
.ant-btn:focus {
  outline: 0;
}

.ant-btn>a:only-child {
  color: currentColor;
}

.ant-btn>a:only-child:after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: transparent;
}

.ant-btn:focus,
.ant-btn:hover {
  color: #40a9ff;
  background-color: #fff;
  border-color: #40a9ff;
}

.ant-btn:focus>a:only-child,
.ant-btn:hover>a:only-child {
  color: currentColor;
}

.ant-btn:focus>a:only-child:after,
.ant-btn:hover>a:only-child:after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: transparent;
}

.ant-btn.active,
.ant-btn:active {
  color: #096dd9;
  background-color: #fff;
  border-color: #096dd9;
}

.ant-btn.active>a:only-child,
.ant-btn:active>a:only-child {
  color: currentColor;
}

.ant-btn.active>a:only-child:after,
.ant-btn:active>a:only-child:after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: transparent;
}

.ant-btn.active,
.ant-btn:active,
.ant-btn:focus,
.ant-btn:hover {
  background: #fff;
  text-decoration: none;
}

.ant-btn>i,
.ant-btn>span {
  pointer-events: none;
}

.ant-btn .anticon {
  transition: margin-left 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.ant-btn:active>span,
.ant-btn:focus>span {
  position: relative;
}

.ant-btn>.anticon+span,
.ant-btn>span+.anticon {
  margin-left: 8px;
}

.zoom {
  display: flex;
  position: absolute;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  height: 40px;
  width: 125px;
  right: 40px;
  margin-top: 30px;
  z-index: 10;
}

.zoom .zoom-in,
.zoom .zoom-out {
  width: 30px;
  height: 30px;
  background: #fff;
  color: #c1c1cd;
  cursor: pointer;
  background-size: 100%;
  background-repeat: no-repeat;
}

.zoom .zoom-out {
  background-image: url(https://gw.alicdn.com/tfs/TB1s0qhBHGYBuNjy0FoXXciBFXa-90-90.png);
}

.zoom .zoom-out.disabled {
  opacity: 0.5;
}

.zoom .zoom-in {
  background-image: url(https://gw.alicdn.com/tfs/TB1UIgJBTtYBeNjy1XdXXXXyVXa-90-90.png);
}

.zoom .zoom-in.disabled {
  opacity: 0.5;
}

.dingflow-design {
  width: 100%;
  background-color: #f5f5f7;
  overflow: auto;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
}

.dingflow-design .box-scale {
  transform: scale(1);
  display: inline-block;
  position: relative;
  width: 100%;
  padding: 54.5px 0;
  -webkit-box-align: start;
  -ms-flex-align: start;
  align-items: flex-start;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  min-width: -webkit-min-content;
  min-width: -moz-min-content;
  min-width: min-content;
  background-color: #f5f5f7;
  -webkit-transform-origin: 0 0 0;
  transform-origin: 0 0 0;
}

.dingflow-design .end-node {
  border-radius: 50%;
  font-size: 14px;
  color: rgba(25, 31, 37, 0.4);
  text-align: left;
}

.dingflow-design .end-node .end-node-circle {
  width: 10px;
  height: 10px;
  margin: auto;
  border-radius: 50%;
  background: #dbdcdc;
}

.dingflow-design .end-node .end-node-text {
  margin-top: 5px;
  text-align: center;
}
</style>

<style lang="scss">
@import '@/assets/workflow_scss/form.scss';
@import '@/assets/workflow_scss/iconfont.css';
</style>
