TrackHistory.vue 3.47 KB
<template>
  <template>
    <BasicDrawer
      @register="register"
      v-bind="$attrs"
      title="操作记录"
      width="40%"
      :isDetail="true"
      :showDetailBack="false"
      okText="保存"
      :destroyOnClose="true"
    >
      <a-list :pagination="pagination1" className="w-full">
        <template v-for="item in list1" :key="item.id">
          <a-list-item class="list">
            <a-list-item-meta>
              <template #avatar> </template>
              <template #title>
                <div>TRACKER</div>
                <span>{{ item.opinionType }}</span>
              </template>
              <template #description>
                <div class="description">
                  {{ item.showOpinionType }}
                </div>
                <div class="info">
                  <div>操作时间:{{ item.modifyTime }}</div>
                </div>
              </template>
            </a-list-item-meta>
          </a-list-item>
        </template>
      </a-list>

      <!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
      <template #appendFooter>
        <!-- <a-button type="primary" @click="onGoCheckDetail"> 申请权限</a-button> -->
      </template>
    </BasicDrawer>
  </template>
</template>
<script lang="ts" setup>
  import { defineComponent, ref, computed } from 'vue';
  import { Tabs, Progress, Row, Col, List } from 'ant-design-vue';
  import { FormSchema, useForm } from '/@/components/Form/index';

  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import { trackHistory, getOrderOptLog } from '/@/api/project/order';
  import { formatToDateTime } from '/@/utils/dateUtil';

  const list1 = ref([]);
  const total1 = ref(0);
  const page1 = ref(1);
  const orderId = ref('');
  // const activeKey = ref(1);

  function removeTFromTimestamp(timestamp: string): string {
    // 使用 replace 方法将 "T" 替换为空字符串
    return timestamp.replace('T', ' ');
  }

  const getOrderOptLogFunc = async (data, page) => {
    console.log('%c [ data ]-135', 'font-size:13px; background:pink; color:#bf2c9f;', data);
    const res = await trackHistory({ orderId: data, page: page, pageSize: 20 });
    list1.value = res;
    for (const item of list1.value) {
      item.modifyTime = removeTFromTimestamp(item.modifyTime);
      item.showOpinionType = modifyConfirmResult(item.field, item.modifyTime);
    }
  };
  const [register] = useDrawerInner((data) => {
    orderId.value = data.id;
    // const res = await trackHistory({ orderId: data, page: page, pageSize: 20 });
    getOrderOptLogFunc(orderId.value, 1);
  });
  function modifyConfirmResult(Result: string, Time: string): string {
    // 获取 Time 的日期部分,去掉时间
    let datePart = Time.split(' ')[0]; // 获取日期部分
    datePart += ' ';
    // 找到第一个"."的位置
    const dotIndex = Result.indexOf('.');

    // 如果找到了".",则进行拼接
    if (dotIndex !== -1) {
      // 生成新的结果
      const modifiedResult = `${Result.slice(0, dotIndex + 1)}${datePart}${Result.slice(
        dotIndex + 1,
      )}`;
      return modifiedResult;
    }
    // 如果没有找到".",直接返回原始字符串
    return Result;
  }
  const pagination1 = computed(() => {
    return {
      show: true,
      pageSize: 20,
      page: page1.value,
      total: total1.value,
      onChange(cur) {
        console.log(cur);
        getOrderOptLogFunc(orderId.value, 1, cur);
      },
    };
  });
</script>