project-message.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <script setup>
  2. import { propertyData } from "../configs/properites";
  3. import moduleDialog from "@/views//modules/project-config/components/test-module-dialog.vue";
  4. import TitleHeader from "@/views/modules/project-config/com/titleHeader.vue";
  5. import { delTestModule } from "@/api/project";
  6. import { useCommonStoreHook } from "@/store";
  7. import { getProjectById, getTestProjectList } from "@/api/project/index";
  8. const { currentProjectId, currentTestItemId } = toRefs(useCommonStoreHook());
  9. const emits = defineEmits(["onClickItem"]);
  10. const router = useRouter();
  11. const goGlobalConfig = () => {
  12. router.push({
  13. name: "GlobalConfig",
  14. params: { engineerId: currentProjectId.value },
  15. });
  16. };
  17. // 当前正在配置的项目信息
  18. const currentProject = ref();
  19. onMounted(() => {
  20. getProjectById(currentProjectId.value).then((res) => {
  21. currentProject.value = res.data;
  22. toGetTestProjectList();
  23. });
  24. });
  25. const testProjectList = ref([]);
  26. const toGetTestProjectList = () => {
  27. // 获取完配置工程信息后,获取测试项目列表
  28. getTestProjectList({
  29. engineeringId: currentProject.value.engineeringId,
  30. }).then((res) => {
  31. testProjectList.value = res.data ?? [];
  32. });
  33. };
  34. let clickItem = null;
  35. // 当点击了项目
  36. const clickTestProjectItem = (item) => {
  37. let data = JSON.parse(JSON.stringify(item));
  38. clickItem = data;
  39. currentTestItemId.value = item.id;
  40. emits("onClickItem", data);
  41. };
  42. const moduleDialogRef = ref();
  43. //新增测试项目
  44. const addProject = () => {
  45. moduleDialogRef.value.openDialog(false, null, currentProjectId.value);
  46. };
  47. //修改测试项目
  48. const editProject = () => {
  49. clickItem &&
  50. moduleDialogRef.value.openDialog(true, clickItem, currentProjectId.value);
  51. };
  52. //删除测试项目
  53. const confirmEvent = () => {
  54. if (currentTestItemId.value) {
  55. delTestModule({
  56. id: currentTestItemId.value,
  57. }).then((res) => {
  58. currentTestItemId.value = "";
  59. toGetTestProjectList(); //重新获取
  60. });
  61. }
  62. };
  63. </script>
  64. <template>
  65. <div class="project-message-col">
  66. <TitleHeader> 工程信息</TitleHeader>
  67. <div class="project-msg-item">
  68. <span class="text-l">产品:</span>
  69. <span class="text-r">{{ currentProject?.engineeringProductName }}</span>
  70. <span class="edit">
  71. <svg-icon icon-class="homeIcon2" />
  72. </span>
  73. </div>
  74. <div class="project-msg-item">
  75. <span class="text-l">工程类型:</span
  76. ><span class="text-r">{{ currentProject?.engineeringType }}</span>
  77. </div>
  78. <div class="project-msg-item">
  79. <span class="text-l">版本:</span
  80. ><span class="text-r">{{ currentProject?.engineeringVersion }}</span>
  81. </div>
  82. <div class="project-msg-item">
  83. <!-- <span class="text-l">更新时间:</span>-->
  84. <span class="text-r">{{ currentProject?.updated }}</span>
  85. </div>
  86. <div class="project-all-config" @click="goGlobalConfig">
  87. <svg-icon icon-class="project-config" />
  88. 全局配置
  89. </div>
  90. <div class="project-test-btn">
  91. <div class="name">测试项目</div>
  92. <div class="btn">
  93. <el-popconfirm
  94. width="220"
  95. confirm-button-text="确认"
  96. cancel-button-text="取消"
  97. title="是否删除"
  98. @confirm="confirmEvent"
  99. >
  100. <template #reference>
  101. <span>-</span>
  102. </template>
  103. </el-popconfirm>
  104. <span @click="addProject">+</span>
  105. <span class="edit" @click="editProject">
  106. <svg-icon icon-class="homeIcon2" />
  107. </span>
  108. </div>
  109. </div>
  110. <div class="project-list-cont">
  111. <el-scrollbar>
  112. <div
  113. class="project-list-item"
  114. :class="[
  115. item.id === currentTestItemId ? 'selected-item' : 'normal-item',
  116. ]"
  117. v-for="item in testProjectList"
  118. :key="item.id"
  119. @click="clickTestProjectItem(item)"
  120. >
  121. {{ item.projectName }}
  122. </div>
  123. </el-scrollbar>
  124. </div>
  125. </div>
  126. <moduleDialog ref="moduleDialogRef" @saveFinish="toGetTestProjectList" />
  127. </template>
  128. <style scoped lang="scss">
  129. .project-message-col {
  130. width: 200px;
  131. flex-shrink: 0;
  132. height: calc(100vh - $main-header-height);
  133. background-color: $hj-black-2;
  134. border-right: 1px solid $hj-white-4;
  135. .project-msg-item {
  136. position: relative;
  137. padding: 0 11px;
  138. margin-bottom: 10px;
  139. .text-l {
  140. font-size: var(--hj-fs-12);
  141. color: var(--fc-color-3);
  142. }
  143. .text-r {
  144. font-size: var(--hj-fs-14);
  145. color: var(--hj-white-1);
  146. }
  147. .edit {
  148. cursor: pointer;
  149. position: absolute;
  150. right: 20px;
  151. color: var(--hj-white-1);
  152. }
  153. }
  154. .project-all-config {
  155. width: 130px;
  156. height: 36px;
  157. line-height: 36px;
  158. margin: 0 auto;
  159. background: var(--fc-color-7);
  160. color: var(--hj-white-1);
  161. text-align: center;
  162. border-radius: 4px 4px 4px 4px;
  163. cursor: pointer;
  164. }
  165. .project-test-btn {
  166. display: flex;
  167. justify-content: space-between;
  168. margin: 0 12px;
  169. margin-top: 12px;
  170. position: relative;
  171. padding: 14px 0;
  172. &::before {
  173. position: absolute;
  174. top: 0;
  175. content: "";
  176. display: block;
  177. width: 100%;
  178. height: 1px;
  179. background-color: var(--hj-white-4);
  180. }
  181. .name {
  182. font-size: var(--hj-fs-14);
  183. font-weight: 400;
  184. color: var(--hj-white-1);
  185. }
  186. .btn {
  187. span {
  188. cursor: pointer;
  189. display: inline-block;
  190. width: 18px;
  191. height: 18px;
  192. text-align: center;
  193. line-height: 16px;
  194. border-radius: 0px 0px 0px 0px;
  195. border: 1px solid #ffffff;
  196. color: var(--hj-white-1);
  197. //&:nth-of-type(2) {
  198. margin-left: 8px;
  199. //}
  200. }
  201. }
  202. }
  203. .project-list-cont {
  204. height: calc(100vh - $main-header-height - 310px);
  205. overflow-y: auto;
  206. .project-list-item {
  207. cursor: pointer;
  208. margin: 0 12px;
  209. margin-bottom: 12px;
  210. height: 36px;
  211. line-height: 36px;
  212. text-align: center;
  213. border-radius: 4px 4px 4px 4px;
  214. border: 1px solid #3b7cff;
  215. }
  216. .normal-item {
  217. background-color: transparent;
  218. color: $hj-white-3;
  219. font-weight: normal;
  220. font-size: var(--hj-fs-12);
  221. }
  222. .selected-item {
  223. background: rgba(59, 124, 255, 0.5);
  224. color: $hj-white-1;
  225. font-weight: bold;
  226. font-size: var(--hj-fs-14);
  227. }
  228. }
  229. }
  230. </style>