|
@@ -0,0 +1,213 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
|
|
|
+ <span class="tw-mr-4"></span>
|
|
|
+ <a-input
|
|
|
+ v-model:value="name"
|
|
|
+ class="tw-mr-4"
|
|
|
+ style="width: 178px"
|
|
|
+ placeholder="项目名称"
|
|
|
+ allowClear
|
|
|
+ ></a-input>
|
|
|
+
|
|
|
+ <span class="tw-mr-4"></span>
|
|
|
+ <ProjectStatusSelect v-model:value="projectStatus" />
|
|
|
+ <span class="tw-mr-4"></span>
|
|
|
+ <a-button @click="search">查询</a-button>
|
|
|
+
|
|
|
+ <div class="tw-mt-4">
|
|
|
+ <a-button @click="newProject">新增</a-button>
|
|
|
+ <a-button @click="handleDeleteProjects(selectIds)"> 批量删除 </a-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="tw-bg-white tw-p-5 tw-rounded-xl">
|
|
|
+ <a-table
|
|
|
+ row-key="id"
|
|
|
+ :columns="columns"
|
|
|
+ :data-source="data"
|
|
|
+ :row-selection="rowSelection"
|
|
|
+ :pagination="{
|
|
|
+ pageSize: pageSize,
|
|
|
+ current: pageNo,
|
|
|
+ total: totalElements,
|
|
|
+ showTotal: (total: number) => `总数:${total}`,
|
|
|
+ onChange: (pageNoChanged: number, pageSizeChanged: number) => {
|
|
|
+ pageNo = pageNoChanged;
|
|
|
+ pageSize = pageSizeChanged;
|
|
|
+ }
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <template #status="{ text }">
|
|
|
+ <a>{{ $filters.projectStatusFilter(text) }}</a>
|
|
|
+ </template>
|
|
|
+ <template #action="{ record }">
|
|
|
+ <span>
|
|
|
+ <a-button @click="showModal(record)">编辑</a-button>
|
|
|
+ <a-button @click="handleDeleteProjects([record.id])">
|
|
|
+ 删除
|
|
|
+ </a-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </a-table>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <a-modal
|
|
|
+ v-model:visible="visible"
|
|
|
+ title="项目信息页"
|
|
|
+ @ok="handleOk"
|
|
|
+ ok-text="确定"
|
|
|
+ cancel-text="取消"
|
|
|
+ >
|
|
|
+ <a-form>
|
|
|
+ <a-form-item v-show="projectObj.id" label="项目id">
|
|
|
+ <a-input
|
|
|
+ :disabled="!!projectObj.id"
|
|
|
+ v-model:value="projectObj.id"
|
|
|
+ ></a-input>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="项目名称">
|
|
|
+ <a-input v-model:value="projectObj.name"></a-input>
|
|
|
+ </a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </a-modal>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import {
|
|
|
+ deleteProjects,
|
|
|
+ getProjectList,
|
|
|
+ updateProject,
|
|
|
+} from "@/api/projectManagementPage";
|
|
|
+import { useMainStore } from "@/store";
|
|
|
+import { message } from "ant-design-vue";
|
|
|
+import { watch, onMounted, ref, reactive, toRaw } from "vue-demi";
|
|
|
+
|
|
|
+const store = useMainStore();
|
|
|
+store.currentLocation = "基础管理 / 项目列表";
|
|
|
+
|
|
|
+let rootOrgId = $ref(undefined as unknown as number);
|
|
|
+let name = $ref("");
|
|
|
+let projectStatus = $ref(undefined as undefined | string);
|
|
|
+
|
|
|
+let data = $ref([]);
|
|
|
+let pageSize = $ref(10);
|
|
|
+let pageNo = $ref(1);
|
|
|
+let totalElements = $ref(0);
|
|
|
+
|
|
|
+async function search() {
|
|
|
+ await fetchData();
|
|
|
+}
|
|
|
+
|
|
|
+watch(() => [pageNo, pageSize], fetchData);
|
|
|
+
|
|
|
+async function fetchData() {
|
|
|
+ const res = await getProjectList({
|
|
|
+ name,
|
|
|
+ status: projectStatus,
|
|
|
+ rootOrgId,
|
|
|
+ pageSize,
|
|
|
+ pageNo,
|
|
|
+ });
|
|
|
+ // console.log(res);
|
|
|
+ data = res.data.content;
|
|
|
+ pageNo = res.data.pageNo;
|
|
|
+ pageSize = res.data.pageSize;
|
|
|
+ totalElements = res.data.totalElements;
|
|
|
+}
|
|
|
+
|
|
|
+const columns = [
|
|
|
+ {
|
|
|
+ title: "项目id",
|
|
|
+ dataIndex: "id",
|
|
|
+ width: 80,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "项目名称",
|
|
|
+ dataIndex: "name",
|
|
|
+ width: 150,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "分析状态",
|
|
|
+ dataIndex: "status",
|
|
|
+ slots: { customRender: "status" },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "创建时间",
|
|
|
+ dataIndex: "createTime",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "创建人",
|
|
|
+ dataIndex: "creator",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "更新时间",
|
|
|
+ dataIndex: "updateTime",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "更新人",
|
|
|
+ dataIndex: "updater",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "操作",
|
|
|
+ key: "action",
|
|
|
+ slots: { customRender: "action" },
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ rootOrgId = store.userInfo.rootOrgId;
|
|
|
+ await search();
|
|
|
+});
|
|
|
+
|
|
|
+const visible = ref<boolean>(false);
|
|
|
+
|
|
|
+const showModal = (record: any) => {
|
|
|
+ Object.assign(projectObj, record);
|
|
|
+ visible.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+const handleOk = async (e: MouseEvent) => {
|
|
|
+ await updateProject(toRaw(projectObj));
|
|
|
+ visible.value = false;
|
|
|
+ await search();
|
|
|
+};
|
|
|
+
|
|
|
+const initProject = {
|
|
|
+ id: undefined,
|
|
|
+ code: "",
|
|
|
+ name: "",
|
|
|
+ enable: true,
|
|
|
+ type: undefined,
|
|
|
+ rootOrgId: store.userInfo.rootOrgId,
|
|
|
+};
|
|
|
+const projectObj = reactive({ ...initProject });
|
|
|
+
|
|
|
+const newProject = async () => {
|
|
|
+ Object.assign(projectObj, initProject);
|
|
|
+ showModal(projectObj);
|
|
|
+};
|
|
|
+
|
|
|
+function checkEmpty(selectIds: number[]): boolean {
|
|
|
+ if (selectIds && selectIds.length > 0) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ message.warn({ content: "请先选择行" });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|
|
|
+async function handleDeleteProjects(ids: number[]) {
|
|
|
+ if (checkEmpty(ids)) return;
|
|
|
+ await deleteProjects(ids);
|
|
|
+ await search();
|
|
|
+}
|
|
|
+
|
|
|
+let selectIds = $ref<number[]>([]);
|
|
|
+const rowSelection = {
|
|
|
+ onChange: (selectedRowKeys: (string | number)[]) => {
|
|
|
+ console.log(`selectedRowKeys: ${selectedRowKeys}`);
|
|
|
+ selectIds = selectedRowKeys as number[];
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|