MyProject.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <script setup lang="ts">
  2. import { ElMessage, ElMessageBox } from 'element-plus'
  3. import { GlobalStore } from '@/stores/index'
  4. import { ref, nextTick } from 'vue'
  5. import TableBase from '@/components/TableBase/index.vue'
  6. import { ColumnProps } from '@/components/TableBase/interface/index'
  7. import { Edit, Delete, View } from '@element-plus/icons-vue'
  8. import { Project_Del, Project_Project_User_list } from '@/api/project/index'
  9. import ProjectForm from './ProjectForm.vue'
  10. const TableRef = ref()
  11. const globalStore = GlobalStore()
  12. const User_tokey = globalStore.GET_User_tokey
  13. const projctFormRef = ref<InstanceType<typeof ProjectForm> | null>(null)
  14. const columns: ColumnProps[] = [
  15. { type: 'index', label: '序号' },
  16. { prop: 'T_name', label: '项目名称' },
  17. { prop: 'T_user_name', label: '项目负责人' },
  18. { prop: 'T_set_up_date', label: '立项日期' },
  19. { prop: 'T_end_date', label: '结束时间' },
  20. { prop: 'T_planning_cycle', label: '计划完成周期(工作日)', width: 125 },
  21. { prop: 'T_Perf', label: '绩效总金额' },
  22. { prop: 'T_State', label: '状态', name: 'T_State' },
  23. { prop: 'operation', label: '操作', width: 200, fixed: 'right' }
  24. ]
  25. const DeleteProject = (Id: number) => {
  26. ElMessageBox.confirm('您确定要删除项目吗?', '警告', {
  27. confirmButtonText: '确定',
  28. cancelButtonText: '取消',
  29. type: 'warning'
  30. })
  31. .then(async () => {
  32. const res: any = await Project_Del({ User_tokey, T_id: Id })
  33. if (res.Code === 200) {
  34. ElMessage.success('删除成功!')
  35. nextTick(() => {
  36. onUpdateTableList
  37. })
  38. }
  39. })
  40. .catch(() => {
  41. ElMessage.warning('取消成功!')
  42. })
  43. }
  44. const onUpdateTableList = () => TableRef.value?.getTableList()
  45. const openProjectDrawer = (type: string, row?: any) => projctFormRef.value?.projectFromOpen(type, row)
  46. </script>
  47. <template>
  48. <div class="my-project">
  49. <TableBase ref="TableRef" :columns="columns" :requestApi="Project_Project_User_list" :initParam="{ User_tokey }">
  50. <template #table-header>
  51. <el-row :gutter="20" class="w-100">
  52. <el-col :span="4"><h3 class="title">我的项目</h3></el-col>
  53. <el-col :span="4" :offset="16"
  54. ><el-button type="primary" @click="openProjectDrawer('new')">立项申请</el-button></el-col
  55. >
  56. </el-row>
  57. </template>
  58. <template #T_State="{ row }">
  59. <el-tag v-if="row.T_State === 4" effect="dark">已发绩效</el-tag>
  60. <el-tag v-else-if="row.T_State === 3" type="success" effect="dark">已完成</el-tag>
  61. <el-tag v-else-if="row.T_State === 2" type="warning" effect="dark">进行中</el-tag>
  62. <el-tag v-else type="danger" effect="dark">待审核</el-tag>
  63. </template>
  64. <template #right="{ row }">
  65. <el-button link type="success" size="small" :icon="View" @click="openProjectDrawer('view', row)"
  66. >详情</el-button
  67. >
  68. <el-button
  69. link
  70. type="primary"
  71. size="small"
  72. :icon="Edit"
  73. :disabled="[3, 4].includes(row.T_State)"
  74. @click="openProjectDrawer('edit', row)"
  75. >编辑</el-button
  76. >
  77. <el-button
  78. link
  79. type="danger"
  80. size="small"
  81. :icon="Delete"
  82. :disabled="[3, 4].includes(row.T_State)"
  83. @click="DeleteProject(row.Id)"
  84. >删除</el-button
  85. >
  86. </template>
  87. </TableBase>
  88. <ProjectForm ref="projctFormRef" projectName="myProject" @onTableList="onUpdateTableList" />
  89. </div>
  90. </template>
  91. <style scoped lang="scss">
  92. @import '@/styles/var.scss';
  93. .my-project {
  94. height: 100%;
  95. display: flex;
  96. overflow: hidden;
  97. @include f-direction;
  98. :deep(.table-header),
  99. :deep(.card) {
  100. margin: 0;
  101. border-radius: 8px;
  102. }
  103. :deep(.el-table .cell) {
  104. white-space: normal !important;
  105. }
  106. }
  107. </style>