部门管理增加省、市、区选择
This commit is contained in:
parent
53b7241cfb
commit
345b51130f
|
@ -138,8 +138,10 @@
|
|||
<a-col :span="selectedScreenSpan">
|
||||
<div style="height: 31px;margin-left: 4px;">
|
||||
<a-tag color="#2db7f5">
|
||||
已选择<span style="font-size: 13px;font-weight: bold;">{{ ' ' +
|
||||
Array.from(selectedItems.values()).length + ' ' }}</span>条
|
||||
已选择
|
||||
<span style="font-size: 13px;font-weight: bold;">
|
||||
{{ ' ' + selectedSize + ' ' }}
|
||||
</span>条
|
||||
</a-tag>
|
||||
</div>
|
||||
<a-card size="small" :bordered="false" class="selected-list-container">
|
||||
|
@ -207,17 +209,18 @@
|
|||
<script lang="ts" name="synchronization-directive" setup>
|
||||
import { ref, onMounted, computed, onBeforeMount, reactive } from 'vue';
|
||||
import { initDictOptions } from '/@/utils/dict';
|
||||
import { list, asyncFunc } from '@/views/services/serviceDirective/ConfigServiceDirective.api';
|
||||
|
||||
import { queryDepartTreeSync } from '/@/api/common/api';
|
||||
import { Empty } from 'ant-design-vue';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
import AsyncListComponent from '@/components/dataAsync/AsyncMainList.vue'
|
||||
import { number } from 'vue-types';
|
||||
|
||||
const props = defineProps({
|
||||
// showJMCom: { type: Boolean, default: false },
|
||||
selectedSize: 0
|
||||
});
|
||||
const emit = defineEmits(['changeShowJMCom', 'viewTypeChanged','sourceOrgCodeChanged']);
|
||||
const emit = defineEmits(['changeShowJMCom', 'viewTypeChanged', 'sourceOrgCodeChanged', 'orgChanged']);
|
||||
|
||||
interface OrganizationData {
|
||||
id?: string;
|
||||
|
@ -234,7 +237,7 @@ interface OrganizationData {
|
|||
|
||||
onBeforeMount(async () => {
|
||||
const dictData = await initDictOptions('org_code')
|
||||
emit('sourceOrgCodeChanged',dictData.filter(d => d.text == 'shi_yan_tian')[0].value)
|
||||
emit('sourceOrgCodeChanged', dictData.filter(d => d.text == 'shi_yan_tian')[0].value)
|
||||
emit('changeShowJMCom', true)
|
||||
})
|
||||
const initialDataIds = ref<Array<string | number>>([]);
|
||||
|
@ -300,45 +303,10 @@ const handleOrgSelected = async (org) => {
|
|||
};
|
||||
|
||||
const loadOrgData = async (org) => {
|
||||
try {
|
||||
// 清空当前选择
|
||||
selectedItems.value.clear();
|
||||
// 清空初始化数据
|
||||
initialDataIds.value = [];
|
||||
// 更新机构数据
|
||||
orgData.value = org;
|
||||
|
||||
// 加载新机构数据
|
||||
const res = await list({ dataSourceCode: org.orgCode, pageNo: 1, pageSize: -1 });
|
||||
|
||||
// 更新机构数据
|
||||
orgData.value = org;
|
||||
|
||||
// 如果有数据,更新右侧列表
|
||||
if (res.records && res.records.length > 0) {
|
||||
const newRecords = res.records;
|
||||
newRecords.forEach(record => {
|
||||
selectedItems.value.set(record.id, record);
|
||||
if (!orgData.value?.operationStartTime || new Date() >= new Date(orgData.value?.operationStartTime)) {
|
||||
initialDataIds.value.push(record.id);
|
||||
}
|
||||
});
|
||||
|
||||
// 更新左侧列表的选中状态
|
||||
listComRef.value?.updateSelection?.(newRecords);
|
||||
} else {
|
||||
// 没有数据时也确保清空
|
||||
selectedItems.value.clear();
|
||||
listComRef.value?.updateSelection?.([]);
|
||||
}
|
||||
|
||||
// 切换视图
|
||||
orgSelectedCon.value = false;
|
||||
} catch (err) {
|
||||
console.error('机构数据查询失败:', err);
|
||||
createMessage.error('机构数据查询失败');
|
||||
// 失败时也确保清空状态
|
||||
selectedItems.value.clear();
|
||||
listComRef.value?.updateSelection?.([]);
|
||||
}
|
||||
emit('orgChanged', org)
|
||||
};
|
||||
|
||||
|
||||
|
@ -346,6 +314,10 @@ const handleResetOrg = () => {
|
|||
orgSelectedCon.value = true
|
||||
}
|
||||
|
||||
const resetOrgSelectedCon = (v_) => {
|
||||
orgSelectedCon.value = v_
|
||||
}
|
||||
|
||||
//数据同步
|
||||
const handleAsync = () => {
|
||||
Modal.confirm({
|
||||
|
@ -509,6 +481,8 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
defineExpose({
|
||||
orgData,
|
||||
resetOrgSelectedCon
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<SyncComponent ref="syncComRef" @changeShowJMCom="changeShowJMCom" @sourceOrgCodeChanged="sourceOrgCodeChanged"
|
||||
@viewTypeChanged="viewTypeChanged">
|
||||
<SyncComponent ref="syncComRef" :selectedSize="Array.from(selectedItems.values()).length"
|
||||
@changeShowJMCom="changeShowJMCom" @sourceOrgCodeChanged="sourceOrgCodeChanged"
|
||||
@viewTypeChanged="viewTypeChanged" @orgChanged="orgChanged">
|
||||
<!-- 表单 -->
|
||||
<template #searchFormSlot>
|
||||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol"
|
||||
|
@ -143,85 +144,26 @@
|
|||
</template>
|
||||
|
||||
<script setup name="synchronization-directive2" lang="ts">
|
||||
// ↓↓↓↓↓ 组件自带
|
||||
import { ref, reactive } from 'vue'
|
||||
import SyncComponent from '/@/components/Sync/SyncComponent.vue'
|
||||
import ConfigServiceDirectiveList from '@/views/services/serviceDirective/ConfigServiceDirectiveList.vue'
|
||||
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils'
|
||||
import JInput from "/@/components/Form/src/jeecg/components/JInput.vue";
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
// ↑↑↑↑↑ 组件自带
|
||||
// ↓↓↓↓↓ 服务指令用
|
||||
import { list, asyncFunc } from '@/views/services/serviceDirective/ConfigServiceDirective.api';
|
||||
import ConfigServiceDirectiveList from '@/views/services/serviceDirective/ConfigServiceDirectiveList.vue'
|
||||
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils'
|
||||
import { selectedColumns } from './org.data';
|
||||
// ↑↑↑↑↑ 服务指令用
|
||||
|
||||
// 表格列定义
|
||||
const selectedColumns = [
|
||||
{
|
||||
title: '服务指令',
|
||||
dataIndex: 'directiveName',
|
||||
key: 'directiveName',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '服务类别',
|
||||
dataIndex: 'categoryName',
|
||||
key: 'categoryName',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '服务类型',
|
||||
dataIndex: 'typeName',
|
||||
key: 'typeName',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '分类标签',
|
||||
dataIndex: 'instructionTagName',
|
||||
key: 'instructionTagName',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '体型标签',
|
||||
dataIndex: 'bodyTagList',
|
||||
key: 'bodyTagList',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '情绪标签',
|
||||
dataIndex: 'emotionTagList',
|
||||
key: 'emotionTagList',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '预览图',
|
||||
dataIndex: 'previewFile',
|
||||
key: 'previewFile',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '即时图',
|
||||
dataIndex: 'immediateFile',
|
||||
key: 'immediateFile',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '音频',
|
||||
dataIndex: 'mp3File',
|
||||
key: 'mp3File',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '视频',
|
||||
dataIndex: 'mp4File',
|
||||
key: 'mp4File',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
width: 80,
|
||||
fixed: 'right'
|
||||
}
|
||||
]
|
||||
|
||||
// >>>>>>>>>>>>>组件:无需处理代码
|
||||
const { createMessage } = useMessage();
|
||||
const syncComRef = ref(null)
|
||||
const sourceOrgCode = ref('')
|
||||
const showJMCom = ref(false)
|
||||
const labelCol = reactive({
|
||||
xs: 24,
|
||||
sm: 4,
|
||||
|
@ -232,13 +174,6 @@ const wrapperCol = reactive({
|
|||
xs: 24,
|
||||
sm: 20,
|
||||
});
|
||||
const sourceOrgCode = ref('')
|
||||
const syncComRef = ref(null)
|
||||
const listComRef = ref();
|
||||
const selectedItems = ref(new Map<string | number, any>());
|
||||
const queryParam = ref({ viewType: 'all' })//源数据查询参数
|
||||
const initialDataIds = ref<string[]>([]);
|
||||
const showJMCom = ref(false)
|
||||
|
||||
/**
|
||||
* 获取到了试验田的机构编码
|
||||
|
@ -255,19 +190,59 @@ const sourceOrgCodeChanged = (v_) => {
|
|||
const changeShowJMCom = (v_) => {
|
||||
showJMCom.value = v_
|
||||
}
|
||||
|
||||
// <<<<<<<<<<<<<组件:无需处理代码
|
||||
/**
|
||||
* 源数据的全部、已选择、未选择变更时触发
|
||||
* @param v_ all、selected、unselected
|
||||
* 机构变更
|
||||
*/
|
||||
const viewTypeChanged = (v_) => {
|
||||
queryParam.value.viewType = v_
|
||||
//组件内部监听了queryParam值的变化,自动刷新
|
||||
const orgChanged = async (org) => {
|
||||
// 清空当前选择
|
||||
selectedItems.value.clear();
|
||||
// 清空初始化数据
|
||||
initialDataIds.value = [];
|
||||
try {
|
||||
// 加载新机构数据
|
||||
const res = await list({ dataSourceCode: org.orgCode, pageNo: 1, pageSize: -1 });
|
||||
// 如果有数据,更新右侧列表
|
||||
if (res.records && res.records.length > 0) {
|
||||
const newRecords = res.records;
|
||||
newRecords.forEach(record => {
|
||||
selectedItems.value.set(record.id, record);
|
||||
if (!syncComRef.value.orgData.value?.operationStartTime || new Date() >= new Date(syncComRef.value.orgData.value?.operationStartTime)) {
|
||||
initialDataIds.value.push(record.id);
|
||||
}
|
||||
});
|
||||
|
||||
// 更新左侧列表的选中状态
|
||||
listComRef.value?.updateSelection?.(newRecords);
|
||||
} else {
|
||||
// 没有数据时也确保清空
|
||||
selectedItems.value.clear();
|
||||
listComRef.value?.updateSelection?.([]);
|
||||
}
|
||||
|
||||
// 切换视图
|
||||
syncComRef.value.resetOrgSelectedCon(false);
|
||||
|
||||
console.log("🌊 ~ orgChanged ~ selectedItems.value:", selectedItems.value)
|
||||
} catch (err) {
|
||||
console.error('机构数据查询失败:', err);
|
||||
createMessage.error('机构数据查询失败');
|
||||
// 失败时也确保清空状态
|
||||
selectedItems.value.clear();
|
||||
listComRef.value?.updateSelection?.([]);
|
||||
}
|
||||
}
|
||||
// >>>>>>>>>>>>>组件:需要处理代码
|
||||
// <<<<<<<<<<<<<组件:需要处理代码
|
||||
|
||||
|
||||
// >>>>>>>>>>>>>非组件代码
|
||||
const listComRef = ref();
|
||||
const selectedItems = ref(new Map<string | number, any>());
|
||||
const queryParam = ref({ viewType: 'all' })//源数据查询参数
|
||||
const initialDataIds = ref<string[]>([]);
|
||||
const showVideoModal = ref(false);
|
||||
const videoUrl = ref('');
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
|
@ -283,6 +258,14 @@ function searchReset() {
|
|||
listComRef.value?.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 源数据的全部、已选择、未选择变更时触发
|
||||
* @param v_ all、selected、unselected
|
||||
*/
|
||||
const viewTypeChanged = (v_) => {
|
||||
queryParam.value.viewType = v_
|
||||
//组件内部监听了queryParam值的变化,自动刷新
|
||||
}
|
||||
const handleSelectChange = (items: Map<string | number, any>) => {
|
||||
selectedItems.value = new Map(items);
|
||||
};
|
||||
|
@ -301,6 +284,7 @@ const closeVideoModal = () => {
|
|||
showVideoModal.value = false;
|
||||
videoUrl.value = '';
|
||||
};
|
||||
// <<<<<<<<<<<<<非组件代码
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
@ -65,7 +65,7 @@ export const saveOrUpdateDict = (params, isUpdate) => {
|
|||
* 查询全部树形节点数据
|
||||
* @param params
|
||||
*/
|
||||
export const loadTreeData = (params) => defHttp.get({ url: Api.loadTreeData, params });
|
||||
export const loadTreeData = (params) => defHttp.get({ url: Api.loadTreeData,timeout:100*1000, params });
|
||||
/**
|
||||
* 查询子节点数据
|
||||
* @param params
|
||||
|
|
|
@ -64,4 +64,10 @@ export const formSchema: FormSchema[] = [
|
|||
required: true,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '编码(非必要无需填写)',
|
||||
field: 'code',
|
||||
required: false,
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose width="550px" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose width="50vw" :title="getTitle" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
@ -21,11 +21,11 @@
|
|||
showActionButtonGroup: false,
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 4 },
|
||||
sm: { span: 5 },
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 18 },
|
||||
sm: { span: 15 },
|
||||
},
|
||||
});
|
||||
//表单赋值
|
||||
|
|
|
@ -147,6 +147,9 @@
|
|||
* 成功回调
|
||||
*/
|
||||
async function handleSuccess({ isUpdate,isSubAdd, values, expandedArr }) {
|
||||
reload();
|
||||
return
|
||||
//几百条数据:直接重新加载比框架写的代码要加载快得多 框架设计师不知道在寻思鸡毛🤡 新增一条数据几百个请求处理 处理半天处理不完
|
||||
if (isUpdate) {
|
||||
//编辑回调
|
||||
updateTableDataRecord(values.id, values);
|
||||
|
|
|
@ -1,96 +1,142 @@
|
|||
<template>
|
||||
<BasicModal :title="title" :width="800" v-bind="$attrs" @ok="handleOk" @register="registerModal">
|
||||
<BasicForm @register="registerForm" />
|
||||
<BasicForm @register="registerForm">
|
||||
<!-- 省份 -->
|
||||
<template #province="{ model, field }">
|
||||
<j-dict-select-tag @change="provinceChanged(model)" v-model:value="model[field]"
|
||||
:dictCode="getProvinceDictCode()" placeholder="请选择所在省份" :disabled="model.orgCategory != '1'" />
|
||||
</template>
|
||||
<!-- 城市 -->
|
||||
<template #city="{ model, field }">
|
||||
<j-dict-select-tag @change="cityChanged(model)" v-model:value="model[field]" :dictCode="getCityDictCode(model)"
|
||||
placeholder="请选择所在城市" :disabled="model.orgCategory != '1' && !model.province" />
|
||||
</template>
|
||||
<!-- 区县 -->
|
||||
<template #district="{ model, field }">
|
||||
<j-dict-select-tag v-model:value="model[field]" :dictCode="getDistrictDictCode(model)" placeholder="请选择所在区县"
|
||||
:disabled="model.orgCategory != '1' && (!model.province || !model.city)" />
|
||||
</template>
|
||||
</BasicForm>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watch, computed, inject, ref, unref, onMounted } from 'vue';
|
||||
import { watch, computed, inject, ref, unref, onMounted } from 'vue';
|
||||
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
|
||||
import { saveOrUpdateDepart } from '../depart.api';
|
||||
import { useBasicFormSchema, orgCategoryOptions } from '../depart.data';
|
||||
import { saveOrUpdateDepart } from '../depart.api';
|
||||
import { useBasicFormSchema, orgCategoryOptions } from '../depart.data';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
const props = defineProps({
|
||||
rootTreeData: { type: Array, default: () => [] },
|
||||
});
|
||||
const prefixCls = inject('prefixCls');
|
||||
// 当前是否是更新模式
|
||||
const isUpdate = ref<boolean>(false);
|
||||
// 当前的弹窗数据
|
||||
const model = ref<object>({});
|
||||
const title = computed(() => (isUpdate.value ? '编辑' : '新增'));
|
||||
|
||||
//注册表单
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||
schemas: useBasicFormSchema().basicFormSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
const props = defineProps({
|
||||
rootTreeData: { type: Array, default: () => [] },
|
||||
});
|
||||
const prefixCls = inject('prefixCls');
|
||||
// 当前是否是更新模式
|
||||
const isUpdate = ref<boolean>(false);
|
||||
// 当前的弹窗数据
|
||||
const model = ref<object>({});
|
||||
const title = computed(() => (isUpdate.value ? '编辑' : '新增'));
|
||||
|
||||
// 注册弹窗
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
isUpdate.value = unref(data?.isUpdate);
|
||||
// 当前是否为添加子级
|
||||
let isChild = unref(data?.isChild);
|
||||
let categoryOptions = isChild ? orgCategoryOptions.child : orgCategoryOptions.root;
|
||||
// 隐藏不需要展示的字段
|
||||
updateSchema([
|
||||
{
|
||||
field: 'parentId',
|
||||
show: isChild,
|
||||
componentProps: {
|
||||
// 如果是添加子部门,就禁用该字段
|
||||
disabled: isChild,
|
||||
treeData: props.rootTreeData,
|
||||
},
|
||||
//注册表单
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||
schemas: useBasicFormSchema().basicFormSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
|
||||
// 注册弹窗
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
isUpdate.value = unref(data?.isUpdate);
|
||||
// 当前是否为添加子级
|
||||
let isChild = unref(data?.isChild);
|
||||
let categoryOptions = isChild ? orgCategoryOptions.child : orgCategoryOptions.root;
|
||||
// 隐藏不需要展示的字段
|
||||
updateSchema([
|
||||
{
|
||||
field: 'parentId',
|
||||
show: isChild,
|
||||
componentProps: {
|
||||
// 如果是添加子部门,就禁用该字段
|
||||
disabled: isChild,
|
||||
treeData: props.rootTreeData,
|
||||
},
|
||||
{
|
||||
field: 'platType',
|
||||
show: !isChild
|
||||
},
|
||||
{
|
||||
field: 'orgCode',
|
||||
show: false,
|
||||
},
|
||||
{
|
||||
field: 'orgCategory',
|
||||
componentProps: { options: categoryOptions },
|
||||
},
|
||||
]);
|
||||
},
|
||||
{
|
||||
field: 'platType',
|
||||
show: !isChild
|
||||
},
|
||||
{
|
||||
field: 'orgCode',
|
||||
show: false,
|
||||
},
|
||||
{
|
||||
field: 'orgCategory',
|
||||
componentProps: { options: categoryOptions },
|
||||
},
|
||||
]);
|
||||
|
||||
let record = unref(data?.record);
|
||||
if (typeof record !== 'object') {
|
||||
record = {};
|
||||
}
|
||||
// 赋默认值
|
||||
record = Object.assign(
|
||||
{
|
||||
departOrder: 0,
|
||||
orgCategory: categoryOptions[0].value,
|
||||
},
|
||||
record
|
||||
);
|
||||
model.value = record;
|
||||
await setFieldsValue({ ...record });
|
||||
});
|
||||
|
||||
// 提交事件
|
||||
async function handleOk() {
|
||||
try {
|
||||
setModalProps({ confirmLoading: true });
|
||||
let values = await validate();
|
||||
//提交表单
|
||||
await saveOrUpdateDepart(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeModal();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
let record = unref(data?.record);
|
||||
if (typeof record !== 'object') {
|
||||
record = {};
|
||||
}
|
||||
// 赋默认值
|
||||
record = Object.assign(
|
||||
{
|
||||
departOrder: 0,
|
||||
orgCategory: categoryOptions[0].value,
|
||||
},
|
||||
record
|
||||
);
|
||||
model.value = record;
|
||||
await setFieldsValue({ ...record });
|
||||
});
|
||||
|
||||
// 提交事件
|
||||
async function handleOk() {
|
||||
try {
|
||||
setModalProps({ confirmLoading: true });
|
||||
let values = await validate();
|
||||
//提交表单
|
||||
await saveOrUpdateDepart(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeModal();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 省份字典
|
||||
*/
|
||||
function getProvinceDictCode() {
|
||||
return 'sys_category,name,id,pid = \'xzqhdm\' order by code asc'
|
||||
}
|
||||
function provinceChanged(model) {
|
||||
model.city = null
|
||||
model.district = null
|
||||
}
|
||||
/**
|
||||
* 城市字典
|
||||
* @param v_
|
||||
*/
|
||||
function getCityDictCode(v_) {
|
||||
return 'sys_category,name,id,pid = \'' + v_.province + '\' order by code asc'
|
||||
}
|
||||
function cityChanged(model) {
|
||||
model.district = null
|
||||
}
|
||||
/**
|
||||
* 区县字典
|
||||
* @param v_
|
||||
*/
|
||||
function getDistrictDictCode(v_) {
|
||||
return 'sys_category,name,id,pid = \'' + v_.city + '\' order by code asc'
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
<template>
|
||||
<a-spin :spinning="loading">
|
||||
<BasicForm @register="registerForm" />
|
||||
<BasicForm @register="registerForm">
|
||||
<!-- 省份 -->
|
||||
<template #province="{ model, field }">
|
||||
<j-dict-select-tag @change="provinceChanged(model)" v-model:value="model[field]"
|
||||
:dictCode="getProvinceDictCode()" placeholder="请选择所在省份" :disabled="model.orgCategory != '1'" />
|
||||
</template>
|
||||
<!-- 城市 -->
|
||||
<template #city="{ model, field }">
|
||||
<j-dict-select-tag @change="cityChanged(model)" v-model:value="model[field]" :dictCode="getCityDictCode(model)"
|
||||
placeholder="请选择所在城市" :disabled="model.orgCategory != '1' && !model.province" />
|
||||
</template>
|
||||
<!-- 区县 -->
|
||||
<template #district="{ model, field }">
|
||||
<j-dict-select-tag v-model:value="model[field]" :dictCode="getDistrictDictCode(model)" placeholder="请选择所在区县"
|
||||
:disabled="model.orgCategory != '1' && (!model.province || !model.city)" />
|
||||
</template>
|
||||
</BasicForm>
|
||||
<div class="j-box-bottom-button offset-20" style="margin-top: 30px">
|
||||
<div class="j-box-bottom-button-float" :class="[`${prefixCls}`]">
|
||||
<a-button preIcon="ant-design:sync-outlined" @click="onReset">重置</a-button>
|
||||
|
@ -11,118 +27,148 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watch, computed, inject, ref, unref, onMounted } from 'vue';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { saveOrUpdateDepart } from '../depart.api';
|
||||
import { useBasicFormSchema, orgCategoryOptions } from '../depart.data';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { watch, computed, inject, ref, unref, onMounted } from 'vue';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { saveOrUpdateDepart } from '../depart.api';
|
||||
import { useBasicFormSchema, orgCategoryOptions } from '../depart.data';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
|
||||
const { prefixCls } = useDesign('j-depart-form-content');
|
||||
const { prefixCls } = useDesign('j-depart-form-content');
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const props = defineProps({
|
||||
data: { type: Object, default: () => ({}) },
|
||||
rootTreeData: { type: Array, default: () => [] },
|
||||
});
|
||||
const loading = ref<boolean>(false);
|
||||
// 当前是否是更新模式
|
||||
const isUpdate = ref<boolean>(true);
|
||||
// 当前的弹窗数据
|
||||
const model = ref<object>({});
|
||||
const emit = defineEmits(['success']);
|
||||
const props = defineProps({
|
||||
data: { type: Object, default: () => ({}) },
|
||||
rootTreeData: { type: Array, default: () => [] },
|
||||
});
|
||||
const loading = ref<boolean>(false);
|
||||
// 当前是否是更新模式
|
||||
const isUpdate = ref<boolean>(true);
|
||||
// 当前的弹窗数据
|
||||
const model = ref<object>({});
|
||||
|
||||
//注册表单
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||
schemas: useBasicFormSchema().basicFormSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
//注册表单
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||
schemas: useBasicFormSchema().basicFormSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
|
||||
const categoryOptions = computed(() => {
|
||||
if (!!props?.data?.parentId) {
|
||||
return orgCategoryOptions.child;
|
||||
} else {
|
||||
return orgCategoryOptions.root;
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
// 禁用字段
|
||||
updateSchema([
|
||||
{ field: 'parentId', componentProps: { disabled: true } },
|
||||
{ field: 'orgCode', componentProps: { disabled: true } },
|
||||
]);
|
||||
// data 变化,重填表单
|
||||
watch(
|
||||
() => props.data,
|
||||
async () => {
|
||||
let record = unref(props.data);
|
||||
if (typeof record !== 'object') {
|
||||
record = {};
|
||||
}
|
||||
model.value = record;
|
||||
await resetFields();
|
||||
await setFieldsValue({ ...record });
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
// 更新 父部门 选项
|
||||
watch(
|
||||
() => props.rootTreeData,
|
||||
async () => {
|
||||
updateSchema([
|
||||
{
|
||||
field: 'parentId',
|
||||
componentProps: { treeData: props.rootTreeData },
|
||||
},
|
||||
]);
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
// 监听并更改 orgCategory options
|
||||
watch(
|
||||
categoryOptions,
|
||||
async () => {
|
||||
updateSchema([
|
||||
{
|
||||
field: 'orgCategory',
|
||||
componentProps: { options: categoryOptions.value },
|
||||
},
|
||||
]);
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
});
|
||||
|
||||
// 重置表单
|
||||
async function onReset() {
|
||||
await resetFields();
|
||||
await setFieldsValue({ ...model.value });
|
||||
const categoryOptions = computed(() => {
|
||||
if (!!props?.data?.parentId) {
|
||||
return orgCategoryOptions.child;
|
||||
} else {
|
||||
return orgCategoryOptions.root;
|
||||
}
|
||||
});
|
||||
|
||||
// 提交事件
|
||||
async function onSubmit() {
|
||||
try {
|
||||
loading.value = true;
|
||||
let values = await validate();
|
||||
values = Object.assign({}, model.value, values);
|
||||
//提交表单
|
||||
await saveOrUpdateDepart(values, isUpdate.value);
|
||||
//刷新列表
|
||||
emit('success');
|
||||
Object.assign(model.value, values);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
onMounted(() => {
|
||||
// 禁用字段
|
||||
updateSchema([
|
||||
{ field: 'parentId', componentProps: { disabled: true } },
|
||||
{ field: 'orgCode', componentProps: { disabled: true } },
|
||||
]);
|
||||
// data 变化,重填表单
|
||||
watch(
|
||||
() => props.data,
|
||||
async () => {
|
||||
let record = unref(props.data);
|
||||
if (typeof record !== 'object') {
|
||||
record = {};
|
||||
}
|
||||
model.value = record;
|
||||
await resetFields();
|
||||
await setFieldsValue({ ...record });
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
// 更新 父部门 选项
|
||||
watch(
|
||||
() => props.rootTreeData,
|
||||
async () => {
|
||||
updateSchema([
|
||||
{
|
||||
field: 'parentId',
|
||||
componentProps: { treeData: props.rootTreeData },
|
||||
},
|
||||
]);
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
// 监听并更改 orgCategory options
|
||||
watch(
|
||||
categoryOptions,
|
||||
async () => {
|
||||
updateSchema([
|
||||
{
|
||||
field: 'orgCategory',
|
||||
componentProps: { options: categoryOptions.value },
|
||||
},
|
||||
]);
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
});
|
||||
|
||||
// 重置表单
|
||||
async function onReset() {
|
||||
await resetFields();
|
||||
await setFieldsValue({ ...model.value });
|
||||
}
|
||||
|
||||
// 提交事件
|
||||
async function onSubmit() {
|
||||
try {
|
||||
loading.value = true;
|
||||
let values = await validate();
|
||||
values = Object.assign({}, model.value, values);
|
||||
//提交表单
|
||||
await saveOrUpdateDepart(values, isUpdate.value);
|
||||
//刷新列表
|
||||
emit('success');
|
||||
Object.assign(model.value, values);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 省份字典
|
||||
*/
|
||||
function getProvinceDictCode() {
|
||||
return 'sys_category,name,id,pid = \'xzqhdm\' order by code asc'
|
||||
}
|
||||
function provinceChanged(model) {
|
||||
model.city = null
|
||||
model.district = null
|
||||
}
|
||||
/**
|
||||
* 城市字典
|
||||
* @param v_
|
||||
*/
|
||||
function getCityDictCode(v_) {
|
||||
return 'sys_category,name,id,pid = \'' + v_.province + '\' order by code asc'
|
||||
}
|
||||
function cityChanged(model) {
|
||||
model.district = null
|
||||
}
|
||||
/**
|
||||
* 区县字典
|
||||
* @param v_
|
||||
*/
|
||||
function getDistrictDictCode(v_) {
|
||||
return 'sys_category,name,id,pid = \'' + v_.city + '\' order by code asc'
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
// update-begin-author:liusq date:20230625 for: [issues/563]暗色主题部分失效
|
||||
// update-begin-author:liusq date:20230625 for: [issues/563]暗色主题部分失效
|
||||
|
||||
@prefix-cls: ~'@{namespace}-j-depart-form-content';
|
||||
/*begin 兼容暗夜模式*/
|
||||
.@{prefix-cls} {
|
||||
background: @component-background;
|
||||
border-top: 1px solid @border-color-base;
|
||||
}
|
||||
/*end 兼容暗夜模式*/
|
||||
// update-end-author:liusq date:20230625 for: [issues/563]暗色主题部分失效
|
||||
</style>
|
||||
@prefix-cls: ~'@{namespace}-j-depart-form-content';
|
||||
|
||||
/*begin 兼容暗夜模式*/
|
||||
.@{prefix-cls} {
|
||||
background: @component-background;
|
||||
border-top: 1px solid @border-color-base;
|
||||
}
|
||||
|
||||
/*end 兼容暗夜模式*/
|
||||
// update-end-author:liusq date:20230625 for: [issues/563]暗色主题部分失效</style>
|
||||
|
|
|
@ -36,6 +36,24 @@ export function useBasicFormSchema() {
|
|||
component: 'RadioButtonGroup',
|
||||
componentProps: { options: [] },
|
||||
},
|
||||
{
|
||||
field: 'province',
|
||||
label: '省份',
|
||||
component: 'Input',
|
||||
slot: 'province',
|
||||
},
|
||||
{
|
||||
field: 'city',
|
||||
label: '城市',
|
||||
component: 'Input',
|
||||
slot: 'city',
|
||||
},
|
||||
{
|
||||
field: 'district',
|
||||
label: '区县',
|
||||
component: 'Input',
|
||||
slot: 'district',
|
||||
},
|
||||
{
|
||||
field: 'platType',
|
||||
label: '业务平台类型',
|
||||
|
@ -49,12 +67,6 @@ export function useBasicFormSchema() {
|
|||
message: '请选择平台类型'
|
||||
}]
|
||||
},
|
||||
{
|
||||
field: 'departOrder',
|
||||
label: '排序',
|
||||
component: 'InputNumber',
|
||||
componentProps: {},
|
||||
},
|
||||
{
|
||||
field: 'operationStartTime',
|
||||
label: '运营开始时间',
|
||||
|
@ -131,6 +143,12 @@ export function useBasicFormSchema() {
|
|||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'departOrder',
|
||||
label: '排序',
|
||||
component: 'InputNumber',
|
||||
componentProps: {},
|
||||
},
|
||||
{
|
||||
field: 'picUrl',
|
||||
label: '机构图片',
|
||||
|
|
Loading…
Reference in New Issue