index.vue 22.7 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 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
<template>
  <div class="app-container">
    <div>
      <!-- 搜索区域 -->
      <div class="from-Card">
        <el-form
          ref="queryRef" size="small" :model="queryParams" :inline="true" label-width="auto"
          label-position="top"
        >
          <el-row style="width: 100%;">

            <el-col :span="5" style="display: flex">
              <el-form-item style="width: 100%;" label="下发日期" prop="name">
                <el-date-picker
                  v-model="yjTimeRange[0]" type="date" value-format="YYYY-MM-DD HH:mm:ss"
                  placeholder="开始时间" style="width: 100%;"
                />
              </el-form-item>
              <el-form-item style="width: 100%;" label="下发日期" prop="name">
                <el-date-picker
                  v-model="yjTimeRange[1]" type="date" value-format="YYYY-MM-DD HH:mm:ss"
                  placeholder="结束时间" style="width: 100%;"
                  :default-time="defaultTime"
                />
              </el-form-item>
            </el-col>

            <!--            <el-col :span="5">-->
            <!--              <el-form-item label="下发日期" prop="yjTimeRange">-->
            <!--                <el-date-picker-->
            <!--                  v-model="yjTimeRange" value-format="YYYY-MM-DD" type="daterange"-->
            <!--                  range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" style="width: 100%;"-->
            <!--                  @change="serachFN"-->
            <!--                />-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->

            <el-col :span="4">
              <el-form-item label="月结名称" prop="finalDocName">
                <el-input
                  v-model.trim="queryParams.yjName" placeholder="" clearable style="width: 100%;"
                  @keyup.enter="serachFN"
                />
              </el-form-item>
            </el-col>

            <el-col :span="4">
              <el-form-item label="缴费单位" prop="payMemName">
                <el-input
                  v-model.trim="queryParams.payMemName" placeholder="" clearable style="width: 100%;"
                  @keyup.enter="serachFN"
                />
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="缴费状态" prop="type">
                <el-select v-model.trim="queryParams.settleFlag" style="width: 100%;" @change="serachFN">
                  <el-option label="全部" value="" />
                  <el-option label="已结算" value="0" />
                  <el-option label="未结算" value="1" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="月结单号" prop="">
                <el-input
                  v-model.trim="queryParams.yjCode" placeholder="" clearable style="width: 100%"
                  @keyup.enter="serachFN"
                />
              </el-form-item>
            </el-col>
            <!--            <el-col :span="4" :hidden="showCollect">-->
            <!--              <el-form-item label="结算编号" prop="">-->
            <!--                <el-input-->
            <!--                  v-model.trim="queryParams.yjCode" placeholder="" clearable style="width: 100%"-->
            <!--                  @keyup.enter="serachFN"-->
            <!--                />-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <!--            <el-col :span="4" :hidden="showCollect">-->
            <!--              <el-form-item label="结算状态" prop="">-->
            <!--                <el-select v-model.trim="payFlag" style="width: 100%;" @change="serachFN">-->
            <!--                  <el-option label="全部" value="" />-->
            <!--                  <el-option label="已上传凭证" value="0" />-->
            <!--                  <el-option label="未上传凭证" value="1" />-->
            <!--                  <el-option label="已结算" value="3" />-->
            <!--                </el-select>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <div class="po-r-btns">
              <el-button size="small" type="primary" icon="Search" @click="serachFN">查询</el-button>
              <el-button size="small" icon="Refresh" @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
              v-if=" deptType ==1 " icon="plus" type="warning"
              @click="addMonth"
            >生成月结 </el-button>
            <el-button
              v-if=" deptType ==1 " :disabled="show" icon="DocumentChecked" type="primary"
              @click="batchIssue"
            >下发缴费通知单 </el-button>
            <el-button
              v-if=" deptType ==2||deptType ==3 " :icon="Download" :disabled="show" type="primary"
              @click="batchDown"
            >批量下载缴费通知单 </el-button>
          </div>
        </el-row>
      </div>
      <!-- 表格数据 -->
      <div class="table">
        <el-table
          v-loading="loading" :data="list" :row-class-name="tableRowClassName" border
          style="width: 100%" @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="45" align="center" />
          <el-table-column type="index" label="序号" width="55" align="center" />
          <el-table-column label="缴费单位" align="center" prop="payMemName" min-width="120" :show-overflow-tooltip="true" />
          <el-table-column
            label="月结单号" align="center" min-width="120"
          >
            <template #default="scope">
              <el-button :disabled="scope.row.sendFlag == 0" type="text" @click="monthCode(scope.row)">{{ scope.row.yjCode }}</el-button>
            </template>
          </el-table-column>
          <el-table-column
            label="月结名称" align="center" prop="yjName" min-width="260"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="结算单日期范围" align="center" prop="timeRange" min-width="200" />
          <el-table-column label="结算单数量" align="center" prop="" min-width="100">
            <template #default="scope">
              <!--              <el-button :disabled="scope.row.sendFlag == 1" type="text" @click="handleEdit(scope.row)">{{ scope.row.recordCount }}</el-button>-->
              <el-button v-if="deptType==1" :disabled="scope.row.sendFlag == 1" type="text" @click="handleEdit(scope.row)">{{ scope.row.recordCount }} 编辑</el-button>
              <div v-else> {{ scope.row.recordCount }}</div>
            </template>
          </el-table-column>
          <el-table-column label="费用合计" align="center" prop="recordTotalFee" min-width="110" />
          <el-table-column label="年限合计" align="center" prop="yearCounts" min-width="110" />
          <el-table-column label="缴费单" align="center" min-width="120">
            <template #default="scope">
              <span>{{ scope.row.sendFlag==0?'未下发':'已下发' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="缴费凭证" align="center" prop="personCount" min-width="80">
            <template #default="scope">
              <!--              <div>{{ scope.row.payFlag }}</div>-->
              <div v-if="scope.row.payFlag==0">已上传</div>
              <div v-if="scope.row.payFlag==1">--</div>
<!--              <div style="cursor: pointer" v-if="scope.row.payFlag==1" @click="handleUpdate(scope.row)">未上传</div>-->
              <div v-if="scope.row.payFlag==2">未确认</div>
            </template>
          </el-table-column>

          <el-table-column label="下发日期" align="center" min-width="120">
            <template #default="scope">
              <span>{{ scope.row.sendFlag == 1? parseTime(scope.row.yjTime, '{y}-{m}-{d}'):'' }}</span>
            </template>
          </el-table-column>

          <el-table-column label="结算" align="center" prop="" min-width="110">
            <template #default="props">
              <div v-if="props.row.settleFlag == 0" class="text-success s" @click="handleDown(props.row)">已结算</div>
              <div v-if="props.row.settleFlag == 1" class="text-danger">未结算 </div>
              <!--              <div v-if="props.row.settleFlag == 1 && props.row.payFlag == 0" class="text-navy">已上传凭证 </div>-->
              <!--              <div v-if="props.row.settleFlag == 1 && props.row.payFlag == 1" class="text-danger">未上传凭证 </div>-->
              <!--              <div v-if="props.row.settleFlag == 1 && props.row.payFlag == 2" class="text-danger">未确认 </div>-->
            </template>
          </el-table-column>
          <el-table-column label="结算日期" align="center" prop="payTime" min-width="120">
            <template #default="scope">
              <span>{{ parseTime(scope.row.settleTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" prop="payRemark" min-width="100" :show-overflow-tooltip="true" />
          <el-table-column label="操作" align="center" fixed="right" class-name="small-padding" :width="deptType==1?360:340">
            <template #default="scope">
              <el-button type="primary" @click="handleInfo(scope.row)">查看</el-button>
              <!--              <el-button v-if="deptType==1" :disabled="scope.row.sendFlag == 1" type="success" @click="handleEdit(scope.row)">编辑</el-button>-->
              <el-button v-if="deptType==1" :disabled="scope.row.sendFlag == 1||scope.row.recordCount==0" type="primary" style="width: 7rem" @click="sendFile(scope.row)">下发缴费通知单 </el-button>

              <el-button v-if="deptType==1" :disabled="scope.row.settleFlag==0" style="width: auto" type="warning" @click="handleCancel(scope.row)">取消月结缴费</el-button>

              <el-button v-if="deptType==2||deptType==3" :disabled="scope.row.settleFlag == 0||scope.row.payFlag == 2" style="width: 9rem" type="success" @click="handleUpdate(scope.row)">确认并上传缴费凭证</el-button>
              <!--              <el-button v-if="deptType==2||deptType==3" style="width: 7rem" type="warning" :disabled="scope.row.sendFlag==0" @click="handleDownload(scope.row)">下载缴费通知单</el-button>-->
              <el-dropdown v-if="deptType!=1" class="poptdmore">
                <el-button type="primary" plain>更多
                  <el-icon class="el-icon--right">
                    <arrow-down />
                  </el-icon>
                </el-button>
                <template #dropdown>
                  <el-dropdown-menu>
                    <!--                    <el-dropdown-item v-if="deptType==1">-->
                    <!--                      <el-button v-if="deptType==1" :disabled="scope.row.settleFlag==0" style="width: auto" type="warning" @click="handleCancel(scope.row)">取消月结缴费</el-button>-->
                    <!--                    </el-dropdown-item>-->
                    <el-dropdown-item v-if="deptType==1">
                      <el-button :disabled="scope.row.sendFlag == 1||scope.row.recordCount==0" type="primary" @click="sendFile(scope.row)">下发缴费通知单 </el-button>
                    </el-dropdown-item>
                    <el-dropdown-item v-if="deptType!=1">
                      <el-button v-if="deptType==2||deptType==3" style="width: 7rem" type="warning" :disabled="scope.row.sendFlag==0" @click="handleDownload(scope.row)">下载缴费通知单</el-button>
                    </el-dropdown-item>
                    <el-dropdown-item v-if="deptType!=1">
                      <el-button type="danger" :disabled="scope.row.settleFlag==0||scope.row.payFlag==0||scope.row.payFlag==2" @click="handleBack(scope.row)">撤回</el-button>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>

        <div v-show="total>0" class="totalCost">
          总计:<span>{{ statistical.personCount }} </span>
          共:<span>{{ statistical.totalCost?.toFixed(2) }} </span>
          年限合计:<span>{{ statistical.totalYear }} </span>
        </div>

        <pagination
          v-show="total > 0"
          v-model:page="queryParams.pageNum"
          v-model:limit="queryParams.pageSize"
          :total="total"
          @pagination="initData"
        />
      </div>
    </div>
    <!--文件上传-->
    <el-dialog
      v-if="showFileUpload" v-model="showFileUpload" draggable title="上传缴费凭证" width="600px"
      @close="close"
    >
      <el-form ref="refForm" :model="form" :rules="rules">
        <el-form-item label="缴费日期:" prop="payTime">
          <el-date-picker
            v-model="form.payTime" value-format="YYYY-MM-DD hh:mm:ss" type="datetime" placeholder="请选择缴费日期"
            style="width: 100%;"
          />
        </el-form-item>
        <el-form-item label="缴费凭证:" prop="url">
          <file-upload v-model="form.url" :limit="1" :file-type="arr" accept=".png,.jpg,.jpeg,.pdf,.zip" />
        </el-form-item>
        <el-form-item label="备注:" prop="remark">
          <el-input v-model="form.remark" :rows="4" type="textarea" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-row justify="center">
          <el-button type="primary" @click="uploadSure"> </el-button>
          <el-button @click="showFileUpload = false"> </el-button>
        </el-row>
      </template>
    </el-dialog>

    <feeBillView ref="feeBillViewRef" @approval="initData" />
    <bill ref="billRef" />

    <el-dialog
      v-model="showMon" title="结算时间" :close-on-click-modal="true" width="600"
      align-center @close="closeMn"
    >
      <div>
        <el-form-item label="结算时间" prop="commitTime">
          <el-date-picker
            v-model="mon.time" type="daterange" value-format="YYYY-MM-DD"
            range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" style="width: 100%;"
          />
        </el-form-item>
        <div>
          <br>
          <div style="text-align: center">
            <el-button type="primary" @click="submitMon">确定</el-button>
          </div>
        </div>
      </div>

    </el-dialog>
    <monthlyStatement ref="monthlyStatementRef" @backInfo="serachFN" />
    <monthlyStatementList ref="monthlyStatementListRef" @backInfo="serachFN" />
    <!-- 下载缴费凭证 -->
    <el-link v-show="false" ref="linkRef" :href="fillImgUrl(url)" :underline="false" target="_blank" />
  </div>
</template>

<script setup>
import { getCurrentInstance, nextTick, onMounted } from 'vue'
import { reactive } from '@vue/runtime-core'
import { ref, toRefs, computed } from 'vue'
import { Download } from '@element-plus/icons-vue'
import feeBillView from './feeBillView.vue'
import useUserStore from '@/store/modules/user'
import bill from './bill'
import { useRouter } from 'vue-router'

import { mentDocList, cancelYueJie, commitPaymentVoucher, send, wdBack } from '@/api/member/monthlyFeeBill'
import monthlyStatement from '@/views/member/components/monthlyStatement.vue'
import monthlyStatementList from '@/views/member/components/monthlyStatementList.vue'
import { dateEnd } from '/@/utils/ruoyi'

const router = useRouter()
const deptType = computed(() => useUserStore().deptType)
const url = ref()
const show = ref(true)
const { proxy } = getCurrentInstance()
const total = ref(0)
const showFileUpload = ref(false)
const list = ref([])
const lists = ref([])
const batchList = ref([])
const showMon = ref(false)
const mon = ref({})
const yjTimeRange = ref([null, null])
const statistical = ref({})
const arr = ['png', 'jpg', 'jpeg', 'pdf', 'zip']
const payFlag = ref()
const loading = ref(false)
const defaultTime = ref(new Date(0, 0, 0, 23, 59, 59))
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    settleFlag: '1'
  },
  form: {},
  rules: {
    payTime: { required: true, message: '请选择缴费日期', trigger: 'blur' },
    url: { required: true, message: '请上传缴费凭证', trigger: 'blur' }
  }
})
const { queryParams, form, rules } = toRefs(data)

onMounted(() => {
  initData()
})

// // 背景色
const tableRowClassName = ({
  row,
  rowIndex
}) => {
  if (row.settleFlag == 0) {
    return 'success-row'
  }
}

function serachFN() {
  queryParams.value.pageNum = 1
  initData()
}

function handleDown(row) {
  url.value = row.payEvidence?.[0]?.url
  nextTick(() => {
    proxy.$refs['linkRef'].$el.click()
  })
}

// 获取赛会列表
async function initData() {
  if ((yjTimeRange.value[0] == null && yjTimeRange.value[1] != null) || (yjTimeRange.value[1] == null && yjTimeRange.value[0] != null)) return proxy.$modal.msgError('请完善下发日期')
  if (yjTimeRange.value[1])yjTimeRange.value[1] = dateEnd(yjTimeRange.value[1])
  queryParams.value.yjTimeRange = yjTimeRange.value.length == 2 && yjTimeRange.value[0] != null ? yjTimeRange.value?.toString() : null
  loading.value = true
  // queryParams.value.yjTimeRange = yjTimeRange.value?.toString()

  if (deptType.value != 1) { queryParams.value.sendFlag = 1 }

  const res = await mentDocList(queryParams.value)
  statistical.value = {
    totalCost: 0,
    personCount: 0,
    totalYear: 0
  }
  list.value = res.rows
  total.value = res.total
  list.value.forEach(item => {
    item.payEvidence = JSON.parse(item.payEvidence)
    statistical.value.totalCost += (item.recordTotalFee * 1)
    statistical.value.personCount += (item.recordCount * 1)
    statistical.value.totalYear += (item.yearCounts * 1)
  })
  loading.value = false
}

// 上传缴费凭证确定
async function uploadSure() {
  console.log(form.value)
  proxy.$refs['refForm'].validate(async valid => {
    if (valid) {
      const res = await commitPaymentVoucher({
        yjId: form.value.yjId,
        payTime: form.value.payTime,
        url: JSON.stringify(form.value.url),
        remark: form.value.remark
      })
      if (res.code == 200) {
        showFileUpload.value = false
        initData()
        proxy.$modal.msgSuccess('操作成功')
      } else {
        proxy.$modal.msgError('操作失败')
      }
      console.log(res)
    } else {
      proxy.$modal.msgError('请完善信息')
    }
  })
}

// 多选
function handleSelectionChange(e) {
  lists.value = e.map(item => item.yjId)
  batchList.value = e
  show.value = !lists.value.length
}

// 上传缴费凭证
async function handleUpdate(row) {
  form.value = row
  if (form.value.payEvidence) form.value.url = form.value.payEvidence
  showFileUpload.value = true
}

// 查看
function handleInfo(row) {
  proxy.$refs['feeBillViewRef'].open(row)
}

// 批量下载缴费通知单
async function batchDown() {
  const flag = batchList.value.some(item => {
    if (item.sendFlag == 0) {
      return proxy.$message.warning(`月结单号为${item.yjCode}的数据项不符合下载!`)
    }
  })
  if (flag) return
  const routerData = router.resolve({
    path: '/download',
    query: {
      arr: lists.value,
      type: 'batchMemberYJFeeBill'
    }
  })
  window.open(routerData.href, '_blank')
}

function handleDownload(row) {
  const routerData = router.resolve({
    path: '/download',
    query: {
      arr: [row.yjId],
      type: 'batchMemberYJFeeBill'
    }
  })
  window.open(routerData.href, '_blank')
}

// 订单编号
function monthCode(row) {
  proxy.$refs['billRef'].open(row)
}

// 重置
function resetQuery() {
  queryParams.value = {
    pageNum: 1,
    pageSize: 10,
    settleFlag: '1'
  }
  payFlag.value = ''
  yjTimeRange.value = [null, null]
  initData()
}

function close() {
  form.value = {}
}

function handleCancel(row) {
  proxy.$modal.confirm('是否确认取消月结缴费名称为"' + row.yjName + '"的数据项?').then(function() {
    return cancelYueJie(row.yjId)
  }).then(() => {
    proxy.$modal.msgSuccess('操作成功')
    if (list.value.length == 1 && queryParams.value.pageNum > 1) {
      queryParams.value.pageNum--
    }
  }).finally(() => {
    initData()
  })
}


function submitMon() {
  if (!mon.value.time || mon.value.time?.length <= 1) {
    return proxy.$message.warning('请选择结算日期')
  }
  proxy.$refs['monthlyStatementRef'].open(mon.value.time)
  // const res = await addYueJie({
  //   memIds: monthlyFeeBillId.value,
  //   timeBegin: mon.value.time[0],
  //   timeEnd: mon.value.time[1]
  // })
  // if (res.code == 200) {
  //   proxy.$message.success('操作成功')
  //   closeMn()
  //   searchFN()
  // }
  closeMn()
}

function closeMn() {
  mon.value = {}
  showMon.value = false
}

function addMonth() {
  proxy.$refs['monthlyStatementRef'].open(mon.value.time)
}

async function handleEdit(row) {
  proxy.$refs['monthlyStatementListRef'].open(row)
  // const res = await getWaitYueJieInfoListMinePage(row.yjId)
  // console.log(res)
}

// 批量下发缴费通知单
async function batchIssue() {
  const flag = batchList.value.some(item => {
    if (item.sendFlag == 1) {
      return proxy.$message.warning(`月结单号为${item.yjCode}的数据项已下发缴费通知单!`)
    }
    if (item.recordCount == 0) {
      return proxy.$message.warning(`月结单号为${item.yjCode}的数据项不符合下发缴费通知单!`)
    }
  })
  if (flag) return
  await send(lists.value)
  await proxy.$message.success('操作成功')
  await initData()
}

async function sendFile(row) {
  const res = await send([row.yjId])
  if (res.code == 200) {
    await proxy.$message.success('操作成功')
    await initData()
  }
}

// 撤回
function handleBack(row) {
  proxy.$modal.confirm('是否确认撤回月结缴费名称为"' + row.yjName + '"的数据项?').then(function() {
    return wdBack(row.yjId)
  }).then(() => {
    proxy.$modal.msgSuccess('操作成功')
    if (list.value.length == 1 && queryParams.value.pageNum > 1) {
      queryParams.value.pageNum--
    }
  }).finally(() => {
    initData()
  })
}
</script>

<style lang="scss" scoped>
.router {
  margin-right: 20px;
}

.size {
  color: var(--el-button-text-color)
}
</style>