yxk-20260509-党委会反馈表单

新增时,自动加上反馈部门和反馈人
This commit is contained in:
ye1023
2026-05-09 15:52:49 +08:00
parent 0a28b35f37
commit cbd048e7d3
3 changed files with 97 additions and 2 deletions
@@ -60,12 +60,15 @@
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, reactive, ref } from 'vue'; import { nextTick, reactive, ref } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import JModal from '/@/components/Modal/src/JModal/JModal.vue'; import JModal from '/@/components/Modal/src/JModal/JModal.vue';
import { bgPartymatterFeedbackSaveOrUpdate } from '../BgPartymatter.api'; import { bgPartymatterFeedbackSaveOrUpdate } from '../BgPartymatter.api';
import { useUserStore } from '/@/store/modules/user';
const emit = defineEmits(['success']); const emit = defineEmits(['success']);
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const userStore = useUserStore();
const visible = ref(false); const visible = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -101,9 +104,51 @@
function open(mainId: string) { function open(mainId: string) {
resetForm(mainId); resetForm(mainId);
void applyCurrentUserFeedbackInfo();
visible.value = true; visible.value = true;
} }
function getCurrentLoginDepart() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
const loginInfo = (userStore.getLoginInfo || {}) as Record<string, any>;
const departs = Array.isArray(loginInfo.departs) ? loginInfo.departs : [];
if (userInfo.orgCode) {
return departs.find((item) => item.orgCode === userInfo.orgCode);
}
return departs.length === 1 ? departs[0] : undefined;
}
async function getCurrentDepartInfo() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
const loginDepart = getCurrentLoginDepart();
if (loginDepart) {
return {
id: loginDepart.id || '',
departName: loginDepart.departName || '',
};
}
if (userInfo.orgCode) {
const depart = await defHttp.get({ url: '/sys/sysDepart/getDepartName', params: { orgCode: userInfo.orgCode } });
return {
id: depart?.id || '',
departName: depart?.departName || '',
};
}
return {
id: userInfo.departIds || '',
departName: userInfo.departIds_dictText || userInfo.orgCodeTxt || '',
};
}
async function applyCurrentUserFeedbackInfo() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
formData.responPersonid = userInfo.id || userInfo.userId || '';
formData.responPersonname = userInfo.realname || '';
const departInfo = await getCurrentDepartInfo();
formData.responDeptid = departInfo.id;
formData.responDeptname = departInfo.departName;
}
function handleCancel() { function handleCancel() {
visible.value = false; visible.value = false;
} }
@@ -116,6 +161,7 @@
} }
saving.value = true; saving.value = true;
try { try {
await applyCurrentUserFeedbackInfo();
const res = await bgPartymatterFeedbackSaveOrUpdate({ ...formData }, false); const res = await bgPartymatterFeedbackSaveOrUpdate({ ...formData }, false);
if (res.success) { if (res.success) {
createMessage.success(res.message || '保存成功'); createMessage.success(res.message || '保存成功');
@@ -80,7 +80,7 @@
</template> </template>
</a-row> </a-row>
<div v-if="!mainDisabled" class="main-actions"> <div v-if="!mainDisabled" class="main-actions">
<a-button type="primary" :loading="savingMain" @click="submitForm">保存主表数据</a-button> <a-button type="primary" :loading="savingMain" @click="submitForm">保存</a-button>
</div> </div>
</a-form> </a-form>
@@ -423,6 +423,6 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
gap: 12px; gap: 12px;
margin-top: 8px; margin-top: 1px;
} }
</style> </style>
@@ -59,11 +59,13 @@
import { bgPartymatterFeedbackSaveOrUpdate } from '../BgPartymatter.api'; import { bgPartymatterFeedbackSaveOrUpdate } from '../BgPartymatter.api';
import { Form } from 'ant-design-vue'; import { Form } from 'ant-design-vue';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue'; import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
import { useUserStore } from '/@/store/modules/user';
//接收主表id //接收主表id
const mainId = inject('mainId'); const mainId = inject('mainId');
const formRef = ref(); const formRef = ref();
const useForm = Form.useForm; const useForm = Form.useForm;
const userStore = useUserStore();
const emit = defineEmits(['register', 'ok']); const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({ const formData = reactive<Record<string, any>>({
id: '', id: '',
@@ -98,6 +100,9 @@
*/ */
function add() { function add() {
edit({}); edit({});
nextTick(() => {
void applyCurrentUserFeedbackInfo();
});
} }
/** /**
@@ -117,6 +122,47 @@
}); });
} }
function getCurrentLoginDepart() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
const loginInfo = (userStore.getLoginInfo || {}) as Record<string, any>;
const departs = Array.isArray(loginInfo.departs) ? loginInfo.departs : [];
if (userInfo.orgCode) {
return departs.find((item) => item.orgCode === userInfo.orgCode);
}
return departs.length === 1 ? departs[0] : undefined;
}
async function getCurrentDepartInfo() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
const loginDepart = getCurrentLoginDepart();
if (loginDepart) {
return {
id: loginDepart.id || '',
departName: loginDepart.departName || '',
};
}
if (userInfo.orgCode) {
const depart = await defHttp.get({ url: '/sys/sysDepart/getDepartName', params: { orgCode: userInfo.orgCode } });
return {
id: depart?.id || '',
departName: depart?.departName || '',
};
}
return {
id: userInfo.departIds || '',
departName: userInfo.departIds_dictText || userInfo.orgCodeTxt || '',
};
}
async function applyCurrentUserFeedbackInfo() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
formData.responPersonid = userInfo.id || userInfo.userId || '';
formData.responPersonname = userInfo.realname || '';
const departInfo = await getCurrentDepartInfo();
formData.responDeptid = departInfo.id;
formData.responDeptname = departInfo.departName;
}
/** /**
* 提交数据 * 提交数据
*/ */
@@ -141,6 +187,9 @@
if (model.id) { if (model.id) {
isUpdate.value = true; isUpdate.value = true;
} }
if (!isUpdate.value) {
await applyCurrentUserFeedbackInfo();
}
//循环数据 //循环数据
for (let data in model) { for (let data in model) {