<template>
  <div class="content">
    <!-- 年份、批次、标注类型（在建、已建成、持续变化）、图版号  -->
    <div class="screen-div">
      <div class="screen-item">
        <div class="screen-item-label">年份</div>
        <a-select allowClear style="flex: 1" v-model:value="params.year" :options="yearOptions" />
      </div>
      <div class="screen-item">
        <div class="screen-item-label">标注类型</div>
        <a-select
          allowClear
          style="flex: 1"
          v-model:value="params.is_build_complete"
          :options="markTypeOptions"
        />
      </div>
      <div class="screen-item">
        <div class="screen-item-label">图斑号</div>
        <a-input v-model:value="params.geomid" style="flex: 1" />
      </div>
      <div class="screen-item">
        <div class="screen-item-label">
          <a-button type="primary" @click="getTaskList">查询</a-button>
        </div>
      </div>
      <!-- <div class="screen-button-div">
        <a-button type="primary" size="small">排序(图斑面积)</a-button>
        <a-button type="primary" size="small">排序(耕地面积)</a-button>
        <a-button type="primary" size="small">导出</a-button>
        <a-button type="primary" size="small">我的收藏</a-button>
        <a-button size="small">查询</a-button>
      </div> -->
    </div>
    <div class="data-list-div">
      <div v-for="(item, index) in dataList" :key="index" class="data-list-item">
        <div class="select-mark"></div>
        <Icon
          style="font-size: 30px; color: #bf0000; cursor: pointer"
          icon="gis:poi-alt"
          @click="locationFun(item)"
        />
        <div class="data-list-item-content">
          <div class="item-info-div">
            <div class="item-info-id">{{ item.case_no }}</div>
            <div class="item-info-layout">
              <div>{{ item.address }}</div>
              <div class="item-info-batch">
                <a-tag color="success">{{ item.unitname }}</a-tag>
              </div>
            </div>
          </div>
          <div class="item-data-div">
            <div class="item-data-item" v-if="item.area">
              <div class="item-mark-div sum-mark">总</div>
              {{ item.area }}
            </div>
            <div class="item-data-item" v-if="item.gengdi_area">
              <div class="item-mark-div plowland-mark">耕</div>
              {{ item.gengdi_area }}
            </div>
            <div class="item-data-item" v-if="item.nongyongdi_area">
              <div class="item-mark-div farmland-mark">农</div>
              {{ item.nongyongdi_area }}
            </div>
            <div class="item-data-item" v-if="item.zhongdianquyu_area">
              <div class="item-mark-div adjust-mark">重</div>
              {{ item.zhongdianquyu_area }}
            </div>
            <div class="item-data-item" v-if="item.guotukongjianguihua_area">
              <div class="item-mark-div guihua-mark">规</div>
              {{ item.guotukongjianguihua_area }}
            </div>
            <div class="item-data-item" v-if="item.shengtaibaohuhongxian_area">
              <div class="item-mark-div shengtai-mark">生</div>
              {{ item.shengtaibaohuhongxian_area }}
            </div>
          </div>
        </div>
        <div class="button-div">
          <Icon
            style="font-size: 20px; color: #0960bd; cursor: pointer"
            icon="ant-design:audit-outlined"
            @click="goAudit(item)"
          />
        </div>
      </div>
    </div>
    <div class="pagination-div">
      <a-pagination
        size="small"
        :total="total"
        show-size-changer
        show-quick-jumper
        @change="changePagination"
      />
    </div>
    <a-modal
      width="100%"
      wrap-class-name="full-modal"
      v-model:open="auditOpen"
      title="审核"
      footer=""
      :destroyOnClose="true"
    >
      <template #footer> </template>
      <Audit
        ref="posRef"
        :processId="processId"
        :taskId="taskId"
        :isRead="isRead"
        :type="type"
        @closeModel="closeMolder"
      />
    </a-modal>
  </div>
</template>

<script setup lang="ts">
  import { onMounted, ref } from 'vue';
  import { StarOutlined } from '@ant-design/icons-vue';
  import Icon from '@/components/Icon/Icon.vue';
  import { getLoadTaskDetailList } from '@/api/bootstraps/index';
  import { flowStore } from '@/store/modules/flow';
  import { getDetail } from '@/api/sys/WFSchemeInfo';
  import { Audit } from '@/views/demo/workflow/task/process/page';

  const flowWfDataStore = flowStore();

  const props = defineProps(['areaId']);
  const processId = ref('');
  const taskId = ref('');
  const isRead: any = ref(0);
  const type = ref('');
  const auditOpen = ref(false);
  const params = ref({
    page: 1,
    limit: 10,
    level: null,
    areaid: props.areaId,
    geomid: null,
    year: null,
    is_build_complete: null,
  });
  const markTypeOptions = ref([
    { label: '在建', value: 0 },
    { label: '已建成', value: 1 },
    { label: '持续变化', value: 2 },
  ]);

  const yearOptions = ref([
    { label: '2022', value: '2022' },
    { label: '2021', value: '2021' },
    { label: '2020', value: '2020' },
  ]);
  const dataList = ref([]);
  const total = ref(0);
  async function getTaskList() {
    console.log(params.value);
    const data = await getLoadTaskDetailList(params.value);
    dataList.value = data.items;
    total.value = data.total;
  }
  function changePagination(page, pageSize) {
    console.log(page, pageSize);
    params.value.page = page;
    params.value.limit = pageSize;
    getTaskList();
  }
  async function goAudit(record) {
    let data = await getDetail({ code: record.processcode });
    let scheme = JSON.parse(data.scheme.content);
    let wfData = scheme.wfData;
    flowWfDataStore.setWfDataAll(wfData);
    auditOpen.value = true;
    processId.value = record.processid;
    taskId.value = record.taskeid;
    type.value = record.type;
  }
  async function locationFun(record) {
    console.log(record);
  }
  onMounted(() => {
    getTaskList();
  });
</script>
<style lang="less">
  .full-modal {
    .ant-modal {
      max-width: 100%;
    }

    .ant-modal-content {
      height: calc(80vh);
    }

    .ant-modal-body {
      height: 80%;
    }
  }
</style>
<style lang="less" scoped>
  .content {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .screen-div {
    padding: 10px;
    display: flex;
    width: 100%;
    margin-top: 10px;
    flex-wrap: wrap;
    background: @component-background;
    .screen-item {
      width: 50%;
      display: flex;
      margin-bottom: 3px;
      .screen-item-label {
        width: 75px;
        padding-left: 10px;
        display: flex;
        align-items: center;
        font-size: 15px;
      }
    }
    .screen-button-div {
      display: flex;
      justify-content: space-between;
      width: 100%;
    }
  }
  .data-list-div {
    flex: 1;
    overflow: auto;
    padding: 10px;
    background: @component-background;
    margin-top: 10px;
    .data-list-item {
      display: flex;
      height: 60px;
      align-items: center;
      border-bottom: 1px solid #cdcccc;
      .select-mark {
        width: 3px;
        height: 100%;
      }
      .data-list-item-content {
        padding-left: 5px;
        width: 80%;
        .item-info-div {
          display: flex;
          align-items: center;
          margin-bottom: 5px;
          .item-info-id {
            width: 178px;
            background: #bf2c64;
            color: #fff;
            border-radius: 11px;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 22px;
          }
          .item-info-layout {
            padding-left: 15px;
            display: flex;
            flex: 1;
            justify-content: space-between;
          }
          .item-info-batch {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
        .item-data-div {
          display: flex;
          justify-content: space-between;
          .item-data-item {
            display: flex;
            align-items: center;
            .item-mark-div {
              width: 20px;
              height: 20px;
              color: #fff;
              border-radius: 6px;
              display: flex;
              align-items: center;
              justify-content: center;
              margin-right: 7px;
            }
            .sum-mark {
              background: rgb(46 90 173);
            }
            .plowland-mark {
              background: #01692a;
            }
            .adjust-mark {
              background: #bf0000;
            }
            .farmland-mark {
              background: #7d2bb1;
            }
            .guihua-mark {
              background: #c06b1a;
            }
            .shengtai-mark {
              background: #09b66d;
            }
          }
        }
      }
      .button-div {
        flex: 1;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: space-evenly;
        font-size: 20px;
        .collect-button:hover {
          color: rgb(255, 205, 42);
        }
      }
    }
  }
  .pagination-div {
    background: @component-background;
  }
</style>
