modifyNotice.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. <template>
  2. <normal-dialog
  3. :show-dialog.sync="show"
  4. :title="title"
  5. :is-default-close="false"
  6. width="60%"
  7. :show-footer="!disabled"
  8. @confirm="confirmForm()"
  9. @cancel="cancel()"
  10. >
  11. <article>
  12. <h2 v-show="type==='require'" class="form-title">需求范围</h2>
  13. <h2 v-show="type==='task'" class="form-title">任务范围</h2>
  14. <h2 v-show="type==='bug'" class="form-title">缺陷范围</h2>
  15. <el-form ref="form" :model="formData" label-width="100px" label-position="left">
  16. <el-form-item v-if="type === 'require'" label="需求方向">
  17. <el-cascader
  18. v-model="formData.requireOrientIdList"
  19. size="small"
  20. collapse-tags
  21. :props="requireProps"
  22. :options="directionList"
  23. placeholder="请选择"
  24. clearable
  25. :disabled="disabled"
  26. class="input-width"
  27. />
  28. </el-form-item>
  29. <el-form-item v-if="type === 'task' || type === 'bug'" label="技术模块">
  30. <el-cascader
  31. v-model="formData.techModuleIdList"
  32. size="small"
  33. collapse-tags
  34. :props="taskProps"
  35. :options="modulesList"
  36. placeholder="请选择"
  37. clearable
  38. :disabled="disabled"
  39. class="input-width"
  40. />
  41. </el-form-item>
  42. </el-form>
  43. <el-form ref="form" :model="formData" label-width="100px" label-position="left" :inline="true">
  44. <el-form-item v-if="type === 'bug'" label="端类型">
  45. <el-select v-model="formData.sysType" size="small" style="width: 209px;" :disabled="disabled" clearable filterable placeholder="请选择">
  46. <el-option v-for="item in sysTypeEnumList" :key="item.code" :label="item.name" :value="item.code" />
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item v-if="type === 'require' || type === 'task'" label="跟版客户端">
  50. <el-select v-model="formData.clientId" placeholder="请选择" size="small" :disabled="disabled" clearable>
  51. <el-option v-for="item in appClientList" :key="'app'+item.code" :label="item.msg" :value="item.code" />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item v-if="type === 'require' || type === 'task'">
  55. <el-select v-model="formData.clientVersionId" placeholder="请选择" size="small" :disabled="disabled" clearable>
  56. <el-option v-for="item in clientList" :key="'client'+item.code" :label="item.msg" :value="item.code" />
  57. </el-select>
  58. </el-form-item>
  59. </el-form>
  60. <h2 class="form-title">通知条件(必选)</h2>
  61. <el-form ref="form" :model="formData" label-width="100px" label-position="left">
  62. <el-form-item v-for="(item,index) in formData.noticeConditionList" :key="'condition'+index" label="条件">
  63. <el-select v-model="item.type" placeholder="请选择类型" size="small" class="condition-select" :disabled="disabled" @change="changeNoticeItem(item)">
  64. <el-option v-for="key in typeList" :key="key.label" :label="key.label" :value="key.value" />
  65. </el-select>
  66. <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">
  67. <el-option v-for="key in statusList" :key="'status'+key.code" :label="key.msg" :value="key.code" />
  68. </el-select>
  69. <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">
  70. <el-option v-for="key in triggerList" :key="'trigger'+key.code" :label="key.name" :value="key.code" />
  71. </el-select>
  72. <el-select v-show="item.type === 2 || item.type === 4" v-model="item.triggerEvent" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
  73. <el-option v-for="key in noticeEventList" :key="'event'+key.code" :label="key.name" :value="key.code" />
  74. </el-select>
  75. <el-select v-show="item.type === 1 || item.type === 3 || item.type === 5" v-model="item.greaterTime" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
  76. <el-option v-for="key in rangDaysList" :key="'greaterTime'+key.value" :label="key.label" :value="key.value" />
  77. </el-select>
  78. <el-select v-show="item.type === 2 || item.type === 4" v-model="item.lessTime" placeholder="请选择" size="small" class="condition-select" :disabled="disabled">
  79. <el-option v-for="key in aheadDaysList" :key="'lessTime'+key.value" :label="key.label" :value="key.value" />
  80. </el-select>
  81. <i v-show="!disabled" class="el-icon-remove-outline" @click="removeItem(index)" />
  82. </el-form-item>
  83. <div v-show="!disabled" class="add-condition" @click="addCondition()"><i class="el-icon-circle-plus-outline" /> 添加条件</div>
  84. </el-form>
  85. <h2 class="form-title">通知方式(必选)</h2>
  86. <el-form ref="form" :model="formData" label-width="100px" label-position="left">
  87. <!-- 邮件方式 -->
  88. <el-checkbox v-model="noticeList.Email" class="notice-check" :disabled="disabled">邮件</el-checkbox>
  89. <el-form-item v-for="(item,index) in EmailList" :key="'email'+index" :label="index===0?'通知人群':''">
  90. <el-select v-model="item.type" placeholder="请选择" size="small" class="condition-select" :disabled="disabled" @change="changeNoticeType(item)">
  91. <el-option v-for="key in noticeGroupList" :key="'email-type'+key.label" :label="key.label" :value="key.value" />
  92. </el-select>
  93. <el-select v-show="item.type===1" v-model="item.teams" placeholder="请选择" size="small" :multiple="true" :disabled="disabled">
  94. <el-option v-for="key in teamList" :key="'email-team'+key.code" :label="key.name" :value="key.code" />
  95. </el-select>
  96. <search-people v-show="item.type===2" :value.sync="item.customStaffs" :clearable="false" :multiple="true" :disabled="disabled" />
  97. <i v-if="index!==0 && !disabled" class="el-icon-remove-outline" @click="removeMembers(EmailList,index)" />
  98. </el-form-item>
  99. <div v-show="noticeList.Email && !disabled" class="add-notice" @click="addMembers(EmailList)"><i class="el-icon-circle-plus-outline" /> 添加人群</div>
  100. <!-- DChart系统方式 -->
  101. <el-checkbox v-model="noticeList.DChart" class="notice-check" :disabled="disabled">DChart系统通知</el-checkbox>
  102. <el-form-item v-for="(item,index) in DChartList" :key="'DChart'+index" :label="index===0?'通知人群':''">
  103. <el-select v-model="item.type" placeholder="请选择" size="small" class="condition-select" :disabled="disabled" @change="changeNoticeType(item)">
  104. <el-option v-for="key in noticeGroupList" :key="'DChart-type'+key.label" :label="key.label" :value="key.value" />
  105. </el-select>
  106. <el-select v-show="item.type===1" v-model="item.teams" placeholder="请选择" size="small" :multiple="true" :disabled="disabled">
  107. <el-option v-for="key in teamList" :key="'DChart-team'+key.code" :label="key.name" :value="key.code" />
  108. </el-select>
  109. <search-people v-show="item.type===2" :value.sync="item.customStaffs" :clearable="false" :multiple="true" :disabled="disabled" />
  110. <i v-if="index!==0 && !disabled" class="el-icon-remove-outline" @click="removeMembers(DChartList,index)" />
  111. </el-form-item>
  112. <div v-show="noticeList.DChart && !disabled" class="add-notice" @click="addMembers(DChartList)"><i class="el-icon-circle-plus-outline" /> 添加人群</div>
  113. <!-- DChart群方式 -->
  114. <el-checkbox v-model="noticeList.Group" class="notice-check" :disabled="disabled">DChart群通知</el-checkbox>
  115. <div v-show="noticeList.Group && !disabled" class="add-condition">
  116. <ul v-show="GroupList.length>0" class="group-list">
  117. <li v-for="(item,index) in GroupList" :key="'gourp-item'+ index" class="group-item">
  118. <div>{{ item.name }}</div>
  119. <div>{{ item.url }}</div>
  120. <span><i class="el-icon-delete" @click.stop="removeGroup(index)" /></span>
  121. </li>
  122. </ul>
  123. <span @click="showGroupForm = true"><i class="el-icon-circle-plus-outline" /> 添加DChart群</span>
  124. <section v-if="showGroupForm" class="group-form">
  125. <el-form ref="groupForm" :model="GroupItem" :rules="groupRules" label-width="200px" label-position="left">
  126. <el-form-item prop="name" label="群名称或群ID">
  127. <el-input
  128. v-model="GroupItem.name"
  129. type="textarea"
  130. maxlength="150"
  131. show-word-limit
  132. :autosize="{ minRows: 1, maxRows: 5 }"
  133. />
  134. </el-form-item>
  135. <el-form-item prop="url" label="机器人webhook地址">
  136. <el-input
  137. v-model="GroupItem.url"
  138. type="textarea"
  139. maxlength="200"
  140. show-word-limit
  141. :autosize="{ minRows: 3, maxRows: 6 }"
  142. />
  143. </el-form-item>
  144. </el-form>
  145. <div class="group-confirm">
  146. <el-button size="small" @click.stop="showGroupForm = false">取消</el-button>
  147. <el-button type="primary" size="small" @click.stop="addGroup()">确认</el-button>
  148. </div>
  149. </section>
  150. </div>
  151. </el-form>
  152. <h2 class="form-title">通知时刻</h2>
  153. <!-- <div class="notice-time">
  154. <el-time-select
  155. v-if="type === 'task' || type === 'require'"
  156. v-model="formData.noticeTime"
  157. placeholder="任意时间点"
  158. size="small"
  159. value-format="HH:mm"
  160. :picker-options="{
  161. start: '00:00',
  162. step: '00:15',
  163. end: '23:45',
  164. }"
  165. :disabled="disabled"
  166. />
  167. </div> -->
  168. <el-form :model="formData" label-width="100px" label-position="left" :inline="true">
  169. <el-form-item label="时间">
  170. <el-select v-model="formData.noticeTimeList" multiple placeholder="任意时间点" size="small" style="width: 209px;" :disabled="disabled" clearable>
  171. <el-option v-for="(key, index) in timeDateEnum" :key="'continuity'+index" :label="key" :value="key" />
  172. </el-select>
  173. </el-form-item><br>
  174. <el-form-item label="频次">
  175. <el-select v-model="formData.noticeFrequency" placeholder="请选择" size="small" style="width: 209px;" :disabled="disabled" clearable>
  176. <el-option v-for="key in continuityDaysList" :key="'continuity'+key.value" :label="key.label" :value="key.value" />
  177. </el-select>
  178. </el-form-item>
  179. </el-form>
  180. </article>
  181. </normal-dialog>
  182. </template>
  183. <script>
  184. const _ = require('lodash')
  185. import { mapGetters } from 'vuex'
  186. import {
  187. showRequireStatusEnum,
  188. showTaskStatusEnum,
  189. getBizNoticeSettingEnum,
  190. addBizNoticeSetting,
  191. updateBizNoticeSetting
  192. } from '@/api/configure'
  193. import { teamQueryTeamListBelowBiz } from '@/api/toConfigure.js'
  194. import { settingQueryBizRqmtOrntList } from '@/api/requirement.js'
  195. import { settingQueryBizModuleList, bugGetEnum } from '@/api/defectManage'
  196. // import { queryTeamInfoList } from '@/api/workSchedule'
  197. import { showAppClientEnum } from '@/api/version.js'
  198. import normalDialog from '@/components/dialog/normalDialog'
  199. import searchPeople from '@/components/select/searchPeople'
  200. export default {
  201. components: { normalDialog, searchPeople },
  202. props: {
  203. data: {
  204. type: Object,
  205. default: () => null,
  206. required: false
  207. },
  208. visible: {
  209. type: Boolean,
  210. default: false,
  211. required: true
  212. },
  213. type: {
  214. type: String,
  215. default: 'require', // 需求:require,任务:task
  216. required: false
  217. },
  218. disabled: {// 查看状态,不可修改
  219. type: Boolean,
  220. default: false,
  221. required: false
  222. },
  223. copy: {// 复制
  224. type: Boolean,
  225. default: false,
  226. required: false
  227. }
  228. },
  229. data() {
  230. return {
  231. title: '',
  232. requireProps: {
  233. value: 'id',
  234. label: 'rqmtOrntName',
  235. children: 'childRqmtOrnts',
  236. multiple: true
  237. },
  238. taskProps: {
  239. value: 'id',
  240. label: 'moduleName',
  241. children: 'childModules',
  242. multiple: true
  243. },
  244. directionList: [], // 需求方面列表
  245. modulesList: [], // 任务模块列表
  246. formData: {
  247. type: this.type === 'bug' ? 2 : this.type === 'require' ? 0 : 1,
  248. bizId: this.bizId,
  249. requireOrientIdList: [], // 需求方向
  250. techModuleIdList: [], // 技术模块
  251. clientId: null, // 客户端
  252. clientVersionId: null, // 版本
  253. noticeConditionList: [], // 条件列表
  254. noticeSetting: {}, // 通知方式
  255. noticeTime: null // 通知时刻
  256. },
  257. EmailList: [], // Email通知列表
  258. DChartList: [], // DChart系统通知列表
  259. GroupList: [], // DChart群通知列表
  260. GroupItem: { name: null, url: null }, // 当前群添加对象
  261. showGroupForm: false,
  262. groupRules: {// 群填写规则
  263. name: [{ required: true, message: '请填写群名称或群ID', trigger: 'change' }],
  264. url: [{ required: true, message: '请填写机器人webhook地址', trigger: 'change' }]
  265. },
  266. noticeList: {// 通知方式列表
  267. Email: false, // 邮件通知
  268. DChart: false, // DChart系统通知
  269. Group: false // DChart群通知
  270. },
  271. timeDateEnum: [], // 时间list
  272. noticeGroupList: [], // 通知人群类型选择列表
  273. teamList: [], // 团队选择列表
  274. show: this.visible, // 显示弹框
  275. appClientList: [], // 客户端选择列表
  276. typeList: [], // 条件类型选择列表
  277. statusList: [], // 状态选择列表
  278. noticeEventList: [], // 事件列表
  279. sysTypeEnumList: [], // 端类型
  280. triggerList: [], // 触发事件: 0 停留 1 交付 2 提测
  281. aheadDaysList: [
  282. { label: '3天前开始提醒', value: 3 },
  283. { label: '2天前开始提醒', value: 2 },
  284. { label: '1天前开始提醒', value: 1 },
  285. { label: '过期提醒', value: 0 }
  286. ], // 提前几天提醒
  287. rangDaysList: [], // 条件中大于天数列表
  288. continuityDaysList: [] // 通知时刻频次列表
  289. }
  290. },
  291. computed: {
  292. clientList: { // 版本列表
  293. get() {
  294. if (this.formData.clientId !== null) {
  295. const obj = this.appClientList.find(item => item.code === this.formData.clientId)
  296. return (obj && obj.childEnumInfos) || []
  297. } else {
  298. return []
  299. }
  300. }
  301. },
  302. ...mapGetters(['bizId'])
  303. },
  304. watch: {
  305. data: {
  306. handler(newV) {
  307. if (newV) {
  308. this.initData(_.cloneDeep(newV))
  309. }
  310. },
  311. deep: true,
  312. immediate: true
  313. },
  314. type: {
  315. handler(newV) {
  316. this.type = newV
  317. },
  318. immediate: true
  319. },
  320. visible: {
  321. handler(newV) {
  322. this.show = newV
  323. },
  324. immediate: true
  325. },
  326. copy: {
  327. handler(newV) {
  328. this.copy = newV
  329. },
  330. immediate: true
  331. },
  332. disabled: {
  333. handler(newV) {
  334. this.disabled = newV
  335. },
  336. immediate: true
  337. },
  338. 'formData.clientId': { // 客户端改变,版本默认取第一个版本
  339. handler(newV) {
  340. // this.formData.clientVersionId = (this.clientList[0] && this.clientList[0].code) || null
  341. if (newV === null || newV === '' || newV === undefined) {
  342. this.formData.clientVersionId = null
  343. }
  344. }
  345. },
  346. 'noticeList.Email': {
  347. handler(newV, oldV) {
  348. if (newV) {
  349. if (this.EmailList.length === 0) this.EmailList.push({ type: 0, member: true, teams: [], customStaffs: [] })
  350. } else {
  351. this.EmailList = []
  352. }
  353. }
  354. },
  355. 'noticeList.DChart': {
  356. handler(newV, oldV) {
  357. if (newV) {
  358. if (this.DChartList.length === 0) this.DChartList.push({ type: 0, member: true, teams: [], customStaffs: [] })
  359. } else {
  360. this.DChartList = []
  361. }
  362. }
  363. },
  364. 'noticeList.Group': {
  365. handler(newV, oldV) {
  366. if (!newV) {
  367. this.GroupList = []
  368. }
  369. }
  370. },
  371. bizId: {
  372. handler(newV) {
  373. this.formData.bizId = newV
  374. },
  375. immediate: true
  376. }
  377. },
  378. created() {
  379. this.getBizNoticeSettingEnum()
  380. this.getRequireDirection()
  381. this.settingQueryBizModuleList()
  382. this.showAppClientEnum()
  383. this.showBugListEnum()
  384. this.queryTeamInfoList()
  385. this.init()
  386. this.gettimeDate(15)
  387. },
  388. methods: {
  389. initData(data) {
  390. console.log(data)
  391. this.formData = {
  392. type: data.type,
  393. id: data.id,
  394. bizId: data.bizId,
  395. sysType: data.sysType,
  396. requireOrientIdList: data.requireOrientIdList, // 需求方向
  397. techModuleIdList: data.techModuleIdList, // 技术模块
  398. clientId: data.clientId || null, // 客户端
  399. clientVersionId: data.clientVersionId, // 版本
  400. noticeConditionList: data.noticeConditionList || [], // 条件列表
  401. noticeSetting: {}, // 通知方式
  402. noticeTimeList: data.noticeTimeList, // 通知时刻
  403. noticeFrequency: data.noticeFrequency // 频次
  404. }
  405. if (data.noticeSetting.email && data.noticeSetting.email.length > 0) {
  406. this.EmailList = Array(data.noticeSetting.email.length).fill({ type: 0, member: true, teams: [], customStaffs: [] })
  407. this.$nextTick(() => {
  408. this.EmailList = data.noticeSetting.email
  409. })
  410. this.noticeList.Email = true
  411. }
  412. if (data.noticeSetting.dChat && data.noticeSetting.dChat.length > 0) {
  413. this.DChartList = Array(data.noticeSetting.dChat.length).fill({ type: 0, member: true, teams: [], customStaffs: [] })
  414. this.$nextTick(() => {
  415. this.DChartList = data.noticeSetting.dChat
  416. })
  417. this.noticeList.DChart = true
  418. }
  419. if (data.noticeSetting.dChatGroup && data.noticeSetting.dChatGroup.length > 0) {
  420. this.GroupList = data.noticeSetting.dChatGroup || []
  421. this.noticeList.Group = true
  422. }
  423. },
  424. async getBizNoticeSettingEnum() { // 任务需求事件列表
  425. const res = await getBizNoticeSettingEnum(this.bizId)
  426. if (res.code === 200) {
  427. this.triggerList = res.data.noticeConditionOpList
  428. this.type === 'require'
  429. ? this.noticeEventList = res.data.noticeEventRequireOpList
  430. : this.noticeEventList = res.data.noticeEventTaskOpList
  431. }
  432. },
  433. async getRequireDirection() { // 需求方向列表
  434. const res = await settingQueryBizRqmtOrntList(this.bizId)
  435. if (res.code === 200) {
  436. this.directionList = this.getRequireData(res.data)
  437. }
  438. },
  439. async settingQueryBizModuleList() { // 任务模块列表
  440. const res = await settingQueryBizModuleList(this.bizId)
  441. if (res.code === 200) {
  442. this.modulesList = this.getTaskData(res.data)
  443. }
  444. },
  445. gettimeDate(minute) {
  446. const seconds = minute * 60
  447. const len = (60 * 24 * 60) / seconds // 数组长度
  448. for (var i = 0, total = 0, newArr = []; i < len; i++) {
  449. const h = parseInt(total / 3600)
  450. const min = parseInt(total % 3600 / 60)
  451. newArr.push(this.s(h) + ':' + this.s(min))
  452. total = total + seconds
  453. }
  454. console.log(newArr)
  455. this.timeDateEnum = newArr
  456. // return newArr
  457. },
  458. s(n) {
  459. return n < 10 ? '0' + n : n
  460. },
  461. getRequireData(data) {
  462. for (let i = 0; i < data.length; i++) {
  463. data[i].childRqmtOrnts.length < 1 ? delete data[i].childRqmtOrnts : this.getRequireData(data[i].childRqmtOrnts)
  464. }
  465. return data
  466. },
  467. getTaskData(data) {
  468. for (let i = 0; i < data.length; i++) {
  469. data[i].childModules.length < 1 ? delete data[i].childModules : this.getTaskData(data[i].childModules)
  470. }
  471. return data
  472. },
  473. async showAppClientEnum() { // 获取客户端列表
  474. const res = await showAppClientEnum()
  475. if (res.code === 200) {
  476. this.appClientList = res.data.appClient
  477. }
  478. },
  479. async showBugListEnum() {
  480. const res = await bugGetEnum()
  481. if (res.code === 200) {
  482. this.statusList = res.data.bugEnumList.filter(item => {
  483. item.msg = item.name
  484. return item.name !== '已完成' && item.name !== 'Hold'
  485. }) // status
  486. this.sysTypeEnumList = res.data.sysTypeEnumList // 端类型
  487. }
  488. },
  489. async showRequireStatusEnum() { // 获取需求状态列表
  490. const res = await showRequireStatusEnum(this.bizId)
  491. if (res.code === 200) {
  492. this.statusList = res.data.requirementStatus || []
  493. }
  494. },
  495. async showTaskStatusEnum() { // 获取任务状态列表
  496. const res = await showTaskStatusEnum(this.bizId)
  497. if (res.code === 200) {
  498. this.statusList = res.data.taskStatus || []
  499. }
  500. },
  501. async queryTeamInfoList() { // 获取用户团队列表
  502. const res = await teamQueryTeamListBelowBiz(this.bizId)
  503. if (res.code === 200) {
  504. this.teamList = res.data
  505. }
  506. // const res = await queryTeamInfoList({ curIndex: 1, pageSize: 9999 })
  507. // if (res.code === 200 && res.data) {
  508. // this.teamList = res.data.list
  509. // }
  510. },
  511. init() {
  512. if (this.type === 'require') {
  513. this.data && !this.copy ? this.title = '编辑需求定时通知' : this.title = '新建需求定时通知'
  514. this.typeList = [{ label: '需求状态', value: 1 }, { label: '需求事件', value: 2 }]
  515. this.noticeGroupList = [{ label: '需求成员', value: 0 }, { label: '团队', value: 1 }, { label: '自定义人员', value: 2 }]
  516. this.showRequireStatusEnum()
  517. } else if (this.type === 'task') {
  518. this.data && !this.copy ? this.title = '编辑任务定时通知' : this.title = '新建任务定时通知'
  519. this.typeList = [{ label: '任务状态', value: 3 }, { label: '任务事件', value: 4 }]
  520. this.noticeGroupList = [{ label: '任务成员', value: 0 }, { label: '团队', value: 1 }, { label: '自定义人员', value: 2 }]
  521. this.showTaskStatusEnum()
  522. } else if (this.type === 'bug') {
  523. this.data && !this.copy ? this.title = '编辑缺陷定时通知' : this.title = '新建缺陷定时通知'
  524. this.typeList = [{ label: '缺陷状态', value: 5 }]
  525. this.noticeGroupList = [{ label: '缺陷成员', value: 0 }, { label: '自定义人员', value: 2 }]
  526. this.showBugListEnum()
  527. }
  528. let i = 1
  529. while (i <= 100) {
  530. this.rangDaysList.push({ label: `大于${i}天`, value: i })
  531. this.continuityDaysList.push({ label: `连续${i}天`, value: i })
  532. i++
  533. }
  534. this.continuityDaysList.unshift({ label: `每天`, value: -1 })
  535. },
  536. changeNoticeItem(item) { // 修改条件
  537. if (item.type === 1 || item.type === 3) {
  538. item.triggerEvent = this.triggerList[0].code
  539. } else if (item.type === 2 || item.type === 4) {
  540. item.triggerEvent = this.noticeEventList[0].code
  541. }
  542. },
  543. addCondition() { // 添加条件
  544. this.formData.noticeConditionList.push({
  545. type: this.typeList[0].value, // 1 需求状态 2 需求事件 3 任务状态 4 任务事件
  546. status: 0,
  547. triggerEvent: this.triggerList[0].code, // 触发事件
  548. greaterTime: 1, // 大于的时间
  549. lessTime: 3 // 提前提醒的时间
  550. })
  551. },
  552. removeItem(index) { // 移除条件
  553. this.formData.noticeConditionList.splice(index, 1)
  554. },
  555. addMembers(list) { // 添加成员
  556. list.push({ type: 0, member: true, teams: [], customStaffs: [] })
  557. },
  558. removeMembers(list, index) { // 移除成员
  559. list.splice(index, 1)
  560. },
  561. changeNoticeType(item) { // 修改通知
  562. switch (item.type) {
  563. case 0:
  564. item.member = true
  565. item.teamList = []
  566. item.customStaffList = []
  567. break
  568. case 1:
  569. item.member = false
  570. item.customStaffList = []
  571. break
  572. case 2:
  573. item.member = false
  574. item.teamList = []
  575. break
  576. }
  577. },
  578. addGroup() { // 添加DChart群
  579. this.$refs['groupForm'].validate((valid) => {
  580. if (valid) {
  581. this.GroupList.push({
  582. type: 3,
  583. ...this.GroupItem
  584. })
  585. this.GroupItem = { name: null, url: null }
  586. this.showGroupForm = false
  587. }
  588. })
  589. },
  590. removeGroup(index) { // 移除DChart群
  591. this.GroupList.splice(index, 1)
  592. },
  593. validate() { // 校验入参
  594. if (this.formData.noticeConditionList.length < 1) {
  595. this.$message({ message: '请添加通知条件', type: 'error', duration: 1000, offset: 150 })
  596. return false
  597. }
  598. if (this.EmailList.length === 0 && this.DChartList.length === 0 && this.GroupList.length === 0) {
  599. this.$message({ message: '请选择一种通知方式', type: 'error', duration: 1000, offset: 150 })
  600. return false
  601. }
  602. if (!this.formData.noticeTimeList) {
  603. this.$message({ message: '请选择通知时刻', type: 'error', duration: 1000, offset: 150 })
  604. return false
  605. }
  606. this.formData.noticeSetting = {
  607. email: this.noticeList.Email ? this.EmailList : [],
  608. dChat: this.noticeList.DChart ? this.DChartList : [],
  609. dChatGroup: this.noticeList.Group ? this.GroupList : []
  610. }
  611. this.data && !this.copy ? this.updateBizNoticeSetting() : this.addBizNoticeSetting()
  612. },
  613. async addBizNoticeSetting() { // 新增通知
  614. if (this.formData.id) {
  615. delete this.formData.id
  616. }
  617. const res = await addBizNoticeSetting(this.formData)
  618. if (res.code === 200) {
  619. this.$message({ message: '添加成功', type: 'success', duration: 1000, offset: 150 })
  620. this.$emit('confirm')
  621. }
  622. },
  623. async updateBizNoticeSetting() { // 更新通知
  624. const res = await updateBizNoticeSetting(this.formData)
  625. if (res.code === 200) {
  626. this.$message({ message: '修改成功', type: 'success', duration: 1000, offset: 150 })
  627. this.$emit('confirm')
  628. }
  629. },
  630. confirmForm() {
  631. this.validate()
  632. },
  633. cancel() {
  634. this.show = false
  635. this.$emit('update:visible', this.show)
  636. this.$emit('cancel')
  637. }
  638. }
  639. }
  640. </script>
  641. <style lang="scss" scoped>
  642. /deep/.el-input {
  643. width: auto;
  644. }
  645. article::-webkit-scrollbar{
  646. display: none;
  647. }
  648. article{
  649. max-height: 500px;
  650. overflow: scroll;
  651. padding: 0 45px;
  652. .form-title {
  653. margin: 0;
  654. padding: 0;
  655. font-size: 18px;
  656. color: #333333;
  657. margin: 20px 0;
  658. }
  659. .form-title:nth-child(1){
  660. margin-top: 0;
  661. }
  662. /deep/.el-form-item {
  663. font-size: 14px;
  664. margin-bottom: 10px;
  665. label {
  666. color: #666666;
  667. font-weight: 400;
  668. }
  669. }
  670. .condition-select {
  671. width: 22%;
  672. margin-right: 10px;
  673. }
  674. .add-condition,.add-notice {
  675. cursor: pointer;
  676. color: #409EFF;
  677. position: relative;
  678. }
  679. .add-notice {
  680. margin-left: 100px;
  681. width: 150px;
  682. }
  683. .notice-check{
  684. margin: 15px 0;
  685. display: block;
  686. width: 150px;
  687. }
  688. .notice-check:nth-child(1){
  689. margin-top: 0;
  690. }
  691. .el-icon-remove-outline {
  692. cursor: pointer;
  693. color: #409EFF;
  694. font-size: 14px;
  695. margin-left: 5px;
  696. }
  697. .input-width {
  698. /deep/.el-input {
  699. width: 402px;
  700. }
  701. }
  702. }
  703. .group-form {
  704. width: 280px;
  705. position: absolute;
  706. bottom: 30px;
  707. left: 0;
  708. padding: 10px;
  709. z-index: 99;
  710. background:rgba(255,255,255,1);
  711. box-shadow:0px 0px 12px rgba(0,0,0,0.1);
  712. /deep/.el-form-item{
  713. display: flex;
  714. flex-direction: column;
  715. margin-bottom: 10px;
  716. .el-form-item__content {
  717. margin: 0 !important;
  718. width: 100%;
  719. line-height: 10px;
  720. }
  721. }
  722. .group-confirm {
  723. display: flex;
  724. justify-content: center;
  725. margin-top: 20px;
  726. button:nth-child(1) {
  727. margin-right: 10px;
  728. }
  729. }
  730. }
  731. .group-list{
  732. margin: 0;
  733. padding: 0;
  734. list-style: none;
  735. width: 100%;
  736. color: #333333;
  737. font-size: 14px;
  738. .group-item {
  739. margin: 0;
  740. padding: 0;
  741. list-style: none;
  742. width: 100%;
  743. display: grid;
  744. grid-template-columns: 30% 60% 10%;
  745. border:1px solid rgba(209,208,208,1);
  746. height:37px;
  747. border-radius: 4px;
  748. margin-bottom: 10px;
  749. align-items: center;
  750. div{
  751. border-right:1px solid rgba(209,208,208,1);
  752. overflow: hidden;
  753. text-overflow: ellipsis;
  754. white-space: nowrap;
  755. text-align: center;
  756. line-height: 37px;
  757. padding: 0 5px;
  758. }
  759. span {
  760. height: 100%;
  761. display: flex;
  762. align-items: center;
  763. justify-content: center;
  764. font-size: 18px;
  765. }
  766. }
  767. }
  768. </style>