管道气线
This commit is contained in:
@ -35,7 +35,7 @@ export async function getTreeData(params: LngBRegionPageParams, mode: ErrorMessa
|
||||
/**
|
||||
* @description: 分节点查询LngBRegion树
|
||||
*/
|
||||
export async function getTreeChild(params: LngBRegionPageParams, mode: ErrorMessageMode = 'modal') {
|
||||
export async function getAreaList(params: LngBRegionPageParams, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.get<LngBRegionPageResult>(
|
||||
{
|
||||
url: Api.TreeChild,
|
||||
|
||||
@ -14,6 +14,7 @@ enum Api {
|
||||
Disable= '/mdm/pipelineGgasLine/disable',
|
||||
|
||||
DataLog = '/mdm/pipelineGgasLine/datalog',
|
||||
lNGStation = '/mdm/lNGStation/list'
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,3 +121,17 @@ export async function disableLngBPngLine(ids: string[], mode: ErrorMessageMode =
|
||||
},
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @description: 获取LNG气源地数据
|
||||
*/
|
||||
export async function getIngStation(params: LngBPngLinePageParams, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.get<boolean>(
|
||||
{
|
||||
url: Api.lNGStation,
|
||||
params
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -27,6 +27,7 @@ import SelectUserV2 from './components/SelectUserV2.vue';
|
||||
import SelectUserShowTree from './components/SelectUserShowTree.vue';
|
||||
import CommonInfo from './components/CommonInfo.vue';
|
||||
import SelectArea from './components/SelectArea.vue';
|
||||
import SelectAreaCascader from './components/SelectAreaCascader.vue';
|
||||
import AutoCodeRule from './components/AutoCodeRule.vue';
|
||||
import MoneyChineseInput from './components/MoneyChineseInput.vue';
|
||||
import Image from './components/Image.vue';
|
||||
@ -108,6 +109,7 @@ componentMap.set('User', SelectUserV2);
|
||||
componentMap.set('UserTree', SelectUserShowTree);
|
||||
componentMap.set('Info', CommonInfo);
|
||||
componentMap.set('Area', SelectArea);
|
||||
componentMap.set('AreaCascader', SelectAreaCascader);
|
||||
componentMap.set('SubForm', SubForm);
|
||||
componentMap.set('Button', Button);
|
||||
componentMap.set('SelectMap', SelectMap);
|
||||
|
||||
187
src/components/Form/src/components/SelectAreaCascader.vue
Normal file
187
src/components/Form/src/components/SelectAreaCascader.vue
Normal file
@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<Cascader v-model:value="emitData" :options="options" :load-data="loadData" change-on-select @change="handleChange" :displayRender="handleRenderDisplay">
|
||||
<template #suffixIcon v-if="loading">
|
||||
<LoadingOutlined spin />
|
||||
</template>
|
||||
<template #notFoundContent v-if="loading">
|
||||
<span>
|
||||
<LoadingOutlined spin class="mr-1" />
|
||||
{{ t('component.form.apiSelectNotFound') }}
|
||||
</span>
|
||||
</template>
|
||||
</Cascader>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, unref, watch } from 'vue';
|
||||
import { Cascader } from 'ant-design-vue';
|
||||
import { get, omit } from 'lodash-es';
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { getAreaList } from '/@/api/mdm/CountryRegion';
|
||||
|
||||
interface Option {
|
||||
value: string;
|
||||
label: string;
|
||||
loading?: boolean;
|
||||
isLeaf?: boolean;
|
||||
children?: Option[];
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
value: String,
|
||||
excludeType: String
|
||||
});
|
||||
|
||||
const emit = defineEmits(['change', 'defaultChange', 'update:value']);
|
||||
|
||||
const apiData = ref<any[]>([]);
|
||||
const options = ref<Option[]>([]);
|
||||
const loading = ref<boolean>(false);
|
||||
const emitData = ref<any[]>([]);
|
||||
const isChange = ref(false);
|
||||
const labelField = 'name';
|
||||
const valueField = 'id';
|
||||
const childrenField = 'children';
|
||||
const resultField = 'data';
|
||||
|
||||
const asyncFetchParamKey = 'pid';
|
||||
const { t } = useI18n();
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
async (val, oldVal) => {
|
||||
if (!val && !!oldVal && val !== oldVal) {
|
||||
//重置
|
||||
emitData.value = [];
|
||||
return;
|
||||
}
|
||||
//选择时不重复请求接口
|
||||
if (isChange.value) return;
|
||||
|
||||
if (val) {
|
||||
emitData.value = val.split(',');
|
||||
} else {
|
||||
emitData.value = [];
|
||||
}
|
||||
await initialFetch();
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
apiData,
|
||||
(data) => {
|
||||
options.value = generatorOptions(data);
|
||||
if (emitData.value.length > 1) {
|
||||
getParentNodes(emitData.value, options.value);
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
function generatorOptions(options: any[]): Option[] {
|
||||
return options.reduce((prev, next: Recordable) => {
|
||||
if (next) {
|
||||
const value = next[valueField];
|
||||
const item = {
|
||||
...omit(next, [labelField, valueField]),
|
||||
...next,
|
||||
label: next[labelField],
|
||||
value: `${value}`,
|
||||
isLeaf: !next.hasChild
|
||||
};
|
||||
const children = Reflect.get(next, childrenField);
|
||||
if (children) {
|
||||
Reflect.set(item, childrenField, generatorOptions(children));
|
||||
}
|
||||
prev.push(item);
|
||||
}
|
||||
return prev;
|
||||
}, [] as Option[]);
|
||||
}
|
||||
|
||||
async function initialFetch() {
|
||||
apiData.value = [];
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getAreaList({ pid: '', excludeType:props.excludeType });
|
||||
if (Array.isArray(res)) {
|
||||
apiData.value = res;
|
||||
return;
|
||||
}
|
||||
if (resultField) {
|
||||
apiData.value = get(res, resultField) || [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData(selectedOptions: Option[]) {
|
||||
const targetOption = selectedOptions[selectedOptions.length - 1];
|
||||
targetOption.loading = true;
|
||||
|
||||
try {
|
||||
const res = await getAreaList({
|
||||
[asyncFetchParamKey]: Reflect.get(targetOption, 'id'),
|
||||
excludeType:props.excludeType
|
||||
});
|
||||
|
||||
if (Array.isArray(res)) {
|
||||
const children = generatorOptions(res);
|
||||
targetOption.children = children;
|
||||
return;
|
||||
}
|
||||
if (resultField) {
|
||||
const children = generatorOptions(get(res, resultField) || []);
|
||||
targetOption.children = children;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
targetOption.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
//数据回显
|
||||
function getParentNodes(ids: any[], tree: any[]) {
|
||||
ids.forEach((id) => {
|
||||
tree.forEach(async (item: any) => {
|
||||
if (item.code === id) {
|
||||
item.children = [];
|
||||
const res = await getAreaList({ pid: item.id,excludeType:props.excludeType });
|
||||
item.children = res.map((child) => {
|
||||
return {
|
||||
...child,
|
||||
label: child.name,
|
||||
value: child.id,
|
||||
isLeaf: !child.hasChild
|
||||
};
|
||||
});
|
||||
getParentNodes(ids, item.children);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function handleChange(keys) {
|
||||
isChange.value = true;
|
||||
if (!keys) {
|
||||
emit('change', keys);
|
||||
return;
|
||||
}
|
||||
emit('change', keys.join(','));
|
||||
emit('update:value', keys?.join(','));
|
||||
emitData.value = props.value === undefined ? keys : emitData.value;
|
||||
}
|
||||
|
||||
function handleRenderDisplay({ labels, selectedOptions }) {
|
||||
if (unref(emitData).length === selectedOptions.length) {
|
||||
return labels.join(` / `);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -130,6 +130,7 @@ export type ComponentType =
|
||||
| 'UserTree'
|
||||
| 'Info'
|
||||
| 'Area'
|
||||
| 'AreaCascader'
|
||||
| 'SubForm'
|
||||
| 'DicSelect'
|
||||
| 'DbSelect'
|
||||
|
||||
@ -32,6 +32,7 @@ import SelectUser from './components/SelectUser.vue';
|
||||
import CommonInfo from './components/CommonInfo.vue';
|
||||
import SelectArea from './components/SelectArea.vue';
|
||||
// import SelectArea from './components/SelectArea.vue';
|
||||
import SelectAreaCascader from './components/SelectAreaCascader.vue';
|
||||
|
||||
import { BasicUpload } from '/@/components/Upload';
|
||||
import { StrengthMeter } from '/@/components/StrengthMeter';
|
||||
@ -69,7 +70,7 @@ componentMap.set('Dept', SelectDepartment);
|
||||
componentMap.set('User', SelectUser);
|
||||
componentMap.set('Info', CommonInfo);
|
||||
componentMap.set('Area', SelectArea);
|
||||
|
||||
componentMap.set('AreaCascader', SelectAreaCascader);
|
||||
componentMap.set('DatePicker', DatePicker);
|
||||
componentMap.set('MonthPicker', DatePicker.MonthPicker);
|
||||
componentMap.set('RangePicker', DatePicker.RangePicker);
|
||||
|
||||
@ -248,4 +248,5 @@ export type ComponentType =
|
||||
| 'User'
|
||||
| 'Info'
|
||||
| 'Area'
|
||||
| 'Text';
|
||||
| 'AreaCascader'
|
||||
| 'Text'
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
title: '表名',
|
||||
dataIndex: 'tableName',
|
||||
key: 'tableName',
|
||||
width: 100,
|
||||
width: 130,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
},
|
||||
@ -29,7 +29,7 @@
|
||||
title: '属性名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 100,
|
||||
width: 130,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
title: '操作类型',
|
||||
dataIndex: 'operationType',
|
||||
key: 'operationType',
|
||||
width: 80,
|
||||
width: 100,
|
||||
sorter: true,
|
||||
customRender: ({ record }) => {
|
||||
let text = record.operationType
|
||||
@ -52,7 +52,7 @@
|
||||
title: '原数据',
|
||||
dataIndex: 'oldValue',
|
||||
key: 'oldValue',
|
||||
width: 150,
|
||||
// width: 150,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
},
|
||||
@ -60,7 +60,7 @@
|
||||
title: '新数据',
|
||||
dataIndex: 'newValue',
|
||||
key: 'newValue',
|
||||
width: 150,
|
||||
// width: 150,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
},
|
||||
@ -75,7 +75,7 @@
|
||||
title: '操作IP',
|
||||
dataIndex: 'operationIp',
|
||||
key: 'operationIp',
|
||||
width: 150,
|
||||
width: 120,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
|
||||
@ -616,6 +616,7 @@ export function buildAppComponentType(type: string): AppComponentType {
|
||||
return AppComponentType.select;
|
||||
|
||||
case 'area':
|
||||
case 'areacascader':
|
||||
case 'cascader':
|
||||
return AppComponentType.cascader;
|
||||
|
||||
|
||||
@ -44,13 +44,6 @@
|
||||
let customFormEventConfigs=[];
|
||||
|
||||
onMounted(async () => {
|
||||
const treeData = await getTreeData({})
|
||||
formProps.schemas?.forEach(v => {
|
||||
if (v.field == 'regionCode') {
|
||||
v.componentProps.options = treeData
|
||||
}
|
||||
})
|
||||
console.log(formProps.schemas, 667)
|
||||
try {
|
||||
// 合并渲染覆盖配置中的字段配置、表单事件配置
|
||||
await mergeCustomFormRenderConfig();
|
||||
@ -125,7 +118,7 @@
|
||||
async function setFormDataFromId(rowId, skipUpdate) {
|
||||
try {
|
||||
let record = await getLngBBank(rowId);
|
||||
record = {...record, regionCode: (record.regionCode || []).split(',')}
|
||||
record = {...record}
|
||||
if (skipUpdate) {
|
||||
return record;
|
||||
}
|
||||
@ -158,7 +151,7 @@
|
||||
try {
|
||||
values[RowKey] = rowId;
|
||||
state.formModel = values;
|
||||
let saveVal = await updateLngBBank({...values, regionCode: (values.regionCode||[]).join(',')});
|
||||
let saveVal = await updateLngBBank({...values});
|
||||
await submitFormEvent(customFormEventConfigs, state.formModel,
|
||||
systemFormRef.value,
|
||||
formProps.schemas); //表单事件:提交表单
|
||||
@ -169,7 +162,7 @@
|
||||
async function add(values) {
|
||||
try {
|
||||
state.formModel = values;
|
||||
let saveVal = await addLngBBank({...values, regionCode: (values.regionCode||[]).join(',')});
|
||||
let saveVal = await addLngBBank({...values});
|
||||
await submitFormEvent(customFormEventConfigs, state.formModel,
|
||||
systemFormRef.value,
|
||||
formProps.schemas); //表单事件:提交表单
|
||||
|
||||
@ -329,57 +329,32 @@ export const formProps: FormProps = {
|
||||
},
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
key: '1485b829c80a493bb55f37d1c839ccc9',
|
||||
field: 'regionCode',
|
||||
label: '所属国家/地区',
|
||||
type: 'cascader',
|
||||
component: 'Cascader',
|
||||
type: 'areacascader',
|
||||
component: 'AreaCascader',
|
||||
colProps: { span: 8 },
|
||||
defaultValue: [],
|
||||
componentProps: {
|
||||
options: [
|
||||
// {
|
||||
// value: 'zhejiang',
|
||||
// label: '浙江省',
|
||||
// children: [
|
||||
// {
|
||||
// value: 'hangzhou',
|
||||
// label: '杭州市',
|
||||
// children: [
|
||||
// {
|
||||
// value: 'xihu',
|
||||
// label: '西湖区',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// }
|
||||
],
|
||||
fieldNames: {label: 'fullName', value: 'code', children: 'children'},
|
||||
width: '100%',
|
||||
span: '',
|
||||
defaultValue: '',
|
||||
labelWidthMode: 'fix',
|
||||
labelFixWidth: 120,
|
||||
responsive: false,
|
||||
respNewRow: false,
|
||||
placeholder: '请选择',
|
||||
maxlength: null,
|
||||
prefix: '',
|
||||
suffix: '',
|
||||
addonBefore: '',
|
||||
addonAfter: '',
|
||||
disabled: false,
|
||||
allowClear: false,
|
||||
placeholder: '请选择区域',
|
||||
showLabel: true,
|
||||
disabled: false,
|
||||
allowClear: true,
|
||||
clearable: false,
|
||||
required: false,
|
||||
rules: [],
|
||||
events: {},
|
||||
isSave: false,
|
||||
isShow: true,
|
||||
scan: false,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldNames: {label: 'fullName', value: 'code', children: 'children'},
|
||||
excludeType: 'CONTINENT'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: '6461a5e152124abca28bd2114dd577e6',
|
||||
@ -519,15 +494,16 @@ export const formProps: FormProps = {
|
||||
},
|
||||
{
|
||||
key: '8',
|
||||
field: 'soft',
|
||||
field: 'sort',
|
||||
label: '显示顺序',
|
||||
type: 'input',
|
||||
component: 'InputNumber',
|
||||
colProps: { span: 8 },
|
||||
defaultValue: '',
|
||||
defaultValue: null,
|
||||
componentProps: {
|
||||
width: '100%',
|
||||
span: '',
|
||||
min:0,
|
||||
defaultValue: '',
|
||||
labelWidthMode: 'fix',
|
||||
labelFixWidth: 120,
|
||||
|
||||
@ -236,13 +236,13 @@ export const formProps: FormProps = {
|
||||
colProps: { span: 8 },
|
||||
defaultValue: null,
|
||||
componentProps: {
|
||||
min:0,
|
||||
labelWidthMode: 'fix',
|
||||
labelFixWidth: 120,
|
||||
responsive: false,
|
||||
width: '100%',
|
||||
span: '',
|
||||
defaultValue: null,
|
||||
min: 0,
|
||||
max: null,
|
||||
step: 1,
|
||||
maxlength: null,
|
||||
|
||||
@ -7,10 +7,10 @@
|
||||
/>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref,onBeforeMount,onMounted } from 'vue';
|
||||
import { reactive, ref,onBeforeMount,onMounted,watch } from 'vue';
|
||||
import { formProps, formEventConfigs ,formConfig} from './config';
|
||||
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
|
||||
import { addLngBPngLine, getLngBPngLine, updateLngBPngLine, deleteLngBPngLine } from '/@/api/mdm/PipelineGgasLine';
|
||||
import { addLngBPngLine, getLngBPngLine, updateLngBPngLine, deleteLngBPngLine, getIngStation } from '/@/api/mdm/PipelineGgasLine';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { FormDataProps } from '/@/components/Designer/src/types';
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
@ -33,7 +33,9 @@
|
||||
default: FromPageType.MENU,
|
||||
},
|
||||
});
|
||||
const systemFormRef = ref();
|
||||
const systemFormRef = ref({
|
||||
|
||||
});
|
||||
const data: { formDataProps: FormDataProps } = reactive({
|
||||
formDataProps: {schemas:[]} as FormDataProps,
|
||||
});
|
||||
@ -43,7 +45,43 @@
|
||||
|
||||
let customFormEventConfigs=[];
|
||||
|
||||
|
||||
watch(
|
||||
() => getFormModel(),
|
||||
(newVal) => {
|
||||
if (newVal.ownSign === 'Y') {
|
||||
data.formDataProps.schemas?.forEach(v => {
|
||||
if (v.field === 'staCodeLng') {
|
||||
v.componentProps.disabled = false
|
||||
v.componentProps.required = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
data.formDataProps.schemas?.forEach(v => {
|
||||
if (v.field === 'staCodeLng') {
|
||||
v.componentProps.disabled = true
|
||||
v.componentProps.required = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
const a = await getIngStation({ownSign :'Y', valid : 'Y'})
|
||||
const b = a.map(v => {
|
||||
return {
|
||||
label: v.fullName,
|
||||
value: v.code
|
||||
}
|
||||
})
|
||||
formProps.schemas?.forEach(v => {
|
||||
if (v.field === 'staCodeLng') {
|
||||
v.componentProps.staticOptions = b
|
||||
}
|
||||
})
|
||||
try {
|
||||
// 合并渲染覆盖配置中的字段配置、表单事件配置
|
||||
await mergeCustomFormRenderConfig();
|
||||
|
||||
@ -348,11 +348,11 @@ export const formProps: FormProps = {
|
||||
disabled: false,
|
||||
mode: '',
|
||||
staticOptions: [
|
||||
{ key: 1, label: 'Option 1', value: 'Option 1' },
|
||||
{ key: 2, label: 'Option 2', value: 'Option 2' },
|
||||
{ key: 3, label: 'Option 3', value: 'Option 3' },
|
||||
// { key: 1, label: 'Option 1', value: 'Option 1' },
|
||||
// { key: 2, label: 'Option 2', value: 'Option 2' },
|
||||
// { key: 3, label: 'Option 3', value: 'Option 3' },
|
||||
],
|
||||
defaultSelect: 'Option 1',
|
||||
defaultSelect: '',
|
||||
datasourceType: 'staticData',
|
||||
labelField: 'label',
|
||||
valueField: 'value',
|
||||
@ -376,14 +376,14 @@ export const formProps: FormProps = {
|
||||
type: 'number',
|
||||
component: 'InputNumber',
|
||||
colProps: { span: 8 },
|
||||
defaultValue: 0,
|
||||
defaultValue: null,
|
||||
componentProps: {
|
||||
labelWidthMode: 'fix',
|
||||
labelFixWidth: 120,
|
||||
responsive: false,
|
||||
width: '100%',
|
||||
span: '',
|
||||
defaultValue: 0,
|
||||
defaultValue: null,
|
||||
step: 1,
|
||||
disabled: false,
|
||||
showLabel: true,
|
||||
@ -391,6 +391,7 @@ export const formProps: FormProps = {
|
||||
required: false,
|
||||
subTotal: false,
|
||||
isShow: true,
|
||||
min:0,
|
||||
rules: [],
|
||||
events: {},
|
||||
style: { width: '100%' },
|
||||
|
||||
@ -289,7 +289,7 @@ export const formProps: FormProps = {
|
||||
width: '100%',
|
||||
span: '',
|
||||
defaultValue: null,
|
||||
min: null,
|
||||
min: 0,
|
||||
max: null,
|
||||
step: 1,
|
||||
maxlength: null,
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
} from 'vue';
|
||||
const modalVisible = ref(false);
|
||||
const logId = ref('')
|
||||
const logPath = ref('/mdm/TaxRate/datalog');
|
||||
const logPath = ref('/mdm/taxRate/datalog');
|
||||
import { DataLog } from '/@/components/pcitc';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
Reference in New Issue
Block a user