addOrEditDialog.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. contactAddress: ''
  97. },
  98. teamList: [],
  99. userList: [],
  100. deptList: [],
  101. deptTreeList: []
  102. };
  103. },
  104. created() {
  105. this.getDeptList();
  106. this.getTeamList();
  107. },
  108. methods: {
  109. init(row = {}, type) {
  110. this.title = type === 'add' ? '新增' : '编辑';
  111. this.dialogType = type;
  112. if (type === 'add') {
  113. console.log(row);
  114. this.$set(this.dialogForm, 'parentId', row.id);
  115. } else {
  116. this.getInfo(row.id);
  117. }
  118. },
  119. async getInfo(id) {
  120. this.dialogForm = await projectsGetByIdAPI(id);
  121. this.dialogForm.type = this.dialogForm.type + '';
  122. this.dialogForm.level = this.dialogForm.level + '';
  123. this.dialogForm.parentId =
  124. this.dialogForm.parentId == 0 ? '' : this.dialogForm.parentId;
  125. this.dialogForm.stageList.forEach((item, index) => {
  126. let userIds = item.responsibleUserList.map((i) => i.userId) || [];
  127. this.$set(item, 'responsibleUserIds', userIds);
  128. });
  129. if (this.dialogForm.teamId) this.getUserList(this.dialogForm.teamId);
  130. },
  131. // 获取部门数据
  132. getDeptList() {
  133. listOrganizations().then((list) => {
  134. this.deptList = list;
  135. this.deptTreeList = this.$util.toTreeData({
  136. data: list,
  137. idField: 'id',
  138. parentIdField: 'parentId'
  139. });
  140. });
  141. },
  142. // 获取项目团队集合
  143. getTeamList() {
  144. projectsTeamPageAPI({
  145. pageNum: 1,
  146. size: 999
  147. // processStatus: 2
  148. }).then((list) => {
  149. this.teamList = list;
  150. });
  151. },
  152. // 获取项目团队下团队人员集合
  153. getUserList(val) {
  154. if (!val) {
  155. this.userList = [];
  156. return;
  157. }
  158. projectsTeamGetByIdAPI(val).then((list) => {
  159. this.userList = list.teamUserList;
  160. });
  161. },
  162. async submit(type = '') {
  163. let form = await this.$refs.projectForm.validForm();
  164. // form.stageList = await this.$refs.projectInfoTable.getTableValidate();
  165. form.realStartDate = null;
  166. form.realEndDate = null;
  167. // form.stageList.forEach((item) => {
  168. // item.responsibleUserList = item.responsibleUserIds.map(
  169. // i => {
  170. // return {
  171. // userId: i,
  172. // userName: this.userList.find(u => u.id === i).name
  173. // }
  174. // }
  175. // ) || []
  176. // })
  177. const API =
  178. this.dialogType === 'add' ? projectsSaveAPI : projectsUpdateAPI;
  179. const id = await API(form);
  180. if (type === 'sub') {
  181. this.processSubmit(id);
  182. return;
  183. }
  184. this.$message.success('操作成功');
  185. this.cancel();
  186. this.$emit('reload');
  187. },
  188. //流程提交
  189. processSubmit(id = '') {
  190. submit({
  191. projectId: this.dialogType === 'add' ? id : this.dialogForm.id
  192. }).then((res) => {
  193. this.$message.success('提交成功');
  194. this.cancel();
  195. this.$emit('reload');
  196. });
  197. },
  198. cancel() {
  199. this.$refs.projectForm.$refs.form.resetFields();
  200. this.$emit('update:addOrEditDialogFlag', false);
  201. }
  202. }
  203. };
  204. </script>
  205. <style scoped lang="scss">
  206. :deep(.el-dialog) {
  207. margin-top: 0 !important;
  208. }
  209. </style>