ljb 9 months ago
parent
commit
38053950a6

+ 28 - 0
src/api/basicResource/compDeptList.js

@@ -0,0 +1,28 @@
+import request from '@/router/axios';
+
+export const getList = (params) => {
+  return request({
+    url: '/api/kd-scientific/department/list',
+    method: 'get',
+    params: {
+      ...params,
+    }
+  })
+}
+
+export const add = (row) => {
+  return request({
+    url: '/api/kd-scientific/department/submit',
+    method: 'post',
+    data: row
+  })
+}
+
+
+export const update = (row) => {
+  return request({
+    url: '/api/kd-scientific/department/submit',
+    method: 'post',
+    data: row
+  })
+}

+ 57 - 0
src/components/basic-card/index.vue

@@ -0,0 +1,57 @@
+<template>
+  <div class="basic-card">
+    <div v-if="title" class="basic-card__title">
+      <span class="divider"></span>
+      <span class="title">{{ title }}</span>
+      <div class="actions">
+        <slot name="actions"></slot>
+      </div>
+    </div>
+    <div class="basic-card__content">
+      <slot></slot>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "BasicCard",
+  props: {
+    title: String,
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+@import "~@/styles/variables.scss";
+
+.basic-card {
+  background: #fff;
+  border-radius: 3px;
+  padding: 5px 20px 20px;
+  box-sizing: border-box;
+  &__title {
+    padding-bottom: 5px;
+    line-height: 40px;
+    .divider {
+      display: inline-block;
+      width: 4px;
+      height: 20px;
+      background-color: $mainBg;
+      margin-right: 10px;
+      vertical-align: middle;
+    }
+    .title {
+      display: inline-block;
+      color: #333;
+      font-weight: 600;
+      vertical-align: middle;
+      font-size: 16px;
+      margin-bottom: 2px;
+    }
+    .actions {
+      float: right;
+    }
+  }
+}
+</style>

+ 50 - 0
src/option/basicResource/compDeptList.js

@@ -0,0 +1,50 @@
+export default {
+  calcHeight: 30,
+  tip: false,
+  searchShow: true,
+  searchMenuSpan: 6,
+  border: true,
+  index: true,
+  searchLabelWidth: 140,
+  labelWidth: 110,
+  menuWidth: 140,
+  delBtn: false,
+  refreshBtn: false,
+  columnBtn: false,
+  gridBtn: false,
+  dialogClickModal: false,
+  dialogWidth: 500,
+  dialogType: "drawer",
+  column: [
+    {
+      label: '所属二级单位/部门',
+      prop: 'name',
+      type: 'input',
+      span: 24,
+      minWidth: 160,
+      showOverflowTooltip: true,
+      rules: [
+        {
+          required: true,
+          message: '请输入科目代码',
+          trigger: 'blur',
+        },
+      ],
+    },
+    // {
+    //   label: '部门/科室/项目部',
+    //   prop: 'name',
+    //   type: 'input',
+    //   span: 24,
+    //   minWidth: 260,
+    //   showOverflowTooltip: true,
+    //   rules: [
+    //     {
+    //       required: true,
+    //       message: '请输入',
+    //       trigger: 'blur',
+    //     },
+    //   ],
+    // },
+  ],
+};

+ 31 - 0
src/views/basic-resource/comp-basic-info/comp-info-setting.vue

@@ -0,0 +1,31 @@
+<template>
+  <basic-container>
+    <year-month-select v-model="yearAndMonth" :showMonth="false" style="width: 120px;"></year-month-select>
+    <basic-card title="所属二级单位/部门">
+      <div style="width: 680px;">
+        <comp-dept-list :yearAndMonth="yearAndMonth"></comp-dept-list>
+      </div>
+      
+    </basic-card>
+  </basic-container>
+</template>
+
+<script>
+import YearMonthSelect from "@/components/year-month-select";
+import basicCard from "@/components/basic-card";
+import compDeptList from "./components/comp-dept-list.vue";
+import moment from "moment";
+
+export default {
+  components: {
+    YearMonthSelect,
+    basicCard,
+    compDeptList
+  },
+  data() {
+    return {
+      yearAndMonth: moment(new Date()).format('YYYY'),
+    }
+  },
+}
+</script>

+ 69 - 0
src/views/basic-resource/comp-basic-info/components/comp-dept-list.vue

@@ -0,0 +1,69 @@
+<template>
+  <avue-crud v-bind="bindVal" v-on="onEvent" v-model="form"> </avue-crud>
+</template>
+
+<script>
+export default window.$crudCommon(
+  {
+    props: {
+      yearAndMonth: [String, Number],
+    },
+    watch: {
+      yearAndMonth() {
+        this.loadData();
+      },
+    },
+    methods: {
+      buildTree(flatList, options = {}) {
+        const {
+          idKey = 'id',          // 节点ID的键名
+          parentKey = 'parentId', // 父节点ID的键名
+          childrenKey = 'children' // 子节点列表的键名
+        } = options;
+        
+        const nodeMap = {};      // 用于快速查找节点的映射表
+        const tree = [];         // 最终生成的树
+        
+        // 第一次遍历:创建所有节点的映射
+        flatList.forEach(node => {
+          nodeMap[node[idKey]] = {
+            ...node,
+            [childrenKey]: []
+          };
+        });
+        
+        // 第二次遍历:构建父子关系
+        flatList.forEach(node => {
+          const parentId = node[parentKey];
+          if (parentId !== null && parentId !== undefined && nodeMap[parentId]) {
+            // 如果有父节点,则将当前节点添加到父节点的children中
+            nodeMap[parentId][childrenKey].push(nodeMap[node[idKey]]);
+          } else {
+            // 如果没有父节点或父节点不存在,则作为根节点
+            tree.push(nodeMap[node[idKey]]);
+          }
+        });
+        
+        return tree;
+      },
+      loadData() {
+        this.loading = true;
+        this.api[this.option.list || "getList"](
+          { yearAndMonth: this.yearAndMonth }
+        ).then(({ data }) => {
+          console.log(this.buildTree(data.data))
+          this.data = this.buildTree(data.data);
+          this.loading = false;
+        });
+      },
+      // getSearchParams() {
+      //   return { yearAndMonth: this.yearAndMonth };
+      // },
+    },
+  },
+  {
+    // 模块路径
+    name: "basicResource/compDeptList",
+  }
+);
+</script>

+ 3 - 3
src/views/project-manage/project-list.vue

@@ -61,7 +61,7 @@
           <project-budget :projectId="currProjectId"></project-budget>
         </el-tab-pane>
         <el-tab-pane label="3、项目实施" lazy>
-          <implement-form :projectId="currProjectId" :yearAndMonth="params.yearAndMonth"></implement-form>
+          <implement :projectId="currProjectId"></implement>
         </el-tab-pane>
         <el-tab-pane label="4、项目变更" lazy>
           <change :projectId="currProjectId"></change>
@@ -86,7 +86,7 @@ import {getToken} from "@/util/auth";
 import {downloadXls} from "@/util/util";
 import applyForm from "./components/apply-form.vue";
 import projectBudget from "./components/project-budget.vue";
-import implementForm from './components/implement-form.vue';
+import implement from './implement.vue';
 import change from "./change.vue";
 import acceptForm from "./components/accept-form.vue";
 import outsourcingDoc from "./components/outsourcing-doc.vue";
@@ -97,7 +97,7 @@ export default window.$crudCommon({
     YearMonthSelect,
     applyForm,
     projectBudget,
-    implementForm,
+    implement,
     change,
     acceptForm,
     outsourcingDoc,