deteleTables.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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="busiessTableRef" :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 v-for="(item, index) in tableColumns" :prop="item.prop" :label="item.label"
  22. :key="index" :width="item.width">
  23. <template #default="scope">
  24. <template v-if="['customSignerName', 'companySignerName', 'inchargerName', 'creatorName'].includes(item.prop)">
  25. <TextTranslation translationTypes="userName" :translationValue="scope.row[item.prop]"></TextTranslation>
  26. </template>
  27. <template v-else-if="item.prop === 'receivedStatus'">
  28. <div>{{ selectData.RemittanceStatus[scope.row.receivedStatus].name }}</div>
  29. </template>
  30. <span v-else>{{ scope.row[item.prop] }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="操作" fixed="right" width="120">
  34. <template #default="scope">
  35. <el-button link type="primary" size="large"
  36. @click="businessOperationItem(scope.row.id, scope.row.orderName, '恢复')">恢复</el-button>
  37. <el-button link type="danger" size="large"
  38. @click="businessOperationItem(scope.row.id, scope.row.orderName, '删除')">删除</el-button>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. </div>
  43. <div class="flex justify-end pt-3">
  44. <el-pagination layout="total, prev, pager, next, sizes" :page-size="tableForm.pageSize"
  45. @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="businessTotalTable"
  46. :hide-on-single-page="true" />
  47. </div>
  48. </div>
  49. </el-dialog>
  50. </template>
  51. <script lang="ts" setup>
  52. import { post } from '@/utils/request';
  53. import { ref, reactive, onMounted, watchEffect, watch, inject } from 'vue'
  54. import { GETTABLELIST, paymentStatus, tableColumns, URL_BATCHDELETE, URL_RECOVER } from '../api';
  55. import { ElTable } from 'element-plus';
  56. import { confirmAction } from '@/utils/tools';
  57. import { formatDate } from '@/utils/times';
  58. type operationType = '恢复' | '删除'
  59. const emits = defineEmits(['closeVisible']);
  60. const globalPopup = inject<GlobalPopup>('globalPopup')
  61. const deteleBusinessTable = ref([])
  62. const deteleBusinessDialogVisible = ref(false)
  63. const businessTotalTable = ref(0)
  64. const batchTableData = ref([])
  65. const allLoading = reactive({
  66. batchRecoveryLoading: false,
  67. batchDeteleLoading: false,
  68. tableLoading: false
  69. })
  70. const tableForm = reactive({
  71. pageIndex: 1,
  72. pageSize: 10
  73. })
  74. const busiessTableRef = ref<InstanceType<typeof ElTable>>() // 线索table dom
  75. const props = defineProps<{
  76. visibles: boolean
  77. }>()
  78. const selectData = reactive({ // 下拉数据
  79. Personnel: [] as personnelInterface[],
  80. Customer: [] as any[], // 客户名称
  81. OrderType: [] as any[], // 订单类型
  82. RemittanceStatus: [{ id: 0, name: '未回款' }, { id: 1, name: '已回款' }, { id: 2, name: '已完全回款' }] as any[], // 回款状态
  83. AllProduct: [] as any[] // 所有产品
  84. })
  85. watch(() => props.visibles, (newVal) => {
  86. deteleBusinessDialogVisible.value = newVal
  87. if (newVal) {
  88. getTableList()
  89. }
  90. })
  91. function batchOperation(type: operationType) {
  92. const value = batchTableData.value.map((item: any) => item.id).join(',')
  93. const label = batchTableData.value.map((item: any) => item.orderName).join(',')
  94. businessOperationItem(value, label, type, true)
  95. }
  96. function businessOperationItem(value: string | number, label: string, type: operationType, batch: boolean = false) {
  97. confirmAction(`确定${batch ? '批量' : ''}${type}【${label}】销售订单吗?`).then(() => {
  98. let url = type == '恢复' ? URL_RECOVER : URL_BATCHDELETE
  99. // let url = ''
  100. post(url, { ids: value }).then(res => {
  101. if (res.code != 'ok') {
  102. globalPopup?.showError(res.msg)
  103. return
  104. }
  105. globalPopup?.showSuccess(`${type}成功`)
  106. getTableList()
  107. changeBatch(false)
  108. }).catch((err) => {
  109. globalPopup?.showError(err.msg)
  110. })
  111. })
  112. }
  113. function changeBatch(flag: boolean = true) {
  114. if (flag) {
  115. batchTableData.value = busiessTableRef.value && busiessTableRef.value.getSelectionRows()
  116. } else {
  117. batchTableData.value = []
  118. busiessTableRef.value && busiessTableRef.value.clearSelection()
  119. }
  120. }
  121. function getTableList() {
  122. allLoading.tableLoading = true
  123. post(GETTABLELIST, { ...tableForm, isDelete: 1 }).then((res) => {
  124. if (res.code == 'ok') {
  125. const { record, total } = res.data
  126. deteleBusinessTable.value = (record || []).map((item: any) => {
  127. let val = paymentStatus.find((items: any) => items.value == item.status)
  128. return {
  129. ...item,
  130. statusValue: val ? val.label : ''
  131. }
  132. })
  133. businessTotalTable.value = total
  134. }
  135. }).finally(() => {
  136. allLoading.tableLoading = false
  137. })
  138. }
  139. function handleSizeChange(val: number) {
  140. tableForm.pageIndex = 1
  141. tableForm.pageSize = val
  142. getTableList()
  143. }
  144. function handleCurrentChange(val: number) {
  145. tableForm.pageIndex = val
  146. getTableList()
  147. }
  148. function cancel() {
  149. emits('closeVisible', 'deteleOrderVisible')
  150. }
  151. function beForeCancel(done: () => void) {
  152. emits('closeVisible', 'deteleOrderVisible')
  153. done()
  154. }
  155. onMounted(() => {
  156. })
  157. </script>
  158. <style lang="scss" scoped></style>