| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <template>
- <ele-modal
- custom-class="ele-dialog-form long-dialog-form"
- :centered="true"
- :visible.sync="addDialogFlag"
- append-to-body
- :title="title"
- :close-on-click-modal="false"
- width="70%"
- :before-close="cancel">
- <plan-form-table ref="planForm" :dialog-type.sync="dialogType" :dialogForm="dialogForm" :deptList="deptList"
- :deptTreeList="deptTreeList" :userList="userList" @changeProject="changeProject"></plan-form-table>
- <div slot="footer">
- <el-button type="primary" size="small" @click="submit">保 存</el-button>
- <el-button size="small" @click="cancel">关 闭</el-button>
- </div>
- </ele-modal>
- </template>
- <script>
- import planFormTable from "./plan-form-table.vue";
- import {
- getTargetPlanCode,
- projectsPlanGetByIdAPI,
- projectsPlanSaveAPI,
- projectsPlanUpdateAPI,
- submit
- } from "@/api/project-manage/plan";
- import {deepClone} from "@/utils";
- import {getUserPage, listOrganizations} from "@/api/system/organization";
- import {projectsTeamGetByIdAPI} from "@/api/project-manage/team";
- import {projectsGetByIdAPI} from "@/api/project-manage";
- export default {
- name: "addOrEditDialog",
- components: {
- planFormTable
- },
- props: {
- addDialogFlag: {
- type: Boolean,
- default: false,
- }
- },
- data() {
- return {
- title: '',
- dialogType: '',
- dialogForm: {},
- userList: [],
- deptList: [],
- deptTreeList: [],
- allUserList: [],
- }
- },
- async created() {
- this.getDeptList();
- let {list} = await getUserPage({pageNum: 1, size: -1});
- this.allUserList = list
- },
- methods: {
- async init(row = {}, type='add') {
- this.title = type === 'add' ? '新增' : '编辑';
- this.dialogType = type;
- this.dialogForm = {
- projectId: row.projectId,
- projectBomId: row.projectBomId,
- projectStageId: row.projectStageId,
- parentId: row.parentPlanId,
- code: await getTargetPlanCode()
- };
- if (this.dialogForm.projectId && !row.teamId) {
- const data = await projectsGetByIdAPI(this.dialogForm.projectId)
- if (data.teamId) this.getUserList(data.teamId);
- }else {
- if (row.teamId) this.getUserList(row.teamId);
- }
- },
- async submit(type = '') {
- let form = await this.$refs.planForm.validForm();
- // return
- // form.planStageList = await this.$refs.planInfoTable.getTableValidate() || [];
- form.realStartDate = null
- form.realEndDate = null
- for (const item of form.datasource) {
- item.responsibleUserList = await this.getResponsibleUserList(item.responsibleUserIds)
- }
- // form.responsibleUserList = await this.getResponsibleUserList(form.responsibleUserIds)
- console.log(form,'form')
- const API = this.dialogType === 'add' ? projectsPlanSaveAPI : projectsPlanUpdateAPI;
- const id = await API(form)
- if (type === 'sub') {
- this.processSubmit(id);
- return
- }
- this.$message.success('操作成功');
- this.cancel()
- this.$emit('reload');
- },
- async getResponsibleUserList(list = []) {
- console.log(list)
- console.log(this.allUserList)
- return list.map(
- i => {
- return {
- userId: i,
- userName: this.allUserList?.find(u => u.id === i).name
- }
- });
- },
- //流程提交
- processSubmit(id = '') {
- submit({
- planId: id || this.dialogForm.id
- }).then((res) => {
- this.$message.success('提交成功');
- this.cancel();
- this.$emit('reload');
- });
- },
- cancel() {
- this.$emit('update:addDialogFlag', false);
- },
- }
- }
- </script>
- <style scoped lang="scss">
- </style>
|