addOrEditDialog.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="addOrEditDialogFlag"
  6. :title="title"
  7. :close-on-click-modal="false"
  8. :append-to-body="true"
  9. width="70%"
  10. :before-close="cancel"
  11. >
  12. <headerTitle title="基础信息"></headerTitle>
  13. <project-form
  14. ref="projectForm"
  15. :dialog-type="dialogType"
  16. :dialogForm="dialogForm"
  17. :deptList="deptList"
  18. :deptTreeList="deptTreeList"
  19. :teamList="teamList"
  20. @teamChange="getUserList"
  21. ></project-form>
  22. <!-- <headerTitle title="项目阶段"></headerTitle>-->
  23. <!-- <project-info-table ref="projectInfoTable" :dialog-type="dialogType" :dialogForm="dialogForm" :deptList="deptList"-->
  24. <!-- :deptTreeList="deptTreeList" :userList="userList"></project-info-table>-->
  25. <div slot="footer">
  26. <el-button type="primary" size="small" @click="submit">保 存</el-button>
  27. <!-- <el-button type="primary" size="small" @click="submit('sub')">提 交</el-button>-->
  28. <el-button size="small" @click="cancel">关 闭</el-button>
  29. </div>
  30. </ele-modal>
  31. </template>
  32. <script>
  33. import projectForm from './project-form.vue';
  34. import projectInfoTable from './projectInfoTable.vue';
  35. import {
  36. projectsGetByIdAPI,
  37. projectsSaveAPI,
  38. projectsUpdateAPI,
  39. submit
  40. } from '@/api/project-manage';
  41. import { listOrganizations } from '@/api/system/organization';
  42. import {
  43. projectsTeamGetByIdAPI,
  44. projectsTeamPageAPI
  45. } from '@/api/project-manage/team';
  46. import { deepClone } from '@/utils';
  47. export default {
  48. name: 'addOrEditDialog',
  49. components: {
  50. projectForm,
  51. projectInfoTable
  52. },
  53. props: {
  54. addOrEditDialogFlag: {
  55. type: Boolean,
  56. default: false
  57. }
  58. },
  59. data() {
  60. return {
  61. title: '',
  62. dialogType: '',
  63. dialogForm: {
  64. budget: '',
  65. unit: '1',
  66. code: '',
  67. contactId: '',
  68. contactName: '',
  69. contactRelationPhone: '',
  70. contactRelationUserId: '',
  71. contactRelationUserName: '',
  72. content: '',
  73. cycle: '',
  74. deptUserId: '',
  75. deptUserName: '',
  76. level: '',
  77. monitorUserId: '',
  78. monitorUserName: '',
  79. planStartDate: '',
  80. planEndDate: '',
  81. proportion: undefined,
  82. name: '',
  83. parentId: '',
  84. remark: '',
  85. responsibleUserId: '',
  86. responsibleUserName: '',
  87. responsibleDeptId: '',
  88. responsibleDeptName: '',
  89. stage: '',
  90. teamId: '',
  91. teamName: '',
  92. type: '',
  93. contractId: '',
  94. contractName: '',
  95. files: []
  96. },
  97. teamList: [],
  98. userList: [],
  99. deptList: [],
  100. deptTreeList: []
  101. };
  102. },
  103. created() {
  104. this.getDeptList();
  105. this.getTeamList();
  106. },
  107. methods: {
  108. init(row = {}, type) {
  109. this.title = type === 'add' ? '新增' : '编辑';
  110. this.dialogType = type;
  111. if (type === 'add') {
  112. console.log(row);
  113. this.$set(this.dialogForm, 'parentId', row.id);
  114. } else {
  115. this.getInfo(row.id);
  116. }
  117. },
  118. async getInfo(id) {
  119. this.dialogForm = await projectsGetByIdAPI(id);
  120. this.dialogForm.type = this.dialogForm.type + '';
  121. this.dialogForm.level = this.dialogForm.level + '';
  122. this.dialogForm.parentId =
  123. this.dialogForm.parentId == 0 ? '' : this.dialogForm.parentId;
  124. this.dialogForm.stageList.forEach((item, index) => {
  125. let userIds = item.responsibleUserList.map((i) => i.userId) || [];
  126. this.$set(item, 'responsibleUserIds', userIds);
  127. });
  128. if (this.dialogForm.teamId) this.getUserList(this.dialogForm.teamId);
  129. },
  130. // 获取部门数据
  131. getDeptList() {
  132. listOrganizations().then((list) => {
  133. this.deptList = list;
  134. this.deptTreeList = this.$util.toTreeData({
  135. data: list,
  136. idField: 'id',
  137. parentIdField: 'parentId'
  138. });
  139. });
  140. },
  141. // 获取项目团队集合
  142. getTeamList() {
  143. projectsTeamPageAPI({
  144. pageNum: 1,
  145. size: 999,
  146. processStatus: 2
  147. }).then((list) => {
  148. this.teamList = list;
  149. });
  150. },
  151. // 获取项目团队下团队人员集合
  152. getUserList(val) {
  153. if (!val) {
  154. this.userList = [];
  155. return;
  156. }
  157. projectsTeamGetByIdAPI(val).then((list) => {
  158. this.userList = list.teamUserList;
  159. });
  160. },
  161. async submit(type = '') {
  162. let form = await this.$refs.projectForm.validForm();
  163. // form.stageList = await this.$refs.projectInfoTable.getTableValidate();
  164. form.realStartDate = null;
  165. form.realEndDate = null;
  166. // form.stageList.forEach((item) => {
  167. // item.responsibleUserList = item.responsibleUserIds.map(
  168. // i => {
  169. // return {
  170. // userId: i,
  171. // userName: this.userList.find(u => u.id === i).name
  172. // }
  173. // }
  174. // ) || []
  175. // })
  176. const API =
  177. this.dialogType === 'add' ? projectsSaveAPI : projectsUpdateAPI;
  178. const id = await API(form);
  179. if (type === 'sub') {
  180. this.processSubmit(id);
  181. return;
  182. }
  183. this.$message.success('操作成功');
  184. this.cancel();
  185. this.$emit('reload');
  186. },
  187. //流程提交
  188. processSubmit(id = '') {
  189. submit({
  190. projectId: this.dialogType === 'add' ? id : this.dialogForm.id
  191. }).then((res) => {
  192. this.$message.success('提交成功');
  193. this.cancel();
  194. this.$emit('reload');
  195. });
  196. },
  197. cancel() {
  198. this.$emit('update:addOrEditDialogFlag', false);
  199. }
  200. }
  201. };
  202. </script>
  203. <style scoped lang="scss">
  204. :deep(.el-dialog) {
  205. margin-top: 0 !important;
  206. }
  207. </style>