<template>
  <!-- 协议详情-->
  <a-modal class="add-custom custom-detail"
           title="协议详情"
           centered
           v-model:visible="visible"
           :maskClosable="false"
           @cancel="cancel"
           width="890px">
    <template #footer>
      <a-button key="submit"
                type="primary"
                @click="cancel">关闭</a-button>
    </template>
    <a-form class="inlineForm">
      <fieldset class="formFieldSet">
        <legend>协议信息</legend>
        <Des :list="desList"
             @onClick="getContent(selectedRow.agreementcontent)" />
      </fieldset>
      <fieldset class="formFieldSet">
        <legend>修改流水</legend>
        <div class="tableDatas tableContextCenter">
          <a-table class="dialogTable"
                   :columns="columns"
                   :data-source="tableList"
                   :pagination="false">
            <!-- 协议类型-->
            <template #agreementcontent="{ record }">
              <a @click="getContent(record.agreementcontent)">查看</a>
            </template>
          </a-table>
        </div>
      </fieldset>
    </a-form>
  </a-modal>
  <a-modal class="commonModal addSpotVariety"
           title="协议内容"
           centered
           v-model:visible="visibleContent"
           :maskClosable="false"
           @cancel="visibleContent = false"
           width="890px">
    <a-textarea class="dialogInput"
                v-model:value="content"
                style="width: 100%"
                placeholder="请输入协议内容"
                readonly
                :autosize="{ minRows: 8, maxRows: 24 }" />
    <template #footer>
      <a-button key="submit"
                type="primary"
                @click="visibleContent = false">关闭</a-button>
    </template>
  </a-modal>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { Des, handleDesList } from '@/common/components/commonDes';
import { QhjAgreementChangeLog, QhjAgreementConfig } from '@/services/go/ermcp/qhj/interface';
import { queryTableList } from '@/common/setup/table';
import { queryAgreementChangeLog } from '@/services/go/ermcp/qhj';
import { _closeModal } from '@/common/setup/modal/modal';
import { handleAgreementLog } from '../setup';

export default defineComponent({
    emits: ['cancel', 'update'],
    name: 'custom-detail',
    components: { Des },
    props: {
        selectedRow: {
            type: Object as PropType<QhjAgreementConfig>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = _closeModal(context);
        const { desList, getDesList } = handleDesList();
        const { columns, visibleContent, content, getContent, list } = handleAgreementLog(props.selectedRow);
        const { loading, tableList, queryTable } = queryTableList<QhjAgreementChangeLog>();

        queryTable(queryAgreementChangeLog, { agreementid: props.selectedRow.agreementid });

        getDesList(list);

        return {
            visibleContent,
            content,
            getContent,
            columns,
            loading,
            cancel,
            desList,
            visible,
            tableList,
        };
    },
});
</script>

<style lang="less">
.custom-detail {
    .ant-form.inlineForm {
        margin-top: 20px;
    }
    .upload {
        .look {
            margin-left: 0;
        }
    }
}
</style>;
