dialog_vue.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <div class="task">
  3. <el-dialog :visible.sync="dialogFormVisible" width="70%" :close-on-click-modal="false">
  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 reserve-keyword 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 reserve-keyword placeholder="请输入姓名或邮箱前缀" :remote-method="remoteMethod" :loading="loading" style="width: 20vw">
  67. <el-option v-for="item in options" :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 reserve-keyword :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 type="primary" @click="tit_Name === '新建任务'?create_task(task_form):uptate_task(task_form)">创 建</el-button>
  98. </div>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script>
  103. import { taskCreate, memberQueryMemberInfoByIDAPorName, configShowTaskEnum, configShowRequirementVersionEnum, taskGet, taskUpdate, projectListProject } from '@/api/taskIndex' // ajax
  104. import { projectList, settingGetBizList } from '@/api/projectIndex'
  105. import { settingQueryBizModuleList } from '@/api/defectManage'
  106. export default {
  107. data() {
  108. return {
  109. 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' }],
  110. dialogFormVisible: false,
  111. task_form: {},
  112. props: { multiple: true },
  113. ascription_project: false, // 归属项目(隐藏)
  114. ascription_demand: false, // 归属需求(隐藏)
  115. test: {},
  116. loading: false,
  117. tit: '', // 跳转
  118. tit_Name: '', // 新建(编辑)
  119. projectId: '', // 项目id
  120. requireId: '', // 需求id
  121. options: [], // 员工信息
  122. noTest: [], // 是否免测
  123. all_bizId: [], // 业务线
  124. appClient: [], // 涉及业务线
  125. arr_Modular: [], // 模块数据‘
  126. business_platform_Modular: [], // 模块
  127. show_Client: false, // 涉及的客户端(显示)
  128. projectList: [], // 归属项目数据
  129. demandList: [], // 需求list
  130. userInformation: localStorage.getItem('username'),
  131. userNames: localStorage.getItem('realname'),
  132. task_rulesForm: {
  133. name: [{ required: true, message: '请输入任务名称', trigger: 'blur' }],
  134. moduleIds: [{ required: true, message: '请选择模块', trigger: 'blur' }],
  135. priority: [{ required: true, message: '请选择优先级', trigger: 'blur' }],
  136. bizId: [{ required: true, message: '请选择业务线', trigger: 'blur' }],
  137. source: [{ required: true, message: '请输入直接归属', trigger: 'blur' }],
  138. requireId: [{ required: true, message: '请选择归属需求', trigger: 'blur' }],
  139. projectId: [{ required: true, message: '请选择归属项目', trigger: 'blur' }],
  140. followVersion: [{ required: true, message: '请选择是否跟版', trigger: 'blur' }],
  141. notest: [{ required: true, message: '请选择是否免测', trigger: 'blur' }],
  142. cliType: [{ required: true, message: '请选择业务/平台/模块', trigger: 'blur' }],
  143. involveApp: [{ required: true, message: '请选择涉及的客户端', trigger: 'blur' }]
  144. }
  145. }
  146. },
  147. created() {
  148. this.get_taskSelect()
  149. },
  150. mounted() {
  151. this.bugDataGet()
  152. },
  153. methods: {
  154. init(e, id) {
  155. this.tit_Name = '新建任务'
  156. switch (e) {
  157. case 1: // 新建任务(任务主页)
  158. this.task_form = {
  159. followVersion: 2
  160. }
  161. this.dialogFormVisible = true
  162. this.ascription_demand = false
  163. this.ascription_project = false
  164. this.$set(this.task_form, 'notest', 0)
  165. this.$set(this.task_form, 'followVersion', 2)
  166. this.$set(this.task_form, 'source', 1)
  167. this.$set(this.task_form, 'bizId', Number(localStorage.getItem('bizId')))
  168. this.show_Client = false
  169. this.$nextTick(() => {
  170. this.$refs['task_form'].clearValidate()
  171. })
  172. break
  173. case 2: // 新建任务(项目详情)
  174. this.tit = '新建任务'
  175. var url = window.location.href // 获取url中"?"符后的字串
  176. this.projectId = url.split('?id=')
  177. projectList({ id: Number(this.projectId[1]), curIndex: 1, pageSize: 15 }).then(res => {
  178. this.dialogFormVisible = true
  179. console.log(res.data[0].id, 'ddsdssdssdds')
  180. var that = this
  181. setTimeout(function() {
  182. that.task_form = {}
  183. that.ascription_demand = false
  184. that.ascription_project = true
  185. that.$set(that.task_form, 'bizId', Number(localStorage.getItem('bizId')))
  186. that.$set(that.task_form, 'source', 3)
  187. that.$set(that.task_form, 'notest', 0)
  188. that.$set(that.task_form, 'followVersion', 2)
  189. that.$set(that.task_form, 'requireId', res.data[0].id)
  190. that.$set(that.task_form, 'projectId', res.data[0].id)
  191. that.task_form.followVersion === 2 ? that.show_Client = false : ''
  192. }, 300)
  193. })
  194. break
  195. case 3: // 编辑任务(任务详情)
  196. this.tit_Name = '编辑任务'
  197. taskGet(id[1]).then(res => {
  198. this.dialogFormVisible = true
  199. var that = this
  200. setTimeout(function() {
  201. that.task_form = {}
  202. that.task_form = res.data
  203. that.task_form.source === 3 ? that.ascription_project = true : that.ascription_project = false
  204. that.task_form.source === 2 ? that.ascription_demand = true : that.ascription_demand = false
  205. that.task_form.source === 1 ? that.ascription_demand = false : ''
  206. that.task_form.source === 1 ? that.ascription_project = false : ''
  207. that.task_form.followVersion === 2 ? that.show_Client = false : that.show_Client = true
  208. that.task_form.followVersion === 1 ? that.show_Client = true : that.show_Client = false
  209. that.task_form.cliType = [res.data.bizId, res.data.type, res.data.clientType]
  210. that.task_form.involveApp = Number(res.data.involveApp)
  211. const arr_object = []
  212. arr_object.push(res.data.rdObject)
  213. arr_object.push(res.data.qaObject)
  214. var hash = {}
  215. that.options = arr_object.reduce(function(item, next) {
  216. hash[next.idap] ? '' : hash[next.idap] = true && item.push(next)
  217. return item
  218. }, [])
  219. }, 100)
  220. })
  221. break
  222. case 4: // 新建任务(项目详情)
  223. this.tit = '新建任务'
  224. var url1 = window.location.href // 获取url中"?"符后的字串
  225. this.requireId = url1.split('/')
  226. var ss = {}
  227. configShowRequirementVersionEnum({ bizId: Number(localStorage.getItem('bizId')) }).then(res => {
  228. res.data.map(item => {
  229. item.id === Number(this.requireId[7]) ? ss = item : ''
  230. })
  231. this.dialogFormVisible = true
  232. var that = this
  233. setTimeout(function() {
  234. that.task_form = {}
  235. that.ascription_demand = true
  236. that.ascription_project = false
  237. that.$set(that.task_form, 'source', 2)
  238. that.$set(that.task_form, 'notest', 0)
  239. that.$set(that.task_form, 'followVersion', 2)
  240. that.$set(that.task_form, 'requireId', ss.id)
  241. that.$set(that.task_form, 'projectId', '')
  242. that.$set(that.task_form, 'bizId', Number(localStorage.getItem('bizId')))
  243. that.task_form.followVersion === 2 ? that.show_Client = false : ''
  244. }, 300)
  245. })
  246. break
  247. }
  248. projectListProject({ bizId: Number(localStorage.getItem('bizId')) }).then(res => { // 获取项目(查询)
  249. this.projectList = res.data.filter(item => item.id !== -1)
  250. })
  251. configShowRequirementVersionEnum({ bizId: Number(localStorage.getItem('bizId')) }).then(res => {
  252. // 获取需求(查询)
  253. this.demandList = res.data.filter(item => item.id !== -1)
  254. })
  255. },
  256. test2(item, e) { // 获取团队人员信息
  257. if (typeof this.test[item.idap] === 'undefined') {
  258. item.role = e
  259. this.test[item.idap] = item
  260. }
  261. return item.idap
  262. },
  263. create_task(e) { // 创建任务(保存)
  264. this.$refs['task_form'].validate((valid) => {
  265. if (valid) {
  266. var taskInfoDO = e
  267. taskInfoDO.followVersion = e.followVersion
  268. taskInfoDO.notest = e.notest
  269. taskInfoDO.source = e.source
  270. switch (taskInfoDO.source) {
  271. case 1: // 无归属
  272. taskInfoDO.requireId = '-1'
  273. taskInfoDO.projectId = '-1'
  274. break
  275. case 2: // 需求
  276. taskInfoDO.requireId = e.requireId
  277. taskInfoDO.projectId = ''
  278. break
  279. case 3: // 项目
  280. taskInfoDO.requireId = '-1'
  281. taskInfoDO.projectId = e.projectId
  282. break
  283. }
  284. if (e.cliType) {
  285. e.cliType !== '' ? taskInfoDO.bizId = e.cliType[0] : taskInfoDO.bizId = null
  286. e.cliType !== '' ? taskInfoDO.type = e.cliType[1] : taskInfoDO.type = null
  287. e.cliType !== '' ? taskInfoDO.clientType = e.cliType[2] : taskInfoDO.clientType = null
  288. }
  289. var user = { name: this.userNames, ename: this.userInformation, id: '' }
  290. taskCreate({ taskInfoDO, user }).then(res => {
  291. this.dialogFormVisible = false
  292. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  293. this.$router.push({ name: '任务详情', query: { id: res.data.id }})
  294. })
  295. }
  296. })
  297. },
  298. uptate_task(e) { // 编辑任务(编辑)
  299. this.$refs['task_form'].validate((valid) => {
  300. if (valid) {
  301. var taskInfoDO = e
  302. taskInfoDO.followVersion = e.followVersion
  303. taskInfoDO.source = e.source
  304. taskInfoDO.notest = e.notest
  305. taskInfoDO.bizId = e.cliType[0]
  306. taskInfoDO.type = e.cliType[1]
  307. taskInfoDO.clientType = e.cliType[2]
  308. var user = { name: this.userNames, ename: this.userInformation, id: '' }
  309. taskUpdate({ taskInfoDO, user }).then(res => {
  310. if (res.code === 200) {
  311. this.dialogFormVisible = false
  312. this.$message({ message: res.msg, type: 'success', duration: 1000, offset: 150 })
  313. location.reload()
  314. }
  315. })
  316. }
  317. })
  318. },
  319. remoteMethod(query) { // 人员查询
  320. if (query !== '') {
  321. this.loading = true
  322. setTimeout(() => {
  323. this.loading = false
  324. memberQueryMemberInfoByIDAPorName({ memberIDAP: query }).then(res => {
  325. const obj = {}
  326. this.options = res.data.reduce((cur, next) => {
  327. obj[next.idap] ? '' : obj[next.idap] = true && cur.push(next)
  328. return cur
  329. }, [])
  330. })
  331. }, 200)
  332. } else {
  333. this.options = []
  334. }
  335. },
  336. get_source(e) {
  337. switch (e) {
  338. case 1:
  339. this.ascription_demand = false
  340. this.ascription_project = false
  341. this.$set(this.task_form, 'requireId', '')
  342. this.$set(this.task_form, 'projectId', '')
  343. break
  344. case 2:
  345. this.ascription_demand = true
  346. this.ascription_project = false
  347. this.$set(this.task_form, 'requireId', '')
  348. break
  349. case 3:
  350. this.ascription_demand = false
  351. this.ascription_project = true
  352. this.$set(this.task_form, 'projectId', '')
  353. break
  354. }
  355. },
  356. get_taskSelect() { // 下拉菜单数据
  357. configShowTaskEnum().then(res => {
  358. this.noTest = res.data.noTest // 是否免测
  359. this.taskSource = res.data.taskSource // 归属需求
  360. this.appClient = res.data.appClient // 涉及客户端
  361. })
  362. settingGetBizList({}).then(res => {
  363. this.all_bizId = res.data
  364. })
  365. },
  366. get_followVersion(e) { // 涉及的客户端(显示/隐藏)
  367. this.$set(this.task_form, 'involveApp', '')
  368. e === 1 ? this.show_Client = true : ''
  369. e === 2 ? this.show_Client = false : ''
  370. },
  371. bugDataGet() { // 所属模块
  372. settingQueryBizModuleList(Number(localStorage.getItem('bizId'))).then(res => {
  373. this.business_platform_Modular = res.data.map(item => ({
  374. ...item,
  375. value: item.id,
  376. label: item.moduleName,
  377. children: item.childModules.length === 0 ? null : item.childModules.map(item1 => ({
  378. ...item1,
  379. value: item1.id,
  380. label: item1.moduleName,
  381. children: item1.childModules.length === 0 ? null : item1.childModules.map(item2 => ({
  382. ...item2,
  383. value: item2.id,
  384. label: item2.moduleName
  385. }))
  386. }))
  387. }))
  388. })
  389. }
  390. }
  391. }
  392. </script>
  393. <style lang="stylus" scoped>
  394. .el-dialog__header {
  395. padding: 0px 0px 0px;
  396. }
  397. </style>