hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
  <div>
    <div class="one" v-if="level !== 1">
      <h1>所属一级项目</h1>
      <div class="tab mr-b-10">
        <v-tool-table :trs="trsOne" :tds="tdsOne">
          <template v-slot:status="{ scope }">
            <span>{{ statusLevel[scope.status] }}</span>
          </template>
          <!-- <template v-slot:btn="{ scope }">
            <el-button @click="clickHandle('edit', scope)" type="text"
              >编辑</el-button
            >
            <el-button @click="clickHandle('details', scope)" type="text"
              >查看</el-button
            >
            <el-button @click="clickHandle('delete', scope)" type="text"
              >删除</el-button
            >
          </template> -->
        </v-tool-table>
      </div>
    </div>
    <div class="one" v-if="level !== 1 && level !== 2">
      <h1>所属二级项目</h1>
      <div class="tab mr-b-10">
        <v-tool-table :trs="trsTwo" :tds="tdsTwo">
          <template v-slot:status="{ scope }">
            <span>{{ statusLevel[scope.status] }}</span>
          </template>
          <!-- <template v-slot:btn="{ scope }">
            <el-button @click="clickHandle('edit', scope)" type="text"
              >编辑</el-button
            >
            <el-button @click="clickHandle('details', scope)" type="text"
              >查看</el-button
            >
            <el-button @click="clickHandle('delete', scope)" type="text"
              >删除</el-button
            >
          </template> -->
        </v-tool-table>
      </div>
    </div>
    <div class="two" v-if="level != 3 && newVal.status !== 4">
      子项目<el-button
        size="small"
        v-if="this.userType !== 3"
        @click="addChilren()"
        >创建子项目</el-button
      >
      <div class="tab">
        <v-tool-table :trs="trs" :tds="tds">
          <template v-slot:status="{ scope }">
            <span>{{ statusLevel[scope.status] }}</span>
          </template>
          <template v-slot:btn="{ scope }">
            <el-button @click="clickHandle('edit', scope)" type="text"
              >编辑</el-button
            >
            <el-button @click="clickHandle('details', scope)" type="text"
              >查看</el-button
            >
            <el-button @click="clickHandle('delete', scope)" type="text"
              >删除</el-button
            >
          </template>
        </v-tool-table>
      </div>
      <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
    </div>
  </div>
</template>
 
<script>
export default {
  props: {
    item: { type: Object },
    level: { type: Number },
  },
  mounted() {
    this.userType = demo.$session.get("user").userType;
  },
  data() {
    return {
      userType: null,
      trs: [
        { text: "序号", val: "index", width: "50px" },
        { text: "项目名称", val: "name" },
        { text: "责任方", val: "responsibility" },
        { text: "一级分类", val: "columnName" },
        { text: "二级分类", val: "secondColumnName" },
        { text: "项目状态", val: "btn", slot: "status" },
        { text: "创建时间", val: "createTime" },
        { text: "操作", val: "btn", slot: "btn", width: "160px" },
      ],
      trsOne: [
        { text: "项目名称", val: "name" },
        { text: "责任方", val: "responsibility" },
        { text: "一级分类", val: "columnName" },
        { text: "二级分类", val: "secondColumnName" },
        { text: "项目状态", val: "btn", slot: "status" },
        { text: "创建时间", val: "createTime" },
        // { text: "操作", val: "btn", slot: "btn" },
      ],
      trsTwo: [
        { text: "项目名称", val: "name" },
        { text: "责任方", val: "responsibility" },
        { text: "一级分类", val: "columnName" },
        { text: "二级分类", val: "secondColumnName" },
        { text: "项目状态", val: "btn", slot: "status" },
        { text: "创建时间", val: "createTime" },
        // { text: "操作", val: "btn", slot: "btn" },
      ],
      tds: [],
      tdsOne: [], //所属一级项目
      tdsTwo: [], //所属二级项目
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      statusLevel: ["", "初创项目", "公开发布", "运作中", "已结束"],
      newVal: {},
    };
  },
  watch: {
    item(val) {
      this.newVal = val;
      this.init();
    },
  },
  methods: {
    // 分页点击
    onPage(v) {
      if (v.page === this.paged.page && v.page && !v.reset) {
        return 0;
      }
      this.paged.page = v.page;
      this.paged.limit = v.limit;
      this.init();
    },
    // 获取数据
    init() {
      let v = {
        page: this.paged.page,
        size: this.paged.limit,
        paramId: this.$route.query.id,
        // paramId:this.newVal.id,
        level: this.newVal.level + 1, //创建子项目的等级
      };
      this.$api.post("comActSocialProject/getRelation", v, (e) => {
        e.socialProjectVOIPage.records.map((item, index) => {
          item.index = (this.paged.page - 1) * this.paged.limit + index + 1;
        });
        this.paged.total = e.socialProjectVOIPage.total;
        this.tds = e.socialProjectVOIPage.records || [];
        this.tdsOne = Array(e.fatherProjectLevelOne);
        this.tdsTwo = Array(e.fatherProjectLevelTwo);
      });
    },
    //创建子项目
    addChilren() {
      let a = this.level + 1;
      this.$router.push(`/addProject?level=${a}&id=${this.item.id}`);
    },
    // 页面操作
    clickHandle(type, row) {
      switch (type) {
        case "edit": {
          this.$router.push(
            `/addProject?level=${this.level + 1}&id=${row.id}&isedit=1`
          );
          break;
        }
        case "details": {
          this.$emit("detailsSuccess", row.id);
          this.$router.push("/projectDetails?id=" + row.id);
          break;
        }
        case "delete": {
          this.$confirm("此操作将删除该数据, 是否继续?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            this.$api.get("comActSocialProject/del", { id: row.id }, (e) => {
              demo.toast("删除成功");
              this.init();
            });
            return;
          });
          break;
        }
        default: {
          break;
        }
      }
    },
  },
};
</script>
 
<style lang="less" scoped>
.tab {
  padding-top: 20px;
}
.two {
  padding-top: 20px;
}
</style>