home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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="showDetailsFun(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. const checkAll = ref(false);
  150. const isIndeterminate = ref(true);
  151. const checkedCities = ref([]);
  152. const typeList = ref([]);
  153. // 获取所有的工程类型
  154. const getEngineeringTypeList = () => {
  155. getProjectTypeCount().then((res) => {
  156. typeList.value = res.data?.statisticsList ?? [];
  157. });
  158. };
  159. const handleCheckAllChange = (val: CheckboxValueType) => {
  160. checkedCities.value = val
  161. ? typeList.value.map((item) => item.engineeringType)
  162. : [];
  163. isIndeterminate.value = false;
  164. getEngineeringList(false);
  165. };
  166. const handleCheckedCitiesChange = (value: CheckboxValueType[]) => {
  167. const checkedCount = value.length;
  168. checkAll.value = checkedCount === typeList.value.length;
  169. isIndeterminate.value =
  170. checkedCount > 0 && checkedCount < typeList.value.length;
  171. getEngineeringList(false);
  172. };
  173. interface VersionItem {
  174. id: string; // 主键 string
  175. engineeringProductName: string; // 产品名称 string
  176. engineeringType: string; // 工程类型 string
  177. engineeringVersion: string; // 工程版本 string
  178. creator: string; //创建人 string 开发人员
  179. updated: string; // 修改时间 string(date-time)
  180. created: string; // 创建时间string(date-time)
  181. deleted: string; // 删除标识;0-未删除;1-已删除 integer(int32)
  182. deptId: string; // 部门ID string
  183. orgId: string; // 组织ID string
  184. updator: string; // 上次修改人 string
  185. publishStatus: number; //发布状态:0-发布 1-未发布
  186. }
  187. /**
  188. * 显示新增弹框
  189. */
  190. const addRef = ref();
  191. const showAddFun = () => {
  192. addRef.value && addRef.value.openDialog();
  193. };
  194. const toEdit = (row) => {
  195. addRef.value &&
  196. addRef.value.openDialog(true, JSON.parse(JSON.stringify(row)));
  197. };
  198. // 发布
  199. const changeProjectStatus = async (item: VersionItem) => {
  200. await updateProject(item);
  201. getEngineeringList(false);
  202. };
  203. /**
  204. * 显示新增弹框
  205. */
  206. const detailRef = ref();
  207. const showDetailsFun = (row: any) => {
  208. detailRef.value &&
  209. detailRef.value.openDialog(true, JSON.parse(JSON.stringify(row)));
  210. };
  211. // 获取列表数据
  212. const currentPage = ref(1);
  213. const pageSize = ref(9);
  214. const total = ref(0);
  215. const engineeringList = ref<VersionItem[]>([]);
  216. const handleSizeChange = (val: number) => {
  217. pageSize.value = val;
  218. currentPage.value = 1;
  219. getEngineeringList();
  220. };
  221. const handleCurrentChange = (val: number) => {
  222. currentPage.value = val;
  223. getEngineeringList();
  224. };
  225. // const isAsc = ref();
  226. const getEngineeringList = (andGetTypes: boolean = true) => {
  227. getProjectPage({
  228. engineeringTypeList: [...checkedCities.value],
  229. // orders: [
  230. // {
  231. // column: "",
  232. // isAsc: true,
  233. // },
  234. // ],
  235. pageNo: currentPage.value,
  236. pageSize: pageSize.value,
  237. // publishStatus: 0,
  238. }).then((res) => {
  239. console.log(res);
  240. engineeringList.value = res.data.records;
  241. total.value = res.data.totalCount;
  242. });
  243. if (andGetTypes) {
  244. getEngineeringTypeList();
  245. }
  246. };
  247. onMounted(() => {
  248. getEngineeringList();
  249. });
  250. // 删除相关
  251. const onDelCancel = () => {};
  252. const deleteConfirm = async (item) => {
  253. await deleteProject(item.id);
  254. ElMessage.success("删除成功");
  255. getEngineeringList();
  256. };
  257. </script>
  258. <style scoped lang="scss">
  259. .mainContentBox {
  260. position: absolute;
  261. width: 100%;
  262. .content-head {
  263. color: var(--hj-white-1);
  264. display: flex;
  265. height: 100px;
  266. background: $hj-white-1;
  267. // width: 100%;
  268. // overflow: hidden;
  269. min-width: 0;
  270. .head-box-all {
  271. padding: 6px;
  272. box-sizing: border-box;
  273. border-radius: 4px 0 0 4px;
  274. width: 90px;
  275. height: 100px;
  276. background: linear-gradient(270deg, #3b7cff 0%, #8aa9ec 100%);
  277. color: var(--hj-white-1);
  278. font-size: var(--hj-fs-12);
  279. text-align: center;
  280. .box-all {
  281. color: var(--hj-white-1);
  282. font-size: var(--hj-fs-12);
  283. }
  284. .box-num {
  285. text-align: center;
  286. font-size: var(--hj-fs-24);
  287. }
  288. }
  289. .head-box-group {
  290. flex: 1;
  291. .el-checkbox-group {
  292. height: 100%;
  293. width: 100%;
  294. overflow-x: auto;
  295. overflow-y: hidden;
  296. white-space: nowrap;
  297. display: flex;
  298. align-content: center;
  299. align-items: center;
  300. flex-direction: row;
  301. .head-box-item {
  302. position: relative;
  303. flex: 0 0 182px;
  304. font-size: var(--hj-fs-14);
  305. margin-top: 16px;
  306. padding: 6px;
  307. margin-left: 12px;
  308. height: 67px;
  309. border: 1px solid #afb9d0;
  310. border-radius: 4px 4px 4px 4px;
  311. text-align: center;
  312. .el-checkbox {
  313. position: absolute;
  314. left: 6px;
  315. top: 0;
  316. }
  317. .name {
  318. line-height: 16px;
  319. margin-top: 12px;
  320. font-size: var(--hj-fs-14);
  321. color: var(--fc-color-5);
  322. }
  323. .num {
  324. line-height: 26px;
  325. font-size: var(--hj-fs-20);
  326. font-weight: bold;
  327. color: var(--fc-color-7);
  328. }
  329. &.active {
  330. background: linear-gradient(90deg, #3cbaff 0%, #3b7cff 100%);
  331. .name {
  332. color: var(--hj-white-1);
  333. }
  334. .num {
  335. color: var(--hj-white-1);
  336. }
  337. }
  338. }
  339. }
  340. }
  341. }
  342. .content-body {
  343. .cotent-btns {
  344. display: flex;
  345. justify-content: space-between;
  346. align-items: center;
  347. margin-top: 26px;
  348. margin-bottom: 12px;
  349. .add {
  350. width: 12px;
  351. height: 12px;
  352. line-height: 12px;
  353. border-radius: 12px;
  354. text-align: center;
  355. background-color: #fff;
  356. color: #3b7cff;
  357. margin-right: 10px;
  358. }
  359. .active,
  360. .normal {
  361. i {
  362. width: 14px;
  363. height: 14px;
  364. border-radius: 14px;
  365. vertical-align: middle;
  366. margin-right: 10px;
  367. }
  368. }
  369. .active {
  370. border: 1px solid #1989fa;
  371. color: #1871f8;
  372. i {
  373. border: 4px solid #3b7cff;
  374. }
  375. }
  376. .normal {
  377. i {
  378. border: 1px solid #d5d8de;
  379. }
  380. }
  381. }
  382. }
  383. .content-list {
  384. width: 100%;
  385. display: grid;
  386. grid-template-columns: repeat(3, 1fr);
  387. gap: 20px;
  388. .content-list-item {
  389. border: 1px solid #ccc;
  390. box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  391. border-radius: 4px 4px 4px 4px;
  392. padding-top: 12px;
  393. background-color: $hj-white-1;
  394. }
  395. .list-item-flex {
  396. margin-bottom: 12px;
  397. padding: 0 20px;
  398. display: flex;
  399. justify-content: space-between;
  400. align-items: center;
  401. font-size: var(--hj-fs-12);
  402. color: var(--fc-color-5);
  403. .list-itme-tit {
  404. font-size: var(--hj-fs-14);
  405. font-weight: bold;
  406. }
  407. .list-item-switch {
  408. .item-gray {
  409. line-height: 32px;
  410. margin-right: 4px;
  411. }
  412. }
  413. .item-gray {
  414. color: var(--fc-color-3);
  415. }
  416. }
  417. .list-item-btns {
  418. height: 37px;
  419. line-height: 37px;
  420. color: var(--fc-color-6);
  421. display: flex;
  422. justify-content: space-around;
  423. border-top: 1px solid rgba(175, 185, 208, 0.3);
  424. span {
  425. cursor: pointer;
  426. }
  427. }
  428. }
  429. .content-pag {
  430. float: right;
  431. margin-right: 20px;
  432. margin-top: 20px;
  433. padding-bottom: 30px;
  434. }
  435. }
  436. </style>