123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822 |
- <template>
- <normal-dialog
- :show-dialog.sync="show"
- :title="title"
- :is-default-close="false"
- width="60%"
- :show-footer="!disabled"
- @confirm="confirmForm()"
- @cancel="cancel()"
- >
- <article>
- <h2 v-show="type==='require'" class="form-title">需求范围</h2>
- <h2 v-show="type==='task'" class="form-title">任务范围</h2>
- <h2 v-show="type==='bug'" class="form-title">缺陷范围</h2>
- <el-form ref="form" :model="formData" label-width="100px" label-position="left">
- <el-form-item v-if="type === 'require'" label="需求方向">
- <el-cascader
- v-model="formData.requireOrientIdList"
- size="small"
- collapse-tags
- :props="requireProps"
- :options="directionList"
- placeholder="请选择"
- clearable
- :disabled="disabled"
- class="input-width"
- />
- </el-form-item>
- <el-form-item v-if="type === 'task' || type === 'bug'" label="技术模块">
- <el-cascader
- v-model="formData.techModuleIdList"
- size="small"
- collapse-tags
- :props="taskProps"
- :options="modulesList"
- placeholder="请选择"
- clearable
- :disabled="disabled"
- class="input-width"
- />
- </el-form-item>
- <el-form-item v-if="type === 'bug' && formData.noticeRange.priorityList" label="缺陷等级">
- <el-select v-model="formData.noticeRange.priorityList" size="small" class="input-width" multiple :disabled="disabled" clearable filterable placeholder="请选择">
- <el-option v-for="item in bugGrade" :key="item.code" :label="item.name" :value="item.code" />
- </el-select>
- </el-form-item>
- </el-form>
- <el-form ref="form" :model="formData" label-width="100px" label-position="left" :inline="true">
- <el-form-item v-if="type === 'bug'" label="端类型">
- <el-select v-model="formData.sysType" size="small" style="width: 209px;" :disabled="disabled" clearable filterable placeholder="请选择">
- <el-option v-for="item in sysTypeEnumList" :key="item.code" :label="item.name" :value="item.code" />
- </el-select>
- </el-form-item>
- <el-form-item v-if="type === 'require' || type === 'task'" label="跟版客户端">
- <el-select v-model="formData.clientId" placeholder="请选择" size="small" :disabled="disabled" clearable>
- <el-option v-for="item in appClientList" :key="'app'+item.code" :label="item.msg" :value="item.code" />
- </el-select>
- </el-form-item>
- <el-form-item v-if="type === 'require' || type === 'task'">
- <el-select v-model="formData.clientVersionId" placeholder="请选择" size="small" :disabled="disabled" clearable>
- <el-option v-for="item in clientList" :key="'client'+item.code" :label="item.msg" :value="item.code" />
- </el-select>
- </el-form-item>
- </el-form>
- <h2 class="form-title">通知条件(必选)</h2>
- <el-form ref="form" :model="formData" label-width="100px" label-position="left">
- <el-form-item v-for="(item,index) in formData.noticeConditionList" :key="'condition'+index" label="条件">
- <el-select v-model="item.type" placeholder="请选择类型" size="small" class="condition-select" :disabled="disabled" @change="changeNoticeItem(item)">
- <el-option v-for="key in typeList" :key="key.label" :label="key.label" :value="key.value" />
- </el-select>
- <el-select v-show="item.type === 1 || item.type === 3 || item.type === 5" v-model="item.status" placeholder="请选择状态" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in statusList" :key="'status'+key.code" :label="key.msg" :value="key.code" />
- </el-select>
- <el-select v-show="item.type === 103 || item.type === 203" v-model="item.status" placeholder="请选择状态" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in noticeConditionScheduleTypeList" :key="'statu'+key.code" :label="key.name" :value="key.code" />
- </el-select>
- <el-select v-show="item.type === 1 || item.type === 3 || item.type === 5" v-model="item.triggerEvent" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in triggerList" :key="'trigger'+key.code" :label="key.name" :value="key.code" />
- </el-select>
- <el-select v-show="item.type === 103 || item.type === 203" v-model="item.triggerEvent" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in noticeScheduleOpList" :key="'trigge'+key.code" :label="key.name" :value="key.code" />
- </el-select>
- <el-select v-show="item.type === 2 || item.type === 4" v-model="item.triggerEvent" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in noticeEventList" :key="'event'+key.code" :label="key.name" :value="key.code" />
- </el-select>
- <el-select v-show="item.type === 1 || item.type === 3" v-model="item.greaterTime" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in rangDaysList" :key="'greaterTime'+key.value" :label="key.label" :value="key.value" />
- </el-select>
- <el-select v-show="item.type === 5" v-model="item.greaterTime" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in sDaysList" :key="'s'+key.value" :label="key.label" :value="key.value" />
- </el-select>
- <el-select v-show="item.type === 2 || item.type === 4" v-model="item.lessTime" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in aheadDaysList" :key="'lessTime'+key.value" :label="key.label" :value="key.value" />
- </el-select>
- <el-select v-show="item.type === 103 || item.type === 203" v-model="item.greaterTime" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
- <el-option v-for="key in DaysList" :key="'daily'+key.value" :label="key.label" :value="key.value" />
- </el-select>
- <i v-show="!disabled" class="el-icon-remove-outline" @click="removeItem(index)" />
- </el-form-item>
- <div v-show="!disabled" class="add-condition" @click="addCondition()"><i class="el-icon-circle-plus-outline" /> 添加条件</div>
- </el-form>
- <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" :disabled="disabled">邮件</el-checkbox>
- <el-form-item v-for="(item,index) in EmailList" :key="'email'+index" :label="index===0?'通知人群':''">
- <el-select v-model="item.type" placeholder="请选择" size="small" class="condition-select" :disabled="disabled" @change="changeNoticeType(item)">
- <el-option v-for="key in noticeGroupList" :key="'email-type'+key.label" :label="key.label" :value="key.value" />
- </el-select>
- <el-select v-show="item.type===1" v-model="item.teams" placeholder="请选择" size="small" :multiple="true" :disabled="disabled">
- <el-option v-for="key in teamList" :key="'email-team'+key.code" :label="key.name" :value="key.code" />
- </el-select>
- <search-people v-show="item.type===2" :value.sync="item.customStaffs" :clearable="false" :multiple="true" :disabled="disabled" />
- <i v-if="index!==0 && !disabled" class="el-icon-remove-outline" @click="removeMembers(EmailList,index)" />
- </el-form-item>
- <div v-show="noticeList.Email && !disabled" class="add-notice" @click="addMembers(EmailList)"><i class="el-icon-circle-plus-outline" /> 添加人群</div>
- <!-- DChart系统方式 -->
- <el-checkbox v-model="noticeList.DChart" class="notice-check" :disabled="disabled">DChart系统通知</el-checkbox>
- <el-form-item v-for="(item,index) in DChartList" :key="'DChart'+index" :label="index===0?'通知人群':''">
- <el-select v-model="item.type" placeholder="请选择" size="small" class="condition-select" :disabled="disabled" @change="changeNoticeType(item)">
- <el-option v-for="key in noticeGroupList" :key="'DChart-type'+key.label" :label="key.label" :value="key.value" />
- </el-select>
- <el-select v-show="item.type===1" v-model="item.teams" placeholder="请选择" size="small" :multiple="true" :disabled="disabled">
- <el-option v-for="key in teamList" :key="'DChart-team'+key.code" :label="key.name" :value="key.code" />
- </el-select>
- <search-people v-show="item.type===2" :value.sync="item.customStaffs" :clearable="false" :multiple="true" :disabled="disabled" />
- <i v-if="index!==0 && !disabled" class="el-icon-remove-outline" @click="removeMembers(DChartList,index)" />
- </el-form-item>
- <div v-show="noticeList.DChart && !disabled" class="add-notice" @click="addMembers(DChartList)"><i class="el-icon-circle-plus-outline" /> 添加人群</div>
- <!-- DChart群方式 -->
- <el-checkbox v-model="noticeList.Group" class="notice-check" :disabled="disabled">DChart群通知</el-checkbox>
- <div v-show="noticeList.Group && !disabled" class="add-condition">
- <ul v-show="GroupList.length>0" class="group-list">
- <li v-for="(item,index) in GroupList" :key="'gourp-item'+ index" class="group-item">
- <div>{{ item.name }}</div>
- <div>{{ item.url }}</div>
- <span><i class="el-icon-delete" @click.stop="removeGroup(index)" /></span>
- </li>
- </ul>
- <span @click="showGroupForm = true"><i class="el-icon-circle-plus-outline" /> 添加DChart群</span>
- <section v-if="showGroupForm" class="group-form">
- <el-form ref="groupForm" :model="GroupItem" :rules="groupRules" label-width="200px" label-position="left">
- <el-form-item prop="name" label="群名称或群ID">
- <el-input
- v-model="GroupItem.name"
- type="textarea"
- maxlength="150"
- show-word-limit
- :autosize="{ minRows: 1, maxRows: 5 }"
- />
- </el-form-item>
- <el-form-item prop="url" label="机器人webhook地址">
- <el-input
- v-model="GroupItem.url"
- type="textarea"
- maxlength="200"
- show-word-limit
- :autosize="{ minRows: 3, maxRows: 6 }"
- />
- </el-form-item>
- </el-form>
- <div class="group-confirm">
- <el-button size="small" @click.stop="showGroupForm = false">取消</el-button>
- <el-button type="primary" size="small" @click.stop="addGroup()">确认</el-button>
- </div>
- </section>
- </div>
- </el-form>
- <h2 class="form-title">通知时刻</h2>
- <!-- <div class="notice-time">
- <el-time-select
- v-if="type === 'task' || type === 'require'"
- v-model="formData.noticeTime"
- placeholder="任意时间点"
- size="small"
- value-format="HH:mm"
- :picker-options="{
- start: '00:00',
- step: '00:15',
- end: '23:45',
- }"
- :disabled="disabled"
- />
- </div> -->
- <el-form :model="formData" label-width="100px" label-position="left" :inline="true">
- <el-form-item label="时间">
- <el-select v-model="formData.noticeTimeList" multiple placeholder="任意时间点" size="small" style="width: 209px;" :disabled="disabled" clearable>
- <el-option v-for="(key, index) in timeDateEnum" :key="'continuity'+index" :label="key" :value="key" />
- </el-select>
- </el-form-item><br>
- <el-form-item label="频次">
- <el-select v-model="formData.noticeFrequency" placeholder="请选择" size="small" style="width: 209px;" :disabled="disabled" clearable>
- <el-option v-for="key in continuityDaysList" :key="'continuity'+key.value" :label="key.label" :value="key.value" />
- </el-select>
- </el-form-item>
- </el-form>
- </article>
- </normal-dialog>
- </template>
- <script>
- const _ = require('lodash')
- import { mapGetters } from 'vuex'
- import {
- showRequireStatusEnum,
- showTaskStatusEnum,
- getBizNoticeSettingEnum,
- addBizNoticeSetting,
- updateBizNoticeSetting
- } from '@/api/configure'
- import { teamQueryTeamListBelowBiz } from '@/api/toConfigure.js'
- import { settingQueryBizRqmtOrntList } from '@/api/requirement.js'
- import { settingQueryBizModuleList, bugGetEnum } from '@/api/defectManage'
- // import { queryTeamInfoList } from '@/api/workSchedule'
- import { showAppClientEnum } from '@/api/version.js'
- import normalDialog from '@/components/dialog/normalDialog'
- import searchPeople from '@/components/select/searchPeople'
- export default {
- components: { normalDialog, searchPeople },
- props: {
- data: {
- type: Object,
- default: () => null,
- required: false
- },
- visible: {
- type: Boolean,
- default: false,
- required: true
- },
- type: {
- type: String,
- default: 'require', // 需求:require,任务:task
- required: false
- },
- disabled: {// 查看状态,不可修改
- type: Boolean,
- default: false,
- required: false
- },
- copy: {// 复制
- type: Boolean,
- default: false,
- required: false
- }
- },
- data() {
- return {
- title: '',
- bugGrade: [], // 缺陷option
- requireProps: {
- value: 'id',
- label: 'rqmtOrntName',
- children: 'childRqmtOrnts',
- multiple: true
- },
- taskProps: {
- value: 'id',
- label: 'moduleName',
- children: 'childModules',
- multiple: true
- },
- directionList: [], // 需求方面列表
- modulesList: [], // 任务模块列表
- formData: {
- type: this.type === 'bug' ? 2 : this.type === 'require' ? 0 : 1,
- bizId: this.bizId,
- requireOrientIdList: [], // 需求方向
- noticeRange: {
- priorityList: [] // 缺陷等级
- },
- techModuleIdList: [], // 技术模块
- clientId: null, // 客户端
- clientVersionId: null, // 版本
- noticeConditionList: [], // 条件列表
- noticeSetting: {}, // 通知方式
- noticeTime: null // 通知时刻
- },
- EmailList: [], // Email通知列表
- DChartList: [], // DChart系统通知列表
- GroupList: [], // DChart群通知列表
- GroupItem: { name: null, url: null }, // 当前群添加对象
- showGroupForm: false,
- groupRules: {// 群填写规则
- name: [{ required: true, message: '请填写群名称或群ID', trigger: 'change' }],
- url: [{ required: true, message: '请填写机器人webhook地址', trigger: 'change' }]
- },
- noticeList: {// 通知方式列表
- Email: false, // 邮件通知
- DChart: false, // DChart系统通知
- Group: false // DChart群通知
- },
- timeDateEnum: [], // 时间list
- noticeGroupList: [], // 通知人群类型选择列表
- teamList: [], // 团队选择列表
- show: this.visible, // 显示弹框
- appClientList: [], // 客户端选择列表
- typeList: [], // 条件类型选择列表
- statusList: [], // 状态选择列表
- noticeEventList: [], // 事件列表
- sysTypeEnumList: [], // 端类型
- triggerList: [], // 触发事件: 0 停留 1 交付 2 提测
- aheadDaysList: [
- { label: '3天前开始提醒', value: 3 },
- { label: '2天前开始提醒', value: 2 },
- { label: '1天前开始提醒', value: 1 },
- { label: '过期提醒', value: 0 }
- ], // 提前几天提醒
- noticeScheduleOpList: [],
- noticeConditionScheduleTypeList: [], // 全周期
- rangDaysList: [], // 条件中大于天数列表
- sDaysList: [],
- DaysList: [], // 排期天数
- continuityDaysList: [] // 通知时刻频次列表
- }
- },
- computed: {
- clientList: { // 版本列表
- get() {
- if (this.formData.clientId !== null) {
- const obj = this.appClientList.find(item => item.code === this.formData.clientId)
- return (obj && obj.childEnumInfos) || []
- } else {
- return []
- }
- }
- },
- ...mapGetters(['bizId'])
- },
- watch: {
- data: {
- handler(newV) {
- if (newV) {
- this.initData(_.cloneDeep(newV))
- }
- },
- deep: true,
- immediate: true
- },
- type: {
- handler(newV) {
- this.type = newV
- },
- immediate: true
- },
- visible: {
- handler(newV) {
- this.show = newV
- },
- immediate: true
- },
- copy: {
- handler(newV) {
- this.copy = newV
- },
- immediate: true
- },
- disabled: {
- handler(newV) {
- this.disabled = newV
- },
- immediate: true
- },
- 'formData.clientId': { // 客户端改变,版本默认取第一个版本
- handler(newV) {
- // this.formData.clientVersionId = (this.clientList[0] && this.clientList[0].code) || null
- if (newV === null || newV === '' || newV === undefined) {
- this.formData.clientVersionId = null
- }
- }
- },
- 'noticeList.Email': {
- handler(newV, oldV) {
- if (newV) {
- if (this.EmailList.length === 0) this.EmailList.push({ type: 0, member: true, teams: [], customStaffs: [] })
- } else {
- this.EmailList = []
- }
- }
- },
- 'noticeList.DChart': {
- handler(newV, oldV) {
- if (newV) {
- if (this.DChartList.length === 0) this.DChartList.push({ type: 0, member: true, teams: [], customStaffs: [] })
- } else {
- this.DChartList = []
- }
- }
- },
- 'noticeList.Group': {
- handler(newV, oldV) {
- if (!newV) {
- this.GroupList = []
- }
- }
- },
- bizId: {
- handler(newV) {
- this.formData.bizId = newV
- },
- immediate: true
- }
- },
- created() {
- this.getBizNoticeSettingEnum()
- this.getRequireDirection()
- this.settingQueryBizModuleList()
- this.showAppClientEnum()
- this.showBugListEnum()
- this.queryTeamInfoList()
- this.init()
- this.gettimeDate(15)
- },
- methods: {
- initData(data) {
- if (this.type === 'bug') {
- data.noticeConditionList.map(item => {
- item.timeUnit === 'DAY' ? item.greaterTime = item.greaterTime + 'D' : item.greaterTime = item.greaterTime + 'H'
- })
- }
- this.formData = {
- type: data.type,
- id: data.id,
- bizId: data.bizId,
- sysType: data.sysType,
- requireOrientIdList: data.requireOrientIdList, // 需求方向
- techModuleIdList: data.techModuleIdList, // 技术模块
- clientId: data.clientId || null, // 客户端
- clientVersionId: data.clientVersionId, // 版本
- noticeConditionList: data.noticeConditionList || [], // 条件列表
- noticeSetting: {}, // 通知方式
- noticeTimeList: data.noticeTimeList, // 通知时刻
- noticeFrequency: data.noticeFrequency // 频次
- }
- if (data.noticeSetting.email && data.noticeSetting.email.length > 0) {
- this.EmailList = Array(data.noticeSetting.email.length).fill({ type: 0, member: true, teams: [], customStaffs: [] })
- this.$nextTick(() => {
- this.EmailList = data.noticeSetting.email
- })
- this.noticeList.Email = true
- }
- if (data.noticeSetting.dChat && data.noticeSetting.dChat.length > 0) {
- this.DChartList = Array(data.noticeSetting.dChat.length).fill({ type: 0, member: true, teams: [], customStaffs: [] })
- this.$nextTick(() => {
- this.DChartList = data.noticeSetting.dChat
- })
- this.noticeList.DChart = true
- }
- if (data.noticeSetting.dChatGroup && data.noticeSetting.dChatGroup.length > 0) {
- this.GroupList = data.noticeSetting.dChatGroup || []
- this.noticeList.Group = true
- }
- if (this.type === 'bug' && data.noticeRange && data.noticeRange.priorityList.length > 0) {
- this.formData = { ...this.formData, noticeRange: { priorityList: data.noticeRange.priorityList }}
- }
- },
- async getBizNoticeSettingEnum() { // 任务需求事件列表
- const res = await getBizNoticeSettingEnum(this.bizId)
- if (res.code === 200) {
- this.noticeConditionScheduleTypeList = res.data.noticeConditionScheduleTypeList
- this.noticeScheduleOpList = res.data.noticeScheduleOpList
- this.triggerList = res.data.noticeConditionOpList
- this.type === 'require'
- ? this.noticeEventList = res.data.noticeEventRequireOpList
- : this.noticeEventList = res.data.noticeEventTaskOpList
- }
- },
- async getRequireDirection() { // 需求方向列表
- const res = await settingQueryBizRqmtOrntList(this.bizId)
- if (res.code === 200) {
- this.directionList = this.getRequireData(res.data)
- }
- },
- async settingQueryBizModuleList() { // 任务模块列表
- const res = await settingQueryBizModuleList(this.bizId)
- if (res.code === 200) {
- this.modulesList = this.getTaskData(res.data)
- }
- },
- gettimeDate(minute) {
- const seconds = minute * 60
- const len = (60 * 24 * 60) / seconds // 数组长度
- for (var i = 0, total = 0, newArr = []; i < len; i++) {
- const h = parseInt(total / 3600)
- const min = parseInt(total % 3600 / 60)
- newArr.push(this.s(h) + ':' + this.s(min))
- total = total + seconds
- }
- this.timeDateEnum = newArr
- },
- s(n) {
- return n < 10 ? '0' + n : n
- },
- getRequireData(data) {
- for (let i = 0; i < data.length; i++) {
- data[i].childRqmtOrnts.length < 1 ? delete data[i].childRqmtOrnts : this.getRequireData(data[i].childRqmtOrnts)
- }
- return data
- },
- getTaskData(data) {
- for (let i = 0; i < data.length; i++) {
- data[i].childModules.length < 1 ? delete data[i].childModules : this.getTaskData(data[i].childModules)
- }
- return data
- },
- async showAppClientEnum() { // 获取客户端列表
- const res = await showAppClientEnum()
- if (res.code === 200) {
- this.appClientList = res.data.appClient
- }
- },
- async showBugListEnum() {
- const res = await bugGetEnum()
- if (res.code === 200) {
- this.bugGrade = res.data.priorityEnumList
- this.statusList = res.data.bugEnumList.filter(item => {
- item.msg = item.name
- return item.name !== '已完成' && item.name !== 'Hold'
- }) // status
- this.sysTypeEnumList = res.data.sysTypeEnumList // 端类型
- }
- },
- async showRequireStatusEnum() { // 获取需求状态列表
- const res = await showRequireStatusEnum(this.bizId)
- if (res.code === 200) {
- this.statusList = res.data.requirementStatus || []
- }
- },
- async showTaskStatusEnum() { // 获取任务状态列表
- const res = await showTaskStatusEnum(this.bizId)
- if (res.code === 200) {
- this.statusList = res.data.taskStatus || []
- }
- },
- async queryTeamInfoList() { // 获取用户团队列表
- const res = await teamQueryTeamListBelowBiz(this.bizId)
- if (res.code === 200) {
- this.teamList = res.data
- }
- // const res = await queryTeamInfoList({ curIndex: 1, pageSize: 9999 })
- // if (res.code === 200 && res.data) {
- // this.teamList = res.data.list
- // }
- },
- init() {
- if (this.type === 'require') {
- this.data && !this.copy ? this.title = '编辑需求定时通知' : this.title = '新建需求定时通知'
- this.typeList = [{ label: '需求状态', value: 1 }, { label: '需求事件', value: 2 }, { label: '需求排期', value: 103 }]
- this.noticeGroupList = [{ label: '需求成员', value: 0 }, { label: '团队', value: 1 }, { label: '自定义人员', value: 2 }]
- this.showRequireStatusEnum()
- } else if (this.type === 'task') {
- this.data && !this.copy ? this.title = '编辑任务定时通知' : this.title = '新建任务定时通知'
- this.typeList = [{ label: '任务状态', value: 3 }, { label: '任务事件', value: 4 }, { label: '任务排期', value: 203 }]
- this.noticeGroupList = [{ label: '任务成员', value: 0 }, { label: '团队', value: 1 }, { label: '自定义人员', value: 2 }]
- this.showTaskStatusEnum()
- } else if (this.type === 'bug') {
- this.data && !this.copy ? this.title = '编辑缺陷定时通知' : this.title = '新建缺陷定时通知'
- this.typeList = [{ label: '缺陷状态', value: 5 }]
- this.noticeGroupList = [{ label: '缺陷成员', value: 0 }, { label: '自定义人员', value: 2 }]
- this.showBugListEnum()
- }
- let i = 1
- let number = 1
- while (number <= 24) {
- number >= 6 ? this.sDaysList.push({ label: `大于${number}小时`, value: `${number}H` }) : ''
- number++
- }
- while (i <= 100) {
- this.rangDaysList.push({ label: `大于${i}天`, value: i })
- this.sDaysList.push({ label: `大于${i}天`, value: `${i}D` })
- this.DaysList.push({ label: `${i}天`, value: i })
- this.continuityDaysList.push({ label: `连续${i}天`, value: i })
- i++
- }
- this.continuityDaysList.unshift({ label: `每天`, value: -1 })
- },
- changeNoticeItem(item) { // 修改条件
- if (item.type === 1 || item.type === 3) {
- item.triggerEvent = this.triggerList[0].code
- } else if (item.type === 2 || item.type === 4) {
- item.triggerEvent = this.noticeEventList[0].code
- } else if (item.type === 103 || item.type === 203) {
- item.triggerEvent = this.noticeScheduleOpList[0].code
- item.greaterTime = 1
- }
- },
- addCondition(val) { // 添加条件
- this.formData.noticeConditionList.push({
- type: this.typeList[0].value, // 1 需求状态 2 需求事件 3 任务状态 4 任务事件
- status: 0,
- triggerEvent: this.triggerList[0].code, // 触发事件
- greaterTime: this.type === 'bug' ? 1 + 'D' : 1, // 大于的时间
- lessTime: 3 // 提前提醒的时间
- })
- },
- removeItem(index) { // 移除条件
- this.formData.noticeConditionList.splice(index, 1)
- },
- addMembers(list) { // 添加成员
- list.push({ type: 0, member: true, teams: [], customStaffs: [] })
- },
- removeMembers(list, index) { // 移除成员
- list.splice(index, 1)
- },
- changeNoticeType(item) { // 修改通知
- switch (item.type) {
- case 0:
- item.member = true
- item.teamList = []
- item.customStaffList = []
- break
- case 1:
- item.member = false
- item.customStaffList = []
- break
- case 2:
- item.member = false
- item.teamList = []
- break
- }
- },
- addGroup() { // 添加DChart群
- this.$refs['groupForm'].validate((valid) => {
- if (valid) {
- this.GroupList.push({
- type: 3,
- ...this.GroupItem
- })
- this.GroupItem = { name: null, url: null }
- this.showGroupForm = false
- }
- })
- },
- removeGroup(index) { // 移除DChart群
- this.GroupList.splice(index, 1)
- },
- validate() { // 校验入参
- if (this.formData.noticeConditionList.length < 1) {
- this.$message({ message: '请添加通知条件', type: 'error', duration: 1000, offset: 150 })
- return false
- }
- if (this.EmailList.length === 0 && this.DChartList.length === 0 && this.GroupList.length === 0) {
- this.$message({ message: '请选择一种通知方式', type: 'error', duration: 1000, offset: 150 })
- return false
- }
- if (!this.formData.noticeTimeList) {
- this.$message({ message: '请选择通知时刻', type: 'error', duration: 1000, offset: 150 })
- return false
- }
- this.formData.noticeSetting = {
- email: this.noticeList.Email ? this.EmailList : [],
- dChat: this.noticeList.DChart ? this.DChartList : [],
- dChatGroup: this.noticeList.Group ? this.GroupList : []
- }
- if (this.type === 'bug') {
- this.formData.noticeConditionList.map(item => {
- const numDay = item.greaterTime
- const str = numDay.split('')
- const targetStr = str[str.length - 1]
- item.timeUnit = targetStr === 'D' ? 'DAY' : 'HOUR'
- const num = numDay.slice(0, numDay.length - 1)
- item.greaterTime = num
- })
- }
- this.data && !this.copy ? this.updateBizNoticeSetting() : this.addBizNoticeSetting()
- },
- async addBizNoticeSetting() { // 新增通知
- if (this.formData.id) {
- delete this.formData.id
- }
- const res = await addBizNoticeSetting(this.formData)
- if (res.code === 200) {
- this.$message({ message: '添加成功', type: 'success', duration: 1000, offset: 150 })
- this.$emit('confirm')
- }
- },
- async updateBizNoticeSetting() { // 更新通知
- const res = await updateBizNoticeSetting(this.formData)
- if (res.code === 200) {
- this.$message({ message: '修改成功', type: 'success', duration: 1000, offset: 150 })
- this.$emit('confirm')
- }
- },
- confirmForm() {
- this.validate()
- },
- cancel() {
- this.show = false
- this.$emit('update:visible', this.show)
- this.$emit('cancel')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/.el-input {
- width: auto;
- }
- article::-webkit-scrollbar{
- display: none;
- }
- article{
- max-height: 500px;
- overflow: scroll;
- padding: 0 45px;
- .form-title {
- margin: 0;
- padding: 0;
- font-size: 18px;
- color: #333333;
- margin: 20px 0;
- }
- .form-title:nth-child(1){
- margin-top: 0;
- }
- /deep/.el-form-item {
- font-size: 14px;
- margin-bottom: 10px;
- label {
- color: #666666;
- font-weight: 400;
- }
- }
- .condition-select {
- width: 22%;
- margin-right: 10px;
- }
- .add-condition,.add-notice {
- cursor: pointer;
- color: #409EFF;
- position: relative;
- }
- .add-notice {
- margin-left: 100px;
- width: 150px;
- }
- .notice-check{
- margin: 15px 0;
- display: block;
- width: 150px;
- }
- .notice-check:nth-child(1){
- margin-top: 0;
- }
- .el-icon-remove-outline {
- cursor: pointer;
- color: #409EFF;
- font-size: 14px;
- margin-left: 5px;
- }
- .input-width {
- /deep/.el-input {
- width: 402px;
- }
- }
- }
- .group-form {
- width: 280px;
- position: absolute;
- bottom: 30px;
- left: 0;
- padding: 10px;
- z-index: 99;
- background:rgba(255,255,255,1);
- box-shadow:0px 0px 12px rgba(0,0,0,0.1);
- /deep/.el-form-item{
- display: flex;
- flex-direction: column;
- margin-bottom: 10px;
- .el-form-item__content {
- margin: 0 !important;
- width: 100%;
- line-height: 10px;
- }
- }
- .group-confirm {
- display: flex;
- justify-content: center;
- margin-top: 20px;
- button:nth-child(1) {
- margin-right: 10px;
- }
- }
- }
- .group-list{
- margin: 0;
- padding: 0;
- list-style: none;
- width: 100%;
- color: #333333;
- font-size: 14px;
- .group-item {
- margin: 0;
- padding: 0;
- list-style: none;
- width: 100%;
- display: grid;
- grid-template-columns: 30% 60% 10%;
- border:1px solid rgba(209,208,208,1);
- height:37px;
- border-radius: 4px;
- margin-bottom: 10px;
- align-items: center;
- div{
- border-right:1px solid rgba(209,208,208,1);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- text-align: center;
- line-height: 37px;
- padding: 0 5px;
- }
- span {
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 18px;
- }
- }
- }
- </style>
|