签报接口
This commit is contained in:
@ -1,21 +1,29 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" width="65%" :title="getTitle" @ok="handleSubmit"
|
||||
@visible-change="handleVisibleChange" >
|
||||
<BasicTable @register="registerTable" class="deptListModal"></BasicTable>
|
||||
<div>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" width="70%" :title="getTitle" @ok="handleSubmit" @visible-change="handleVisibleChange" >
|
||||
<div style="display: flex;">
|
||||
|
||||
<div class="w-1/3 xl:w-1/3 overflow-hidden bg-white" :style="{ 'border-right': '1px solid #e5e7eb' }">
|
||||
<BasicTree :title="t('公司列表')" ref="asyncTreeRef" search toolbar :clickRowToExpand="true" expandOnSearch :treeData="treeData" :fieldNames="{ key: 'id', title: 'name' }" @select="handleSelect" />
|
||||
</div>
|
||||
<BasicTable @register="registerTable" class="deptListModal w-2/3 xl:w-2/3"></BasicTable>
|
||||
</div>
|
||||
</BasicModal>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, unref, nextTick } from 'vue';
|
||||
import { ref, computed, unref, nextTick, reactive } from 'vue';
|
||||
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { BasicTable, useTable, FormSchema, BasicColumn, TableAction } from '/@/components/Table';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { getDept, } from '/@/api/approve/Appro';
|
||||
import { getLngCustomerPage} from '/@/api/sales/Customer';
|
||||
import { BasicTree, TreeActionType, TreeItem } from '/@/components/Tree';
|
||||
import { getDeptByCompany, getAllCompany } from '/@/api/approve/Appro';
|
||||
|
||||
const { t } = useI18n();
|
||||
const treeData = ref<TreeItem[]>([]);
|
||||
const codeFormSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
@ -53,12 +61,13 @@
|
||||
const rowId = ref('');
|
||||
const selectedKeys = ref<string[]>([]);
|
||||
const selectedValues = ref([]);
|
||||
const companyInfo = ref({})
|
||||
const props = defineProps({
|
||||
selectType: { type: String, default: 'radio' },
|
||||
|
||||
});
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
|
||||
fetch()
|
||||
setModalProps({ confirmLoading: false });
|
||||
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
@ -66,7 +75,7 @@
|
||||
|
||||
const [registerTable, { getDataSource, setTableData, updateTableDataRecord, reload }] = useTable({
|
||||
title: t('部门列表'),
|
||||
api: getDept,
|
||||
api: getDeptByCompany,
|
||||
columns,
|
||||
|
||||
bordered: true,
|
||||
@ -77,21 +86,40 @@
|
||||
schemas: codeFormSchema,
|
||||
showResetButton: true,
|
||||
},
|
||||
showIndexColumn: false,
|
||||
immediate: false, // 设置为不立即调用
|
||||
beforeFetch: (params) => {
|
||||
console.log(params, 'params')
|
||||
return { ...params};
|
||||
return { ...params, companyId: companyInfo.value.id};
|
||||
},
|
||||
rowSelection: {
|
||||
type: props.selectType,
|
||||
onChange: onSelectChange
|
||||
},
|
||||
});
|
||||
|
||||
const handleSelect = (val) => {
|
||||
companyInfo.value = findNode(treeData.value, val[0])
|
||||
reload({ searchInfo: { companyId: val[0] } });
|
||||
|
||||
}
|
||||
const findNode = (data, key) => {
|
||||
for (const item of data) {
|
||||
if (item.id === key) {
|
||||
return item;
|
||||
}
|
||||
if (item.children) {
|
||||
const found = findNode(item.children, key);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
async function fetch() {
|
||||
treeData.value = (await getAllCompany()) as unknown as TreeItem[];
|
||||
}
|
||||
const handleVisibleChange = (visible: boolean) => {
|
||||
if (visible) {
|
||||
nextTick(() => {
|
||||
reload();
|
||||
// reload();
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -99,7 +127,7 @@
|
||||
selectedKeys.value = rowKeys;
|
||||
selectedValues.value = e
|
||||
}
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('部门列表') : t('')));
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? t('选择部门') : t('')));
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!selectedValues.value.length) {
|
||||
@ -110,15 +138,9 @@
|
||||
return
|
||||
}
|
||||
closeModal();
|
||||
emit('success', selectedValues.value);
|
||||
emit('success', selectedValues.value, companyInfo.value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<style >
|
||||
.deptListModal .basicCol{
|
||||
|
||||
@ -133,13 +133,6 @@
|
||||
closeModal();
|
||||
emit('success', selectedValues.value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<style >
|
||||
.deptUserModal .basicCol{
|
||||
|
||||
Reference in New Issue
Block a user