dialog_vue.vue 15 KB

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