settlement.vue 14.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
<template>
  <div class="app-container">
    <div class="from-Card">
      <el-form
        v-show="showSearch" ref="queryRef" size="small" :model="queryParams" :inline="true"
        label-position="top"
      >
        <el-row style="width: 100%;">
          <el-col :span="4">
            <el-form-item label="结算编号" prop="payCode">
              <el-input
                v-model="queryParams.payCode"
                placeholder="请输入结算编号"
                clearable
                style="width: 100%;"
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col v-show="queryParams.type == '1'" :span="4">
            <el-form-item label="缴费编号" prop="examCodes">
              <el-input
                v-model="queryParams.examCodes"
                placeholder="请输入缴费编号"
                clearable
                style="width: 100%;"
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="缴费名称" prop="name">
              <el-input
                v-model="queryParams.name"
                placeholder="请输入缴费名称"
                clearable
                style="width: 100%;"
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="缴费状态" prop="payStatus">
              <el-select v-model="queryParams.payStatus" style="width: 100%;" clearable @change="handleQuery">
                <el-option label="全部" value="" />
                <el-option label="未上传凭证" value="4" />
                <el-option label="已上传凭证" value="5" />
                <el-option label="已结算" value="3" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="缴费单位" prop="memName">
              <el-input
                v-model="queryParams.memName"
                placeholder="请输入缴费单位"
                clearable
                style="width: 100%;"
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8" :hidden="showCollect">
            <el-form-item label="缴费日期" prop="payTimeRange">
              <el-date-picker
                v-model="queryParams.payTimeRange"
                clearable
                type="daterange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                value-format="YYYY-MM-DD"
                style="width: 100%;"
                @change="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8" :hidden="showCollect">
            <el-form-item label="结算日期" prop="settleTimeRange">
              <el-date-picker
                v-model="queryParams.settleTimeRange"
                clearable
                type="daterange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                value-format="YYYY-MM-DD"
                style="width: 100%;"
                @change="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="2" />
          <el-col :span="8" :hidden="showCollect">
            <el-form-item label="审核日期" prop="verityTimeRange">
              <el-date-picker
                v-model="queryParams.verityTimeRange"
                clearable
                type="daterange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                value-format="YYYY-MM-DD"
                style="width: 100%;"
                @change="handleQuery"
              />
            </el-form-item>
          </el-col>
          <div class="po-r-btns">
            <el-button size="small" type="primary" @click="handleQuery">搜索</el-button>
            <el-button size="small" @click="resetQuery">重置</el-button>
            <el-button
              v-if="showCollect" size="small" type="primary" link icon="ArrowDown"
              @click="showCollect=!showCollect"
            >展开</el-button>
            <el-button
              v-else size="small" type="primary" link icon="ArrowUp"
              @click="showCollect=!showCollect"
            >收起</el-button>
          </div>
        </el-row>
      </el-form>
      <el-row justify="space-between">
        <div>
          <el-button
            type="primary" :icon="Wallet"
            :disabled="multiple"
            @click="settleAll"
          >批量结算</el-button>
          <el-button type="warning" :icon="Download" @click="handleExport">导出</el-button>
        </div>
      </el-row>
    </div>
    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5" />
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
    </el-row> -->
    <div class="table">
      <el-table v-loading="loading" :row-class-name="tableRowClassName" border :data="infoList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" :selectable="selectable" />
        <el-table-column type="index" width="55" align="center" label="序号" />
        <el-table-column label="结算编号" align="center" prop="payCode" min-width="120" :show-overflow-tooltip="true">
          <template #default="scope">
            <el-button link type="primary" :disabled=" scope.row.verityStatus=='2'||scope.row.verityStatus=='3'" @click="handlePaymentView(scope.row) ">
              {{ scope.row.payCode }}
            </el-button>
          </template>
        </el-table-column>
        <el-table-column label="缴费名称" align="center" prop="name" :show-overflow-tooltip="true" min-width="250" />
        <el-table-column label="缴费单位" align="center" prop="memberName" :show-overflow-tooltip="true" min-width="100" />
        <el-table-column label="审批状态" align="center" prop="verityStatusStr" min-width="100">
          <template #default="scope">
            <span
              :class="{
                'text-success':scope.row.verityStatus=='1',
                'text-danger':scope.row.verityStatus=='2',
                'text-warning':scope.row.verityStatus=='3'
              }"
            >{{ scope.row.verityStatusStr }}</span>
          </template>
        </el-table-column>
        <el-table-column label="缴费状态" align="center" prop="payStatusStr" min-width="100">
          <template #default="scope">
            <div
              :class="{
                ' text-success':scope.row.payStatusStr=='已上传凭证',
                'text-danger':scope.row.payStatusStr=='未上传凭证',
                'text-warning':scope.row.payStatusStr=='已结算'
              }"
            >
              {{ scope.row.payStatusStr }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="人数合计" align="center" prop="totalNum" min-width="80" />
        <el-table-column label="费用合计" align="center" prop="totalAmount" min-width="80" />
        <el-table-column label="缴费单创建日期" align="center" prop="submitTime" min-width="120">
          <template #default="scope">
            <span>{{ parseTime(scope.row.submitTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>

        <el-table-column label="缴费日期" align="center" prop="payTime" min-width="100">
          <template #default="scope">
            <span>{{ parseTime(scope.row.payTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="结算日期" align="center" prop="settleTime" min-width="100">
          <template #default="scope">
            <span>{{ parseTime(scope.row.settleTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="审核日期" align="center" prop="payTime" min-width="100">
          <template #default="scope">
            <span>{{ parseTime(scope.row.verityDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="260" fixed="right" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button type="primary" @click="handleView(scope.row)">查看</el-button>
            <el-button color="#13B5B1" style="--el-color-black:#fff;" :disabled="!(scope.row.payStatus == '3' || scope.row.payStatus == '5')" @click="downloadPayment(scope.row)">下载凭证</el-button>
            <el-button v-if="scope.row.payStatus != '3'" :disabled="!((scope.row.verityStatus == '1'||scope.row.verityStatus == '0') && scope.row.payStatus == '5')" type="warning" @click="settle(scope.row,0)">结算</el-button>
            <el-button v-if="scope.row.payStatus == '3'" :disabled="!(scope.row.verityStatus == '1')" type="danger" @click="settle(scope.row,1)">取消结算</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div v-show="total>0" class="totalCost">
        费用合计:<span>{{ statistical.totalCost?.toFixed(2) }} </span>
        人数合计:<span>{{ statistical.totalNum }} </span>
      </div>
      <pagination
        v-show="total>0"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        :total="total"
        @pagination="getList"
      />
    </div>
    <view-payment ref="viewPaymentRef" />
    <view-merge ref="viewMergeRef" />
    <el-link v-show="false" ref="payCertRef" :href="fillImgUrl(currPayCert.url)" :download="currPayCert.name" target="_blank">{{ currPayCert.name }}</el-link>
  </div>
</template>

<script>
let pageName
if (location.href.indexOf('/level/') > -1) {
  pageName = 'Level_Settlement'
} else if (location.href.indexOf('/rank/') > -1) {
  pageName = 'Rank_Settlement'
} else if (location.href.indexOf('/beyond/') > -1) {
  pageName = 'Beyond_Settlement'
}

export default {
  name: pageName
}
</script>

<script setup>
import { getCurrentInstance, reactive } from '@vue/runtime-core'
import { computed, nextTick, onMounted, ref, toRefs } from 'vue'
import { parseTime } from '@/utils/ruoyi'
import useUserStore from '@/store/modules/user'
import { paymentList, settlePayment } from '@/api/exam/payment'
import ViewPayment from './components/paymentView'
import { useRoute } from 'vue-router'
import { Download, Wallet } from '@element-plus/icons-vue'
import ViewMerge from '@/views/exam/level/approval/components/mergeView'
import _ from 'lodash'

const { proxy } = getCurrentInstance()
const route = useRoute()
const deptType = computed(() => useUserStore().deptType)
const showCollect = ref(true)
const infoList = ref([])
const loading = ref(true)
const showSearch = ref(true)
const multiple = ref(true)
const total = ref(0)
let ids = []
const currPayCert = ref({})
const statistical = ref({})

const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    name: undefined,
    payCode: undefined,
    memName: undefined,
    submitTimeRange: undefined,
    settleTimeRange: undefined,
    payTimeRange: undefined,
    status: undefined,
    payStatus: undefined,
    examCodes: undefined
    // type: '1'
  },
  transcript: [],
  payId: undefined
})
const { queryParams } = toRefs(data)

onMounted(() => {
  if (route.path.indexOf('level') > -1) {
    queryParams.value.type = '1'
  } else if (route.path.indexOf('rank') > -1) {
    queryParams.value.type = '2'
  } else if (route.path.indexOf('beyond') > -1) {
    queryParams.value.type = '3'
  }

  getList()
})

// // 背景色
const tableRowClassName = ({
  row,
  rowIndex
}) => {
  if (row.payStatusStr == '已结算') {
    return 'success-row'
  }
}


/** 查询考级信息列表 */
function getList() {
  loading.value = true
  statistical.value = {
    totalCost: 0,
    totalNum: 0
  }

  paymentList(queryParams.value).then(response => {
    infoList.value = response.rows
    total.value = response.total
    loading.value = false

    _.each(infoList.value, (info) => {
      statistical.value.totalCost += (info.totalAmount * 1)
      statistical.value.totalNum += (info.totalNum * 1)
    })
  })
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids = selection.map(item => item.payId)
  multiple.value = !selection.length
}

function selectable(row) {
  if (deptType.value == '1' && (row.payStatus == '2' || row.payStatus == '5')) {
    return true
  } else {
    return false
  }
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef')
  handleQuery()
}

function handleView(row) {
  // proxy.$refs['viewPaymentRef'].open(row.payId)
  proxy.$refs['viewMergeRef'].open(null, row)
}

function handlePaymentView(row) {
  proxy.$refs['viewPaymentRef'].open(row.payId, queryParams.value.type)
}

function downloadPayment(row) {
  // debugger
  try {
    const payCert = JSON.parse(row.payCert)
    currPayCert.value = payCert[0]
    // console.log(currPayCert.value)
    nextTick(() => {
      proxy.$refs['payCertRef'].$el.click()
    })
  } catch (e) {
    currPayCert.value = {}
    proxy.$modal.msgError('下载失败')
  }
}

// 结算缴费单
function settle(row, flag) {
  const str = flag == 0 ? '结算' : '取消结算'
  proxy.$modal.confirm(`确定${str} ${row.name} 的缴费通知单?`)
    .then(() => {
      settlePayment([row.payId], flag).then(() => {
        proxy.$modal.msgSuccess('结算成功')
        getList()
      })
    })
}

// 批量结算
function settleAll() {
  proxy.$modal.confirm('确定批量结算选定的缴费通知单?')
    .then(() => {
      settlePayment(ids, 0).then(() => {
        proxy.$modal.msgSuccess('结算成功')
        getList()
      })
    })
}

function handleExport() {
  proxy.download('/exam/payment/export', {
    ...queryParams.value
  }, `考试缴费单_${new Date().getTime()}.xlsx`)
}

</script>
<style lang="scss" scoped >

</style>