8
0

list.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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-[354px]">
  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. <hc-card-item v-for="item in tableData" :key="item.id" class="hc-project-list-card" @click="projectClick(item.id)">
  14. <div class="alias">{{ item.projectAlias }}</div>
  15. <div class="name">{{ item.projectName }}</div>
  16. <div class="footer">
  17. <div class="id">{{ item.id }}</div>
  18. <div class="time">{{ item.updateTime }}</div>
  19. </div>
  20. </hc-card-item>
  21. <template #action>
  22. <hc-pages :pages="searchForm" @change="pageChange" />
  23. </template>
  24. <!-- 查看项目信息 -->
  25. <InfoDialog v-model="isProjectInfoDialog" :ids="projectInfoId" @change="projectInfoChange" @check="projectInfoCheck" @close="projectInfoClose" />
  26. <!-- wbs树管理 -->
  27. <HcWbsTree v-model="isWbsTreeDrawer" :type="wbsTreeType" :info="wbsTreeInfo" @change="wbsTreeChange" @close="wbsTreeClose" />
  28. <!-- 创建或编辑项目信息 -->
  29. <hc-drawer v-model="isProjectDrawer" is-close to-id="hc-project-list">
  30. 创建或编辑项目信息
  31. </hc-drawer>
  32. </hc-card>
  33. </template>
  34. <script setup>
  35. import { nextTick, onActivated, ref } from 'vue'
  36. import { getArrValue, getObjValue } from 'js-fast-way'
  37. import InfoDialog from './modules/list/info-dialog.vue'
  38. import HcWbsTree from './modules/list/wbs-tree.vue'
  39. import mainApi from '~api/project/project'
  40. defineOptions({
  41. name: 'ProjectList',
  42. })
  43. //激活
  44. onActivated(() => {
  45. getDataApi()
  46. })
  47. const getDataApi = async () => {
  48. await getProjectData()
  49. searchClick()
  50. }
  51. //项目列表
  52. const projectData = ref([])
  53. const projectId = ref('')
  54. const getProjectData = async () => {
  55. const { data } = await mainApi.page({
  56. current: 1,
  57. size: 999,
  58. })
  59. projectData.value = getArrValue(data?.records)
  60. }
  61. //搜索条件
  62. const searchForm = ref({ current: 1, size: 20, total: 0 })
  63. //搜索
  64. const searchClick = () => {
  65. searchForm.value.current = 1
  66. getTableData()
  67. }
  68. //分页
  69. const pageChange = ({ current, size }) => {
  70. searchForm.value.current = current
  71. searchForm.value.size = size
  72. getTableData()
  73. }
  74. //项目数据
  75. const tableData = ref([])
  76. //获取表格数据
  77. const tableLoading = ref(true)
  78. const getTableData = async () => {
  79. tableData.value = []
  80. tableLoading.value = true
  81. const { error, code, data } = await mainApi.page({
  82. ...searchForm.value,
  83. total: null,
  84. })
  85. tableLoading.value = false
  86. if (!error && code === 200) {
  87. tableData.value = getArrValue(data['records'])
  88. searchForm.value.total = data['total']
  89. } else {
  90. tableData.value = []
  91. searchForm.value.total = 0
  92. }
  93. }
  94. //查看项目信息
  95. const isProjectInfoDialog = ref(false)
  96. const projectInfoId = ref('')
  97. //项目被选择
  98. const projectClick = (id) => {
  99. projectInfoId.value = id
  100. nextTick(() => {
  101. isProjectInfoDialog.value = true
  102. })
  103. }
  104. const projectInfoChange = () => {
  105. searchClick()
  106. }
  107. //关闭项目信息
  108. const projectInfoClose = () => {
  109. projectInfoId.value = ''
  110. isProjectInfoDialog.value = false
  111. }
  112. //wbs树管理
  113. const isWbsTreeDrawer = ref(false)
  114. const wbsTreeType = ref('')
  115. const wbsTreeInfo = ref({})
  116. const wbsTreeChange = () => {
  117. searchClick()
  118. }
  119. //关闭wbs树关联
  120. const wbsTreeClose = () => {
  121. isWbsTreeDrawer.value = false
  122. wbsTreeType.value = ''
  123. wbsTreeInfo.value = {}
  124. }
  125. //功能事件回调
  126. const projectInfoCheck = ({ type, info, item }) => {
  127. //measure, lar, test, wbsTree, logTree, editProject, addContract, editContract, wbsContract
  128. //计量管理,征拆划分,实验划分,WBS树管理,日志树管理,编辑项目,创建合同段,编辑合同段信息,分配WBS
  129. const wbsArr = ['wbsTree', 'test', 'measure', 'logTree', 'lar']
  130. const index = wbsArr.indexOf(type)
  131. if (index !== -1) {
  132. wbsTreeInfo.value = getObjValue(info)
  133. wbsTreeType.value = (index + 1) + ''
  134. isWbsTreeDrawer.value = true
  135. } else if (type === 'editProject') {
  136. console.log('编辑项目')
  137. } else if (type === 'addContract') {
  138. console.log('创建合同段')
  139. } else if (type === 'editContract') {
  140. console.log('创建合同段')
  141. } else if (type === 'wbsContract') {
  142. console.log('分配WBS')
  143. }
  144. //console.log(type, info, item)
  145. }
  146. //创建项目或修改项目
  147. const isProjectDrawer = ref(false)
  148. const projectDrawerId = ref('')
  149. //创建项目
  150. const addProjectClick = () => {
  151. projectDrawerId.value = ''
  152. nextTick(() => {
  153. isProjectDrawer.value = true
  154. })
  155. }
  156. </script>
  157. <style lang="scss">
  158. .hc-card-item-box.hc-project-list-card {
  159. width: 354px;
  160. height: 120px;
  161. display: inline-block;
  162. border-radius: 4px;
  163. margin-right: 14px;
  164. margin-bottom: 14px;
  165. cursor: pointer;
  166. background: #f3f3f3 !important;
  167. transition: all 0.3s;
  168. .alias {
  169. font-size: 16px;
  170. white-space:nowrap;
  171. overflow:hidden;
  172. text-overflow:ellipsis;
  173. text-align: left;
  174. }
  175. .name {
  176. text-align: left;
  177. font-size: 14px;
  178. color: #747474;
  179. margin-top: 10px;
  180. overflow: hidden;
  181. text-overflow: ellipsis; /* 超出部分省略号 */
  182. word-break: break-all; /* 设置省略字母数字 */
  183. display: -webkit-box;
  184. -webkit-box-orient: vertical;
  185. -webkit-line-clamp: 2; /* 显示的行数 */
  186. }
  187. .footer {
  188. position: absolute;
  189. color: #747474;
  190. display: flex;
  191. align-items: center;
  192. font-size: 14px;
  193. justify-content: space-between;
  194. bottom: 0;
  195. width: 100%;
  196. }
  197. &:hover {
  198. box-shadow: 2px 2px var(--el-color-primary-light-7);
  199. }
  200. }
  201. .hc-card-main.hc-project-list {
  202. text-align: center;
  203. }
  204. </style>