yxk-20260509-党委会反馈表单
新增时,自动加上反馈部门和反馈人
This commit is contained in:
@@ -60,12 +60,15 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { nextTick, reactive, ref } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
||||
import { bgPartymatterFeedbackSaveOrUpdate } from '../BgPartymatter.api';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const { createMessage } = useMessage();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const visible = ref(false);
|
||||
const saving = ref(false);
|
||||
@@ -101,9 +104,51 @@
|
||||
|
||||
function open(mainId: string) {
|
||||
resetForm(mainId);
|
||||
void applyCurrentUserFeedbackInfo();
|
||||
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() {
|
||||
visible.value = false;
|
||||
}
|
||||
@@ -116,6 +161,7 @@
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await applyCurrentUserFeedbackInfo();
|
||||
const res = await bgPartymatterFeedbackSaveOrUpdate({ ...formData }, false);
|
||||
if (res.success) {
|
||||
createMessage.success(res.message || '保存成功');
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
</template>
|
||||
</a-row>
|
||||
<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>
|
||||
</a-form>
|
||||
|
||||
@@ -423,6 +423,6 @@
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -59,11 +59,13 @@
|
||||
import { bgPartymatterFeedbackSaveOrUpdate } from '../BgPartymatter.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
|
||||
//接收主表id
|
||||
const mainId = inject('mainId');
|
||||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const userStore = useUserStore();
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: '',
|
||||
@@ -98,6 +100,9 @@
|
||||
*/
|
||||
function add() {
|
||||
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) {
|
||||
isUpdate.value = true;
|
||||
}
|
||||
if (!isUpdate.value) {
|
||||
await applyCurrentUserFeedbackInfo();
|
||||
}
|
||||
|
||||
//循环数据
|
||||
for (let data in model) {
|
||||
|
||||
Reference in New Issue
Block a user