<template>
  <div class="detail-wrap">
    <el-form ref="editForm" :model="pushData">
      <div class="d-header clearfix">
        <div class="fl">
          <i class="el-icon-info"/>
          {{ dataId ? $t1('查看在途推送数据') : $t1('新增在途推送数据') }}
        </div>
        <div class="fr">
          <el-button type="primary" plain class="button-sty" @click="$baseReload()" icon="el-icon-refresh-right">
            {{ $t1('重置') }}
          </el-button>
        </div>
      </div>
      <baseTabs>
        <baseTabPane :label="$t1('基本信息')">
          <template #default>
            <table class="table-detail">
              <tbody>
              <tr>
                <th>{{ $t1('ID') }}</th>
                <td>{{ pushData.id }}</td>
                <th>{{ $t1('任务编码') }}</th>
                <td>{{ pushData.taskCode }}</td>
                <th>{{ $t1('业务方产生时间点') }}</th>
                <td>{{ pushData.generateDate }}</td>
              </tr>
              <tr>
                <th>{{ $t1('组织编码') }}</th>
                <td>{{ pushData.callbackCompanyCode }}</td>
                <th>{{ $t1('数据唯一标识') }}</th>
                <td colspan="3">{{ pushData.sid }}</td>
              </tr>
              <tr>
                <th>{{ $t1('业务数据标识') }}</th>
                <td colspan="7">{{ pushData.transfer }}</td>
              </tr>
              <tr>
                <th>{{ $t1('推送数据') }}</th>
                <td colspan="7">{{ pushData.data }}</td>
              </tr>
              <tr>
                <th>{{ $t1('冗余字段1') }}</th>
                <td>{{ pushData.field1 }}</td>
                <th>{{ $t1('冗余字段2') }}</th>
                <td>{{ pushData.field2 }}</td>
                <th>{{ $t1('冗余字段3') }}</th>
                <td>{{ pushData.field3 }}</td>
              </tr>
              <tr>
                <th>{{ $t1('冗余字段4') }}</th>
                <td>{{ pushData.field4 }}</td>
                <th>{{ $t1('冗余字段5') }}</th>
                <td>{{ pushData.field5 }}</td>
              </tr>
              <tr>
                <th>{{ $t1('备注') }}</th>
                <td colspan="7">{{ pushData.remark }}</td>
              </tr>
              <tr>
                <th>{{ $t1('服务名') }}</th>
                <td colspan="7">{{ pushData.serverName }}</td>
              </tr>
              <tr>
                <th>{{ $t1('创建人') }}</th>
                <td>{{ pushData.createBy }}</td>
                <th>{{ $t1('创建时间') }}</th>
                <td>{{ pushData.createDate }}</td>
                <th class="no"></th>
                <td></td>
                <th class="no"></th>
                <td></td>
              </tr>
              </tbody>
            </table>
          </template>
        </baseTabPane>
      </baseTabs>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'push_dataEdit',
  props: {
    _dataId: [String, Number],
    serverName: String
  },
  components: {},
  data() {
    return {
      isEdit: false,
      tabIndex: 'first',
      dataId: '',
      pushData: {
        enabled: true,
        connectTimeout: 10000,
        readTimeout: 60000,
        script: null,
        postScript: null,
        exeCompanyCode: null
      },
      showCodeEditor: false
    };
  },
  computed: {
    current_prefix() {
      return this.serverName ? `/${this.serverName}` : "";
    }
  },
  created() {
    if (this._dataId && !isNaN(this._dataId)) this.dataId = this._dataId;
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      if (this.dataId && !isNaN(this.dataId)) {
        this.isEdit = true;
        this.$commonHttp({
          url: this.current_prefix + `/push_data/get`,
          method: `post`,
          data: {
            id: this.dataId
          },
          isLoading: true,
          modalStrictly: true,
          success: res => {
            this.pushData = res.objx || {};
          }
        });
      }
    }
  }
};

</script>
