dialog_vue.vue 14 KB

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