|
|
@@ -10,31 +10,32 @@
|
|
|
</template>
|
|
|
</ProTable>
|
|
|
|
|
|
- <UserDialog ref="userDialogRef" :law-firm-options="lawFirmOptions" @success="refreshTable" />
|
|
|
+ <UserDialog
|
|
|
+ ref="userDialogRef"
|
|
|
+ :law-firm-options="lawFirmOptions"
|
|
|
+ :law-firm-loading="lawFirmLoading"
|
|
|
+ :fetch-law-firms="fetchLawFirmOptions"
|
|
|
+ @success="refreshTable"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, reactive, onMounted, computed } from "vue";
|
|
|
+import { ref, reactive, onMounted } from "vue";
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
import ProTable from "@/components/ProTable/index.vue";
|
|
|
import type { ProTableInstance, ColumnProps } from "@/components/ProTable/interface";
|
|
|
import type { User } from "@/api/interface";
|
|
|
import { getUserList, addUser, editUser, deleteUser } from "@/api/modules/user";
|
|
|
-import { getLawFirmPage } from "@/api/modules/lawyer";
|
|
|
+import { getSelectList } from "@/api/modules/lawyer";
|
|
|
import { CirclePlus, Delete, EditPen } from "@element-plus/icons-vue";
|
|
|
import UserDialog from "./components/UserDialog.vue";
|
|
|
|
|
|
const proTable = ref<ProTableInstance>();
|
|
|
const userDialogRef = ref<InstanceType<typeof UserDialog>>();
|
|
|
const lawFirmOptions = ref<{ label: string; value: string | number }[]>([]);
|
|
|
-const lawFirmMap = computed<Record<string, string>>(() => {
|
|
|
- const map: Record<string, string> = {};
|
|
|
- lawFirmOptions.value.forEach(item => {
|
|
|
- map[String(item.value)] = item.label;
|
|
|
- });
|
|
|
- return map;
|
|
|
-});
|
|
|
+const lawFirmLoading = ref(false);
|
|
|
+const lawFirmMap = ref<Record<string, string>>({});
|
|
|
type UserRow = Partial<User.ResUserList> & { userName?: string };
|
|
|
|
|
|
const statusOptions = [
|
|
|
@@ -136,17 +137,27 @@ const handleDelete = (row: UserRow) => {
|
|
|
.catch(() => {});
|
|
|
};
|
|
|
|
|
|
-const fetchLawFirmOptions = async () => {
|
|
|
+const fetchLawFirmOptions = async (keyword = "") => {
|
|
|
+ lawFirmLoading.value = true;
|
|
|
try {
|
|
|
- const res: any = await getLawFirmPage({ page: 1, size: 999 });
|
|
|
- const list = res?.records || res?.data?.records || res?.data?.list || [];
|
|
|
+ const res: any = await getSelectList({ firmName: keyword });
|
|
|
+ const list = res?.data || [];
|
|
|
lawFirmOptions.value = list.map((item: any) => ({
|
|
|
label: item.firmName,
|
|
|
value: item.id
|
|
|
}));
|
|
|
+ if (list.length) {
|
|
|
+ const map = { ...lawFirmMap.value };
|
|
|
+ list.forEach((item: any) => {
|
|
|
+ map[String(item.id)] = item.firmName;
|
|
|
+ });
|
|
|
+ lawFirmMap.value = map;
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
console.error("获取律所列表失败", error);
|
|
|
lawFirmOptions.value = [];
|
|
|
+ } finally {
|
|
|
+ lawFirmLoading.value = false;
|
|
|
}
|
|
|
};
|
|
|
|