dialog_vue.vue 20 KB

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