dialog_vue.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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" style="padding:0 27px">
  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. data() {
  106. return {
  107. arr_priority: [{ value: 0, name: 'P0' }, { value: 1, name: 'P1' }, { value: 2, name: 'P2' }, { value: 3, name: 'P3' }],
  108. dialogFormVisible: false,
  109. task_form: {},
  110. props: { multiple: true },
  111. ascription_project: false, // 归属项目(隐藏)
  112. ascription_demand: false, // 归属需求(隐藏)
  113. test: {},
  114. loading: false,
  115. tit: '', // 跳转
  116. tit_Name: '', // 新建(编辑)
  117. projectId: '', // 项目id
  118. requireId: '', // 需求id
  119. options: [], // 员工信息
  120. options1: [],
  121. noTest: [], // 是否免测
  122. all_bizId: [], // 业务线
  123. appClient: [], // 涉及业务线
  124. arr_Modular: [], // 模块数据‘
  125. business_platform_Modular: [], // 模块
  126. show_Client: false, // 涉及的客户端(显示)
  127. projectList: [], // 归属项目数据
  128. demandList: [], // 需求list
  129. userInformation: localStorage.getItem('username'),
  130. userNames: localStorage.getItem('realname'),
  131. task_rulesForm: {
  132. name: [{ required: true, message: '请输入任务名称', trigger: 'blur' }],
  133. moduleIds: [{ required: true, message: '请选择模块', trigger: 'blur' }],
  134. priority: [{ required: true, message: '请选择优先级', trigger: 'blur' }],
  135. bizId: [{ required: true, message: '请选择业务线', trigger: 'blur' }],
  136. source: [{ required: true, message: '请输入直接归属', trigger: 'blur' }],
  137. requireId: [{ required: true, message: '请选择归属需求', trigger: 'blur' }],
  138. projectId: [{ required: true, message: '请选择归属项目', trigger: 'blur' }],
  139. followVersion: [{ required: true, message: '请选择是否跟版', trigger: 'blur' }],
  140. notest: [{ required: true, message: '请选择是否免测', trigger: 'blur' }],
  141. cliType: [{ required: true, message: '请选择业务/平台/模块', trigger: 'blur' }],
  142. involveApp: [{ required: true, message: '请选择涉及的客户端', trigger: 'blur' }]
  143. }
  144. }
  145. },
  146. created() {
  147. this.get_taskSelect()
  148. },
  149. mounted() {
  150. this.bugDataGet()
  151. },
  152. methods: {
  153. init(e, id, data = null) {
  154. this.tit_Name = '新建任务'
  155. switch (e) {
  156. case 1: // 新建任务(任务主页)
  157. this.task_form = {
  158. followVersion: 2
  159. }
  160. this.dialogFormVisible = true
  161. this.ascription_demand = false
  162. this.ascription_project = false
  163. this.$set(this.task_form, 'notest', 0)
  164. this.$set(this.task_form, 'followVersion', 2)
  165. this.$set(this.task_form, 'source', 1)
  166. this.$set(this.task_form, 'bizId', Number(localStorage.getItem('bizId')))
  167. this.show_Client = false
  168. this.$nextTick(() => {
  169. this.$refs['task_form'].clearValidate()
  170. })
  171. break
  172. case 2: // 新建任务(项目详情)
  173. this.tit = '新建任务'
  174. var url = window.location.href // 获取url中"?"符后的字串
  175. this.projectId = url.split('?id=')
  176. projectList({ id: Number(this.projectId[1]), curIndex: 1, pageSize: 15 }).then(res => {
  177. this.dialogFormVisible = true
  178. var that = this
  179. setTimeout(function() {
  180. that.task_form = {}
  181. that.ascription_demand = false
  182. that.ascription_project = true
  183. that.$set(that.task_form, 'bizId', Number(localStorage.getItem('bizId')))
  184. that.$set(that.task_form, 'source', 3)
  185. that.$set(that.task_form, 'notest', 0)
  186. that.$set(that.task_form, 'followVersion', 2)
  187. that.$set(that.task_form, 'requireId', res.data[0].id)
  188. that.$set(that.task_form, 'projectId', res.data[0].id)
  189. that.task_form.followVersion === 2 ? that.show_Client = false : ''
  190. }, 300)
  191. })
  192. break
  193. case 3: // 编辑任务(任务详情)
  194. this.tit_Name = '编辑任务'
  195. taskGet(id[1]).then(res => {
  196. this.dialogFormVisible = true
  197. var that = this
  198. setTimeout(function() {
  199. that.task_form = {}
  200. that.task_form = res.data
  201. that.task_form.source === 3 ? that.ascription_project = true : that.ascription_project = false
  202. that.task_form.source === 2 ? that.ascription_demand = true : that.ascription_demand = false
  203. that.task_form.source === 1 ? that.ascription_demand = false : ''
  204. that.task_form.source === 1 ? that.ascription_project = false : ''
  205. that.task_form.followVersion === 2 ? that.show_Client = false : that.show_Client = true
  206. that.task_form.followVersion === 1 ? that.show_Client = true : that.show_Client = false
  207. that.task_form.cliType = [res.data.bizId, res.data.type, res.data.clientType]
  208. that.task_form.involveApp = Number(res.data.involveApp)
  209. const arr_object = []
  210. arr_object.push(res.data.rdObject)
  211. arr_object.push(res.data.qaObject)
  212. var hash = {}
  213. that.options = arr_object.reduce(function(item, next) {
  214. hash[next.idap] ? '' : hash[next.idap] = true && item.push(next)
  215. return item
  216. }, [])
  217. that.options1 = arr_object.reduce(function(item, next) {
  218. hash[next.idap] ? '' : hash[next.idap] = true && item.push(next)
  219. return item
  220. }, [])
  221. }, 100)
  222. })
  223. break
  224. case 4: // 新建任务(项目详情)
  225. this.tit = '新建任务'
  226. var url1 = window.location.href // 获取url中"?"符后的字串
  227. this.requireId = url1.split('/')
  228. var ss = {}
  229. configShowRequirementVersionEnum({ bizId: Number(localStorage.getItem('bizId')) }).then(res => {
  230. res.data.map(item => {
  231. item.id === Number(this.requireId[7]) ? ss = item : ''
  232. })
  233. this.dialogFormVisible = true
  234. var that = this
  235. setTimeout(function() {
  236. that.task_form = {}
  237. that.ascription_demand = true
  238. that.ascription_project = false
  239. that.$set(that.task_form, 'source', 2)
  240. that.$set(that.task_form, 'notest', 0)
  241. that.$set(that.task_form, 'followVersion', 2)
  242. that.$set(that.task_form, 'requireId', ss.id)
  243. that.$set(that.task_form, 'projectId', '')
  244. that.$set(that.task_form, 'bizId', Number(localStorage.getItem('bizId')))
  245. that.task_form.followVersion === 2 ? that.show_Client = false : ''
  246. if (data.requirementId) {
  247. that.task_form.requireId = data.requirementId
  248. }
  249. }, 300)
  250. })
  251. break
  252. }
  253. projectListProject({ bizId: Number(localStorage.getItem('bizId')) }).then(res => { // 获取项目(查询)
  254. this.projectList = res.data.filter(item => item.id !== -1)
  255. })
  256. configShowRequirementVersionEnum({ bizId: Number(localStorage.getItem('bizId')) }).then(res => {
  257. // 获取需求(查询)
  258. this.demandList = 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. create_task(e) { // 创建任务(保存)
  269. this.$refs['task_form'].validate((valid) => {
  270. if (valid) {
  271. var taskInfoDO = e
  272. taskInfoDO.followVersion = e.followVersion
  273. taskInfoDO.notest = e.notest
  274. taskInfoDO.source = e.source
  275. switch (taskInfoDO.source) {
  276. case 1: // 无归属
  277. taskInfoDO.requireId = '-1'
  278. taskInfoDO.projectId = '-1'
  279. break
  280. case 2: // 需求
  281. taskInfoDO.requireId = e.requireId
  282. taskInfoDO.projectId = ''
  283. break
  284. case 3: // 项目
  285. taskInfoDO.requireId = '-1'
  286. taskInfoDO.projectId = e.projectId
  287. break
  288. }
  289. if (e.cliType) {
  290. e.cliType !== '' ? taskInfoDO.bizId = e.cliType[0] : taskInfoDO.bizId = null
  291. e.cliType !== '' ? taskInfoDO.type = e.cliType[1] : taskInfoDO.type = null
  292. e.cliType !== '' ? taskInfoDO.clientType = e.cliType[2] : taskInfoDO.clientType = null
  293. }
  294. var user = { name: this.userNames, ename: this.userInformation, id: '' }
  295. taskCreate({ taskInfoDO, user }).then(res => {
  296. this.dialogFormVisible = false
  297. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  298. this.$router.push({ name: '任务详情', query: { id: res.data.id }})
  299. })
  300. }
  301. })
  302. },
  303. uptate_task(e) { // 编辑任务(编辑)
  304. this.$refs['task_form'].validate((valid) => {
  305. if (valid) {
  306. var taskInfoDO = e
  307. taskInfoDO.followVersion = e.followVersion
  308. taskInfoDO.source = e.source
  309. taskInfoDO.notest = e.notest
  310. taskInfoDO.bizId = e.cliType[0]
  311. taskInfoDO.type = e.cliType[1]
  312. taskInfoDO.clientType = e.cliType[2]
  313. var user = { name: this.userNames, ename: this.userInformation, id: '' }
  314. taskUpdate({ taskInfoDO, user }).then(res => {
  315. if (res.code === 200) {
  316. this.dialogFormVisible = false
  317. this.$emit('updateIteration')
  318. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  319. location.reload()
  320. }
  321. })
  322. }
  323. })
  324. },
  325. remoteMethod(query) { // 人员查询
  326. if (query !== '') {
  327. this.loading = true
  328. setTimeout(() => {
  329. this.loading = false
  330. memberQueryMemberInfoByIDAPorName({ memberIDAP: query }).then(res => {
  331. const obj = {}
  332. this.options = res.data.reduce((cur, next) => {
  333. obj[next.idap] ? '' : obj[next.idap] = true && cur.push(next)
  334. return cur
  335. }, [])
  336. })
  337. }, 200)
  338. } else {
  339. this.options = []
  340. }
  341. },
  342. remoteMethod1(query) { // 人员查询
  343. if (query !== '') {
  344. this.loading = true
  345. setTimeout(() => {
  346. this.loading = false
  347. memberQueryMemberInfoByIDAPorName({ memberIDAP: query }).then(res => {
  348. const obj = {}
  349. this.options1 = res.data.reduce((cur, next) => {
  350. obj[next.idap] ? '' : obj[next.idap] = true && cur.push(next)
  351. return cur
  352. }, [])
  353. })
  354. }, 200)
  355. } else {
  356. this.options1 = []
  357. }
  358. },
  359. get_source(e) {
  360. switch (e) {
  361. case 1:
  362. this.ascription_demand = false
  363. this.ascription_project = false
  364. this.$set(this.task_form, 'requireId', '')
  365. this.$set(this.task_form, 'projectId', '')
  366. break
  367. case 2:
  368. this.ascription_demand = true
  369. this.ascription_project = false
  370. this.$set(this.task_form, 'requireId', '')
  371. break
  372. case 3:
  373. this.ascription_demand = false
  374. this.ascription_project = true
  375. this.$set(this.task_form, 'projectId', '')
  376. break
  377. }
  378. },
  379. get_taskSelect() { // 下拉菜单数据
  380. configShowTaskEnum().then(res => {
  381. this.noTest = res.data.noTest // 是否免测
  382. this.taskSource = res.data.taskSource // 归属需求
  383. this.appClient = res.data.appClient // 涉及客户端
  384. })
  385. settingGetBizList({}).then(res => {
  386. this.all_bizId = res.data
  387. })
  388. },
  389. get_followVersion(e) { // 涉及的客户端(显示/隐藏)
  390. this.$set(this.task_form, 'involveApp', '')
  391. e === 1 ? this.show_Client = true : ''
  392. e === 2 ? this.show_Client = false : ''
  393. },
  394. bugDataGet() { // 所属模块
  395. settingQueryBizModuleList(Number(localStorage.getItem('bizId'))).then(res => {
  396. this.business_platform_Modular = res.data.map(item => ({
  397. ...item,
  398. value: item.id,
  399. label: item.moduleName,
  400. children: item.childModules.length === 0 ? null : item.childModules.map(item1 => ({
  401. ...item1,
  402. value: item1.id,
  403. label: item1.moduleName,
  404. children: item1.childModules.length === 0 ? null : item1.childModules.map(item2 => ({
  405. ...item2,
  406. value: item2.id,
  407. label: item2.moduleName
  408. }))
  409. }))
  410. }))
  411. })
  412. }
  413. }
  414. }
  415. </script>
  416. <style lang="scss" scoped>
  417. .task {
  418. /deep/ .el-dialog__title {
  419. line-height: 24px;
  420. font-size: 18px;
  421. color: #303133;
  422. padding-left: 10px;
  423. }
  424. .blueStripe {
  425. width:4px;
  426. height:17px;
  427. background:#409EFF;
  428. border-radius:1px;
  429. position: absolute;
  430. top: 23px;
  431. left: 20px;
  432. }
  433. }
  434. </style>