Newer
Older
HuangJiPC / src / pages / views / publicService / report.vue
@zhangdeliang zhangdeliang on 21 Jun 10 KB update
<template>
  <!-- 公众举报 -->
  <div class="reportPage">
    <div class="searchBoxs">
      <n-space>
        <n-input v-model:value="searchVal1" placeholder="请输入举报人微信昵称" style="width: 200px" clearable> </n-input>
        <n-select v-model:value="searchVal2" placeholder="请选择是否转工单" style="width: 150px" :options="ifgdOptions" clearable>
        </n-select>
        <n-date-picker
          v-model:value="timeRange"
          clearable
          start-placeholder="举报开始时间"
          end-placeholder="举报结束时间"
          type="datetimerange"
        />
        <n-button type="primary" @click="handleClick('search')">
          <template #icon>
            <n-icon><Search /></n-icon>
          </template>
          搜索
        </n-button>
      </n-space>
    </div>
    <!-- 表格 -->
    <div class="tableBox">
      <n-data-table
        :bordered="false"
        :max-height="700"
        striped
        :columns="columns"
        :data="tableData"
        :loading="tableLoading"
        :remote="true"
        :pagination="pagination"
      >
      </n-data-table>
    </div>
    <!-- 详情弹窗 -->
    <n-modal
      title="举报信息详情"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '500px' }"
      v-model:show="modalShow"
    >
      <div class="reportDetai">
        <div class="part">
          <div class="title">举报人微信昵称:</div>
          <div class="content">{{ nickName }}</div>
        </div>
        <div class="part">
          <div class="title">举报时间:</div>
          <div class="content">{{ detailData.createTime }}</div>
        </div>
        <div class="part">
          <div class="title">举报地点:</div>
          <div class="content">{{ detailData.address }}</div>
        </div>
        <div class="part">
          <div class="title">问题照片:</div>
          <div class="content">
            <n-image
              width="100"
              src="http://newfiber-cqjb-1255570142.cos.ap-chengdu.myqcloud.com/huangji/upload/file/2208231115291416323023.png"
            >
            </n-image>
          </div>
        </div>
        <div class="part">
          <div class="title">问题描述:</div>
          <div class="content">{{ detailData.describ }}</div>
        </div>
      </div>
    </n-modal>
  </div>
</template>

<script>
import { toRefs, onMounted, reactive, h, ref } from 'vue';
import { Search, Add } from '@vicons/ionicons5';
import { NButton, NImage } from 'naive-ui';
import { gzjbSearch, gzjbToBill, gzjbDetail, gzjbDelete } from '@/services';
import { formatDate } from '@/utils/util';

export default {
  name: 'reportPage',
  components: { Search, Add, NButton },
  setup() {
    const allData = reactive({
      searchVal1: null,
      searchVal2: null,
      timeRange: null,
      modalShow: false,
      detailData: {},
      nickName: '',
      ifgdOptions: [
        { value: 1, label: '是' },
        { value: 0, label: '否' },
      ],
      tableData: [],
      tableLoading: true,
      columns: [
        {
          title: '序号',
          align: 'center',
          width: '80',
          render(row, index) {
            return (paginationReactive.page - 1) * paginationReactive.pageSize + index + 1;
          },
        },
        {
          title: '举报人微信头像',
          align: 'center',
          render(row) {
            let imgs = h(NImage, {
              width: 50,
              height: 50,
              style: 'margin-right:5px;border-radius:50%;',
              src: row.avatar
                ? row.avatar
                : 'https://newfiber-cqjb-1255570142.cos.ap-chengdu.myqcloud.com/huangji/upload/file/2302031457231601406063.jpg',
            });
            return imgs;
          },
        },
        { title: '举报人微信昵称', align: 'center', key: 'nick' },
        { title: '举报内容', align: 'center', key: 'describ' },
        {
          title: '是否转工单',
          align: 'center',
          key: 'dealStatus',
          render(row) {
            return row.dealStatus == 0 ? '否' : '是';
          },
        },
        {
          title: '现场图片',
          align: 'center',
          render(row) {
            let lists = row.fileList == null ? [] : row.fileList;
            let value = [];
            lists.map((item, index) => {
              let imgs = h(NImage, {
                width: 50,
                height: 50,
                style: 'margin-right:5px;',
                src: item.fileCloudStorageKey,
              });
              value.push(imgs);
            });
            return value;
          },
        },
        { title: '举报时间', align: 'center', key: 'createTime' },
        {
          title: '操作',
          key: 'actions',
          width: '260',
          align: 'center',
          render(row) {
            let arrs = [...allData.actionColumn];
            let obj1 = {
              size: 'small',
              btnType: 'primary',
              type: 'zhuangd',
              default: '转工单',
            };
            if (row.dealStatus == 0) {
              arrs.push(obj1);
            }
            const btn = arrs.map((item, index) => {
              return h(
                NButton,
                {
                  text: true,
                  size: item.size,
                  style: {
                    margin: '10px',
                  },
                  type: item.btnType,
                  onClick: () => handleClick(item.type, row),
                },
                {
                  default: () => {
                    return item.default;
                  },
                }
              );
            });
            return btn;
          },
        },
      ],
      actionColumn: [
        {
          size: 'small',
          btnType: 'success',
          type: 'detail',
          default: '详情',
        },
        {
          size: 'small',
          btnType: 'error',
          type: 'delete',
          default: '删除',
        },
      ],
      workDetail: {
        jobName: '',
        jobPerson: '',
        jobStepDesc: '',
        jobStatus: '',
      },
      tableData2: [],
      columns2: [
        {
          title: '序号',
          align: 'center',
          width: '60',
          render(row, index) {
            return (paginationReactive.page - 1) * paginationReactive.pageSize + index + 1;
          },
        },
        { title: '任务名称', align: 'center', key: 'taskName' },
        { title: '任务执行人', align: 'center', key: 'taskAssignee' },
        { title: '审批意见', align: 'center', key: 'remark' },
        {
          title: '创建时间',
          align: 'center',
          key: 'gmtCreated',
          width: '160',
        },
      ],
    });
    //分页
    const paginationReactive = reactive({
      page: 1,
      pageSize: 10,
      showSizePicker: true,
      pageSizes: [10, 20, 50],
      showQuickJumper: true,
      pageCount: 0,
      itemCount: 0,
      prefix: () => {
        return '共 ' + paginationReactive.itemCount + ' 项';
      },
      onChange: (page) => {
        paginationReactive.page = page;
        getTableData();
      },
      onPageSizeChange: (pageSize) => {
        paginationReactive.pageSize = pageSize;
        paginationReactive.page = 1;
        getTableData();
      },
    });
    const getTableData = async () => {
      let startDate = allData.timeRange ? formatDate(allData.timeRange[0]) : null;
      let endDate = allData.timeRange ? formatDate(allData.timeRange[1]) : null;
      allData.tableLoading = true;
      let pramas = {
        current: paginationReactive.page,
        size: paginationReactive.pageSize,
        name: allData.searchVal1,
        billType: allData.searchVal2,
        startDate: startDate,
        endDate: endDate,
      };
      let res = await gzjbSearch(pramas);
      if (res && res.code == 200) {
        allData.tableData = res.data.records;
        paginationReactive.pageCount = res.data.pages;
        paginationReactive.itemCount = res.data.total;
      }
      allData.tableLoading = false;
    };
    // 点击事件
    const handleClick = async (type, row) => {
      switch (type) {
        case 'search':
          paginationReactive.page = 1;
          getTableData();
          break;
        case 'detail':
          allData.modalShow = true;
          allData.nickName = row.nick;
          getDetailData(row);
          break;
        case 'zhuangd':
          // 转工单
          $dialog.success({
            title: '转工单',
            content: '确定转维修工单?',
            positiveText: '确定',
            negativeText: '取消',
            onPositiveClick: async () => {
              // 确定
              let res = await gzjbToBill({ id: row.id });
              if (res && res.code === 200) {
                $message.success('操作成功');
                getTableData();
              } else {
                $message.error(res.msg);
                getTableData();
              }
            },
            onNegativeClick: () => {
              // 取消
            },
          });
          break;
        case 'delete':
          $dialog.info({
            title: '提示',
            content: `确定删除该数据吗?`,
            positiveText: '确定',
            negativeText: '取消',
            onPositiveClick: () => {
              let ids = [row.id];
              dataDel(ids);
            },
          });
          break;
      }
    };
    // 删除数据
    async function dataDel(ids) {
      let res = await gzjbDelete({ ids: ids });
      if (res && res.code === 200) {
        $message.success('删除成功');
        getTableData();
      }
    }
    // 获取详情数据
    async function getDetailData(row) {
      let params = { id: row.id };
      let res = await gzjbDetail(params);
      if (res && res.code == 200) {
        allData.detailData = res.data;
      }
    }
    onMounted(() => {
      getTableData();
    });
    return {
      ...toRefs(allData),
      pagination: paginationReactive,
      handleClick,
      getTableData,
    };
  },
};
</script>

<style lang="less">
.reportPage {
  width: 100%;
  .searchBoxs {
    margin: 10px;
  }
}
.reportDetai {
  margin: 20px auto;
  display: flex;
  flex-wrap: wrap;
  padding-left: 20px;

  .title {
    width: 120px;
    color: #00e6e6;
    font-size: 15px;
  }
  .part {
    display: flex;
    width: 100%;
    margin-bottom: 10px;
    .content {
      flex: 1;
      .n-image {
        margin-right: 10px;
      }
    }
  }
}
</style>