home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div class="mainContentBox">
  3. <div class="content-head">
  4. <div class="head-box-all">
  5. <div class="box-all">
  6. <el-checkbox
  7. v-model="checkAll"
  8. :indeterminate="isIndeterminate"
  9. @change="handleCheckAllChange"
  10. >
  11. </el-checkbox>
  12. <span>显示全部</span>
  13. </div>
  14. <div class="box-num">{{ checkedCities.length }}</div>
  15. <div class="box-text">工程类型</div>
  16. </div>
  17. <div class="head-box-group">
  18. <el-checkbox-group
  19. v-model="checkedCities"
  20. @change="handleCheckedCitiesChange"
  21. >
  22. <div
  23. class="head-box-item"
  24. :class="[
  25. checkedCities.includes(type.engineeringType) ? 'active' : '',
  26. ]"
  27. v-for="type in typeList"
  28. :key="type.engineeringType"
  29. >
  30. <el-checkbox label="" :value="type.engineeringType"></el-checkbox>
  31. <div class="name">{{ type.engineeringType }}</div>
  32. <div class="num">{{ type.typeCount }}</div>
  33. </div>
  34. </el-checkbox-group>
  35. </div>
  36. </div>
  37. <div class="content-body">
  38. <div class="cotent-btns">
  39. <div>工程列表</div>
  40. <div>
  41. <el-button type="primary" @click="showAddFun">
  42. <span class="add">+</span>
  43. 新增工程
  44. </el-button>
  45. <!-- <el-button class="active">-->
  46. <!-- <i />-->
  47. <!-- 按时间倒序-->
  48. <!-- </el-button>-->
  49. <!-- <el-button class="normal">-->
  50. <!-- <i />-->
  51. <!-- 按创建人姓名-->
  52. <!-- </el-button>-->
  53. </div>
  54. </div>
  55. <div class="content-list">
  56. <div
  57. v-for="(item, index) in engineeringList"
  58. :key="index"
  59. class="content-list-item"
  60. >
  61. <div class="list-item-flex">
  62. <div class="list-itme-tit">{{ item.engineeringProductName }}</div>
  63. <div class="list-item-switch">
  64. <span class="item-gray">发布</span
  65. ><el-switch
  66. v-model="item.publishStatus"
  67. @change="changeProjectStatus(item)"
  68. />
  69. </div>
  70. </div>
  71. <div class="list-item-flex">
  72. <div>
  73. <span class="item-gray">工程类型:</span
  74. >{{ item.engineeringType }}
  75. </div>
  76. <div>
  77. <span class="item-gray">版本:</span>{{ item.engineeringVersion }}
  78. </div>
  79. </div>
  80. <div class="list-item-flex">
  81. <div>
  82. <span class="item-gray">开发人员:</span>{{ item.creator }}
  83. </div>
  84. <div>
  85. <span class="item-gray">更新时间:</span>{{ item.updated }}
  86. </div>
  87. </div>
  88. <div class="list-item-btns">
  89. <span @click="toEdit(item)">
  90. <svg-icon icon-class="homeIcon2" />
  91. </span>
  92. <el-popconfirm
  93. width="220"
  94. :icon="InfoFilled"
  95. icon-color="#626AEF"
  96. title="确认要删除这个工程吗?"
  97. @cancel="onDelCancel"
  98. @confirm="deleteConfirm(item)"
  99. >
  100. <template #reference>
  101. <span>
  102. <svg-icon icon-class="homeIcon3" />
  103. </span>
  104. </template>
  105. <template #actions="{ confirm, cancel }">
  106. <el-button size="small" @click="cancel">取消</el-button>
  107. <el-button type="danger" size="small" @click="confirm">
  108. 确认删除
  109. </el-button>
  110. </template>
  111. </el-popconfirm>
  112. <span @click="gotoConfigProject(item)">
  113. <svg-icon icon-class="homeIcon4" />
  114. </span>
  115. <span>
  116. <svg-icon icon-class="homeIcon1" />
  117. </span>
  118. </div>
  119. </div>
  120. </div>
  121. <el-pagination
  122. class="content-pag"
  123. background
  124. layout="sizes,prev, pager, next"
  125. :current-page="currentPage"
  126. :page-size="pageSize"
  127. :total="total"
  128. :page-sizes="[9, 12, 15, 18, 30]"
  129. @size-change="handleSizeChange"
  130. @current-change="handleCurrentChange"
  131. />
  132. </div>
  133. <AddComponent ref="addRef" @save-finish="getEngineeringList" />
  134. <DetailsComponent ref="detailRef" />
  135. </div>
  136. </template>
  137. <script lang="ts" setup>
  138. import { InfoFilled } from "@element-plus/icons-vue";
  139. import AddComponent from "./components/add.vue";
  140. import DetailsComponent from "./components/details.vue";
  141. import { ref } from "vue";
  142. import type { CheckboxValueType } from "element-plus";
  143. import {
  144. deleteProject,
  145. getProjectPage,
  146. getProjectTypeCount,
  147. updateProject,
  148. } from "@/api/project";
  149. import { useCommonStoreHook } from "@/store";
  150. const { currentProjectId, currentMenu, pageSize } =
  151. toRefs(useCommonStoreHook());
  152. const checkAll = ref(false);
  153. const isIndeterminate = ref(true);
  154. const checkedCities = ref([]);
  155. const typeList = ref([]);
  156. // 获取所有的工程类型
  157. const getEngineeringTypeList = () => {
  158. getProjectTypeCount().then((res) => {
  159. typeList.value = res.data?.statisticsList ?? [];
  160. });
  161. };
  162. const handleCheckAllChange = (val: CheckboxValueType) => {
  163. checkedCities.value = val
  164. ? typeList.value.map((item) => item.engineeringType)
  165. : [];
  166. isIndeterminate.value = false;
  167. getEngineeringList(false);
  168. };
  169. const handleCheckedCitiesChange = (value: CheckboxValueType[]) => {
  170. const checkedCount = value.length;
  171. checkAll.value = checkedCount === typeList.value.length;
  172. isIndeterminate.value =
  173. checkedCount > 0 && checkedCount < typeList.value.length;
  174. getEngineeringList(false);
  175. };
  176. interface VersionItem {
  177. id: string; // 主键 string
  178. engineeringProductName: string; // 产品名称 string
  179. engineeringType: string; // 工程类型 string
  180. engineeringVersion: string; // 工程版本 string
  181. creator: string; //创建人 string 开发人员
  182. updated: string; // 修改时间 string(date-time)
  183. created: string; // 创建时间string(date-time)
  184. deleted: string; // 删除标识;0-未删除;1-已删除 integer(int32)
  185. deptId: string; // 部门ID string
  186. orgId: string; // 组织ID string
  187. updator: string; // 上次修改人 string
  188. publishStatus: number; //发布状态:0-发布 1-未发布
  189. }
  190. /**
  191. * 显示新增弹框
  192. */
  193. const addRef = ref();
  194. const showAddFun = () => {
  195. addRef.value && addRef.value.openDialog();
  196. };
  197. const toEdit = (row) => {
  198. addRef.value &&
  199. addRef.value.openDialog(true, JSON.parse(JSON.stringify(row)));
  200. };
  201. // 发布
  202. const changeProjectStatus = async (item: VersionItem) => {
  203. await updateProject(item);
  204. getEngineeringList(false);
  205. };
  206. /**
  207. * 显示新增弹框
  208. */
  209. const detailRef = ref();
  210. const showDetailsFun = (row: any) => {
  211. detailRef.value &&
  212. detailRef.value.openDialog(true, JSON.parse(JSON.stringify(row)));
  213. };
  214. // 获取列表数据
  215. const currentPage = ref(1);
  216. const total = ref(0);
  217. const engineeringList = ref<VersionItem[]>([]);
  218. const handleSizeChange = (val: number) => {
  219. currentPage.value = 1;
  220. pageSize.value = val;
  221. getEngineeringList();
  222. };
  223. const handleCurrentChange = (val: number) => {
  224. currentPage.value = val;
  225. getEngineeringList();
  226. };
  227. // const isAsc = ref();
  228. const getEngineeringList = (andGetTypes: boolean = true) => {
  229. getProjectPage({
  230. engineeringTypeList: [...checkedCities.value],
  231. // orders: [
  232. // {
  233. // column: "",
  234. // isAsc: true,
  235. // },
  236. // ],
  237. pageNo: currentPage.value,
  238. pageSize: pageSize.value,
  239. // publishStatus: 0,
  240. }).then((res) => {
  241. console.log(res);
  242. engineeringList.value = res.data.records;
  243. total.value = res.data.totalCount;
  244. });
  245. if (andGetTypes) {
  246. getEngineeringTypeList();
  247. }
  248. };
  249. onMounted(() => {
  250. getEngineeringList();
  251. });
  252. // 删除相关
  253. const onDelCancel = () => {};
  254. const deleteConfirm = async (item) => {
  255. await deleteProject(item.id);
  256. ElMessage.success("删除成功");
  257. getEngineeringList();
  258. };
  259. // 去到配置工程页面
  260. const router = useRouter();
  261. const gotoConfigProject = (project) => {
  262. currentProjectId.value = project.id;
  263. currentMenu.value = {
  264. name: "工程配置",
  265. icon: "project-config",
  266. route: "/main/project-config",
  267. };
  268. router.push("/main/project-config");
  269. };
  270. </script>
  271. <style scoped lang="scss">
  272. .mainContentBox {
  273. position: absolute;
  274. width: 100%;
  275. .content-head {
  276. color: var(--hj-white-1);
  277. display: flex;
  278. height: 100px;
  279. background: $hj-white-1;
  280. // width: 100%;
  281. // overflow: hidden;
  282. min-width: 0;
  283. .head-box-all {
  284. padding: 6px;
  285. box-sizing: border-box;
  286. border-radius: 4px 0 0 4px;
  287. width: 90px;
  288. height: 100px;
  289. background: linear-gradient(270deg, #3b7cff 0%, #8aa9ec 100%);
  290. color: var(--hj-white-1);
  291. font-size: var(--hj-fs-12);
  292. text-align: center;
  293. .box-all {
  294. color: var(--hj-white-1);
  295. font-size: var(--hj-fs-12);
  296. }
  297. .box-num {
  298. text-align: center;
  299. font-size: var(--hj-fs-24);
  300. }
  301. }
  302. .head-box-group {
  303. flex: 1;
  304. .el-checkbox-group {
  305. height: 100%;
  306. width: 100%;
  307. overflow-x: auto;
  308. overflow-y: hidden;
  309. white-space: nowrap;
  310. display: flex;
  311. align-content: center;
  312. align-items: center;
  313. flex-direction: row;
  314. .head-box-item {
  315. position: relative;
  316. flex: 0 0 182px;
  317. font-size: var(--hj-fs-14);
  318. margin-top: 16px;
  319. padding: 6px;
  320. margin-left: 12px;
  321. height: 67px;
  322. border: 1px solid #afb9d0;
  323. border-radius: 4px 4px 4px 4px;
  324. text-align: center;
  325. .el-checkbox {
  326. position: absolute;
  327. left: 6px;
  328. top: 0;
  329. }
  330. .name {
  331. line-height: 16px;
  332. margin-top: 12px;
  333. font-size: var(--hj-fs-14);
  334. color: var(--fc-color-5);
  335. }
  336. .num {
  337. line-height: 26px;
  338. font-size: var(--hj-fs-20);
  339. font-weight: bold;
  340. color: var(--fc-color-7);
  341. }
  342. &.active {
  343. background: linear-gradient(90deg, #3cbaff 0%, #3b7cff 100%);
  344. .name {
  345. color: var(--hj-white-1);
  346. }
  347. .num {
  348. color: var(--hj-white-1);
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. .content-body {
  356. .cotent-btns {
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. margin-top: 26px;
  361. margin-bottom: 12px;
  362. .add {
  363. width: 12px;
  364. height: 12px;
  365. line-height: 12px;
  366. border-radius: 12px;
  367. text-align: center;
  368. background-color: #fff;
  369. color: #3b7cff;
  370. margin-right: 10px;
  371. }
  372. .active,
  373. .normal {
  374. i {
  375. width: 14px;
  376. height: 14px;
  377. border-radius: 14px;
  378. vertical-align: middle;
  379. margin-right: 10px;
  380. }
  381. }
  382. .active {
  383. border: 1px solid #1989fa;
  384. color: #1871f8;
  385. i {
  386. border: 4px solid #3b7cff;
  387. }
  388. }
  389. .normal {
  390. i {
  391. border: 1px solid #d5d8de;
  392. }
  393. }
  394. }
  395. }
  396. .content-list {
  397. width: 100%;
  398. display: grid;
  399. grid-template-columns: repeat(3, 1fr);
  400. gap: 20px;
  401. .content-list-item {
  402. border: 1px solid #ccc;
  403. box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  404. border-radius: 4px 4px 4px 4px;
  405. padding-top: 12px;
  406. background-color: $hj-white-1;
  407. }
  408. .list-item-flex {
  409. margin-bottom: 12px;
  410. padding: 0 20px;
  411. display: flex;
  412. justify-content: space-between;
  413. align-items: center;
  414. font-size: var(--hj-fs-12);
  415. color: var(--fc-color-5);
  416. .list-itme-tit {
  417. font-size: var(--hj-fs-14);
  418. font-weight: bold;
  419. }
  420. .list-item-switch {
  421. .item-gray {
  422. line-height: 32px;
  423. margin-right: 4px;
  424. }
  425. }
  426. .item-gray {
  427. color: var(--fc-color-3);
  428. }
  429. }
  430. .list-item-btns {
  431. height: 37px;
  432. line-height: 37px;
  433. color: var(--fc-color-6);
  434. display: flex;
  435. justify-content: space-around;
  436. border-top: 1px solid rgba(175, 185, 208, 0.3);
  437. span {
  438. cursor: pointer;
  439. }
  440. }
  441. }
  442. .content-pag {
  443. float: right;
  444. margin-right: 20px;
  445. margin-top: 20px;
  446. padding-bottom: 30px;
  447. }
  448. }
  449. </style>