Newer
Older
vue3-front / src / views / business / subpackage / approve / list.vue
bairujie on 7 Apr 2023 8 KB 合同管理页面接口
<!-- 分包方资格审批列表 -->
<script lang="ts" setup name="approve">
import type { Ref } from 'vue'
import { ElLoading, ElMessage } from 'element-plus'
import type { DateModelType } from 'element-plus'
import type { IListQueryApprove } from '../subpackage-interface'
import { printJSON } from '@/utils/printUtils'
import { exportFile } from '@/utils/exportUtils'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { getDictByCode } from '@/api/system/dict'
import type { dictType } from '@/views/device/receive/receive'
import type { IMenu } from '@/components/buttonBox/buttonBox'
import ButtonBox from '@/components/buttonBox/buttonBox.vue'
import { getListPage } from '@/api/business/subpackage/approval'

const $router = useRouter()
const { proxy } = getCurrentInstance() as any
const TabActiveButton = 'SubpackageApproveActive'
const timeRange = ref<[DateModelType, DateModelType]>(['', ''])

// 查询条件
const listQuery: Ref<IListQueryApprove> = ref({
  applicantEndTime: '', // 开始时间
  applicantName: '', // 申请人名称
  applicantStartTime: '', // 结束时间
  approvalStatus: '', // 申请状态
  formId: '', // 表单id
  outsourcerName: '', // 	分包方名称
  projectName: '', // 分包项目名称
  projectNo: '', // 分包项目编号
  businessSize: '', //	业务规模-字典code
  evaluation: '', // 	整体评价-字典code
  grade: '', // 	履约评级-字典code
  outsourcerNo: '', // 	分包方编号
  offset: 1,
  limit: 20,
})
const loadingTable = ref(false)
const menu = ref<IMenu[]>([]) // 审批状态按钮组合
const active = ref('')
// 表头
const columns = ref<TableColumn[]>([
  { text: '分包项目编号', value: 'interchangeCode', align: 'center', width: '160px' },
  { text: '公司名称', value: 'customerNo', align: 'center', width: '160px' },
  { text: '公司规模', value: 'customerName', align: 'center', width: '160px' },
  { text: '业务规模', value: 'reciever', align: 'center', width: '180px' },
  { text: '履约评级', value: 'deliverer', align: 'center', width: '180px' },
  { text: '整体评价', value: 'deliverTime', align: 'center', width: '180px' },
  { text: '业务内容', value: 'deliverTime', align: 'center', width: '180px' },
  { text: '公司地址', value: 'deliverTime', align: 'center', width: '180px' },
  { text: '创建时间', value: 'deliverTime', align: 'center', width: '180px' },
  { text: '审批状态', value: 'deliverTime', align: 'center', width: '180px' },
])
const list = ref([])
const total = ref(0)

// 时间变更
watch(timeRange, (val) => {
  if (val) {
    listQuery.value.applicantStartTime = `${val[0]}`
    listQuery.value.applicantEndTime = `${val[1]}`
  }
  else {
    listQuery.value.applicantStartTime = ''
    listQuery.value.applicantEndTime = ''
  }
})

// 数据查询
function fetchData(isNowPage = false) {
  loadingTable.value = true
  if (!isNowPage) {
    // 是否显示当前页,否则跳转第一页
    listQuery.value.offset = 1
  }
  // 模拟数据
  loadingTable.value = false
  getListPage(listQuery.value).then((response) => {
    list.value = response.data.rows
    let interfaceStr = ''
    for (const key in response.data.rows[0]) {
      const item = response.data.rows[0][key]
      interfaceStr += `${key}:${typeof (item)}\n`
    }
    console.log(interfaceStr)
    total.value = parseInt(response.data.total)
    loadingTable.value = false
  })
}

// 清除条件
const clearList = () => {
  listQuery.value = {
    applicantEndTime: '', // 开始时间
    applicantName: '', // 申请人名称
    applicantStartTime: '', // 结束时间
    approvalStatus: '', // 申请状态
    formId: '', // 表单id
    outsourcerName: '', // 	分包方名称
    projectName: '', // 分包项目名称
    projectNo: '', // 分包项目编号
    businessSize: '', //	业务规模-字典code
    evaluation: '', // 	整体评价-字典code
    grade: '', // 	履约评级-字典code
    outsourcerNo: '', // 	分包方编号
    offset: 1,
    limit: 20,
  }
  timeRange.value = ['', '']
  fetchData()
}

// 搜索
const searchList = () => {
  fetchData(true)
}
// 新建
const add = () => {

}
// 导出
const exportAll = () => {

}
// 打印
const printList = () => {

}
// 分页
const changePage = () => {

}
// 选中
const handleSelectionChange = () => {

}
// 详情或者编辑
const handleEdit = (row, status) => {

}
// 取消
const handleCancle = (row) => {

}
// 获取字典值
const getDict = async () => {
  // 审批状态
  const res = await getDictByCode('approvalStatus')
  // 制作右上角的菜单
  res.data.forEach((item: dictType) => {
    if (item.name === '全部' || item.name === '草稿箱'
      || item.name === '待审批' || item.name === '审批中'
      || item.name === '已通过' || item.name === '未通过'
      || item.name === '已取消') {
      menu.value.push({
        name: item.name,
        id: `${item.value}`,
      })
    }
  })
}
// 切换tab状态
const changeCurrentButton = (val: string) => {
  active.value = val
  window.sessionStorage.setItem(TabActiveButton, val)
  clearList()
}

onMounted(async () => {
  await getDict()
  if (window.sessionStorage.getItem(TabActiveButton) !== 'undefined' && window.sessionStorage.getItem(TabActiveButton) !== '' && window.sessionStorage.getItem(TabActiveButton) !== null) {
    active.value = window.sessionStorage.getItem(TabActiveButton)!
  }
  else {
    active.value = menu.value.find(item => item.name === '全部')!.id as string // 全部
  }
})
</script>

<template>
  <div>
    <!-- 布局 -->
    <app-container>
      <search-area :need-clear="true" @search="searchList" @clear="clearList">
        <search-item>
          <el-input v-model.trim="listQuery.outsourcerNo" placeholder="分包项目编号" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.outsourcerName" placeholder="公司名称" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.businessSize" placeholder="业务规模" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.grade" placeholder="履约评级" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.evaluation" placeholder="整体评价" class="short-input" clearable />
        </search-item>
      </search-area>
      <table-container>
        <template #btns-right>
          <icon-button icon="icon-add" title="新建" type="primary" @click="add" />
          <icon-button icon="icon-export" title="导出" type="primary" @click="exportAll" />
          <icon-button icon="icon-print" title="打印" type="primary" @click="printList" />
        </template>
        <normal-table
          :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable"
          is-showmulti-select @change="changePage" @multi-select="handleSelectionChange"
        >
          <template #preColumns>
            <el-table-column label="序号" width="55" align="center">
              <template #default="scope">
                {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }}
              </template>
            </el-table-column>
          </template>
          <template #columns>
            <el-table-column label="操作" align="center" fixed="right" width="120">
              <template #default="{ row }">
                <el-button size="small" type="primary" link @click="handleEdit(row, 'edit')">
                  编辑
                </el-button>
                <el-button size="small" link type="primary" @click="handleEdit(row, 'detail')">
                  详情
                </el-button>
                <el-button size="small" link type="danger" @click="handleCancle(row.id)">
                  取消
                </el-button>
              </template>
            </el-table-column>
          </template>
        </normal-table>
      </table-container>
      <button-box :active="active" :menu="menu" @changeCurrentButton="changeCurrentButton" />
    </app-container>
  </div>
</template>