<template>
  <ele-modal
    custom-class="ele-dialog-form long-dialog-form"
    :centered="true"
    :visible.sync="addOrEditDialogFlag"
    :title="title"
    :append-to-body="false"
    :close-on-click-modal="false"
    width="70%"
    :before-close="cancel"
    :maxable="true"
    :resizable="true"
  >
    <ele-pro-table
      ref="table"
      :columns="columns"
      :datasource="datasource"
      height="calc(100vh - 350px)"
      class="dict-table"
      :initLoad="false"
    >
      <!-- <template v-slot:content="{ row }">
        <el-link type="primary" :underline="false" @click="openDetail(row)">
          {{ row.content }}</el-link
        >
      </template> -->
      <template v-slot:files="{ row }">
        <fileMain v-model="row.files" type="view"></fileMain>
      </template>
    </ele-pro-table>
    <div slot="footer">
      <el-button @click="cancel">返回</el-button>
    </div>
  </ele-modal>
</template>
<script>
  import dictMixins from '@/mixins/dictMixins';
  // import fileMain from '@/components/addDoc/index.vue';
  import { getTableList } from '@/api/saleManage/businessFollow';
  export default {
    mixins: [dictMixins],
    // components: { fileMain },

    data() {
      return {
        addOrEditDialogFlag: false,
        columns: [
          {
            columnKey: 'index',
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center',
            showOverflowTooltip: true,
            fixed: 'left'
          },
          {
            prop: 'contactName',
            align: 'center',
            label: '客户名称',
            showOverflowTooltip: true,
            minWidth: 200
          },
          {
            prop: 'opportunityName',
            label: '商机名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 200
          },
          {
            prop: 'content',
            align: 'center',
            label: '跟进内容',
            slot: 'content',
            showOverflowTooltip: true,
            minWidth: 200
          },
          {
            align: 'center',
            prop: 'stageName',
            label: '跟进阶段',
            slot: 'stageName',
            showOverflowTooltip: true,
            minWidth: 100
          },
          {
            prop: 'agreement',
            align: 'center',
            label: '达成共识',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            align: 'center',
            prop: 'linkName',
            label: '客户联系人名称',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            align: 'center',
            prop: 'nextPlan',
            label: '下一步计划',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'followupTime',
            label: '跟进时间',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110,
            formatter: (_row, _column, cellValue) => {
              return this.$util.toDateString(cellValue);
            }
          },
          {
            prop: 'createTime',
            label: '创建时间',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110,
            formatter: (_row, _column, cellValue) => {
              return this.$util.toDateString(cellValue);
            }
          },
          {
            prop: 'files',
            label: '附件',
            align: 'center',
            slot: 'files',
            showOverflowTooltip: true,
            minWidth: 110
          }
        ]
      };
    },
    mounted() {},
    created() {},
    methods: {
      open(params) {
        this.addOrEditDialogFlag = true;
        this.$nextTick(() => {
          this.reload(params);
        });
      },
      /* 表格数据源 */
      datasource({ page, limit, where, order }) {
        return getTableList({
          pageNum: page,
          size: limit,
          ...where
        });
      },

      /* 刷新表格 */
      reload(where) {
        this.$refs.table.reload({ pageNum: 1, where: where });
      },
      //关闭弹窗
      cancel() {
        this.addOrEditDialogFlag = false;
      }
    }
  };
</script>
<style scoped lang="scss"></style>
