list.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <hc-card v-loading="tableLoading" id-ref="hc-project-list" div-p="12px" body-ui="hc-project-list" scrollbar>
  3. <template #header>
  4. <div class="w-300px">
  5. <el-select v-model="projectId" filterable clearable block placeholder="选择项目" @change="projectClick">
  6. <el-option v-for="item in projectData" :key="item.id" :label="item.projectAlias" :value="item.id" />
  7. </el-select>
  8. </div>
  9. </template>
  10. <template #extra>
  11. <el-button hc-btn type="primary" @click="addProjectClick">创建项目</el-button>
  12. </template>
  13. <div class="hc-project-list-row">
  14. <template v-for="item in tableData" :key="item.id">
  15. <hc-card-item class="hc-project-list-card" @click="projectClick(item.id)">
  16. <div class="card-content hc-flex">
  17. <div class="name-avatar hc-flex-center h-60px w-60px">{{ item.projectName.substring(0, 1) }}</div>
  18. <div class="name-content flex-1">
  19. <div class="alias">{{ item.projectAlias }}</div>
  20. <div class="name">{{ item.projectName }}</div>
  21. </div>
  22. </div>
  23. <div class="footer">
  24. <div class="id">{{ item.id }}</div>
  25. <div class="time">{{ item.updateTime }}</div>
  26. </div>
  27. </hc-card-item>
  28. </template>
  29. </div>
  30. <template #action>
  31. <hc-pages :pages="searchForm" @change="pageChange" />
  32. </template>
  33. <!-- 查看项目信息 -->
  34. <InfoDialog v-model="isProjectInfoDialog" :ids="projectInfoId" @change="projectInfoChange" @check="projectInfoCheck" @close="projectInfoClose" />
  35. <!-- wbs树管理 -->
  36. <HcWbsTree v-model="isWbsTreeDrawer" :type="wbsTreeType" :info="wbsTreeInfo" @change="wbsTreeChange" @close="wbsTreeClose" />
  37. <!-- 创建或编辑项目信息 -->
  38. <HcInfoDetail v-model="isProjectDrawer" :data="projectItem" />
  39. </hc-card>
  40. </template>
  41. <script setup>
  42. import { nextTick, onActivated, onDeactivated, ref } from 'vue'
  43. import { getArrValue, getObjValue } from 'js-fast-way'
  44. import InfoDialog from './list/info-dialog.vue'
  45. import HcWbsTree from './list/wbs-tree.vue'
  46. import HcInfoDetail from './info/detail.vue'
  47. import mainApi from '~api/project/project'
  48. defineOptions({
  49. name: 'ProjectList',
  50. })
  51. //激活
  52. onActivated(() => {
  53. getDataApi()
  54. })
  55. const getDataApi = async () => {
  56. await getProjectData()
  57. searchClick()
  58. }
  59. //项目列表
  60. const projectData = ref([])
  61. const projectId = ref('')
  62. const getProjectData = async () => {
  63. const { data } = await mainApi.page({
  64. current: 1,
  65. size: 999,
  66. })
  67. projectData.value = getArrValue(data?.records)
  68. }
  69. //搜索条件
  70. const searchForm = ref({ current: 1, size: 20, total: 0 })
  71. //搜索
  72. const searchClick = () => {
  73. searchForm.value.current = 1
  74. getTableData()
  75. }
  76. //分页
  77. const pageChange = ({ current, size }) => {
  78. searchForm.value.current = current
  79. searchForm.value.size = size
  80. getTableData()
  81. }
  82. //项目数据
  83. const tableData = ref([])
  84. //获取表格数据
  85. const tableLoading = ref(true)
  86. const getTableData = async () => {
  87. tableData.value = []
  88. tableLoading.value = true
  89. const { data } = await mainApi.page({
  90. ...searchForm.value,
  91. total: null,
  92. })
  93. tableLoading.value = false
  94. tableData.value = getArrValue(data?.records)
  95. searchForm.value.total = data?.total
  96. }
  97. //查看项目信息
  98. const isProjectInfoDialog = ref(false)
  99. const projectInfoId = ref('')
  100. //项目被选择
  101. const projectClick = (id) => {
  102. projectInfoId.value = id
  103. nextTick(() => {
  104. isProjectInfoDialog.value = true
  105. })
  106. }
  107. const projectInfoChange = () => {
  108. searchClick()
  109. }
  110. //关闭项目信息
  111. const projectInfoClose = () => {
  112. projectInfoId.value = ''
  113. isProjectInfoDialog.value = false
  114. }
  115. //wbs树管理
  116. const isWbsTreeDrawer = ref(false)
  117. const wbsTreeType = ref('')
  118. const wbsTreeInfo = ref({})
  119. const wbsTreeChange = () => {
  120. searchClick()
  121. }
  122. //关闭wbs树关联
  123. const wbsTreeClose = () => {
  124. isWbsTreeDrawer.value = false
  125. wbsTreeType.value = ''
  126. wbsTreeInfo.value = {}
  127. }
  128. //功能事件回调
  129. const projectInfoCheck = ({ type, info, item }) => {
  130. //measure, lar, test, wbsTree, logTree, editProject, addContract, editContract, wbsContract
  131. //计量管理,征拆划分,实验划分,WBS树管理,日志树管理,编辑项目,创建合同段,编辑合同段信息,分配WBS
  132. const wbsArr = ['wbsTree', 'test', 'measure', 'logTree', 'lar']
  133. const index = wbsArr.indexOf(type)
  134. if (index !== -1) {
  135. wbsTreeInfo.value = getObjValue(info)
  136. wbsTreeType.value = (index + 1) + ''
  137. isWbsTreeDrawer.value = true
  138. } else if (type === 'editProject') {
  139. projectItem.value = getObjValue(info)
  140. nextTick(() => {
  141. isProjectDrawer.value = true
  142. })
  143. } else if (type === 'addContract') {
  144. console.log('创建合同段')
  145. } else if (type === 'editContract') {
  146. console.log('创建合同段')
  147. } else if (type === 'wbsContract') {
  148. console.log('分配WBS')
  149. }
  150. //console.log(type, info, item)
  151. }
  152. //创建项目或修改项目
  153. const isProjectDrawer = ref(false)
  154. const projectItem = ref({})
  155. //创建项目
  156. const addProjectClick = () => {
  157. projectItem.value = {}
  158. nextTick(() => {
  159. isProjectDrawer.value = true
  160. })
  161. }
  162. //离开了当前页面
  163. onDeactivated(() => {
  164. isWbsTreeDrawer.value = false
  165. })
  166. </script>
  167. <style lang="scss">
  168. @import '~src/styles/view/project/list';
  169. </style>