dialog_vue.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <div class="task">
  3. <el-dialog :title="tit_Name" :visible.sync="dialogFormVisible" width="70%" :close-on-click-modal="false" :destroy-on-close="true">
  4. <div class="blueStripe" />
  5. <el-form ref="task_form" :model="task_form" :rules="task_rulesForm" label-position="right" style="margin-right: 3%;" label-width="120px">
  6. <el-form-item label="任务名称" prop="name" style="width: 100%">
  7. <el-input v-model="task_form.name" autocomplete="off" placeholder="请输入任务名称" />
  8. </el-form-item>
  9. <div style="display:flex;align-items: center;justify-content: space-between;">
  10. <el-form-item label="直接归属" prop="source">
  11. <el-radio-group v-model="task_form.source" @change="get_source(task_form.source)">
  12. <el-radio :label="1">不归属</el-radio>
  13. <el-radio :label="2">需求</el-radio>
  14. <el-radio :label="3">项目</el-radio>
  15. </el-radio-group>
  16. </el-form-item>
  17. <el-form-item v-if="ascription_demand" label="归属需求" prop="requireId">
  18. <el-select v-model="task_form.requireId" filterable clearable placeholder="请选择" style="width:20vw">
  19. <el-option v-for="item in demandList" :key="item.id" :label="item.name" :value="item.id" />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item v-if="ascription_project" label="归属项目" prop="projectId">
  23. <el-select v-model="task_form.projectId" filterable clearable placeholder="请选择" style="width:20vw">
  24. <el-option v-for="item in projectList" :key="item.id" :label="item.name" :value="item.id" />
  25. </el-select>
  26. </el-form-item>
  27. </div>
  28. <div style="display:flex;align-items: center;justify-content: space-between;">
  29. <div>
  30. <el-form-item label="优先级" prop="priority">
  31. <el-select v-model="task_form.priority" filterable placeholder="请选择" style="width:20vw">
  32. <el-option v-for="item in arr_priority" :key="item.value" :label="item.name" :value="item.value" />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="业务线" prop="bizId">
  36. <el-select v-model="task_form.bizId" :disabled="task_form.source !== 2" placeholder="请选择" style="width:100%" filterable @change="task_change_bizId(task_form.bizId)">
  37. <el-option-group v-for="group in bizList" :key="group.code" :label="group.name">
  38. <el-option v-for="item in group.options" :key="item.code" :label="item.name" :value="item.code" />
  39. </el-option-group>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="开发负责人">
  43. <el-select v-model="task_form.rdOwner" filterable clearable remote placeholder="请输入姓名或邮箱前缀" :remote-method="remoteMethod" :loading="loading" style="width: 100%">
  44. <el-option v-for="item in options" :key="item.idap" :label="item.name" :value="test2(item, 0)">
  45. <div style="display: flex;justify-content: start;">
  46. <div style="min-width:100px;color: #8492a6; font-size: 13px; overflow:hidden">{{ item.deptName }}</div>
  47. <div style="min-width:80px">{{ item.name }}</div>
  48. <div style="min-width:100px;color: #8492a6; font-size: 13px; overflow:hidden">{{ item.idap }}</div>
  49. </div>
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. </div>
  54. <div>
  55. <el-form-item label="是否免测" prop="notest">
  56. <el-radio-group v-model="task_form.notest">
  57. <el-radio :label="0">否</el-radio>
  58. <el-radio :label="1">是</el-radio>
  59. </el-radio-group>
  60. </el-form-item>
  61. <el-form-item label="模块" prop="moduleIds">
  62. <el-cascader v-model="task_form.moduleIds" clearable collapse-tags :props="props" :options="business_platform_Modular" placeholder="请选择" style="width: 20vw" @click.native="bugDataGet" />
  63. </el-form-item>
  64. <el-form-item label="测试负责人">
  65. <el-select v-model="task_form.qaOwner" filterable clearable remote placeholder="请输入姓名或邮箱前缀" :remote-method="remoteMethod1" :loading="loading" style="width: 20vw">
  66. <el-option v-for="item in options1" :key="item.idap" :label="item.name" :value="test2(item, 0)">
  67. <div style="display: flex;justify-content: start;">
  68. <div style="min-width:100px;color: #8492a6; font-size: 13px; overflow:hidden">{{ item.deptName }}</div>
  69. <div style="min-width:80px">{{ item.name }}</div>
  70. <div style="min-width:100px;color: #8492a6; font-size: 13px; overflow:hidden">{{ item.idap }}</div>
  71. </div>
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. </div>
  76. </div>
  77. <el-form-item label="技术文档链接">
  78. <el-input v-model="task_form.devUrl" placeholder="请粘贴链接" />
  79. </el-form-item>
  80. <div style="display:flex;align-items: center;justify-content: space-between;">
  81. <el-form-item label="是否跟版" prop="followVersion">
  82. <el-radio-group v-model="task_form.followVersion" @change="get_followVersion(task_form.followVersion)">
  83. <el-radio :label="2">否</el-radio>
  84. <el-radio :label="1">是</el-radio>
  85. </el-radio-group>
  86. </el-form-item>
  87. <el-form-item v-if="show_Client" label="涉及的客户端" prop="involveApp">
  88. <el-select v-model="task_form.involveApp" filterable remote :loading="loading" clearable placeholder="请选择" style="width: 20vw">
  89. <el-option v-for="item in appClient" :key="item.code" :label="item.msg" :value="item.code" />
  90. </el-select>
  91. </el-form-item>
  92. </div>
  93. </el-form>
  94. <div slot="footer">
  95. <el-button @click="dialogFormVisible = false">取 消</el-button>
  96. <el-button v-if="tit_Name === '新建任务'" type="primary" @click="tit_Name === '新建任务'?throttleTask(task_form):uptate_task(task_form)">创 建</el-button>
  97. <el-button v-else type="primary" @click="tit_Name === '新建任务'?throttleTask(task_form):uptate_task(task_form)">保 存</el-button>
  98. </div>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script>
  103. import { mapGetters } from 'vuex'
  104. import { analysisBizId_id, EncryptId } from '@/utils/crypto-js.js'
  105. const _ = require('lodash')
  106. import { taskCreate, memberQueryMemberInfoByIDAPorName, configShowTaskEnum, configShowRequirementVersionEnum, taskGet, taskUpdate, projectListProject } from '@/api/taskIndex' // ajax
  107. import { projectList, settingGetBizList, settingGetMyAndOtherBizList } from '@/api/projectIndex'
  108. import { settingQueryBizModuleList } from '@/api/defectManage'
  109. export default {
  110. props: {
  111. noJump: {
  112. type: Boolean,
  113. default: false,
  114. required: false
  115. }
  116. },
  117. data() {
  118. return {
  119. arr_priority: [{ value: 0, name: 'P0' }, { value: 1, name: 'P1' }, { value: 2, name: 'P2' }, { value: 3, name: 'P3' }],
  120. dialogFormVisible: false,
  121. task_form: {},
  122. props: { multiple: true },
  123. ascription_project: false, // 归属项目(隐藏)
  124. ascription_demand: false, // 归属需求(隐藏)
  125. test: {},
  126. bizList: [],
  127. loading: false,
  128. tit: '', // 跳转
  129. tit_Name: '', // 新建(编辑)
  130. projectId: -1, // 项目id
  131. requireId: -1, // 需求id
  132. options: [], // 员工信息
  133. options1: [],
  134. noTest: [], // 是否免测
  135. all_bizId: [], // 业务线
  136. appClient: [], // 涉及业务线
  137. arr_Modular: [], // 模块数据‘
  138. business_platform_Modular: [], // 模块
  139. show_Client: false, // 涉及的客户端(显示)
  140. projectList: [], // 归属项目数据
  141. demandList: [], // 需求list
  142. userInformation: localStorage.getItem('username'),
  143. userNames: localStorage.getItem('realname'),
  144. requirementIdList: {},
  145. task_rulesForm: {
  146. name: [{ required: true, message: '请输入任务名称', trigger: 'blur' }],
  147. // moduleIds: [{ required: true, message: '请选择模块', trigger: 'blur' }],
  148. priority: [{ required: true, message: '请选择优先级', trigger: 'blur' }],
  149. bizId: [{ required: true, message: '请选择业务线', trigger: 'blur' }],
  150. source: [{ required: true, message: '请输入直接归属', trigger: 'blur' }],
  151. requireId: [{ required: true, message: '请选择归属需求', trigger: 'blur' }],
  152. projectId: [{ required: true, message: '请选择归属项目', trigger: 'blur' }],
  153. followVersion: [{ required: true, message: '请选择是否跟版', trigger: 'blur' }],
  154. notest: [{ required: true, message: '请选择是否免测', trigger: 'blur' }],
  155. cliType: [{ required: true, message: '请选择业务/平台/模块', trigger: 'blur' }],
  156. involveApp: [{ required: true, message: '请选择涉及的客户端', trigger: 'blur' }]
  157. }
  158. }
  159. },
  160. computed: {
  161. ...mapGetters(['bizId'])
  162. },
  163. created() {
  164. this.analysisBizId_id()
  165. this.settingGetBizList()
  166. },
  167. mounted() {
  168. this.get_taskSelect()
  169. this.bugDataGet()
  170. },
  171. methods: {
  172. analysisBizId_id() { // 解析路由中的bizId_id
  173. if (!this.$route.query.bizId_id) return
  174. const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
  175. this.projectId = bizId_id[1]
  176. this.requireId = bizId_id[1]
  177. },
  178. async init(e, id, data = null) {
  179. this.tit_Name = '新建任务'
  180. switch (e) {
  181. case 1: // 新建任务(任务主页)
  182. this.dialogFormVisible = true
  183. this.ascription_demand = false
  184. this.ascription_project = false
  185. this.task_form = { 'notest': 0, 'followVersion': 2, 'source': 1, 'bizId': this.bizId }
  186. this.requirementIdList = { 'name': '主页' }
  187. this.show_Client = false
  188. this.$nextTick(() => {
  189. this.$refs['task_form'].clearValidate()
  190. })
  191. this.task_change_bizId(this.bizId)
  192. break
  193. case 2: // 新建任务(项目详情)
  194. this.tit = '新建任务'
  195. projectList({ id: this.projectId, curIndex: 1, pageSize: 15 }).then(res => {
  196. this.dialogFormVisible = true
  197. this.task_form = { 'followVersion': 2, 'notest': 0, 'source': 3, 'projectId': res.data[0].id, 'requireId': res.data[0].id, 'bizId': this.bizId }
  198. this.requirementIdList = { 'name': '项目', 'data': res.data[0].id }
  199. this.ascription_demand = false
  200. this.ascription_project = true
  201. this.show_Client = false
  202. this.task_change_bizId(this.bizId)
  203. })
  204. break
  205. case 3: // 编辑任务(任务详情)
  206. this.tit_Name = '编辑任务'
  207. taskGet(id[1]).then(res => {
  208. this.dialogFormVisible = true
  209. var that = this
  210. setTimeout(function() {
  211. that.task_form = {}
  212. that.task_form = res.data
  213. that.task_form.source === 3 ? that.ascription_project = true : that.ascription_project = false
  214. that.task_form.source === 2 ? that.ascription_demand = true : that.ascription_demand = false
  215. that.task_form.source === 1 ? that.ascription_demand = false : ''
  216. that.task_form.source === 1 ? that.ascription_project = false : ''
  217. that.task_form.followVersion === 2 ? that.show_Client = false : that.show_Client = true
  218. that.task_form.followVersion === 1 ? that.show_Client = true : that.show_Client = false
  219. that.task_form.cliType = [res.data.bizId, res.data.type, res.data.clientType]
  220. that.task_form.involveApp = Number(res.data.involveApp)
  221. const arr_object = []
  222. arr_object.push(res.data.rdObject)
  223. arr_object.push(res.data.qaObject)
  224. var hash = {}
  225. that.options = arr_object.reduce(function(item, next) {
  226. hash[next.idap] ? '' : hash[next.idap] = true && item.push(next)
  227. return item
  228. }, [])
  229. that.options1 = arr_object.reduce(function(item, next) {
  230. hash[next.idap] ? '' : hash[next.idap] = true && item.push(next)
  231. return item
  232. }, [])
  233. }, 100)
  234. this.task_change_bizId(res.data.bizId, res.data.id)
  235. })
  236. break
  237. case 4: // 新建任务(需求详情)
  238. this.tit = '新建任务'
  239. var ss = {}
  240. configShowRequirementVersionEnum({ bizId: this.bizId }).then(res => {
  241. res.data.map(item => {
  242. item.id === this.requireId ? ss = item : ''
  243. })
  244. this.dialogFormVisible = true
  245. this.ascription_demand = true
  246. this.ascription_project = false
  247. this.task_form = { 'followVersion': 2, 'notest': 0, 'source': 2, 'projectId': '', 'requireId': ss.id, 'bizId': this.bizId }
  248. this.show_Client = false
  249. if (data) {
  250. this.task_form = { ...this.task_form, 'requireId': data.requirementId, 'name': data.name, 'priority': data.priority }
  251. this.requirementIdList = { 'name': '需求', 'data': data.requirementId }
  252. }
  253. this.task_change_bizId(this.bizId)
  254. })
  255. break
  256. }
  257. projectListProject({ bizId: this.bizId }).then(res => { // 获取项目(查询)
  258. this.projectList = res.data.filter(item => item.id !== -1)
  259. })
  260. },
  261. test2(item, e) { // 获取团队人员信息
  262. if (typeof this.test[item.idap] === 'undefined') {
  263. item.role = e
  264. this.test[item.idap] = item
  265. }
  266. return item.idap
  267. },
  268. throttleTask: _.throttle(function() {
  269. this.create_task(...arguments)
  270. }, 5000, {
  271. leading: true,
  272. trailing: false
  273. }),
  274. async settingGetBizList() { // 获取业务线列表
  275. const res = await settingGetMyAndOtherBizList()
  276. if (res.code === 200) {
  277. this.bizList = [{
  278. name: '我的业务线',
  279. options: res.data[0] || []
  280. }, {
  281. name: '其他业务线',
  282. options: res.data[1] ? res.data[1].filter(item => item.isSecret !== 1) : []
  283. }]
  284. }
  285. },
  286. async task_change_bizId(biz, id) { // 获取业务线需求
  287. const data = { bizId: biz }
  288. id ? data.taskId = id : ''
  289. const res = await configShowRequirementVersionEnum(data) // 获取需求(查询)
  290. if (res.code === 200) {
  291. this.demandList = res.data.filter(item => item.id !== -1)
  292. }
  293. },
  294. create_task(e) { // 创建任务(保存)
  295. this.$refs['task_form'].validate((valid) => {
  296. if (valid) {
  297. var taskInfoDO = e
  298. taskInfoDO.followVersion = e.followVersion
  299. taskInfoDO.notest = e.notest
  300. taskInfoDO.source = e.source
  301. switch (taskInfoDO.source) {
  302. case 1: // 无归属
  303. taskInfoDO.requireId = '-1'
  304. taskInfoDO.projectId = '-1'
  305. break
  306. case 2: // 需求
  307. taskInfoDO.requireId = e.requireId
  308. taskInfoDO.projectId = ''
  309. break
  310. case 3: // 项目
  311. taskInfoDO.requireId = '-1'
  312. taskInfoDO.projectId = e.projectId
  313. break
  314. }
  315. if (e.cliType) {
  316. e.cliType !== '' ? taskInfoDO.bizId = e.cliType[0] : taskInfoDO.bizId = null
  317. e.cliType !== '' ? taskInfoDO.type = e.cliType[1] : taskInfoDO.type = null
  318. e.cliType !== '' ? taskInfoDO.clientType = e.cliType[2] : taskInfoDO.clientType = null
  319. }
  320. var user = { name: this.userNames, ename: this.userInformation, id: '' }
  321. taskCreate({ taskInfoDO, user }).then(res => {
  322. this.dialogFormVisible = false
  323. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  324. if (!this.noJump) {
  325. const bizId_id = EncryptId(`${this.bizId}_${res.data.id}`)
  326. this.$router.push({ name: '任务详情', query: { bizId_id: bizId_id }})
  327. } else {
  328. this.$emit('change')
  329. }
  330. })
  331. }
  332. })
  333. },
  334. uptate_task(e) { // 编辑任务(编辑)
  335. this.$refs['task_form'].validate((valid) => {
  336. if (valid) {
  337. var taskInfoDO = e
  338. taskInfoDO.followVersion = e.followVersion
  339. taskInfoDO.source = e.source
  340. taskInfoDO.notest = e.notest
  341. taskInfoDO.bizId = e.cliType[0]
  342. taskInfoDO.type = e.cliType[1]
  343. taskInfoDO.clientType = e.cliType[2]
  344. var user = { name: this.userNames, ename: this.userInformation, id: '' }
  345. taskUpdate({ taskInfoDO, user }).then(res => {
  346. if (res.code === 200) {
  347. this.dialogFormVisible = false
  348. this.$emit('updateIteration')
  349. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  350. location.reload()
  351. }
  352. })
  353. }
  354. })
  355. },
  356. remoteMethod(query) { // 人员查询
  357. if (query !== '') {
  358. this.loading = true
  359. setTimeout(() => {
  360. this.loading = false
  361. memberQueryMemberInfoByIDAPorName({ memberIDAP: query }).then(res => {
  362. const obj = {}
  363. this.options = res.data.reduce((cur, next) => {
  364. obj[next.idap] ? '' : obj[next.idap] = true && cur.push(next)
  365. return cur
  366. }, [])
  367. })
  368. }, 200)
  369. } else {
  370. this.options = []
  371. }
  372. },
  373. remoteMethod1(query) { // 人员查询
  374. if (query !== '') {
  375. this.loading = true
  376. setTimeout(() => {
  377. this.loading = false
  378. memberQueryMemberInfoByIDAPorName({ memberIDAP: query }).then(res => {
  379. const obj = {}
  380. this.options1 = res.data.reduce((cur, next) => {
  381. obj[next.idap] ? '' : obj[next.idap] = true && cur.push(next)
  382. return cur
  383. }, [])
  384. })
  385. }, 200)
  386. } else {
  387. this.options1 = []
  388. }
  389. },
  390. get_source(e) {
  391. switch (e) {
  392. case 1:
  393. this.ascription_demand = false
  394. this.ascription_project = false
  395. this.$set(this.task_form, 'bizId', this.bizId)
  396. this.$set(this.task_form, 'requireId', '')
  397. this.$set(this.task_form, 'projectId', '')
  398. break
  399. case 2:
  400. this.ascription_demand = true
  401. this.ascription_project = false
  402. this.requirementIdList.name === '需求' ? this.$set(this.task_form, 'requireId', this.requirementIdList.data) : this.$set(this.task_form, 'requireId', '')
  403. this.$set(this.task_form, 'projectId', '')
  404. break
  405. case 3:
  406. this.ascription_demand = false
  407. this.ascription_project = true
  408. this.$set(this.task_form, 'bizId', this.bizId)
  409. this.requirementIdList.name === '项目' ? this.$set(this.task_form, 'projectId', this.requirementIdList.data) : this.$set(this.task_form, 'projectId', '')
  410. this.$set(this.task_form, 'requireId', '')
  411. break
  412. }
  413. },
  414. get_taskSelect() { // 下拉菜单数据
  415. configShowTaskEnum().then(res => {
  416. this.noTest = res.data.noTest // 是否免测
  417. this.taskSource = res.data.taskSource // 归属需求
  418. this.appClient = res.data.appClient // 涉及客户端
  419. })
  420. settingGetBizList({}).then(res => {
  421. this.all_bizId = res.data
  422. })
  423. },
  424. get_followVersion(e) { // 涉及的客户端(显示/隐藏)
  425. this.$set(this.task_form, 'involveApp', '')
  426. e === 1 ? this.show_Client = true : ''
  427. e === 2 ? this.show_Client = false : ''
  428. },
  429. bugDataGet() { // 所属模块
  430. settingQueryBizModuleList(this.bizId).then(res => {
  431. this.business_platform_Modular = res.data.map(item => ({
  432. ...item,
  433. value: item.id,
  434. label: item.moduleName,
  435. children: item.childModules.length === 0 ? null : item.childModules.map(item1 => ({
  436. ...item1,
  437. value: item1.id,
  438. label: item1.moduleName,
  439. children: item1.childModules.length === 0 ? null : item1.childModules.map(item2 => ({
  440. ...item2,
  441. value: item2.id,
  442. label: item2.moduleName
  443. }))
  444. }))
  445. }))
  446. })
  447. }
  448. }
  449. }
  450. </script>
  451. <style lang="scss" scoped>
  452. .task {
  453. /deep/ .el-dialog__title {
  454. line-height: 24px;
  455. font-size: 18px;
  456. color: #303133;
  457. padding-left: 10px;
  458. }
  459. .blueStripe {
  460. width:4px;
  461. height:17px;
  462. background:#409EFF;
  463. border-radius:1px;
  464. position: absolute;
  465. top: 23px;
  466. left: 20px;
  467. }
  468. }
  469. </style>