modifyNotice.vue 32 KB

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