deteleTables.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <el-dialog v-model="deteleBusinessDialogVisible" width="1000" :before-close="beForeCancel" :show-close="false"
  3. top="10vh">
  4. <template #header="{ close, titleId, titleClass }">
  5. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  6. <h4 :id="titleId">客户回收站</h4>
  7. <div>
  8. <el-button type="primary" v-loading="allLoading.batchRecoveryLoading"
  9. :disabled="batchTableData.length == 0" @click="batchOperation('恢复')">批量恢复</el-button>
  10. <el-button type="primary" v-loading="allLoading.batchDeteleLoading"
  11. :disabled="batchTableData.length == 0" @click="batchOperation('删除')">批量删除</el-button>
  12. <el-button @click="cancel()">取消</el-button>
  13. </div>
  14. </div>
  15. </template>
  16. <div class="h-[60vh] flex flex-col">
  17. <div class="flex-1 w-full overflow-hidden">
  18. <el-table ref="deteleTableRef" :data="deteleBusinessTable" border v-loading="allLoading.tableLoading"
  19. @selection-change="changeBatch" style="width: 100%;height: 100%;">
  20. <el-table-column type="selection" width="55" />
  21. <el-table-column prop="customName" label="客户名称" width="180"></el-table-column>
  22. <el-table-column prop="customSourceValue" label="客户来源" width="180"></el-table-column>
  23. <el-table-column prop="companyPhone" label="公司电话" width="180"></el-table-column>
  24. <el-table-column prop="email" label="邮箱" width="200"></el-table-column>
  25. <el-table-column prop="customerIndustryValue" label="客户行业" width="180"></el-table-column>
  26. <el-table-column prop="customerLevelValue" label="客户级别" width="180"></el-table-column>
  27. <el-table-column prop="inchargerName" label="负责人" width="190"></el-table-column>
  28. <el-table-column prop="creatorName" label="创建人" width="180"></el-table-column>
  29. <el-table-column prop="newCreateTime" label="创建时间" width="180"></el-table-column>
  30. <el-table-column label="操作" fixed="right" width="120">
  31. <template #default="scope">
  32. <el-button link type="primary" size="large"
  33. @click="operationItem(scope.row.id, scope.row.customName, '恢复')">恢复</el-button>
  34. <el-button link type="danger" size="large"
  35. @click="operationItem(scope.row.id, scope.row.customName, '删除')">删除</el-button>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. </div>
  40. <div class="flex justify-end pt-3">
  41. <el-pagination layout="total, prev, pager, next, sizes" :page-size="tableForm.pageFrom"
  42. @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="businessTotalTable"
  43. :hide-on-single-page="true" />
  44. </div>
  45. </div>
  46. </el-dialog>
  47. </template>
  48. <script lang="ts" setup>
  49. import { post } from '@/utils/request';
  50. import { ref, reactive, onMounted, watchEffect, watch, inject } from 'vue'
  51. import { URL_RECYCLELIST, URL_ROWBACK, URL_THOROUGHLYDETELE } from '../api';
  52. import { ElTable } from 'element-plus';
  53. import { confirmAction } from '@/utils/tools';
  54. import { formatDate } from '@/utils/times';
  55. type operationType = '恢复' | '删除'
  56. const emits = defineEmits(['closeVisible']);
  57. const globalPopup = inject<GlobalPopup>('globalPopup')
  58. const deteleBusinessTable = ref([])
  59. const deteleBusinessDialogVisible = ref(false)
  60. const businessTotalTable = ref(0)
  61. const batchTableData = ref([])
  62. const allLoading = reactive({
  63. batchRecoveryLoading: false,
  64. batchDeteleLoading: false,
  65. tableLoading: false
  66. })
  67. const tableForm = reactive({
  68. pageIndex: 1,
  69. pageFrom: 10
  70. })
  71. const deteleTableRef = ref<InstanceType<typeof ElTable>>() // 线索table dom
  72. const props = defineProps<{
  73. visibles: boolean
  74. }>()
  75. watch(() => props.visibles, (newVal) => {
  76. deteleBusinessDialogVisible.value = newVal
  77. if (newVal) {
  78. getTableList()
  79. }
  80. })
  81. function batchOperation(type: operationType) {
  82. const value = batchTableData.value.map((item: any) => item.id).join(',')
  83. const label = batchTableData.value.map((item: any) => item.customName).join(',')
  84. operationItem(value, label, type, true)
  85. }
  86. function operationItem(value: string | number, label: string, type: operationType, batch: boolean = false) {
  87. confirmAction(`确定${batch ? '批量' : ''}${type}【${label}】客户吗?`).then(() => {
  88. let url = type == '恢复' ? URL_ROWBACK : URL_THOROUGHLYDETELE
  89. post(url, { ids: value }).then(res => {
  90. if (res.code != 'ok') {
  91. globalPopup?.showError(res.msg)
  92. return
  93. }
  94. globalPopup?.showSuccess(`${type}成功`)
  95. getTableList()
  96. changeBatch(false)
  97. }).catch((err) => {
  98. globalPopup?.showError(err.msg)
  99. })
  100. })
  101. }
  102. function changeBatch(flag: boolean = true) {
  103. if (flag) {
  104. batchTableData.value = deteleTableRef.value && deteleTableRef.value.getSelectionRows()
  105. } else {
  106. batchTableData.value = []
  107. deteleTableRef.value && deteleTableRef.value.clearSelection()
  108. }
  109. }
  110. function getTableList() {
  111. allLoading.tableLoading = true
  112. post(URL_RECYCLELIST, { ...tableForm }).then((res) => {
  113. if (res.code == 'ok') {
  114. const { data, total } = res.data
  115. deteleBusinessTable.value = data.map((item: any) => {
  116. return {
  117. ...item,
  118. expectedTransactionDate: formatDate(new Date(item.expectedTransactionDate))
  119. }
  120. })
  121. businessTotalTable.value = total
  122. }
  123. }).finally(() => {
  124. allLoading.tableLoading = false
  125. })
  126. }
  127. function handleSizeChange(val: number) {
  128. tableForm.pageIndex = 1
  129. tableForm.pageFrom = val
  130. getTableList()
  131. }
  132. function handleCurrentChange(val: number) {
  133. tableForm.pageIndex = val
  134. getTableList()
  135. }
  136. function cancel() {
  137. emits('closeVisible', 'deteleCustomerVisible')
  138. }
  139. function beForeCancel(done: () => void) {
  140. emits('closeVisible', 'deteleCustomerVisible')
  141. done()
  142. }
  143. onMounted(() => {
  144. })
  145. </script>
  146. <style lang="scss" scoped></style>