dialog_vue.vue 19 KB

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