|
|
@@ -51,7 +51,7 @@
|
|
|
<EmployeeSelector
|
|
|
v-model:visible="showEmployeeSelector"
|
|
|
:selected-ids="selectedEmployeeIds"
|
|
|
- :enterprise-id="props.enterpriseId || ''"
|
|
|
+ :enterprise-id="getEnterpriseId() || ''"
|
|
|
@confirm="handleEmployeeConfirm"
|
|
|
/>
|
|
|
</el-dialog>
|
|
|
@@ -67,6 +67,7 @@ import EmployeeAPI from "@/api/module_payment/employee";
|
|
|
import EmployeeSelector from "./EmployeeSelector.vue";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import { ref, watch, computed } from "vue";
|
|
|
+import { useEnterpriseStore } from "@/store/modules/enterprise.store";
|
|
|
|
|
|
interface Props {
|
|
|
modelValue: boolean;
|
|
|
@@ -97,6 +98,10 @@ const formData = ref({
|
|
|
});
|
|
|
const selectedEmployeeIds = ref<string[]>([]);
|
|
|
|
|
|
+function getEnterpriseId(): string | undefined {
|
|
|
+ return props.enterpriseId || useEnterpriseStore().getCurrentEnterprise?.enterprise_id;
|
|
|
+}
|
|
|
+
|
|
|
watch(
|
|
|
() => props.modelValue,
|
|
|
async (val) => {
|
|
|
@@ -107,9 +112,10 @@ watch(
|
|
|
);
|
|
|
|
|
|
async function loadDepartments() {
|
|
|
- if (!props.enterpriseId) return;
|
|
|
+ const eid = getEnterpriseId();
|
|
|
+ if (!eid) return;
|
|
|
try {
|
|
|
- const res = await DepartmentAPI.listDepartment({ enterprise_id: props.enterpriseId, page_no: 1, page_size: 200 });
|
|
|
+ const res = await DepartmentAPI.listDepartment({ enterprise_id: eid, page_no: 1, page_size: 200 });
|
|
|
const items = res?.data?.data?.items || [];
|
|
|
departmentOptions.value = items.map((d: any) => ({
|
|
|
value: d.department_id,
|
|
|
@@ -121,9 +127,10 @@ async function loadDepartments() {
|
|
|
}
|
|
|
|
|
|
async function loadEmployees() {
|
|
|
- if (!props.enterpriseId) return;
|
|
|
+ const eid = getEnterpriseId();
|
|
|
+ if (!eid) return;
|
|
|
try {
|
|
|
- const res = await EmployeeAPI.listEmployee({ enterprise_id: props.enterpriseId, page_no: 1, page_size: 500 });
|
|
|
+ const res = await EmployeeAPI.listEmployee({ enterprise_id: eid, page_no: 1, page_size: 500 });
|
|
|
const items = res?.data?.data?.items || [];
|
|
|
const map: Record<string, string> = {};
|
|
|
for (const emp of items) {
|
|
|
@@ -140,8 +147,9 @@ async function loadEmployees() {
|
|
|
async function fetchScope() {
|
|
|
if (!props.institutionId) return;
|
|
|
try {
|
|
|
+ const eid = getEnterpriseId();
|
|
|
const res = await InstitutionAPI.listScope(props.institutionId, {
|
|
|
- enterprise_id: props.enterpriseId,
|
|
|
+ enterprise_id: eid,
|
|
|
});
|
|
|
const data = res.data.data;
|
|
|
if (data) {
|