wangziqian 5 anni fa
parent
commit
eea0f18a9f

+ 34 - 0
src/api/configure.js

@@ -201,3 +201,37 @@ export function getBizNoticeSettingEnum(id) {
     method: 'get'
   })
 }
+
+// 通知列表
+export function getBizNoticeSettingList(bizId, status) {
+  return request({
+    url: TeamManagement + `/setting/getBizNoticeSettingList?bizId=${bizId}&status=${status}`,
+    method: 'get'
+  })
+}
+
+// 新增需求或任务定时通知
+export function addBizNoticeSetting(data) {
+  return request({
+    url: TeamManagement + `/setting/addBizNoticeSetting`,
+    method: 'post',
+    data
+  })
+}
+
+// 更新需求或任务定时通知
+export function updateBizNoticeSetting(data) {
+  return request({
+    url: TeamManagement + `/setting/updateBizNoticeSetting`,
+    method: 'post',
+    data
+  })
+}
+
+// 删除
+export function deleteBizNoticeSetting(id) {
+  return request({
+    url: TeamManagement + `/setting/deleteBizNoticeSetting?id=` + id,
+    method: 'get'
+  })
+}

+ 71 - 14
src/views/ToConfigure/components/modifyNotice.vue

@@ -71,7 +71,7 @@
         </el-form-item>
         <div class="add-condition" @click="addCondition()"><i class="el-icon-circle-plus-outline" /> 添加条件</div>
       </el-form>
-      <h2 class="form-title">通知方式</h2>
+      <h2 class="form-title">通知方式(必选)</h2>
       <el-form ref="form" :model="formData" label-width="100px" label-position="left">
         <!-- 邮件方式 -->
         <el-checkbox v-model="noticeList.Email" class="notice-check">邮件</el-checkbox>
@@ -138,7 +138,7 @@
           </section>
         </div>
       </el-form>
-      <h2 class="form-title">通知方式</h2>
+      <h2 class="form-title">通知时刻</h2>
       <div class="notice-time">
         <el-time-picker
           v-model="formData.noticeTime"
@@ -154,7 +154,8 @@
 import {
   showRequireStatusEnum,
   showTaskStatusEnum,
-  getBizNoticeSettingEnum
+  getBizNoticeSettingEnum,
+  addBizNoticeSetting
 } from '@/api/configure'
 import { settingQueryBizRqmtOrntList } from '@/api/requirement.js'
 import { settingQueryBizModuleList } from '@/api/defectManage'
@@ -183,7 +184,7 @@ export default {
   },
   data() {
     return {
-      bizId: localStorage.getItem('bizId'),
+      bizId: Number(localStorage.getItem('bizId')),
       title: this.type === 'require' ? '新建需求定时通知' : '新建任务定时通知',
       requireProps: {
         value: 'id',
@@ -194,12 +195,13 @@ export default {
       directionList: [], // 需求方面列表
       modulesList: [], // 任务模块列表
       formData: {
+        bizId: Number(localStorage.getItem('bizId')),
         requireOrientId: [], // 需求方向
         techModuleId: [], // 技术模块
         clientId: null, // 客户端
         clientVersionId: null, // 版本
         noticeConditionList: [], // 条件列表
-        noticeSetting: [], // 通知方式
+        noticeSetting: {}, // 通知方式
         noticeTime: null // 通知时刻
       },
       EmailList: [], // Email通知列表
@@ -249,7 +251,7 @@ export default {
     data: {
       handler(newV) {
         if (newV) {
-          this.formData = newV
+          this.initData(newV)
         }
       },
       deep: true,
@@ -291,6 +293,30 @@ export default {
     this.init()
   },
   methods: {
+    initData(data) {
+      this.formData = {
+        bizId: data.bizId,
+        requireOrientId: data.requireOrientId, // 需求方向
+        techModuleId: data.techModuleId, // 技术模块
+        clientId: data.clientId || null, // 客户端
+        clientVersionId: data.clientVersionId, // 版本
+        noticeConditionList: data.noticeConditionList || [], // 条件列表
+        noticeSetting: {}, // 通知方式
+        noticeTime: data.noticeTime // 通知时刻
+      }
+      if (data.email.length > 0) {
+        this.EmailList = data.email
+        this.noticeList.Email = true
+      }
+      if (data.dChart.length > 0) {
+        this.DChartList = data.email
+        this.noticeList.DChart = true
+      }
+      if (data.dChartGroup.length > 0) {
+        this.GroupList = data.email
+        this.noticeList.Group = true
+      }
+    },
     async getBizNoticeSettingEnum() { // 任务需求事件列表
       const res = await getBizNoticeSettingEnum(this.bizId)
       if (res.code === 200) {
@@ -407,23 +433,54 @@ export default {
       }
     },
     addGroup() { // 添加DChart群
-      this.GroupList.push({
-        ...this.GroupItem
+      this.$refs['groupForm'].validate((valid) => {
+        if (valid) {
+          this.GroupList.push({
+            type: 3,
+            ...this.GroupItem
+          })
+          this.GroupItem = { name: null, url: null }
+          this.showGroupForm = false
+        }
       })
-      this.GroupItem = { name: null, url: null }
-      this.showGroupForm = false
     },
     removeGroup(index) { // 移除DChart群
       this.GroupList.splice(index, 1)
     },
-    confirmForm() {
+    validate() { // 校验入参
+      if (this.formData.requireOrientId.length < 1 && this.type === 'require') {
+        this.$message({ message: '请选择需求方向', type: 'error', duration: 1000, offset: 150 })
+      }
+      if (this.formData.techModuleId.length < 1 && this.type === 'task') {
+        this.$message({ message: '请选择技术方向', type: 'error', duration: 1000, offset: 150 })
+      }
+      if (!this.formData.clientId) {
+        this.$message({ message: '请选择客户端', type: 'error', duration: 1000, offset: 150 })
+      }
+      if (!this.EmailList && !this.DChartList && !this.GroupList) {
+        this.$message({ message: '请选择一种通知方式', type: 'error', duration: 1000, offset: 150 })
+      }
+      if (!this.formData.noticeTime) {
+        this.$message({ message: '请选择通知时刻', type: 'error', duration: 1000, offset: 150 })
+      }
       this.formData.noticeSetting = {
         email: this.noticeList.Email ? this.EmailList : [],
         dChart: this.noticeList.DChart ? this.DChartList : [],
-        dchartGroup: this.noticeList.Group ? this.GroupList : []
+        dChartGroup: this.noticeList.Group ? this.GroupList : []
+      }
+      this.addBizNoticeSetting()
+    },
+    async addBizNoticeSetting() { // 新增通知
+      const res = await addBizNoticeSetting(this.formData)
+      if (res.code === 200) {
+        this.data
+          ? this.$message({ message: '修改成功', type: 'success', duration: 1000, offset: 150 })
+          : this.$message({ message: '添加成功', type: 'success', duration: 1000, offset: 150 })
+        this.$emit('confirm')
       }
-      console.log(this.formData)
-      this.$emit('confirm')
+    },
+    confirmForm() {
+      this.validate()
     },
     cancel() {
       this.show = false

+ 21 - 4
src/views/ToConfigure/components/noticeConfig.vue

@@ -3,9 +3,8 @@
     <div class="top-control">
       <el-button-group>
         <el-button size="medium" :class="{'is-active':activeTab===1}" @click="activeTab=1">启用中</el-button>
-        <el-button size="medium" :class="{'is-active':activeTab===2}" @click="activeTab=2">已停用</el-button>
-        <el-button size="medium" :class="{'is-active':activeTab===3}" @click="activeTab=3">未启用</el-button>
-        <el-button size="medium" :class="{'is-active':activeTab===4}" @click="activeTab=4">全部</el-button>
+        <el-button size="medium" :class="{'is-active':activeTab===0}" @click="activeTab=0">未启用</el-button>
+        <el-button size="medium" :class="{'is-active':activeTab===-1}" @click="activeTab=-1">全部</el-button>
       </el-button-group>
       <el-popover
         placement="bottom"
@@ -92,6 +91,9 @@
   </section>
 </template>
 <script>
+import {
+  getBizNoticeSettingList
+} from '@/api/configure'
 import modifyNotice from './modifyNotice'
 import requireImg from '@/assets/detailPage/需求@2x.png'
 import taskImg from '@/assets/detailPage/任务@2x.png'
@@ -113,10 +115,25 @@ export default {
       modifyType: 'require'// 弹框类型
     }
   },
+  watch: {
+    activeTab: {
+      handler(newV) {
+        this.getBizNoticeSettingList()
+      }
+    }
+  },
   created() {
-
+    this.getBizNoticeSettingList()
   },
   methods: {
+    async getBizNoticeSettingList() {
+      const params = [Number(localStorage.getItem('bizId'))]
+      this.activeTab > 0 ? params.push(this.activeTab) : params.push()
+      const res = await getBizNoticeSettingList(...params)
+      if (res.code === 200) {
+        console.log(res.data)
+      }
+    },
     confirmModify() {
       this.visibleModify = false
     },