index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header @add="table_add"></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.system.project" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns">
  5. <template #tree_select>
  6. <el-tree-select v-model="formConfig.data.projectFirmName" v-bind="treeSelectProps"></el-tree-select>
  7. </template>
  8. <template #action="{ row }">
  9. <el-button type="primary" link @click="table_items(row)">
  10. <template #icon><sc-iconify icon="pajamas:list-bulleted"></sc-iconify></template>验收清单
  11. </el-button>
  12. <el-button type="primary" link @click="table_edit(row)">
  13. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  14. </el-button>
  15. <el-button type="primary" link @click="table_del(row)">
  16. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  17. </el-button>
  18. </template>
  19. </scTable>
  20. </el-container>
  21. <project-detail v-if="dialog.detail" ref="projectRef" :treeSelectProps="treeSelectProps" @success="refreshTable" @closed="dialog.detail = false"></project-detail>
  22. <accept-item-detail v-if="dialog.items" ref="acceptItemRef" @closed="dialog.items = false"></accept-item-detail>
  23. </template>
  24. <script setup>
  25. import XEUtils from "xe-utils";
  26. import API from "@/api";
  27. import TOOL from "@/utils/tool";
  28. import { mapFormItemInput, mapFormItemSelect } from "@/components/scTable/helper";
  29. import { typeDic, statusDic } from "./main";
  30. import projectDetail from "./detail";
  31. import acceptItemDetail from "./items";
  32. const router = useRouter();
  33. const treeSelectProps = reactive({
  34. popperClass: "vxe-table-slot--popper",
  35. data: [],
  36. filterable: true,
  37. clearable: true,
  38. checkStrictly: true,
  39. placeholder: "请选择所属企业",
  40. props: { label: "name", value: "name" }
  41. })
  42. const toolbarConfig = reactive({
  43. enabled: true,
  44. print: false
  45. });
  46. const formConfig = reactive({
  47. data: {
  48. projectStatusNot: "学校"
  49. },
  50. items: [
  51. mapFormItemInput("projectNameLike", "项目名称"),
  52. mapFormItemInput("projectFirmName", "所属企业", { slots: { default: "tree_select" } })
  53. ]
  54. });
  55. const paramsColums = reactive([
  56. { column: "projectStatusNot" },
  57. { column: "projectNameLike" },
  58. { column: "projectFirmName" }
  59. ])
  60. const columns = reactive([
  61. { type: "html", field: "fpiId", title: "ID", width: 60, sortable: true },
  62. { type: "html", field: "projectName", title: "项目名称", minWidth: 160, sortable: true },
  63. { type: "html", field: "projectFirmName", title: "所属企业", minWidth: 160, sortable: true },
  64. { type: "html", field: "projectType", title: "项目类型", width: 120, sortable: true },
  65. { type: "html", field: "projectStatus", title: "项目状态", width: 100, sortable: true },
  66. { title: "操作", fixed: "right", width: 220, align: "center", slots: { default: "action" } }
  67. ])
  68. // 获取组织树
  69. const getSelectTreeData = async () => {
  70. const res = await API.system.project.dept();
  71. treeSelectProps.data = XEUtils.toArrayTree(XEUtils.filter(res, item => item.firmNature !== "学校"), { parentKey: "pid", key: "deptId" });
  72. }
  73. // 显示隐藏 筛选表单
  74. const xGridTable = ref();
  75. const refreshTable = (mode = "add", fpiId) => {
  76. xGridTable.value.reloadColumn(columns);
  77. xGridTable.value.searchData(mode);
  78. router.getProject(fpiId);
  79. }
  80. const projectRef = ref();
  81. const acceptItemRef = ref();
  82. const dialog = reactive({
  83. detail: false,
  84. items: false
  85. });
  86. const table_add = () => {
  87. dialog.detail = true;
  88. nextTick(() => projectRef.value?.open());
  89. }
  90. const table_edit = row => {
  91. dialog.detail = true;
  92. nextTick(() => projectRef.value?.setData(row.fpiId));
  93. }
  94. const table_items = row => {
  95. dialog.items = true;
  96. nextTick(() => acceptItemRef.value?.setData(row));
  97. }
  98. const table_del = ({ fpiId }) => {
  99. ElMessageBox.confirm("是否确认删除该项目?", "删除警告", {
  100. type: "warning",
  101. confirmButtonText: "确定",
  102. cancelButtonText: "取消"
  103. }).then(() => {
  104. API.system.project.del({ fpiId }).then(() => {
  105. ElMessage.success("操作成功");
  106. refreshTable("add", fpiId);
  107. });
  108. });
  109. }
  110. getSelectTreeData();
  111. </script>