<template>
  <div :class="$style.wrapHeight">
    <div :class="$style.rowHeight">
      <sd-worktree
        ref="my-communication"
        :data-type="activeKey"
        @treeSelectd="treeSelectd"
      ></sd-worktree>
      <div :class="$style.rightcard">
        <a-card>
          <sd-data-table
            ref="feedback"
            data-url="api/flow-mobile/v1/communicatecontroller/communicate/mylist"
            :columns="columns"
            show-selection
            :row-key="'instId'"
            :filter-expressions="expressions['my-communicatio']"
            :search-fields="['title']"
            @rowClick="rowClick"
          >
            <span slot="sendDate" slot-scope="sendDate">{{
              sendDate | sdDateFormat('YYYY-MM-DD HH:mm:ss')
            }}</span>
          </sd-data-table>
        </a-card>
      </div>
    </div>
  </div>
</template>

<script>
import crossWindowWatcher from '@/common/services/cross-window-watcher'
import flowcenter from './sd-flowcenter-mixins'
import components from './_import-components/sd-feedback-list-import'

export default {
  name: 'SdFeedbackList',
  metaInfo: {
    title: '我的沟通记录',
  },
  components,
  mixins: [flowcenter],
  data() {
    return {
      columns: [
        {
          title: '标题',
          dataIndex: 'title',
          sdClickable: true,
        },
        {
          title: '创建时间',
          dataIndex: 'sendDate',
          scopedSlots: { customRender: 'sendDate' },
        },
        {
          title: '发起沟通环节',
          dataIndex: 'stepName',
        },
      ],
      expressions: { 'my-communicatio': [] },
      treeId: { 'my-communicatio': '' },
      activeKey: 'my-communication',
    }
  },
  methods: {
    // 查看详情
    rowClick(record) {
      const url = '/sd-webflow/pages/communication/' + record.topCommId
      crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
        if (refreshFlag) this.refresh()
      })
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.wrap-height {
  height: 100%;
  .row-height {
    display: flex;
    flex: auto;
    height: 100%;
    .rightcard {
      flex: 1;
      width: calc(100% - 20%);
      height: 100%;
    }
  }
}
</style>
