123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <template>
- <el-dialog v-model="deteleBusinessDialogVisible" width="1000" :before-close="beForeCancel" :show-close="false"
- top="10vh">
- <template #header="{ close, titleId, titleClass }">
- <div class="flex justify-between items-center border-b pb-3 dialog-header">
- <h4 :id="titleId">商机回收站</h4>
- <div>
- <el-button type="primary" v-loading="allLoading.batchRecoveryLoading" :disabled="batchTableData.length == 0"
- @click="batchOperation('恢复')">批量恢复</el-button>
- <el-button type="primary" v-loading="allLoading.batchDeteleLoading" :disabled="batchTableData.length == 0"
- @click="batchOperation('删除')">批量删除</el-button>
- <el-button @click="cancel()">取消</el-button>
- </div>
- </div>
- </template>
- <div class="h-[60vh] flex flex-col">
- <div class="flex-1 w-full overflow-hidden">
- <el-table ref="busiessTableRef" :data="deteleBusinessTable" border v-loading="allLoading.tableLoading"
- @selection-change="changeBatch" style="width: 100%;height: 100%;">
- <el-table-column type="selection" width="55" />
- <el-table-column v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index"
- :width="item.width">
- <template #default="scope">
- <span>{{ scope.row[item.prop] }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" fixed="right" width="120">
- <template #default="scope">
- <el-button link type="primary" size="large"
- @click="businessOperationItem(scope.row.id, scope.row.name, '恢复')">恢复</el-button>
- <el-button link type="danger" size="large"
- @click="businessOperationItem(scope.row.id, scope.row.name, '删除')">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div class="flex justify-end pt-3">
- <el-pagination layout="total, prev, pager, next, sizes" :page-size="tableForm.pageFrom"
- @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="businessTotalTable"
- :hide-on-single-page="true" />
- </div>
- </div>
- </el-dialog>
- </template>
- <script lang="ts" setup>
- import { post } from '@/utils/request';
- import { ref, reactive, onMounted, watchEffect, watch, inject } from 'vue'
- import { BUSIESS_DETELELIST, BUSIESS_PERDETELE, BUSIESS_ROWBACK, tableColumn } from '../api';
- import { ElTable } from 'element-plus';
- import { confirmAction } from '@/utils/tools';
- import { formatDate } from '@/utils/times';
- type operationType = '恢复' | '删除'
- const emits = defineEmits(['closeVisible']);
- const globalPopup = inject<GlobalPopup>('globalPopup')
- const deteleBusinessTable = ref([])
- const deteleBusinessDialogVisible = ref(false)
- const businessTotalTable = ref(0)
- const batchTableData = ref([])
- const allLoading = reactive({
- batchRecoveryLoading: false,
- batchDeteleLoading: false,
- tableLoading: false
- })
- const tableForm = reactive({
- pageIndex: 1,
- pageFrom: 10
- })
- const busiessTableRef = ref<InstanceType<typeof ElTable>>() // 线索table dom
- const props = defineProps<{
- visibles: boolean
- }>()
- watch(() => props.visibles, (newVal) => {
- deteleBusinessDialogVisible.value = newVal
- if (newVal) {
- getTableList()
- }
- })
- function batchOperation(type: operationType) {
- const value = batchTableData.value.map((item: any) => item.id).join(',')
- const label = batchTableData.value.map((item: any) => item.name).join(',')
- businessOperationItem(value, label, type, true)
- }
- function businessOperationItem(value: string | number, label: string, type: operationType, batch: boolean = false) {
- confirmAction(`确定${batch ? '批量' : ''}${type}【${label}】商机吗?`).then(() => {
- let url = type == '恢复' ? BUSIESS_ROWBACK : BUSIESS_PERDETELE
- post(url, { ids: value }).then(res => {
- if (res.code != 'ok') {
- globalPopup?.showError(res.msg)
- return
- }
- globalPopup?.showSuccess(`${type}成功`)
- getTableList()
- changeBatch(false)
- }).catch((err) => {
- globalPopup?.showError(err.msg)
- })
- })
- }
- function changeBatch(flag: boolean = true) {
- if (flag) {
- batchTableData.value = busiessTableRef.value && busiessTableRef.value.getSelectionRows()
- } else {
- batchTableData.value = []
- busiessTableRef.value && busiessTableRef.value.clearSelection()
- }
- }
- function getTableList() {
- allLoading.tableLoading = true
- post(BUSIESS_DETELELIST, { ...tableForm }).then((res) => {
- if (res.code == 'ok') {
- const { data, total } = res.data
- deteleBusinessTable.value = data.map((item: any) => {
- return {
- ...item,
- expectedTransactionDate: formatDate(new Date(item.expectedTransactionDate))
- }
- })
- businessTotalTable.value = total
- }
- }).finally(() => {
- allLoading.tableLoading = false
- })
- }
- function handleSizeChange(val: number) {
- tableForm.pageIndex = 1
- tableForm.pageFrom = val
- getTableList()
- }
- function handleCurrentChange(val: number) {
- tableForm.pageIndex = val
- getTableList()
- }
- function cancel() {
- emits('closeVisible', 'deteleBusinessVisible')
- }
- function beForeCancel(done: () => void) {
- emits('closeVisible', 'deteleBusinessVisible')
- done()
- }
- onMounted(() => {
- })
- </script>
- <style lang="scss" scoped></style>
|