wenbobowen 4 jaren geleden
bovenliggende
commit
c9ad6b83e3

+ 26 - 0
src/api/taskIndex.js

@@ -309,3 +309,29 @@ export function getByTasks(data) {
     data
   })
 }
+
+// 获取过滤器
+export function getFilterList(data) {
+  return request({
+    url: TeamManagement + '/filter/getFilterList',
+    method: 'post',
+    data
+  })
+}
+
+// 创建过滤器
+export function createFilter(data) {
+  return request({
+    url: TeamManagement + `/filter/createFilter`,
+    method: 'post',
+    data
+  })
+}
+
+// 获取单个筛选项
+export function filterGetFilter(id) {
+  return request({
+    url: TeamManagement + `/filter/getFilter?id=${id}`,
+    method: 'get'
+  })
+}

+ 2 - 1
src/apiConfig/requestIP.js

@@ -1,4 +1,5 @@
-export let host = 'http://zhihui-test.intra.xiaojukeji.com'
+// export let host = 'http://zhihui-test.intra.xiaojukeji.com'
+export let host = 'http://zhihui-pre.intra.xiaojukeji.com'
 export let requestIp = host + '/zuul'
 export let loginUrl = host + '/sso/login?jumpto=' + 'http://zhihui-test.intra.xiaojukeji.com' + location.pathname
 export let logoutUrl = host + '/sso/logout?jumpto=' + 'http://zhihui-test.intra.xiaojukeji.com' + location.pathname

+ 34 - 28
src/views/projectManage/bugList/bugindex.vue

@@ -225,21 +225,17 @@
               </el-row>
             </el-form>
           </el-col>
-          <el-row v-if="filterList.length && filterList.length>0" type="flex" justify="space-between" class="filter">
-            <el-col :span="2">
-              <span>我的过滤器:</span>
-            </el-col>
-            <el-col :span="20" class="mine-filter">
-              <span v-for="item in filterList" :key="item.id" class="filter-item" @click="getFilterItem(item.id)">
-                <el-tooltip class="item" effect="dark" :content="item.name" placement="bottom">
-                  <span>{{ item.name }}</span>
-                </el-tooltip>
-              </span>
-            </el-col>
-            <el-col :span="2" align="end">
+          <div v-if="filterList.length && filterList.length > 0" class="filter">
+            <div class="filterWrap">
+              <div class="title">我的过滤器:</div>
+              <div class="itemBox">
+                <el-tag v-for="item in filterList" :key="item.id" class="item" @click="getFilterItem(item.id)">{{ item.name }}</el-tag>
+              </div>
+            </div>
+            <div class="btn">
               <span @click.stop="showEditSearch = true">管理过滤器</span>
-            </el-col>
-          </el-row>
+            </div>
+          </div>
         </el-row>
       </el-header>
       <el-main style="padding: 10px">
@@ -608,22 +604,32 @@ export default {
 </script>
 <style scoped lang="scss">
 .filter {
-  font-size: 14px;
   width: 100%;
-  padding: 0 11px 15px 15px;
-  color: #606266;
-  cursor: pointer;
-  .mine-filter {
-    .filter-item {
-      display: inline-block;
-      width: 15%;
-      color: #409EFF;
-      margin-right: 15px;
-      overflow: hidden;
-      text-overflow:ellipsis;
-      white-space: nowrap;
-      margin-bottom: 5px;
+  display: flex;
+  justify-content: space-between;
+  align-items: baseline;
+  margin-top: 15px;
+  .filterWrap {
+    display: flex;
+    align-items: baseline;
+    .title {
+      width: 100px;
     }
+    .itemBox {
+      .item {
+        display: inline-block;
+        margin-right: 20px;
+        margin-bottom: 10px;
+        cursor: pointer;
+      }
+    }
+  }
+  .btn {
+    font-size: 14px;
+    color: #00A0FF;
+    cursor: pointer;
+    min-width: 80px;
+    text-align: center;
   }
 }
 .belong-task {

+ 7 - 2
src/views/projectManage/components/filterList.vue

@@ -78,6 +78,11 @@ export default {
       type: Boolean,
       default: false,
       required: true
+    },
+    filterType: {
+      type: Number,
+      default: 3,
+      required: false
     }
   },
   data() {
@@ -109,7 +114,7 @@ export default {
         pageSize: this.pageSize,
         curIndex: this.curIndex,
         bizId: Number(localStorage.getItem('bizId')),
-        filterType: 3
+        filterType: this.filterType
       }
       const res = await filtergetFilterList(params)
       if (res.code === 200) {
@@ -159,7 +164,7 @@ export default {
         this.$set(this.filterList[e.index], 'name', this.copyFilterList[e.index].name)
         return false
       }
-      const res = await filterUpdateFilter({ id: e.id, name: e.name, filterType: 3, creator: localStorage.getItem('username') })
+      const res = await filterUpdateFilter({ id: e.id, name: e.name, filterType: this.filterType, creator: localStorage.getItem('username') })
       if (res.code === 200) {
         this.$message({ showClose: true, message: '修改名称成功', type: 'success' })
         this.getFilterList()

+ 37 - 17
src/views/projectManage/requirement/list/index.vue

@@ -118,7 +118,18 @@
           </div>
         </div>
       </div>
-      <el-row v-if="filterList.length && filterList.length>0" type="flex" justify="space-between" class="filter">
+      <div v-if="filterList.length && filterList.length > 0" class="filter">
+        <div class="filterWrap">
+          <div class="title">我的过滤器:</div>
+          <div class="itemBox">
+            <el-tag v-for="item in filterList" :key="item.id" class="item" @click="getFilterItem(item.id)">{{ item.name }}</el-tag>
+          </div>
+        </div>
+        <div class="btn">
+          <span @click.stop="showEditSearch = true">管理过滤器</span>
+        </div>
+      </div>
+      <!-- <el-row v-if="filterList.length && filterList.length>0" type="flex" justify="space-between" class="filter">
         <el-col :span="2">
           <span>我的过滤器:</span>
         </el-col>
@@ -132,7 +143,7 @@
         <el-col :span="2" align="end">
           <span @click.stop="showEditSearch = true">管理过滤器</span>
         </el-col>
-      </el-row>
+      </el-row> -->
     </div>
     <div class="stylus-content">
       <el-table
@@ -646,22 +657,31 @@ export default {
   position: relative;
 }
 .filter {
-  font-size: 14px;
-  width: 100%;
-  padding: 15px 11px 0px 15px;
-  color: #606266;
-  cursor: pointer;
-  .mine-filter {
-    .filter-item {
-      display: inline-block;
-      width: 15%;
-      color: #409EFF;
-      margin-right: 15px;
-      overflow: hidden;
-      text-overflow:ellipsis;
-      white-space: nowrap;
-      // margin-bottom: 5px;
+  display: flex;
+  justify-content: space-between;
+  align-items: baseline;
+  margin-top: 15px;
+  .filterWrap {
+    display: flex;
+    align-items: baseline;
+    .title {
+      width: 100px;
     }
+    .itemBox {
+      .item {
+        display: inline-block;
+        margin-right: 20px;
+        margin-bottom: 10px;
+        cursor: pointer;
+      }
+    }
+  }
+  .btn {
+    font-size: 14px;
+    color: #00A0FF;
+    cursor: pointer;
+    min-width: 80px;
+    text-align: center;
   }
 }
 </style>

+ 107 - 47
src/views/projectManage/taskList/taskIndex.vue

@@ -146,21 +146,17 @@
           </div>
         </div>
       </div>
-      <el-row v-if="filterList.length && filterList.length>0" type="flex" justify="space-between" class="filter">
-        <el-col :span="2">
-          <span>我的过滤器:</span>
-        </el-col>
-        <el-col :span="20" class="mine-filter">
-          <span v-for="item in filterList" :key="item.id" class="filter-item" @click="getFilterItem(item.id)">
-            <el-tooltip class="item" effect="dark" :content="item.name" placement="bottom">
-              <span>{{ item.name }}</span>
-            </el-tooltip>
-          </span>
-        </el-col>
-        <el-col :span="2" align="end">
-          <span style="min-width: 84px" @click.stop="showEditSearch = true">管理过滤器</span>
-        </el-col>
-      </el-row>
+      <div v-if="filterList.length && filterList.length > 0" class="filter">
+        <div class="filterWrap">
+          <div class="title">我的过滤器:</div>
+          <div class="itemBox">
+            <el-tag v-for="item in filterList" :key="item.id" class="item" @click="getFilterItem(item.id)">{{ item.name }}</el-tag>
+          </div>
+        </div>
+        <div class="btn">
+          <span @click.stop="showEditSearch = true">管理过滤器</span>
+        </div>
+      </div>
     </div>
     <div class="stylus-content">
       <el-table
@@ -259,12 +255,13 @@
       </div>
     </normal-dialog>
     <normal-dialog :show-footer="false" :show-dialog="showEditSearch" :title="'管理过滤器'" :width="'65%'" @cancel="showEditSearch=false">
-      <filter-list :show-filter="showEditSearch" @deleteFilter="deleteFilter" />
+      <filter-list :show-filter="showEditSearch" :filter-type="2" @deleteFilter="deleteFilter" />
     </normal-dialog>
   </div>
 </template>
 
 <script>
+const _ = require('lodash')
 import { EncryptId } from '@/utils/crypto-js.js'
 import { mapGetters } from 'vuex'
 import {
@@ -273,7 +270,10 @@ import {
   memberQueryMemberInfoByIDAPorName,
   configShowRequirementVersionEnum,
   projectListProject,
-  configShowTaskStatusEnum
+  getFilterList,
+  configShowTaskStatusEnum,
+  createFilter,
+  filterGetFilter
 } from '@/api/taskIndex' // ajax
 import { settingQueryBizModuleList } from '@/api/defectManage'
 import openDialog from '@/views/projectManage/dialog_vue'
@@ -358,11 +358,13 @@ export default {
       task_table: [],
       form: {},
       arry: [],
-      filterList: [{
-        name: 'ss',
-        id: 1
-      }],
+      filterList: [],
       showEditSearch: false, // 显示管理过滤器
+      searchForm: { name: null }, // 筛选项obj
+      searchFormRules: { name: [
+        { required: true, message: '请输入筛选项名称', trigger: 'blur' },
+        { min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
+      ] },
       showSaveSearch: false // 显示保存筛选项对话框
     }
   },
@@ -373,6 +375,7 @@ export default {
     bizId() {
       this.get_taskList()
       this.get_taskSelect()
+      this.getFilterList() // 筛选项保存
     }
   },
   created() {
@@ -384,6 +387,7 @@ export default {
   mounted() {
     this.$nextTick(() => {
       this.bugDataGet()
+      this.getFilterList() // 筛选项保存
     })
   },
   destroyed() {
@@ -401,6 +405,57 @@ export default {
       }
       return item.idap
     },
+    // 保存筛选项
+    saveSearch(formName) { // 保存筛选项
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.stratAndEnd = this.stratAndEnd ? this.stratAndEnd : []
+          this.form_task.createStartTime = this.stratAndEnd[0] || null
+          this.form_task.createEndTime = this.stratAndEnd[1] || null
+          const isExistName = this.filterList.some(item => {
+            return item.name === this.searchForm.name
+          })
+          if (isExistName) {
+            this.$message({ showClose: true, message: '筛选项名称重名', type: 'error' })
+          } else {
+            this.toSave()
+          }
+        } else {
+          this.$message({ showClose: true, message: '筛选项名称不能为空', type: 'error' })
+          return false
+        }
+      })
+    },
+    // 保存过滤器
+    async toSave() {
+      const saveObj = _.cloneDeep(this.form_task)
+      delete saveObj.curIndex
+      delete saveObj.pageSize
+      const res = await createFilter({
+        name: this.searchForm.name,
+        content: JSON.stringify(saveObj),
+        bizId: this.bizId,
+        filterType: 2
+      })
+      if (res.code === 200) {
+        this.$message({ showClose: true, message: '保存成功', type: 'success' })
+        this.showSaveSearch = false
+        this.getFilterList()
+        this.searchForm.name = null
+      }
+    },
+    async getFilterList() { // 获取过滤器列表
+      const params = {
+        bizId: this.bizId,
+        filterType: 2
+      }
+      const res = await getFilterList(params)
+      this.filterList = res.data
+    },
+    deleteFilter() {
+      this.$router.push({ path: this.$route.path })
+      this.getFilterList()
+    },
     get_taskList(e) {
       if (this.bizId === -1) return
       // 查询
@@ -550,18 +605,14 @@ export default {
       }
       return data
     },
-    deleteFilter() {
-      console.log(1111)
-    },
     async getFilterItem(filterId) { // 获取单个过滤器
-      // const res = await filterGetFilter(filterId)
-      // if (res.code === 200) {
-      //   const filter = JSON.parse(res.data.content)
-      //   Object.assign(this.searchForm, filter)
-      //   this.requirementName = filter.name
-      //   this.curIndex = 1
-      //   this.getTableData()
-      // }
+      const res = await filterGetFilter(filterId)
+      if (res.code === 200) {
+        const filter = JSON.parse(res.data.content)
+        Object.assign(this.form_task, filter)
+        this.curIndex = 1
+        this.get_taskList()
+      }
     }
   }
 }
@@ -575,22 +626,31 @@ export default {
   left: 120px;
 }
 .filter {
-  font-size: 14px;
-  width: 100%;
-  padding: 15px 11px 0px 15px;
-  color: #606266;
-  cursor: pointer;
-  .mine-filter {
-    .filter-item {
-      display: inline-block;
-      width: 15%;
-      color: #409EFF;
-      margin-right: 15px;
-      overflow: hidden;
-      text-overflow:ellipsis;
-      white-space: nowrap;
-      // margin-bottom: 5px;
+  display: flex;
+  justify-content: space-between;
+  align-items: baseline;
+  margin-top: 15px;
+  .filterWrap {
+    display: flex;
+    align-items: baseline;
+    .title {
+      width: 100px;
     }
+    .itemBox {
+      .item {
+        display: inline-block;
+        margin-right: 20px;
+        margin-bottom: 10px;
+        cursor: pointer;
+      }
+    }
+  }
+  .btn {
+    font-size: 14px;
+    color: #00A0FF;
+    cursor: pointer;
+    min-width: 80px;
+    text-align: center;
   }
 }
 </style>