<template>
  <div v-if="permission != 'n'">
    <relevant-flow
      v-if="!isMobile"
      v-model="currentValue"
      :model-name="modelName"
      :permission="permission"
      :name="name"
      :flow-data="flowData"
      :status-str="statusStr"
      :flow-define-def-key-str="flowDefineDefKeyStr"
      :flow-type-id-str="flowTypeIdStr"
    ></relevant-flow>
    <mobile-relevant-flow
      v-else
      v-model="currentValue"
      :model-name="modelName"
      :name="name"
      :permission="permission"
      :flow-data="flowData"
      :status-str="statusStr"
      :flow-define-def-key-str="flowDefineDefKeyStr"
      :flow-type-id-str="flowTypeIdStr"
    ></mobile-relevant-flow>
  </div>
</template>

<script>
  import RelevantFlow from './RelevantFlow.vue'
  import MobileRelevantFlow from './MobileRelevantFlow.vue'
  import permission from '@/mixins/permission.js'
  import mobileMode from '@/mixins/mobileMode.js'
  import inputName from '@/mixins/inputName.js'

  export default {
    name: 'HtAssociateProcesses',
    components: {
      RelevantFlow,
      MobileRelevantFlow,
    },
    mixins: [permission, mobileMode, inputName],
    props: {
      value: String,
      searchConfig: {
        type: Object,
        default: () => {
          return {
            isPaging: true,
            pageSize: 10,
          }
        },
      },
      flowRangeKey: String,
      flowData: {
        type: Object,
        default: () => {
          return {}
        },
      },
      statusStr: {
        type: String,
        default: 'end',
      },
      flowDefineDefKeyStr: {
        type: String,
        default: '',
      },
      flowTypeIdStr: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        currentValue: '',
      }
    },
    watch: {
      value: {
        handler(val) {
          this.currentValue = val
        },
        immediate: true,
      },
      currentValue(val) {
        this.$emit('input', val)
      },
    },
    mounted() {
      if (this.isMobile) {
        this.addMobileTopLabelClass('mobile-relevant-flow__form-item')
      }
    },
  }
</script>

<style lang="scss" scoped>
  ::v-deep .el-dialog__body {
    padding: 0px 20px;
    color: #666;
    font-size: 14px;
    word-break: break-all;

    .record-content {
      margin-top: 20px;
    }
    .relevant-flow_page {
      text-align: right;
      margin-top: 20px;
      &.mobile {
        text-align: center;
      }
    }
  }
  .searchStyle {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 20px;
  }
  .subject {
    cursor: pointer;
    color: $base-color-blue;
  }
  ::v-deep .mobile-related-dialog {
    height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .el-dialog__body {
      flex: 1;
      overflow: auto;
      .mobile-search {
        display: flex;
        align-items: center;
        padding-top: 20px;
        .mobile-search_input {
          flex: 1;
        }
      }
    }
    .dialog-footer {
      text-align: center;
    }
  }
  ::v-deep .el-pagination__editor.el-input {
    width: 50px !important;
  }
</style>
