dialog_vue.vue 17 KB

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