scorpioyq 2 år sedan
förälder
incheckning
9989b9653f

+ 7 - 1
src/api/project/index.js

@@ -6,7 +6,7 @@ export default {
      * @returns {Promise<unknown>}
      */
     projectList(current, size, params) { // 项目列表
-        return fetch('/blade-project-manage/project/v2/page', {
+        return fetch('/blade-project-manage-v2/project/v2/page', {
             ...params,
             current,
             size
@@ -18,6 +18,12 @@ export default {
     projectRemove(params) { // 删除项目
         return fetch('/blade-project-manage-v2/project/v2/remove', params, 'post')
     },
+    proContact(params) { //关联子项目
+        return fetch('/blade-project-manage/project/v2/connect', params, 'post', 'json')
+    },
+    childrenList(params) { //已关联子项目列表
+        return fetch('/blade-project-manage/project/v2/childrenList', params)
+    },
     typeList(params) { // 项目分类列表
         return fetch('/blade-project-manage-v2/typeAndStage/v2/page', params)
     },

+ 1 - 1
src/views/home/component/dash.vue

@@ -116,7 +116,7 @@
         </el-form>
       </div>
     </el-dialog>
-    <form_dialog :dialogType="diaType"/>
+    <form_dialog :dialogType="diaType" @close="diaType = -1"/>
   </div>
 </template>
 

+ 5 - 0
src/views/home/component/form_dialog.vue

@@ -5,6 +5,7 @@
                append-to-body
                center
                title="数据表格导入"
+               @close="close"
                width="45%">
       <div class='flex flex-center flex-col'>
         <img src="../../../assets/img/import.png" class="pic"/>
@@ -39,6 +40,7 @@
     <el-dialog v-model='showExport'
                append-to-body
                center
+               @close="close"
                title="数据表格导出"
                width="45%">
       <div class='flex flex-center'>
@@ -158,6 +160,9 @@ export default {
   },
 
   methods: {
+    close() {
+      this.$emit('close')
+    },
     upload(res) {
       console.log(res)
       this.attaches = res.fileList

+ 14 - 5
src/views/home/component/pro_left.vue

@@ -25,9 +25,14 @@
           </el-select>
         </div>
         <el-divider></el-divider>
+        <div class="flex flex-center full-width">
+          <span class="title pointer" @click="showRelation = !showRelation">已关联子项目</span>
+        </div>
       </div>
-      <div class="flex flex-center flex-col hide-scrollbar" style="height: 55vh;overflow-x: auto;margin-top: -20px">
-        <div class="flex flex-center grey-9 font-15 bold" :class="active === index ? 'box-s' : 'box'"
+      <div class="flex flex-center flex-justify-between flex-col mt-15 hide-scrollbar"
+           style="height: 50vh;overflow-x: auto;">
+        <div class="flex flex-center grey-9 font-15 bold pointer"
+             :class="active === index ? 'box-s' : 'box'"
              v-for="(item,index) in dicList1" :key="item.id" @click="active = index">{{
             item.dictValue
           }}
@@ -36,15 +41,17 @@
         </div>
       </div>
     </div>
+    <pro-relation :showRelation="showRelation" :projectId="data.id" @close="showRelation = false"/>
   </div>
 </template>
 
 <script>
 import mainButton from "@/components/main-button.vue";
+import proRelation from "@/views/home/component/pro_relation.vue";
 
 export default {
   name: "pro_left",
-  components: {mainButton},
+  components: {mainButton, proRelation},
   props: {
     data: Object,
   },
@@ -64,7 +71,9 @@ export default {
       dicList: [],
       dicList1: [],
       currentSituation: '',
-      active: 0
+      active: 0,
+      showRelation: false,
+      projectId: ''
     }
   },
   created() {
@@ -137,7 +146,7 @@ export default {
   border-bottom: 1px dashed #AFAFAF;
   width: 150px;
   padding-top: 32px;
-  padding-bottom: 32px
+  padding-bottom: 32px;
 }
 
 .box-s {

+ 208 - 0
src/views/home/component/pro_relation.vue

@@ -0,0 +1,208 @@
+<template>
+  <div>
+    <!--    项目关联-->
+    <el-dialog v-model='showRelation'
+               append-to-body
+               center
+               title="关联子项目"
+               width="65%"
+               @close="close"
+    >
+      <avue-crud ref="crud"
+                 v-model="form"
+                 v-model:page="page"
+                 :before-open="beforeOpen"
+                 :data="data"
+                 :option="option"
+                 :permission="permissionList"
+                 :table-loading="loading"
+                 class="curd"
+                 @row-del="rowDel"
+                 @current-change="currentChange"
+                 @size-change="sizeChange"
+                 @refresh-change="refreshChange"
+                 @on-load="onLoad">
+      </avue-crud>
+    </el-dialog>
+    <!--    新增关联项目-->
+    <el-dialog v-model='showAdd'
+               append-to-body
+               center
+               title="新增关联项目"
+               width="65%">
+      <div class="flex flex-col">
+        <el-input
+            v-model="keyWords"
+            clearable
+            placeholder="项目信息快速搜索"
+            prefix-icon="Search"
+            @keydown="searchPro"
+        />
+      </div>
+      <div class="hide-scrollbar full-width" style="height: 30vh;overflow-x: scroll">
+        <!--        <div v-if='attaches.length === 0' class='full-width flex flex-center '>-->
+        <!--          <el-empty image-size='100'/>-->
+        <!--        </div>-->
+        <div class="flex flex-justify-between mt-20 flex-center">
+          <span class="bold font-15 grey ml-5 ">搜索结果</span>
+        </div>
+        <el-divider/>
+        <div class="flex flex-center flex-justify-between mt-5" v-for="item in proList" :key="item.id">
+          <span class="bold">{{ item.name }}</span>
+          <baseButton icon="Lock" title="关联" type="0" width="60" @click="connectProject(item)"/>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import baseButton from "@/components/base-button.vue";
+
+export default {
+  name: "pro_relation",
+  components: {baseButton},
+  props: {
+    showRelation: {
+      type: Boolean,
+      default: false
+    },
+    projectId: ''
+  },
+  watch: {
+    showRelation: {
+      handler(val) {
+        console.log(val)
+      },
+      immediate: true
+    },
+  },
+  data() {
+    return {
+      showAdd: false,
+      data: [],
+      form: {},
+      option: {
+        refreshBtn: false,
+        tip: false,
+        columnBtn: false,
+        searchShow: true,
+        editBtn: true,
+        editBtnText: '解绑',
+        editBtnIcon: 'Unlock',
+        addBtn: true,
+        delBtn: false,
+        border: true,
+        index: true,
+        align: 'center',
+        viewBtn: true,
+        viewBtnText: '详情',
+        menuWidth: 320,
+        dialogClickModal: false,
+        column: [
+          {
+            label: '项目名称',
+            prop: 'name',
+            addDisplay: false,
+            editDisplay: false
+          },]
+      },
+      page: {
+        size: 10,
+        current: 1,
+        total: 0
+      },
+      keyWords: '',
+      proList: []
+    }
+  },
+  methods: {
+    close() {
+      this.$emit('close')
+    },
+    onLoad(query = {}) {
+      this.loading = true
+      this.$api.project.childrenList({parentId: this.projectId}).then(res => {
+        this.loading = false
+        if (res.code === 200) {
+          this.data = res.data
+          // this.page.total = res.data.total
+        }
+      }).finally(() => {
+        this.loading = false
+      })
+    },
+    beforeOpen(done, type) {
+      if (['edit'].includes(type)) {
+        this.$router.push({
+          path: '/home/details',
+          query: {id: this.form.id, type: '0', ownerId: this.form.createUser}
+        })
+      } else if (type === 'view') {
+        // this.$alert('功能建设中,尽情期待...', '消息提醒', {
+        //   confirmButtonText: 'OK'
+        // })
+        this.$router.push({
+          path: '/home/pro_detail',
+          query: {id: this.form.id}
+        })
+      } else if (type === 'add') {
+        this.showAdd = true
+        this.showRelation = false
+      }
+    },
+    currentChange(currentPage) {
+      this.page.current = currentPage
+    },
+    sizeChange(pageSize) {
+      this.page.size = pageSize
+    },
+    refreshChange() {
+      this.onLoad()
+    },
+    rowDel(row) {
+      this.$confirm('确定删除选择的项目?', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+          .then(() => {
+            this.$api.project.projectRemove({ids: row.id}).then(res => {
+              if (res.code === 200) {
+                this.$message.success(res.msg)
+                this.onLoad()
+              } else {
+                this.$message.error(res.msg)
+              }
+            })
+          })
+    },
+    searchPro() {
+      const data = {projectName: this.keyWords}
+      this.$api.project.projectList(this.page.current, this.page.size, data).then(res => {
+        if (res.code === 200) {
+          this.proList = res.data.records
+        }
+      })
+    },
+    connectProject(item) {
+      let params = {
+        projectId: this.projectId,
+        childrenIdList: [item.id]
+      }
+      this.$api.project.proContact(params).then(res => {
+        if (res.code === 200) {
+          this.showAdd = false
+          this.$message.success(res.msg)
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
+    }
+  },
+}
+</script>
+
+<style scoped>
+
+</style>