VerifyContractDetail.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script setup lang="ts">
  2. // import VerifyForm from './VerifyForm.vue'
  3. import { useRouter, useRoute } from 'vue-router'
  4. import { ElMessageBox, ElMessage } from 'element-plus'
  5. import { ref, reactive, onMounted, nextTick, defineAsyncComponent } from 'vue'
  6. import TableBase from '@/components/TableBase/index.vue'
  7. import { Edit, Delete, View } from '@element-plus/icons-vue'
  8. import type { ColumnProps } from '@/components/TableBase/interface/index'
  9. import { Storehouse_VerifyContract_List, Storehouse_VerifyContract_Del } from '@/api/storehouse/index'
  10. import { useTablePublic } from '@/hooks/useTablePublic'
  11. const VerifyForm = defineAsyncComponent({
  12. loader: () => import(/*webpackChunkName: 'ContractForm'*/ './VerifyForm.vue'),
  13. delay: 500,
  14. timeout: 3000,
  15. suspensible: true
  16. })
  17. const customer_id = ref('')
  18. const route = useRoute()
  19. const router = useRouter()
  20. const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
  21. const VerifyFormRef = ref<InstanceType<typeof VerifyForm> | null>(null)
  22. const { globalStore, updateOnTableList } = useTablePublic()
  23. const columns: ColumnProps[] = [
  24. { type: 'index', label: '序号', width: 80 },
  25. { prop: 'T_number', label: '合同编号' },
  26. { prop: 'T_date', label: '签订时间' },
  27. { prop: 'T_discount', label: '金额' },
  28. { prop: 'T_start_date', label: '起始时间' },
  29. { prop: 'T_end_date', label: '终止时间' },
  30. { prop: 'T_verify_state', label: '是否过期', name: 'T_verify_state' },
  31. { prop: 'operation', label: '操作', width: 260, fixed: 'right' }
  32. ]
  33. const initParam = reactive({
  34. User_tokey: globalStore.GET_User_tokey,
  35. T_customer_id: route.params.id
  36. })
  37. const openContract = (type: string, row?: any) => VerifyFormRef.value?.openDrawer(type, row)
  38. const verifyDetail = (id: string) => router.push({ name: 'ContractDetail', params: { id, verify: 'verify' } })
  39. const verifyDelete = (number: number) => {
  40. ElMessageBox.confirm('您确定要删除该合同明细吗?', '警告', {
  41. confirmButtonText: '确定',
  42. cancelButtonText: '取消',
  43. type: 'warning'
  44. })
  45. .then(async () => {
  46. const res: any = await Storehouse_VerifyContract_Del({
  47. User_tokey: globalStore.GET_User_tokey,
  48. T_number: number
  49. })
  50. if (res.Code === 200) {
  51. ElMessage.success('删除成功!')
  52. nextTick(() => {
  53. updateOnTableList(TableRef.value)
  54. })
  55. }
  56. })
  57. .catch(() => {
  58. ElMessage.warning('取消成功!')
  59. })
  60. }
  61. onMounted(() => {
  62. const { params } = route
  63. customer_id.value = params.id as string
  64. })
  65. </script>
  66. <template>
  67. <div class="verify-contract">
  68. <TableBase ref="TableRef" :columns="columns" :requestApi="Storehouse_VerifyContract_List" :initParam="initParam">
  69. <template #table-header>
  70. <el-row :gutter="20" style="margin-bottom: 0" class="input-suffix">
  71. <el-col :xl="6" :md="8">
  72. <h3>合同明细</h3>
  73. </el-col>
  74. <el-col :xl="6" :md="4" :offset="12" class="btn"
  75. ><el-button type="primary" @click="openContract('new')">添加</el-button>
  76. <el-button type="primary" @click="router.back()">返回</el-button>
  77. </el-col>
  78. </el-row>
  79. </template>
  80. <template #T_verify_state="{ row }">
  81. <el-tag v-if="row.T_verify_state === 1" type="warning" effect="dark"> 未签约 </el-tag>
  82. <el-tag v-else-if="row.T_verify_state === 2" type="info" effect="dark"> 已作废 </el-tag>
  83. <el-tag v-else-if="row.T_verify_state === 3" type="success" effect="dark"> 已签约 </el-tag>
  84. <el-tag v-else type="danger" effect="dark"> 即将到期 </el-tag>
  85. </template>
  86. <template #right="{ row }">
  87. <el-button link type="primary" size="small" :icon="Edit" @click="openContract('edit', row)">编辑</el-button>
  88. <el-button link type="success" size="small" :icon="View" @click="verifyDetail(row.T_number)">详情</el-button>
  89. <el-button link type="danger" size="small" :icon="Delete" @click="verifyDelete(row.T_number)">删除</el-button>
  90. </template>
  91. </TableBase>
  92. <VerifyForm ref="VerifyFormRef" @onTableList="updateOnTableList(TableRef)" :verify_customer_id="customer_id" />
  93. </div>
  94. </template>
  95. <style scoped lang="scss">
  96. @import '@/styles/var.scss';
  97. .verify-contract {
  98. @include f-direction;
  99. :deep(.el-drawer__header) {
  100. margin-bottom: 0;
  101. }
  102. .input-suffix {
  103. width: 100%;
  104. .btn {
  105. display: flex;
  106. justify-content: end;
  107. }
  108. }
  109. }
  110. </style>