数据管理子系统-BUG修改
This commit is contained in:
parent
86a7f990d3
commit
978232ed5e
@ -11,9 +11,9 @@ VITE_APP_BASE_URL = 'http://localhost:8093'
|
|||||||
# 测试环境
|
# 测试环境
|
||||||
# VITE_APP_BASE_URL = 'http://172.16.21.142:8093'
|
# VITE_APP_BASE_URL = 'http://172.16.21.142:8093'
|
||||||
# 汤伟
|
# 汤伟
|
||||||
# VITE_APP_BASE_URL = 'http://10.84.111.235:8093'
|
VITE_APP_BASE_URL = 'http://10.84.111.235:8093'
|
||||||
# 李林
|
# 李林
|
||||||
VITE_APP_BASE_URL = 'http://10.84.111.25:8093'
|
# VITE_APP_BASE_URL = 'http://10.84.111.25:8093'
|
||||||
|
|
||||||
## 开发环境 附件服务地址
|
## 开发环境 附件服务地址
|
||||||
VITE_APP_ATTACHMENT_URL = 'https://211.99.26.225:12125'
|
VITE_APP_ATTACHMENT_URL = 'https://211.99.26.225:12125'
|
||||||
|
|||||||
@ -51,6 +51,14 @@ export function assignmentPer (queryParams:any){
|
|||||||
params: queryParams
|
params: queryParams
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//获取分配权限(改动之后)
|
||||||
|
export function permissionAssignmentGrouped (queryParams:any){
|
||||||
|
return request({
|
||||||
|
url:'/system/menu/permissionAssignmentGrouped' ,
|
||||||
|
method: 'post',
|
||||||
|
params: queryParams
|
||||||
|
});
|
||||||
|
}
|
||||||
//发出分配权限
|
//发出分配权限
|
||||||
export function setMenuById (queryParams:any){
|
export function setMenuById (queryParams:any){
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -33,6 +33,14 @@ export function getRvcdDropdown(params: any) {
|
|||||||
params: params
|
params: params
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// /、鱼类资源
|
||||||
|
export function selectForDropdown(data:any) {
|
||||||
|
return request({
|
||||||
|
url: '/env/fishDictory/list',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
//电站下拉列表
|
//电站下拉列表
|
||||||
export function getEngInfoDropdown(data: any) {
|
export function getEngInfoDropdown(data: any) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -105,6 +105,7 @@
|
|||||||
</a-select> -->
|
</a-select> -->
|
||||||
<!-- 流域下拉框 -->
|
<!-- 流域下拉框 -->
|
||||||
<a-select
|
<a-select
|
||||||
|
:key="`rvcd-ly-${shuJuTianBaoStore.lyOption.length}`"
|
||||||
:value="formData.rvcd"
|
:value="formData.rvcd"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
@change="lyChange"
|
@change="lyChange"
|
||||||
|
|||||||
@ -359,6 +359,7 @@ const getData = async () => {
|
|||||||
try {
|
try {
|
||||||
if (props.url && modelStore.params.stcd) {
|
if (props.url && modelStore.params.stcd) {
|
||||||
let res: any = await getStcdDetail(props.url, modelStore.params.stcd);
|
let res: any = await getStcdDetail(props.url, modelStore.params.stcd);
|
||||||
|
// debugger
|
||||||
if (res && res.code) {
|
if (res && res.code) {
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
data2.value = data;
|
data2.value = data;
|
||||||
|
|||||||
@ -129,7 +129,7 @@ const dvtp = ref([]);
|
|||||||
const initSearchData = {
|
const initSearchData = {
|
||||||
rvcd: 'all',
|
rvcd: 'all',
|
||||||
rstcd: null,
|
rstcd: null,
|
||||||
topHynm: null,
|
topHycd: null,
|
||||||
hycd: null,
|
hycd: null,
|
||||||
baseId: null,
|
baseId: null,
|
||||||
hbrvcd: null,
|
hbrvcd: null,
|
||||||
@ -157,7 +157,7 @@ const searchList: any = computed(() => [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'Select',
|
type: 'Select',
|
||||||
name: 'topHynm',
|
name: 'topHycd',
|
||||||
label: '所属集团',
|
label: '所属集团',
|
||||||
width: 140,
|
width: 140,
|
||||||
fieldProps: {
|
fieldProps: {
|
||||||
|
|||||||
@ -8,10 +8,10 @@
|
|||||||
@ok="handleDataSourceConfirm"
|
@ok="handleDataSourceConfirm"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<p style="color: red; margin-bottom: 8px">请输入修改依据以继续删除操作</p>
|
<p style="color: red; margin-bottom: 8px">请输入删除依据以继续删除操作</p>
|
||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="dataSource"
|
v-model:value="dataSource"
|
||||||
placeholder="请输入修改依据"
|
placeholder="请输入删除依据"
|
||||||
:rows="4"
|
:rows="4"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1131,6 +1131,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const formRules = computed(() => ({
|
const formRules = computed(() => ({
|
||||||
stcd: props.isAdd
|
stcd: props.isAdd
|
||||||
? [{ required: true, message: '请输入电站编码', trigger: 'blur' }]
|
? [{ required: true, message: '请输入电站编码', trigger: 'blur' }]
|
||||||
@ -1196,7 +1197,7 @@ const bldsttCodeOptions = ref<any[]>([
|
|||||||
{ label: '已建', value: 2 }
|
{ label: '已建', value: 2 }
|
||||||
]); // TODO: 建设状态接口
|
]); // TODO: 建设状态接口
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter(item => item.wbsCode !== 'all') // 过滤掉"当前全部"
|
.filter(item => item.wbsCode !== 'all') // 过滤掉"当前全部"
|
||||||
.map(item => ({
|
.map(item => ({
|
||||||
@ -1263,7 +1264,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -1300,6 +1301,14 @@ watch(
|
|||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveSelectLabel(key, converted[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
|
|||||||
@ -93,10 +93,12 @@ import { getEngInfoById } from '@/api/select';
|
|||||||
import { calcTableScrollY } from '@/utils/index';
|
import { calcTableScrollY } from '@/utils/index';
|
||||||
import { useModelStore } from '@/store/modules/model';
|
import { useModelStore } from '@/store/modules/model';
|
||||||
import { useUserStore } from "@/store/modules/user";
|
import { useUserStore } from "@/store/modules/user";
|
||||||
|
import { useShuJuTianBaoStore } from '@/store/modules/shuJuTianBao';
|
||||||
|
|
||||||
|
|
||||||
const modelStore = useModelStore();
|
const modelStore = useModelStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const shuJuTianBaoStore = useShuJuTianBaoStore();
|
||||||
|
|
||||||
const sort = ref<any>([
|
const sort = ref<any>([
|
||||||
{
|
{
|
||||||
@ -360,12 +362,12 @@ const buildSearchParams = (values: any) => {
|
|||||||
value: values.hycd
|
value: values.hycd
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
values.topHynm
|
values.topHycd
|
||||||
? {
|
? {
|
||||||
field: 'topHynm',
|
field: 'topHycd',
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.topHynm
|
value: values.topHycd
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
values.ttpwr && values.ttpwr.min
|
values.ttpwr && values.ttpwr.min
|
||||||
@ -472,6 +474,8 @@ const handleEdit = (record: any) => {
|
|||||||
|
|
||||||
// 编辑成功回调
|
// 编辑成功回调
|
||||||
const handleEditSuccess = () => {
|
const handleEditSuccess = () => {
|
||||||
|
const rvcd = searchRef.value?.searchData?.rvcd ?? 'all';
|
||||||
|
shuJuTianBaoStore.getEngOption(rvcd, 'rvcd');
|
||||||
initTable(currentSearchParams.value);
|
initTable(currentSearchParams.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -290,6 +290,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.shapedesc"
|
v-model:value="formData.shapedesc"
|
||||||
placeholder="请输入形态描述"
|
placeholder="请输入形态描述"
|
||||||
|
:maxlength="500"
|
||||||
|
show-count
|
||||||
:rows="3"
|
:rows="3"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -299,6 +301,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.description"
|
v-model:value="formData.description"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
|
:maxlength="100"
|
||||||
|
show-count
|
||||||
:rows="3"
|
:rows="3"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -337,7 +341,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message, Upload } from 'ant-design-vue';
|
import { message, Upload } from 'ant-design-vue';
|
||||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||||
import { addFishDictoryInfo, updateFishDictoryInfo } from '@/api/DataQueryMenuModule';
|
import { addFishDictoryInfo, updateFishDictoryInfo } from '@/api/DataQueryMenuModule';
|
||||||
@ -366,6 +370,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
// 图片上传相关
|
// 图片上传相关
|
||||||
@ -489,6 +494,11 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:优先用预解析快照,不依赖实时选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
return resolveSelectLabel(field, originalRecord.value[field]);
|
||||||
|
};
|
||||||
|
|
||||||
// 监听 formData 变化
|
// 监听 formData 变化
|
||||||
watch(
|
watch(
|
||||||
() => formData.value,
|
() => formData.value,
|
||||||
@ -516,7 +526,7 @@ watch(
|
|||||||
|
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -588,9 +598,23 @@ watch(
|
|||||||
newRecord => {
|
newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免控件显示异常
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
// 处理已有图片
|
// 处理已有图片
|
||||||
if (converted.inffile) {
|
if (converted.inffile) {
|
||||||
const ids = converted.inffile.split(',').filter(Boolean);
|
const ids = converted.inffile.split(',').filter(Boolean);
|
||||||
@ -609,6 +633,22 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 流域选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
() => shuJuTianBaoStore.lyOption,
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.open,
|
() => props.open,
|
||||||
val => {
|
val => {
|
||||||
|
|||||||
@ -222,6 +222,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -231,6 +233,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -249,7 +253,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addAiboxInfo, updateAiboxInfo } from '@/api/DataQueryMenuModule';
|
import { addAiboxInfo, updateAiboxInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -276,23 +280,22 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
stcd: [{ required: true, message: '请输入站码', trigger: 'blur' }],
|
stcd: [{ required: true, message: '请输入站码', trigger: 'blur' }],
|
||||||
stnm: [{ required: true, message: '请输入站名', trigger: 'blur' }]
|
stnm: [{ required: true, message: '请输入站名', trigger: 'blur' }],
|
||||||
|
sttp: [{ required: true, message: '请输入站类', trigger: 'blur' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
// 下拉选项
|
// 下拉选项
|
||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
@ -355,6 +358,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -387,7 +400,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -416,17 +429,51 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 监听 record 变化
|
// 监听 record 变化
|
||||||
watch(
|
const isInitLoading = ref(false);
|
||||||
() => props.record,
|
watch(() => props.record, newRecord => {
|
||||||
newRecord => {
|
if (newRecord) {
|
||||||
if (newRecord) {
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
originalRecord.value = { ...converted };
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
formData.value = { ...converted };
|
for (const key in converted) {
|
||||||
changeOrder.value = [];
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
originalRecord.value = { ...converted };
|
||||||
{ deep: true }
|
formData.value = { ...converted };
|
||||||
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
@ -442,17 +489,11 @@ const loadEngOptions = async (baseId?: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载下拉数据
|
|
||||||
const loadDropdownData = () => {
|
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
@ -461,7 +502,6 @@ watch(
|
|||||||
() => props.open,
|
() => props.open,
|
||||||
val => {
|
val => {
|
||||||
if (val) {
|
if (val) {
|
||||||
loadDropdownData();
|
|
||||||
if (props.isAdd) {
|
if (props.isAdd) {
|
||||||
formData.value = {};
|
formData.value = {};
|
||||||
originalRecord.value = {};
|
originalRecord.value = {};
|
||||||
|
|||||||
@ -187,6 +187,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -196,6 +198,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -214,7 +218,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addOtweInfo, updateOtweInfo } from '@/api/DataQueryMenuModule';
|
import { addOtweInfo, updateOtweInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -242,6 +246,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -253,13 +258,10 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
@ -322,6 +324,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -353,7 +365,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -381,17 +393,52 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
// 监听 record 变化
|
||||||
() => props.record,
|
const isInitLoading = ref(false);
|
||||||
newRecord => {
|
watch(() => props.record, newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
const converted = { ...newRecord };
|
isInitLoading.value = true;
|
||||||
originalRecord.value = { ...converted };
|
const converted = { ...newRecord };
|
||||||
formData.value = { ...converted };
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
changeOrder.value = [];
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
originalRecord.value = { ...converted };
|
||||||
{ deep: true }
|
formData.value = { ...converted };
|
||||||
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
@ -426,15 +473,14 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -231,6 +231,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -240,6 +242,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -258,7 +262,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addAiInfo, updateAiInfo } from '@/api/DataQueryMenuModule';
|
import { addAiInfo, updateAiInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -286,6 +290,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -298,13 +303,10 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
@ -368,6 +370,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -399,11 +411,7 @@ watch(
|
|||||||
)
|
)
|
||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect ? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)) : oldNorm === null ? '空' : String(oldNorm);
|
||||||
? resolveSelectLabel(key, oldNorm)
|
|
||||||
: oldNorm === null
|
|
||||||
? '空'
|
|
||||||
: String(oldNorm);
|
|
||||||
const newDisplay = isSelect
|
const newDisplay = isSelect
|
||||||
? resolveSelectLabel(key, newNorm)
|
? resolveSelectLabel(key, newNorm)
|
||||||
: newNorm === null
|
: newNorm === null
|
||||||
@ -429,17 +437,51 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 监听 record 变化
|
// 监听 record 变化
|
||||||
watch(
|
const isInitLoading = ref(false);
|
||||||
() => props.record,
|
watch(() => props.record, newRecord => {
|
||||||
newRecord => {
|
if (newRecord) {
|
||||||
if (newRecord) {
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
originalRecord.value = { ...converted };
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
formData.value = { ...converted };
|
for (const key in converted) {
|
||||||
changeOrder.value = [];
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
originalRecord.value = { ...converted };
|
||||||
{ deep: true }
|
formData.value = { ...converted };
|
||||||
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
@ -476,16 +518,14 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
// 从 store 获取水电基地数据
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -55,12 +55,12 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="开工日期" name="swdt">
|
<a-form-item label="开工日期" name="swdt">
|
||||||
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开工日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled-date="disabledSwdtDate" placeholder="请选择开工日期" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="建成日期" name="jcdt">
|
<a-form-item label="建成日期" name="jcdt">
|
||||||
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择建成日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled-date="disabledJcdtDate" placeholder="请选择建成日期" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
@ -114,7 +114,9 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="过鱼月份" name="fpssmn">
|
<a-form-item label="过鱼月份" name="fpssmn">
|
||||||
<a-input v-model:value="formData.fpssmn" placeholder="多个月份用,隔开" style="width: 100%" />
|
<a-select :key="visible" v-model:value="formData.fpssmn" mode="multiple" placeholder="请选择过鱼月份" allow-clear>
|
||||||
|
<a-select-option v-for="item in fpssmnOptions" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
@ -138,7 +140,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addFpInfo, updateFpInfo } from '@/api/DataQueryMenuModule';
|
import { addFpInfo, updateFpInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -156,8 +159,9 @@ useDraggable(visible, { boundary: true, resetOnOpen: true });
|
|||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({ fpssmn: [] });
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -168,12 +172,15 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
);
|
);
|
||||||
|
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
|
|
||||||
|
// 过鱼月份静态选项 1月-12月
|
||||||
|
const fpssmnOptions = ref(Array.from({ length: 12 }, (_, i) => ({ label: `${i + 1}月`, value: `${i + 1}` })));
|
||||||
|
|
||||||
const fieldLabelMap: Record<string, string> = {
|
const fieldLabelMap: Record<string, string> = {
|
||||||
stcd: '设施编码', stnm: '设施名称', sttp: '设施类型', stlc: '站址/位置',
|
stcd: '设施编码', stnm: '设施名称', sttp: '设施类型', stlc: '站址/位置',
|
||||||
baseId: '水电基地', rstcd: '所属电站', lgtd: '经度(°)', lttd: '纬度(°)',
|
baseId: '水电基地', rstcd: '所属电站', lgtd: '经度(°)', lttd: '纬度(°)',
|
||||||
@ -196,7 +203,8 @@ const selectOptionsMap: Record<string, () => any[]> = {
|
|||||||
mway: () => [
|
mway: () => [
|
||||||
{ label: '人工', value: 1 },
|
{ label: '人工', value: 1 },
|
||||||
{ label: '自动', value: 2 }
|
{ label: '自动', value: 2 }
|
||||||
]
|
],
|
||||||
|
fpssmn: () => fpssmnOptions.value
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeOrder = ref<{ field: string; label: string; oldValue: string; newValue: string }[]>([]);
|
const changeOrder = ref<{ field: string; label: string; oldValue: string; newValue: string }[]>([]);
|
||||||
@ -204,6 +212,16 @@ const diffList = changeOrder;
|
|||||||
|
|
||||||
const resolveSelectLabel = (field: string, value: any): string => {
|
const resolveSelectLabel = (field: string, value: any): string => {
|
||||||
if (value === null || value === undefined || value === '') return '空';
|
if (value === null || value === undefined || value === '') return '空';
|
||||||
|
// fpssmn 多选:按逗号分隔,分别解析 label 再合并
|
||||||
|
if (field === 'fpssmn') {
|
||||||
|
const arr = Array.isArray(value) ? value : String(value).split(',');
|
||||||
|
return arr.map((v: any) => {
|
||||||
|
const trimmed = String(v).trim();
|
||||||
|
if (!trimmed) return '';
|
||||||
|
const opt = fpssmnOptions.value.find((o) => String(o.value) === trimmed);
|
||||||
|
return opt ? opt.label : trimmed;
|
||||||
|
}).filter(Boolean).join('、');
|
||||||
|
}
|
||||||
const getOptions = selectOptionsMap[field];
|
const getOptions = selectOptionsMap[field];
|
||||||
if (getOptions) {
|
if (getOptions) {
|
||||||
const opt = getOptions().find((o: any) => String(o.value) === String(value));
|
const opt = getOptions().find((o: any) => String(o.value) === String(value));
|
||||||
@ -212,24 +230,55 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
return label.includes(inputValue || '');
|
return label.includes(inputValue || '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 开工日期不能晚于建成日期
|
||||||
|
const disabledSwdtDate = (current: any) => {
|
||||||
|
if (!formData.value.jcdt) return false;
|
||||||
|
return current && current > dayjs(formData.value.jcdt).endOf('day');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 建成日期不能早于开工日期
|
||||||
|
const disabledJcdtDate = (current: any) => {
|
||||||
|
if (!formData.value.swdt) return false;
|
||||||
|
return current && current < dayjs(formData.value.swdt).startOf('day');
|
||||||
|
};
|
||||||
|
|
||||||
watch(() => formData.value, newData => {
|
watch(() => formData.value, newData => {
|
||||||
const original = originalRecord.value;
|
const original = originalRecord.value;
|
||||||
for (const key in newData) {
|
for (const key in newData) {
|
||||||
const oldVal = original[key];
|
const oldVal = original[key];
|
||||||
const newVal = newData[key];
|
const newVal = newData[key];
|
||||||
if (oldVal !== newVal) {
|
if (oldVal !== newVal) {
|
||||||
|
// fpssmn 多选:数组 vs 字符串比较,需标准化
|
||||||
|
if (key === 'fpssmn') {
|
||||||
|
const normalize = (v: any) => {
|
||||||
|
if (!v) return '';
|
||||||
|
const arr = Array.isArray(v) ? v : String(v).split(',');
|
||||||
|
return arr.map((s: string) => s.trim()).filter(Boolean).sort().join(',');
|
||||||
|
};
|
||||||
|
if (normalize(oldVal) === normalize(newVal)) continue;
|
||||||
|
}
|
||||||
const existingIdx = changeOrder.value.findIndex(c => c.field === key);
|
const existingIdx = changeOrder.value.findIndex(c => c.field === key);
|
||||||
const oldNorm = oldVal === null || oldVal === undefined || oldVal === '-' ? null : oldVal;
|
const oldNorm = oldVal === null || oldVal === undefined || oldVal === '-' ? null : oldVal;
|
||||||
const newNorm = newVal === null || newVal === undefined ? null : newVal;
|
const newNorm = newVal === null || newVal === undefined ? null : newVal;
|
||||||
if (oldNorm === newNorm) continue;
|
if (oldNorm === newNorm) continue;
|
||||||
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect ? resolveSelectLabel(key, oldNorm) : oldNorm === null ? '空' : String(oldNorm);
|
const oldDisplay = isSelect ? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)) : oldNorm === null ? '空' : String(oldNorm);
|
||||||
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
||||||
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
||||||
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
||||||
@ -240,15 +289,56 @@ watch(() => formData.value, newData => {
|
|||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(() => props.record, newRecord => {
|
watch(() => props.record, newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
// fpssmn 多选回显:逗号分隔字符串 → 数组
|
||||||
|
const fpssmnArr = converted.fpssmn ? String(converted.fpssmn).split(',').map((s: string) => s.trim()).filter(Boolean) : [];
|
||||||
|
formData.value = { ...converted, fpssmn: fpssmnArr.length > 0 ? fpssmnArr : undefined };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -268,11 +358,15 @@ const loadDropdownData = () => {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }));
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 水电基地变化时联动电站
|
// 水电基地变化时联动电站
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
@ -280,7 +374,7 @@ watch(() => formData.value?.baseId, (newBaseId) => {
|
|||||||
watch(() => props.open, val => {
|
watch(() => props.open, val => {
|
||||||
if (val) {
|
if (val) {
|
||||||
if (props.isAdd) {
|
if (props.isAdd) {
|
||||||
formData.value = {};
|
formData.value = { fpssmn: [] };
|
||||||
originalRecord.value = {};
|
originalRecord.value = {};
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
loadEngOptions();
|
loadEngOptions();
|
||||||
@ -304,10 +398,14 @@ const handleConfirmSubmit = async (source: string) => {
|
|||||||
let res: any;
|
let res: any;
|
||||||
if (props.isAdd) {
|
if (props.isAdd) {
|
||||||
Object.assign(engInfo, formData.value);
|
Object.assign(engInfo, formData.value);
|
||||||
|
// fpssmn 多选:数组 → 逗号分隔字符串
|
||||||
|
if (Array.isArray(engInfo.fpssmn)) engInfo.fpssmn = engInfo.fpssmn.join(',');
|
||||||
res = await addFpInfo({ engInfo, source: source.trim() || '新增' });
|
res = await addFpInfo({ engInfo, source: source.trim() || '新增' });
|
||||||
} else {
|
} else {
|
||||||
engInfo.stcd = formData.value.stcd;
|
engInfo.stcd = formData.value.stcd;
|
||||||
changeOrder.value.forEach(item => { engInfo[item.field] = formData.value[item.field]; });
|
changeOrder.value.forEach(item => { engInfo[item.field] = formData.value[item.field]; });
|
||||||
|
// fpssmn 多选:数组 → 逗号分隔字符串
|
||||||
|
if (Array.isArray(engInfo.fpssmn)) engInfo.fpssmn = engInfo.fpssmn.join(',');
|
||||||
res = await updateFpInfo({ engInfo, source: source.trim() || '编辑' });
|
res = await updateFpInfo({ engInfo, source: source.trim() || '编辑' });
|
||||||
}
|
}
|
||||||
if (res?.code == 0 || res?.success) {
|
if (res?.code == 0 || res?.success) {
|
||||||
|
|||||||
@ -125,6 +125,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="3"
|
:rows="3"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -134,6 +136,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -152,7 +156,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addTeInfo, updateTeInfo } from '@/api/DataQueryMenuModule';
|
import { addTeInfo, updateTeInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -180,6 +184,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -192,13 +197,10 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}))
|
|
||||||
);
|
);
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
|
|
||||||
@ -242,6 +244,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -273,11 +285,7 @@ watch(
|
|||||||
)
|
)
|
||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect ? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)) : oldNorm === null ? '空' : String(oldNorm);
|
||||||
? resolveSelectLabel(key, oldNorm)
|
|
||||||
: oldNorm === null
|
|
||||||
? '空'
|
|
||||||
: String(oldNorm);
|
|
||||||
const newDisplay = isSelect
|
const newDisplay = isSelect
|
||||||
? resolveSelectLabel(key, newNorm)
|
? resolveSelectLabel(key, newNorm)
|
||||||
: newNorm === null
|
: newNorm === null
|
||||||
@ -303,17 +311,51 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 监听 record 变化
|
// 监听 record 变化
|
||||||
watch(
|
const isInitLoading = ref(false);
|
||||||
() => props.record,
|
watch(() => props.record, newRecord => {
|
||||||
newRecord => {
|
if (newRecord) {
|
||||||
if (newRecord) {
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
originalRecord.value = { ...converted };
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
formData.value = { ...converted };
|
for (const key in converted) {
|
||||||
changeOrder.value = [];
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
originalRecord.value = { ...converted };
|
||||||
{ deep: true }
|
formData.value = { ...converted };
|
||||||
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// 加载电站下拉(支持按 baseId 筛选)
|
// 加载电站下拉(支持按 baseId 筛选)
|
||||||
@ -351,17 +393,15 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
// 从 store 获取水电基地数据
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 水电基地变化时联动电站
|
// 水电基地变化时联动电站
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -18,81 +18,174 @@
|
|||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="栖息地站码" name="stcd">
|
<a-form-item label="栖息地站码" name="stcd">
|
||||||
<a-input v-model:value="formData.stcd" placeholder="请输入栖息地站码" :disabled="!isAdd" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.stcd"
|
||||||
|
placeholder="请输入栖息地站码"
|
||||||
|
:disabled="!isAdd"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="栖息地名称" name="stnm">
|
<a-form-item label="栖息地名称" name="stnm">
|
||||||
<a-input v-model:value="formData.stnm" placeholder="请输入栖息地名称" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.stnm"
|
||||||
|
placeholder="请输入栖息地名称"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="站址" name="stlc">
|
<a-form-item label="站址" name="stlc">
|
||||||
<a-input v-model:value="formData.stlc" placeholder="请输入站址" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.stlc"
|
||||||
|
placeholder="请输入站址"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="经度(°)" name="lgtd">
|
<a-form-item label="经度(°)" name="lgtd">
|
||||||
<a-input-number v-model:value="formData.lgtd" placeholder="请输入" :precision="6" style="width: 100%" />
|
<a-input-number
|
||||||
|
v-model:value="formData.lgtd"
|
||||||
|
placeholder="请输入"
|
||||||
|
:precision="6"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="纬度(°)" name="lttd">
|
<a-form-item label="纬度(°)" name="lttd">
|
||||||
<a-input-number v-model:value="formData.lttd" placeholder="请输入" :precision="6" style="width: 100%" />
|
<a-input-number
|
||||||
|
v-model:value="formData.lttd"
|
||||||
|
placeholder="请输入"
|
||||||
|
:precision="6"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="水电基地" name="baseId">
|
<a-form-item label="水电基地" name="baseId">
|
||||||
<a-select v-model:value="formData.baseId" placeholder="请选择水电基地" allow-clear show-search :filter-option="filterOption">
|
<a-select
|
||||||
<a-select-option v-for="item in baseNameOptions" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</a-select-option>
|
v-model:value="formData.baseId"
|
||||||
|
placeholder="请选择水电基地"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
:filter-option="filterOption"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="item in baseNameOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
>{{ item.label }}</a-select-option
|
||||||
|
>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="所属电站" name="rstcd">
|
<a-form-item label="所属电站" name="rstcd">
|
||||||
<a-select v-model:value="formData.rstcd" placeholder="请选择所属电站" allow-clear show-search :loading="engLoading" :filter-option="filterOption">
|
<a-select
|
||||||
<a-select-option v-for="item in engInfoOptions" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</a-select-option>
|
v-model:value="formData.rstcd"
|
||||||
|
placeholder="请选择所属电站"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
:loading="engLoading"
|
||||||
|
:filter-option="filterOption"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="item in engInfoOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
>{{ item.label }}</a-select-option
|
||||||
|
>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="保护对象" name="bhdx">
|
<a-form-item label="保护对象" name="bhdx">
|
||||||
<a-input v-model:value="formData.bhdx" placeholder="请输入保护对象" style="width: 100%" />
|
<a-select
|
||||||
|
v-model:value="formData.bhdx"
|
||||||
|
mode="multiple"
|
||||||
|
placeholder="请选择保护对象"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
:filter-option="filterOption"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="item in fishOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
>{{ item.label }}</a-select-option
|
||||||
|
>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="保护范围" name="bhfw">
|
<a-form-item label="保护范围" name="bhfw">
|
||||||
<a-input v-model:value="formData.bhfw" placeholder="请输入保护范围" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.bhfw"
|
||||||
|
placeholder="请输入保护范围"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="保护核心长度(km)" name="bhhxcd">
|
<a-form-item label="保护核心长度(km)" name="bhhxcd">
|
||||||
<a-input-number v-model:value="formData.bhhxcd" placeholder="请输入" :precision="2" style="width: 100%" />
|
<a-input-number
|
||||||
|
v-model:value="formData.bhhxcd"
|
||||||
|
placeholder="请输入"
|
||||||
|
:precision="2"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="保护河流" name="bhhl">
|
<a-form-item label="保护河流" name="bhhl">
|
||||||
<a-input v-model:value="formData.bhhl" placeholder="请输入保护河流" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.bhhl"
|
||||||
|
placeholder="请输入保护河流"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="保护河段" name="bhhd">
|
<a-form-item label="保护河段" name="bhhd">
|
||||||
<a-input v-model:value="formData.bhhd" placeholder="请输入保护河段" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.bhhd"
|
||||||
|
placeholder="请输入保护河段"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="保护措施" name="bhcs">
|
<a-form-item label="保护措施" name="bhcs">
|
||||||
<a-input v-model:value="formData.bhcs" placeholder="请输入保护措施" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.bhcs"
|
||||||
|
placeholder="请输入保护措施"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="保护方式" name="bhfs">
|
<a-form-item label="保护方式" name="bhfs">
|
||||||
<a-input v-model:value="formData.bhfs" placeholder="请输入保护方式" style="width: 100%" />
|
<a-input
|
||||||
|
v-model:value="formData.bhfs"
|
||||||
|
placeholder="请输入保护方式"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="投资(亿元)" name="inv">
|
<a-form-item label="投资(亿元)" name="inv">
|
||||||
<a-input-number v-model:value="formData.inv" placeholder="请输入" :precision="3" style="width: 100%" />
|
<a-input-number
|
||||||
|
v-model:value="formData.inv"
|
||||||
|
placeholder="请输入"
|
||||||
|
:precision="3"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -109,10 +202,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addFhInfo, updateFhInfo } from '@/api/DataQueryMenuModule';
|
import { addFhInfo, updateFhInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown, selectForDropdown } from '@/api/select';
|
||||||
import { useJidiSelectEventStore } from '@/store/modules/jidiSelectEvent';
|
import { useJidiSelectEventStore } from '@/store/modules/jidiSelectEvent';
|
||||||
import ConfirmModal from '@/components/ConfirmModal/index.vue';
|
import ConfirmModal from '@/components/ConfirmModal/index.vue';
|
||||||
import { useDraggable } from '@/utils/drag';
|
import { useDraggable } from '@/utils/drag';
|
||||||
@ -121,13 +214,17 @@ const props = defineProps<{ open: boolean; record?: any; isAdd?: boolean }>();
|
|||||||
const emit = defineEmits(['update:open', 'success']);
|
const emit = defineEmits(['update:open', 'success']);
|
||||||
const jidiSelectEventStore = useJidiSelectEventStore();
|
const jidiSelectEventStore = useJidiSelectEventStore();
|
||||||
|
|
||||||
const visible = computed({ get: () => props.open, set: val => emit('update:open', val) });
|
const visible = computed({
|
||||||
|
get: () => props.open,
|
||||||
|
set: val => emit('update:open', val)
|
||||||
|
});
|
||||||
useDraggable(visible, { boundary: true, resetOnOpen: true });
|
useDraggable(visible, { boundary: true, resetOnOpen: true });
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -137,7 +234,7 @@ const formRules = ref<any>({
|
|||||||
|
|
||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
@ -146,73 +243,221 @@ const baseNameOptions = ref<any[]>(
|
|||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
|
|
||||||
const fieldLabelMap: Record<string, string> = {
|
const fieldLabelMap: Record<string, string> = {
|
||||||
stcd: '栖息地站码', stnm: '栖息地名称', stlc: '站址', baseId: '水电基地',
|
stcd: '栖息地站码',
|
||||||
rstcd: '所属电站', bhdx: '保护对象', bhfw: '保护范围',
|
stnm: '栖息地名称',
|
||||||
bhhxcd: '保护核心长度(km)',
|
stlc: '站址',
|
||||||
bhhl: '保护河流', bhhd: '保护河段', bhcs: '保护措施', bhfs: '保护方式', inv: '投资(亿元)', lgtd: '经度(°)', lttd: '纬度(°)'
|
baseId: '水电基地',
|
||||||
|
rstcd: '所属电站',
|
||||||
|
bhdx: '保护对象',
|
||||||
|
bhfw: '保护范围',
|
||||||
|
bhhxcd: '保护核心长度(km)',
|
||||||
|
bhhl: '保护河流',
|
||||||
|
bhhd: '保护河段',
|
||||||
|
bhcs: '保护措施',
|
||||||
|
bhfs: '保护方式',
|
||||||
|
inv: '投资(亿元)',
|
||||||
|
lgtd: '经度(°)',
|
||||||
|
lttd: '纬度(°)'
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectOptionsMap: Record<string, () => any[]> = {
|
const selectOptionsMap: Record<string, () => any[]> = {
|
||||||
baseId: () => baseNameOptions.value,
|
baseId: () => baseNameOptions.value,
|
||||||
rstcd: () => engInfoOptions.value
|
rstcd: () => engInfoOptions.value,
|
||||||
|
bhdx: () => fishOptions.value
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeOrder = ref<{ field: string; label: string; oldValue: string; newValue: string }[]>([]);
|
const changeOrder = ref<
|
||||||
|
{ field: string; label: string; oldValue: string; newValue: string }[]
|
||||||
|
>([]);
|
||||||
const diffList = changeOrder;
|
const diffList = changeOrder;
|
||||||
|
|
||||||
const resolveSelectLabel = (field: string, value: any): string => {
|
const resolveSelectLabel = (field: string, value: any): string => {
|
||||||
if (value === null || value === undefined || value === '') return '空';
|
if (value === null || value === undefined || value === '') return '空';
|
||||||
|
// bhdx 多选:按逗号分隔,分别解析 label 再合并
|
||||||
|
if (field === 'bhdx') {
|
||||||
|
const arr = Array.isArray(value) ? value : String(value).split(',');
|
||||||
|
return arr
|
||||||
|
.map((v: any) => {
|
||||||
|
const trimmed = String(v).trim();
|
||||||
|
if (!trimmed) return '';
|
||||||
|
const opt = fishOptions.value.find(
|
||||||
|
(o: any) => String(o.value) === trimmed
|
||||||
|
);
|
||||||
|
return opt ? opt.label : trimmed;
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('、');
|
||||||
|
}
|
||||||
const getOptions = selectOptionsMap[field];
|
const getOptions = selectOptionsMap[field];
|
||||||
if (getOptions) {
|
if (getOptions) {
|
||||||
const opt = getOptions().find((o: any) => String(o.value) === String(value));
|
const opt = getOptions().find(
|
||||||
|
(o: any) => String(o.value) === String(value)
|
||||||
|
);
|
||||||
if (opt) return opt.label;
|
if (opt) return opt.label;
|
||||||
}
|
}
|
||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
return label.includes(inputValue || '');
|
return label.includes(inputValue || '');
|
||||||
};
|
};
|
||||||
|
const fishOptions = ref<any[]>([]);
|
||||||
|
const getFishzy = async () => {
|
||||||
|
try {
|
||||||
|
const res = await selectForDropdown({
|
||||||
|
"select": ["name","id"],
|
||||||
|
"filter": {"logic": "and","filters": []}});
|
||||||
|
fishOptions.value = (res.data || []).map((item: any) => ({
|
||||||
|
label: item.name ,
|
||||||
|
value: item.id
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取保护对象列表失败:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
watch(() => formData.value, newData => {
|
watch(
|
||||||
|
() => formData.value,
|
||||||
|
newData => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
for (const key in newData) {
|
||||||
|
const oldVal = original[key];
|
||||||
|
const newVal = newData[key];
|
||||||
|
if (oldVal !== newVal) {
|
||||||
|
// bhdx 多选:数组 vs 字符串比较,需标准化
|
||||||
|
if (key === 'bhdx') {
|
||||||
|
const normalize = (v: any) => {
|
||||||
|
if (!v) return '';
|
||||||
|
const arr = Array.isArray(v) ? v : String(v).split(',');
|
||||||
|
return arr
|
||||||
|
.map((s: string) => s.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
.sort()
|
||||||
|
.join(',');
|
||||||
|
};
|
||||||
|
if (normalize(oldVal) === normalize(newVal)) continue;
|
||||||
|
}
|
||||||
|
const existingIdx = changeOrder.value.findIndex(c => c.field === key);
|
||||||
|
const oldNorm =
|
||||||
|
oldVal === null || oldVal === undefined || oldVal === '-'
|
||||||
|
? null
|
||||||
|
: oldVal;
|
||||||
|
const newNorm = newVal === null || newVal === undefined ? null : newVal;
|
||||||
|
if (oldNorm === newNorm) continue;
|
||||||
|
if (
|
||||||
|
oldNorm !== null &&
|
||||||
|
newNorm !== null &&
|
||||||
|
!isNaN(Number(oldNorm)) &&
|
||||||
|
!isNaN(Number(newNorm)) &&
|
||||||
|
Number(oldNorm) === Number(newNorm)
|
||||||
|
)
|
||||||
|
continue;
|
||||||
|
const isSelect = !!selectOptionsMap[key];
|
||||||
|
const oldDisplay = isSelect
|
||||||
|
? originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)
|
||||||
|
: oldNorm === null
|
||||||
|
? '空'
|
||||||
|
: String(oldNorm);
|
||||||
|
const newDisplay = isSelect
|
||||||
|
? resolveSelectLabel(key, newNorm)
|
||||||
|
: newNorm === null
|
||||||
|
? '空'
|
||||||
|
: String(newNorm);
|
||||||
|
const entry = {
|
||||||
|
field: key,
|
||||||
|
label: fieldLabelMap[key] || key,
|
||||||
|
oldValue: oldDisplay,
|
||||||
|
newValue: newDisplay
|
||||||
|
};
|
||||||
|
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
||||||
|
else changeOrder.value.push(entry);
|
||||||
|
} else {
|
||||||
|
changeOrder.value = changeOrder.value.filter(c => c.field !== key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
|
watch(
|
||||||
|
() => props.record,
|
||||||
|
newRecord => {
|
||||||
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalRecord.value = { ...converted };
|
||||||
|
// bhdx 多选回显:逗号分隔字符串 → 数组
|
||||||
|
const bhdxArr = converted.bhdx
|
||||||
|
? String(converted.bhdx)
|
||||||
|
.split(',')
|
||||||
|
.map((s: string) => s.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
: [];
|
||||||
|
formData.value = {
|
||||||
|
...converted,
|
||||||
|
bhdx: bhdxArr.length > 0 ? bhdxArr : undefined
|
||||||
|
};
|
||||||
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch([baseNameOptions, engInfoOptions, fishOptions], () => {
|
||||||
const original = originalRecord.value;
|
const original = originalRecord.value;
|
||||||
for (const key in newData) {
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
const oldVal = original[key];
|
const labels: Record<string, string> = {};
|
||||||
const newVal = newData[key];
|
for (const key in original) {
|
||||||
if (oldVal !== newVal) {
|
if (selectOptionsMap[key]) {
|
||||||
const existingIdx = changeOrder.value.findIndex(c => c.field === key);
|
labels[key] = resolveOriginalLabel(key);
|
||||||
const oldNorm = oldVal === null || oldVal === undefined || oldVal === '-' ? null : oldVal;
|
|
||||||
const newNorm = newVal === null || newVal === undefined ? null : newVal;
|
|
||||||
if (oldNorm === newNorm) continue;
|
|
||||||
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
|
||||||
const isSelect = !!selectOptionsMap[key];
|
|
||||||
const oldDisplay = isSelect ? resolveSelectLabel(key, oldNorm) : oldNorm === null ? '空' : String(oldNorm);
|
|
||||||
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
|
||||||
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
|
||||||
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
|
||||||
else changeOrder.value.push(entry);
|
|
||||||
} else {
|
|
||||||
changeOrder.value = changeOrder.value.filter(c => c.field !== key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
originalLabels.value = labels;
|
||||||
|
});
|
||||||
watch(() => props.record, newRecord => {
|
|
||||||
if (newRecord) {
|
|
||||||
const converted = { ...newRecord };
|
|
||||||
originalRecord.value = { ...converted };
|
|
||||||
formData.value = { ...converted };
|
|
||||||
changeOrder.value = [];
|
|
||||||
}
|
|
||||||
}, { deep: true });
|
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const params = baseId ? { baseId } : {};
|
const params = baseId ? { baseId } : {};
|
||||||
const res = await getEngInfoDropdown(params);
|
const res = await getEngInfoDropdown(params);
|
||||||
engInfoOptions.value = (res.data || []).map((item: any) => ({ label: item.ennm, value: item.stcd }));
|
engInfoOptions.value = (res.data || []).map((item: any) => ({
|
||||||
|
label: item.ennm,
|
||||||
|
value: item.stcd
|
||||||
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取电站列表失败:', error);
|
console.error('获取电站列表失败:', error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -220,30 +465,44 @@ const loadEngOptions = async (baseId?: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadDropdownData = () => {
|
watch(
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
() => formData.value?.baseId,
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
newBaseId => {
|
||||||
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }));
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
};
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
|
||||||
|
|
||||||
watch(() => props.open, val => {
|
|
||||||
if (val) {
|
|
||||||
loadDropdownData();
|
|
||||||
if (props.isAdd) { formData.value = {}; originalRecord.value = {}; changeOrder.value = []; loadEngOptions(); }
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.open,
|
||||||
|
val => {
|
||||||
|
if (val) {
|
||||||
|
if (props.isAdd) {
|
||||||
|
formData.value = {};
|
||||||
|
originalRecord.value = {};
|
||||||
|
changeOrder.value = [];
|
||||||
|
loadEngOptions();
|
||||||
|
}
|
||||||
|
getFishzy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
try {
|
try {
|
||||||
await formRef.value?.validateFields();
|
await formRef.value?.validateFields();
|
||||||
if (!props.isAdd && changeOrder.value.length === 0) { message.info('未检测到任何修改'); return; }
|
if (!props.isAdd && changeOrder.value.length === 0) {
|
||||||
|
message.info('未检测到任何修改');
|
||||||
|
return;
|
||||||
|
}
|
||||||
confirmModalVisible.value = true;
|
confirmModalVisible.value = true;
|
||||||
} catch (error) { console.error('验证失败:', error); }
|
} catch (error) {
|
||||||
|
console.error('验证失败:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirmSubmit = async (source: string) => {
|
const handleConfirmSubmit = async (source: string) => {
|
||||||
@ -253,10 +512,16 @@ const handleConfirmSubmit = async (source: string) => {
|
|||||||
let res: any;
|
let res: any;
|
||||||
if (props.isAdd) {
|
if (props.isAdd) {
|
||||||
Object.assign(engInfo, formData.value);
|
Object.assign(engInfo, formData.value);
|
||||||
|
// bhdx 多选:数组 → 逗号分隔字符串
|
||||||
|
if (Array.isArray(engInfo.bhdx)) engInfo.bhdx = engInfo.bhdx.join(',');
|
||||||
res = await addFhInfo({ engInfo, source: source.trim() || '新增' });
|
res = await addFhInfo({ engInfo, source: source.trim() || '新增' });
|
||||||
} else {
|
} else {
|
||||||
engInfo.stcd = formData.value.stcd;
|
engInfo.stcd = formData.value.stcd;
|
||||||
changeOrder.value.forEach(item => { engInfo[item.field] = formData.value[item.field]; });
|
changeOrder.value.forEach(item => {
|
||||||
|
engInfo[item.field] = formData.value[item.field];
|
||||||
|
});
|
||||||
|
// bhdx 多选:数组 → 逗号分隔字符串
|
||||||
|
if (Array.isArray(engInfo.bhdx)) engInfo.bhdx = engInfo.bhdx.join(',');
|
||||||
res = await updateFhInfo({ engInfo, source: source.trim() || '编辑' });
|
res = await updateFhInfo({ engInfo, source: source.trim() || '编辑' });
|
||||||
}
|
}
|
||||||
if (res?.code == 0 || res?.success) {
|
if (res?.code == 0 || res?.success) {
|
||||||
@ -264,11 +529,22 @@ const handleConfirmSubmit = async (source: string) => {
|
|||||||
confirmModalVisible.value = false;
|
confirmModalVisible.value = false;
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
emit('success');
|
emit('success');
|
||||||
} else { message.error(res?.msg || (props.isAdd ? '新增失败' : '编辑失败')); }
|
} else {
|
||||||
} catch (error) { message.error('提交失败,请重试'); }
|
message.error(res?.msg || (props.isAdd ? '新增失败' : '编辑失败'));
|
||||||
finally { confirmLoading.value = false; }
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error('提交失败,请重试');
|
||||||
|
} finally {
|
||||||
|
confirmLoading.value = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirmCancel = () => { confirmModalVisible.value = false; };
|
const handleConfirmCancel = () => {
|
||||||
const handleCancel = () => { visible.value = false; confirmModalVisible.value = false; formRef.value?.resetFields(); };
|
confirmModalVisible.value = false;
|
||||||
|
};
|
||||||
|
const handleCancel = () => {
|
||||||
|
visible.value = false;
|
||||||
|
confirmModalVisible.value = false;
|
||||||
|
formRef.value?.resetFields();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -62,7 +62,7 @@ const columns = ref<any[]>([
|
|||||||
{ key: 'stcd', title: '栖息地站码', dataIndex: 'stcd', visible: true, width: 320, fixed: 'left', ellipsis: true },
|
{ key: 'stcd', title: '栖息地站码', dataIndex: 'stcd', visible: true, width: 320, fixed: 'left', ellipsis: true },
|
||||||
{ key: 'baseName', title: '水电基地', dataIndex: 'baseName', visible: true, width: 120, ellipsis: true },
|
{ key: 'baseName', title: '水电基地', dataIndex: 'baseName', visible: true, width: 120, ellipsis: true },
|
||||||
{ key: 'ennm', title: '所属电站', dataIndex: 'ennm', visible: true, width: 150, ellipsis: true },
|
{ key: 'ennm', title: '所属电站', dataIndex: 'ennm', visible: true, width: 150, ellipsis: true },
|
||||||
{ key: 'bhdx', title: '保护对象', dataIndex: 'bhdx', visible: true, width: 120, ellipsis: true },
|
{ key: 'bhdxName', title: '保护对象', dataIndex: 'bhdxName', visible: true, width: 240, ellipsis: true },
|
||||||
{ key: 'bhhl', title: '保护河流', dataIndex: 'bhhl', visible: true, width: 120, ellipsis: true },
|
{ key: 'bhhl', title: '保护河流', dataIndex: 'bhhl', visible: true, width: 120, ellipsis: true },
|
||||||
{ key: 'bhhd', title: '保护河段', dataIndex: 'bhhd', visible: true, width: 240, ellipsis: true },
|
{ key: 'bhhd', title: '保护河段', dataIndex: 'bhhd', visible: true, width: 240, ellipsis: true },
|
||||||
{ key: 'bhfw', title: '保护范围', dataIndex: 'bhfw', visible: true, width: 120, ellipsis: true },
|
{ key: 'bhfw', title: '保护范围', dataIndex: 'bhfw', visible: true, width: 120, ellipsis: true },
|
||||||
|
|||||||
@ -188,6 +188,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -197,6 +199,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -215,7 +219,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addVaInfo, updateVaInfo } from '@/api/DataQueryMenuModule';
|
import { addVaInfo, updateVaInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -243,6 +247,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -254,7 +259,7 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
@ -270,18 +275,16 @@ const fieldLabelMap: Record<string, string> = {
|
|||||||
stnm: '救助站名称',
|
stnm: '救助站名称',
|
||||||
sttp: '测站类型',
|
sttp: '测站类型',
|
||||||
stlc: '站址',
|
stlc: '站址',
|
||||||
lgtd: '经度(°)',
|
|
||||||
lttd: '纬度(°)',
|
|
||||||
baseId: '水电基地',
|
baseId: '水电基地',
|
||||||
rstcd: '所属电站',
|
rstcd: '所属电站',
|
||||||
place: '地点',
|
place: '地点',
|
||||||
area: '面积',
|
area: '面积(km²)',
|
||||||
bhfs: '保护方式',
|
bhfs: '保护方式',
|
||||||
bhyy: '保护原因',
|
bhyy: '保护原因',
|
||||||
bhdx: '保护对象',
|
bhdx: '保护对象',
|
||||||
usfl: '是否启用',
|
usfl: '是否启用',
|
||||||
jcdt: '建成日期',
|
jcdt: '建成日期',
|
||||||
inv: '投资',
|
inv: '投资(亿元)',
|
||||||
introduce: '简介',
|
introduce: '简介',
|
||||||
remark: '备注'
|
remark: '备注'
|
||||||
};
|
};
|
||||||
@ -317,6 +320,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -337,8 +350,16 @@ watch(
|
|||||||
if (oldNorm === newNorm) continue;
|
if (oldNorm === newNorm) continue;
|
||||||
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect ? resolveSelectLabel(key, oldNorm) : oldNorm === null ? '空' : String(oldNorm);
|
const oldDisplay = isSelect
|
||||||
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
|
: oldNorm === null
|
||||||
|
? '空'
|
||||||
|
: String(oldNorm);
|
||||||
|
const newDisplay = isSelect
|
||||||
|
? resolveSelectLabel(key, newNorm)
|
||||||
|
: newNorm === null
|
||||||
|
? '空'
|
||||||
|
: String(newNorm);
|
||||||
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
||||||
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
||||||
else changeOrder.value.push(entry);
|
else changeOrder.value.push(entry);
|
||||||
@ -350,14 +371,56 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(() => props.record, newRecord => {
|
const isInitLoading = ref(false);
|
||||||
if (newRecord) {
|
watch(
|
||||||
const converted = { ...newRecord };
|
() => props.record,
|
||||||
originalRecord.value = { ...converted };
|
newRecord => {
|
||||||
formData.value = { ...converted };
|
if (newRecord) {
|
||||||
changeOrder.value = [];
|
isInitLoading.value = true;
|
||||||
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalRecord.value = { ...converted };
|
||||||
|
formData.value = { ...converted };
|
||||||
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
@ -381,23 +444,27 @@ const loadDropdownData = () => {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }));
|
// baseNameOptions 已改为 computed,无需手动赋值
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(() => props.open, val => {
|
watch(() => props.open, val => {
|
||||||
if (val) {
|
if (val) {
|
||||||
|
loadDropdownData();
|
||||||
if (props.isAdd) {
|
if (props.isAdd) {
|
||||||
formData.value = {};
|
formData.value = {};
|
||||||
originalRecord.value = {};
|
originalRecord.value = {};
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
loadEngOptions();
|
loadEngOptions();
|
||||||
}
|
}
|
||||||
loadDropdownData();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -55,12 +55,12 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="开工日期" name="swdt">
|
<a-form-item label="开工日期" name="swdt">
|
||||||
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开工日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled-date="disabledSwdtDate" placeholder="请选择开工日期" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="建成日期" name="jcdt">
|
<a-form-item label="建成日期" name="jcdt">
|
||||||
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择建成日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled-date="disabledJcdtDate" placeholder="请选择建成日期" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
@ -110,7 +110,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addEqInfo, updateEqInfo } from '@/api/DataQueryMenuModule';
|
import { addEqInfo, updateEqInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -130,6 +131,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -142,7 +144,7 @@ const engInfoOptions = ref<any[]>([]);
|
|||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -178,11 +180,33 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
return label.includes(inputValue || '');
|
return label.includes(inputValue || '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 开工日期不能晚于建成日期
|
||||||
|
const disabledSwdtDate = (current: any) => {
|
||||||
|
if (!formData.value.jcdt) return false;
|
||||||
|
return current && current > dayjs(formData.value.jcdt).endOf('day');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 建成日期不能早于开工日期
|
||||||
|
const disabledJcdtDate = (current: any) => {
|
||||||
|
if (!formData.value.swdt) return false;
|
||||||
|
return current && current < dayjs(formData.value.swdt).startOf('day');
|
||||||
|
};
|
||||||
|
|
||||||
watch(() => formData.value, newData => {
|
watch(() => formData.value, newData => {
|
||||||
const original = originalRecord.value;
|
const original = originalRecord.value;
|
||||||
for (const key in newData) {
|
for (const key in newData) {
|
||||||
@ -195,7 +219,7 @@ watch(() => formData.value, newData => {
|
|||||||
if (oldNorm === newNorm) continue;
|
if (oldNorm === newNorm) continue;
|
||||||
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect ? resolveSelectLabel(key, oldNorm) : oldNorm === null ? '空' : String(oldNorm);
|
const oldDisplay = isSelect ? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)) : oldNorm === null ? '空' : String(oldNorm);
|
||||||
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
||||||
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
||||||
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
||||||
@ -206,15 +230,54 @@ watch(() => formData.value, newData => {
|
|||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(() => props.record, newRecord => {
|
watch(() => props.record, newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// 加载电站下拉(支持按 baseId 筛选)
|
// 加载电站下拉(支持按 baseId 筛选)
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
@ -235,11 +298,15 @@ const loadDropdownData = () => {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }));
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 水电基地变化时联动电站
|
// 水电基地变化时联动电站
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -51,7 +51,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addVdInfo, updateVdInfo } from '@/api/DataQueryMenuModule';
|
import { addVdInfo, updateVdInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -71,6 +71,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -82,8 +83,10 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
jidiSelectEventStore.jidiData
|
||||||
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
);
|
);
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
|
|
||||||
@ -113,6 +116,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
return label.includes(inputValue || '');
|
return label.includes(inputValue || '');
|
||||||
@ -130,7 +143,7 @@ watch(() => formData.value, newData => {
|
|||||||
if (oldNorm === newNorm) continue;
|
if (oldNorm === newNorm) continue;
|
||||||
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect ? resolveSelectLabel(key, oldNorm) : oldNorm === null ? '空' : String(oldNorm);
|
const oldDisplay = isSelect ? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)) : oldNorm === null ? '空' : String(oldNorm);
|
||||||
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
||||||
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
||||||
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
||||||
@ -141,15 +154,54 @@ watch(() => formData.value, newData => {
|
|||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(() => props.record, newRecord => {
|
watch(() => props.record, newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// 加载电站下拉(支持按 baseId 筛选)
|
// 加载电站下拉(支持按 baseId 筛选)
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
@ -170,11 +222,15 @@ const loadDropdownData = () => {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }));
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 水电基地变化时联动电站
|
// 水电基地变化时联动电站
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -125,6 +125,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="3"
|
:rows="3"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -134,6 +136,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -152,7 +156,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addWeInfo, updateWeInfo } from '@/api/DataQueryMenuModule';
|
import { addWeInfo, updateWeInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -180,6 +184,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -192,7 +197,7 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
@ -242,6 +247,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -274,7 +289,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -303,19 +318,57 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 监听 record 变化
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(
|
watch(
|
||||||
() => props.record,
|
() => props.record,
|
||||||
newRecord => {
|
newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// 加载电站下拉(支持按 baseId 筛选)
|
// 加载电站下拉(支持按 baseId 筛选)
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
@ -351,17 +404,15 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
// 从 store 获取水电基地数据
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 水电基地变化时联动电站
|
// 水电基地变化时联动电站
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -147,7 +147,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addWtInfo, updateWtInfo } from '@/api/DataQueryMenuModule';
|
import { addWtInfo, updateWtInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -175,6 +175,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -187,7 +188,7 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
@ -241,6 +242,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -273,7 +284,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -302,19 +313,57 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 监听 record 变化
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(
|
watch(
|
||||||
() => props.record,
|
() => props.record,
|
||||||
newRecord => {
|
newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -349,16 +398,14 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
// 从 store 获取水电基地数据
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -177,7 +177,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addWqInfo, updateWqInfo } from '@/api/DataQueryMenuModule';
|
import { addWqInfo, updateWqInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -206,6 +206,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -219,7 +220,7 @@ const engInfoOptions = ref<any[]>([]);
|
|||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
const wwqtgOptions = ref<any[]>([]);
|
const wwqtgOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
@ -282,6 +283,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -314,7 +325,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -343,19 +354,57 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 监听 record 变化
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(
|
watch(
|
||||||
() => props.record,
|
() => props.record,
|
||||||
newRecord => {
|
newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions, wwqtgOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -399,15 +448,14 @@ const loadDropdownData = () => {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -176,6 +176,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -185,6 +187,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -203,7 +207,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addSonarInfo, updateSonarInfo } from '@/api/DataQueryMenuModule';
|
import { addSonarInfo, updateSonarInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -231,18 +235,20 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
stcd: [{ required: true, message: '请输入站码', trigger: 'blur' }],
|
stcd: [{ required: true, message: '请输入站码', trigger: 'blur' }],
|
||||||
stnm: [{ required: true, message: '请输入站名', trigger: 'blur' }],
|
stnm: [{ required: true, message: '请输入站名', trigger: 'blur' }],
|
||||||
sttp: [{ required: true, message: '请选择监控类别', trigger: 'change' }]
|
sttp: [{ required: true, message: '请选择监控类别', trigger: 'change' }],
|
||||||
|
mntp: [{ required: true, message: '请输入监控类型', trigger: 'blur' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
@ -304,6 +310,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -335,7 +351,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -363,17 +379,52 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
// 监听 record 变化
|
||||||
() => props.record,
|
const isInitLoading = ref(false);
|
||||||
newRecord => {
|
watch(() => props.record, newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
const converted = { ...newRecord };
|
isInitLoading.value = true;
|
||||||
originalRecord.value = { ...converted };
|
const converted = { ...newRecord };
|
||||||
formData.value = { ...converted };
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
changeOrder.value = [];
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
originalRecord.value = { ...converted };
|
||||||
{ deep: true }
|
formData.value = { ...converted };
|
||||||
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
@ -408,15 +459,14 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
// baseNameOptions 已改为 computed,无需手动赋值
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -179,6 +179,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -188,6 +190,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -206,7 +210,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addDwInfo, updateDwInfo } from '@/api/DataQueryMenuModule';
|
import { addDwInfo, updateDwInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -234,6 +238,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -246,7 +251,7 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({
|
||||||
@ -310,6 +315,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -342,7 +357,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -371,19 +386,57 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 监听 record 变化
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(
|
watch(
|
||||||
() => props.record,
|
() => props.record,
|
||||||
newRecord => {
|
newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -418,15 +471,14 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -187,6 +187,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.introduce"
|
v-model:value="formData.introduce"
|
||||||
placeholder="请输入简介"
|
placeholder="请输入简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -196,6 +198,8 @@
|
|||||||
<a-textarea
|
<a-textarea
|
||||||
v-model:value="formData.remark"
|
v-model:value="formData.remark"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
|
:maxlength="150"
|
||||||
|
show-count
|
||||||
:rows="2"
|
:rows="2"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@ -214,7 +218,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addOtteInfo, updateOtteInfo } from '@/api/DataQueryMenuModule';
|
import { addOtteInfo, updateOtteInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -242,6 +246,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -254,13 +259,10 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
@ -325,6 +327,16 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
const keyword = inputValue || '';
|
const keyword = inputValue || '';
|
||||||
@ -356,7 +368,7 @@ watch(
|
|||||||
continue;
|
continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect
|
const oldDisplay = isSelect
|
||||||
? resolveSelectLabel(key, oldNorm)
|
? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm))
|
||||||
: oldNorm === null
|
: oldNorm === null
|
||||||
? '空'
|
? '空'
|
||||||
: String(oldNorm);
|
: String(oldNorm);
|
||||||
@ -384,19 +396,58 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(
|
watch(
|
||||||
() => props.record,
|
() => props.record,
|
||||||
newRecord => {
|
newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -429,15 +480,14 @@ const loadDropdownData = () => {
|
|||||||
value: item.sttpCode
|
value: item.sttpCode
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.wbsName,
|
|
||||||
value: item.wbsCode
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -57,12 +57,12 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="开工日期" name="swdt">
|
<a-form-item label="开工日期" name="swdt">
|
||||||
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开工日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开工日期" :disabled-date="disabledSwdtDate" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
<a-form-item label="建成日期" name="jcdt">
|
<a-form-item label="建成日期" name="jcdt">
|
||||||
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择建成日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择建成日期" :disabled-date="disabledJcdtDate" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8">
|
<a-col :span="8">
|
||||||
@ -123,7 +123,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addFbInfo, updateFbInfo } from '@/api/DataQueryMenuModule';
|
import { addFbInfo, updateFbInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -143,6 +144,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -154,7 +156,7 @@ const formRules = ref<any>({
|
|||||||
const engInfoOptions = ref<any[]>([]);
|
const engInfoOptions = ref<any[]>([]);
|
||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData
|
jidiSelectEventStore.jidiData
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
.filter((item: any) => item.wbsCode !== 'all')
|
||||||
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
@ -189,11 +191,32 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
return label.includes(inputValue || '');
|
return label.includes(inputValue || '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 开工日期不能晚于建成日期
|
||||||
|
const disabledSwdtDate = (current: any) => {
|
||||||
|
if (!formData.value.jcdt) return false;
|
||||||
|
return current && current > dayjs(formData.value.jcdt).endOf('day');
|
||||||
|
};
|
||||||
|
// 建成日期不能早于开工日期
|
||||||
|
const disabledJcdtDate = (current: any) => {
|
||||||
|
if (!formData.value.swdt) return false;
|
||||||
|
return current && current < dayjs(formData.value.swdt).startOf('day');
|
||||||
|
};
|
||||||
|
|
||||||
watch(() => formData.value, newData => {
|
watch(() => formData.value, newData => {
|
||||||
const original = originalRecord.value;
|
const original = originalRecord.value;
|
||||||
for (const key in newData) {
|
for (const key in newData) {
|
||||||
@ -206,7 +229,7 @@ watch(() => formData.value, newData => {
|
|||||||
if (oldNorm === newNorm) continue;
|
if (oldNorm === newNorm) continue;
|
||||||
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect ? resolveSelectLabel(key, oldNorm) : oldNorm === null ? '空' : String(oldNorm);
|
const oldDisplay = isSelect ? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)) : oldNorm === null ? '空' : String(oldNorm);
|
||||||
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
||||||
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
||||||
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
||||||
@ -217,15 +240,54 @@ watch(() => formData.value, newData => {
|
|||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(() => props.record, newRecord => {
|
watch(() => props.record, newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -245,13 +307,15 @@ const loadDropdownData = () => {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
.filter((item: any) => item.wbsCode !== 'all')
|
|
||||||
.map((item: any) => ({ label: item.wbsName, value: item.wbsCode }));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 水电基地变化时联动电站
|
// 水电基地变化时联动电站
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -50,12 +50,12 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="开工日期" name="swdt">
|
<a-form-item label="开工日期" name="swdt">
|
||||||
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开工日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.swdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled-date="disabledSwdtDate" placeholder="请选择开工日期" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="建成日期" name="jcdt">
|
<a-form-item label="建成日期" name="jcdt">
|
||||||
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择建成日期" style="width: 100%" />
|
<a-date-picker v-model:value="formData.jcdt" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择建成日期" style="width: 100%" :disabled-date="disabledJcdtDate" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
@ -81,7 +81,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch, nextTick } from 'vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { addVpInfo, updateVpInfo } from '@/api/DataQueryMenuModule';
|
import { addVpInfo, updateVpInfo } from '@/api/DataQueryMenuModule';
|
||||||
import { getEngInfoDropdown } from '@/api/select';
|
import { getEngInfoDropdown } from '@/api/select';
|
||||||
@ -101,6 +102,7 @@ const formRef = ref();
|
|||||||
const confirmLoading = ref(false);
|
const confirmLoading = ref(false);
|
||||||
const formData = ref<any>({});
|
const formData = ref<any>({});
|
||||||
const originalRecord = ref<any>({});
|
const originalRecord = ref<any>({});
|
||||||
|
const originalLabels = ref<Record<string, string>>({});
|
||||||
const confirmModalVisible = ref(false);
|
const confirmModalVisible = ref(false);
|
||||||
|
|
||||||
const formRules = ref<any>({
|
const formRules = ref<any>({
|
||||||
@ -113,14 +115,14 @@ const engInfoOptions = ref<any[]>([]);
|
|||||||
const sttpOptions = ref<any[]>([]);
|
const sttpOptions = ref<any[]>([]);
|
||||||
const engLoading = ref(false);
|
const engLoading = ref(false);
|
||||||
|
|
||||||
const baseNameOptions = ref<any[]>(
|
const baseNameOptions = computed(() =>
|
||||||
jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }))
|
||||||
);
|
);
|
||||||
|
|
||||||
const fieldLabelMap: Record<string, string> = {
|
const fieldLabelMap: Record<string, string> = {
|
||||||
stcd: '植物园编码', stnm: '植物园名称', stlc: '站址', sttp: '测站类型',
|
stcd: '植物园编码', stnm: '植物园名称', stlc: '站址', sttp: '测站类型',
|
||||||
baseId: '水电基地', rstcd: '所属电站', swdt: '开工日期', jcdt: '建成日期',
|
baseId: '水电基地', rstcd: '所属电站', swdt: '开工日期', jcdt: '建成日期',
|
||||||
bhfs: '保护方式', area: '面积(km²)', inv: '投资(亿元)',
|
bhfs: '保护方式', area: '面积(km²)', inv: '投资(亿元)',
|
||||||
lgtd: '经度(°)', lttd: '纬度(°)'
|
lgtd: '经度(°)', lttd: '纬度(°)'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -143,11 +145,33 @@ const resolveSelectLabel = (field: string, value: any): string => {
|
|||||||
return String(value);
|
return String(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 解析原始值的显示名:rstcd 直接用 record 自带的电站名称 ennm,不依赖异步选项
|
||||||
|
const resolveOriginalLabel = (field: string): string => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (field === 'rstcd') {
|
||||||
|
const ennm = original.ennm || original.rstcdName;
|
||||||
|
if (ennm) return String(ennm);
|
||||||
|
}
|
||||||
|
return resolveSelectLabel(field, original[field]);
|
||||||
|
};
|
||||||
|
|
||||||
const filterOption = (inputValue: string, option: any) => {
|
const filterOption = (inputValue: string, option: any) => {
|
||||||
const label = option.label || option.value;
|
const label = option.label || option.value;
|
||||||
return label.includes(inputValue || '');
|
return label.includes(inputValue || '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 开工日期不能晚于建成日期
|
||||||
|
const disabledSwdtDate = (current: any) => {
|
||||||
|
if (!formData.value.jcdt) return false;
|
||||||
|
return current && current > dayjs(formData.value.jcdt).endOf('day');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 建成日期不能早于开工日期
|
||||||
|
const disabledJcdtDate = (current: any) => {
|
||||||
|
if (!formData.value.swdt) return false;
|
||||||
|
return current && current < dayjs(formData.value.swdt).startOf('day');
|
||||||
|
};
|
||||||
|
|
||||||
watch(() => formData.value, newData => {
|
watch(() => formData.value, newData => {
|
||||||
const original = originalRecord.value;
|
const original = originalRecord.value;
|
||||||
for (const key in newData) {
|
for (const key in newData) {
|
||||||
@ -160,7 +184,7 @@ watch(() => formData.value, newData => {
|
|||||||
if (oldNorm === newNorm) continue;
|
if (oldNorm === newNorm) continue;
|
||||||
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
if (oldNorm !== null && newNorm !== null && !isNaN(Number(oldNorm)) && !isNaN(Number(newNorm)) && Number(oldNorm) === Number(newNorm)) continue;
|
||||||
const isSelect = !!selectOptionsMap[key];
|
const isSelect = !!selectOptionsMap[key];
|
||||||
const oldDisplay = isSelect ? resolveSelectLabel(key, oldNorm) : oldNorm === null ? '空' : String(oldNorm);
|
const oldDisplay = isSelect ? (originalLabels.value[key] ?? resolveSelectLabel(key, oldNorm)) : oldNorm === null ? '空' : String(oldNorm);
|
||||||
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
const newDisplay = isSelect ? resolveSelectLabel(key, newNorm) : newNorm === null ? '空' : String(newNorm);
|
||||||
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
const entry = { field: key, label: fieldLabelMap[key] || key, oldValue: oldDisplay, newValue: newDisplay };
|
||||||
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
if (existingIdx >= 0) changeOrder.value[existingIdx] = entry;
|
||||||
@ -171,15 +195,54 @@ watch(() => formData.value, newData => {
|
|||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 监听 record 变化
|
||||||
|
const isInitLoading = ref(false);
|
||||||
watch(() => props.record, newRecord => {
|
watch(() => props.record, newRecord => {
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
|
isInitLoading.value = true;
|
||||||
const converted = { ...newRecord };
|
const converted = { ...newRecord };
|
||||||
|
// 将 "-" 还原为 null,避免 date-picker 显示 Invalid Date
|
||||||
|
for (const key in converted) {
|
||||||
|
if (converted[key] === '-') {
|
||||||
|
converted[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
originalRecord.value = { ...converted };
|
originalRecord.value = { ...converted };
|
||||||
formData.value = { ...converted };
|
formData.value = { ...converted };
|
||||||
changeOrder.value = [];
|
changeOrder.value = [];
|
||||||
|
// 编辑时必定加载电站选项,保证 rstcd 回显与 diff 解析
|
||||||
|
loadEngOptions(converted.baseId || undefined);
|
||||||
|
// 提前解析 select 字段的原始显示名,防止联动刷新选项后丢失 label
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in converted) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
// 表单填充完成后自动复位标志,避免残留 true 导致后续切换流域不清空电站
|
||||||
|
nextTick(() => {
|
||||||
|
isInitLoading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 选项加载完成后重新解析原始显示名,避免 record 加载时选项未就绪导致存成 code
|
||||||
|
watch(
|
||||||
|
[baseNameOptions, engInfoOptions, sttpOptions],
|
||||||
|
() => {
|
||||||
|
const original = originalRecord.value;
|
||||||
|
if (!original || Object.keys(original).length === 0) return;
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
for (const key in original) {
|
||||||
|
if (selectOptionsMap[key]) {
|
||||||
|
labels[key] = resolveOriginalLabel(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
originalLabels.value = labels;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const loadEngOptions = async (baseId?: string) => {
|
const loadEngOptions = async (baseId?: string) => {
|
||||||
engLoading.value = true;
|
engLoading.value = true;
|
||||||
try {
|
try {
|
||||||
@ -199,11 +262,15 @@ const loadDropdownData = () => {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
sttpOptions.value = (res.data?.data || []).map((item: any) => ({ label: item.sttpName, value: item.sttpCode }));
|
||||||
});
|
});
|
||||||
baseNameOptions.value = jidiSelectEventStore.jidiData.filter((item: any) => item.wbsCode !== 'all').map((item: any) => ({ label: item.wbsName, value: item.wbsCode }));
|
// 从 store 获取水电基地数据(computed 已自动响应,无需手动赋值)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 水电基地变化时联动电站
|
// 水电基地变化时联动电站
|
||||||
watch(() => formData.value?.baseId, (newBaseId) => {
|
watch(() => formData.value?.baseId, (newBaseId) => {
|
||||||
|
// record 加载时已在 record watch 中加载过电站选项,这里仅跳过清空
|
||||||
|
if (isInitLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
formData.value.rstcd = undefined;
|
formData.value.rstcd = undefined;
|
||||||
loadEngOptions(newBaseId || undefined);
|
loadEngOptions(newBaseId || undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
placeholder="起始时间"
|
placeholder="起始时间"
|
||||||
|
:allow-clear="false"
|
||||||
:showToday="false"
|
:showToday="false"
|
||||||
>
|
>
|
||||||
<template #renderExtraFooter>
|
<template #renderExtraFooter>
|
||||||
@ -33,6 +34,7 @@
|
|||||||
<a-form-item-rest>
|
<a-form-item-rest>
|
||||||
<a-date-picker
|
<a-date-picker
|
||||||
class="w-[120px]"
|
class="w-[120px]"
|
||||||
|
:allow-clear="false"
|
||||||
v-model:value="jcdt.max"
|
v-model:value="jcdt.max"
|
||||||
format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
|||||||
@ -119,7 +119,7 @@ const tableScrollX = computed(() =>
|
|||||||
// 人工列
|
// 人工列
|
||||||
const columnsManual: any[] = [
|
const columnsManual: any[] = [
|
||||||
{
|
{
|
||||||
key: 'stnm',
|
key: 'ennm',
|
||||||
title: '电站名称',
|
title: '电站名称',
|
||||||
dataIndex: 'stnm',
|
dataIndex: 'stnm',
|
||||||
visible: true,
|
visible: true,
|
||||||
@ -261,9 +261,9 @@ const columnsManual: any[] = [
|
|||||||
// 自动列
|
// 自动列
|
||||||
const columnsAuto: any[] = [
|
const columnsAuto: any[] = [
|
||||||
{
|
{
|
||||||
key: 'stnm',
|
key: 'ennm',
|
||||||
title: '电站名称',
|
title: '电站名称',
|
||||||
dataIndex: 'stnm',
|
dataIndex: 'ennm',
|
||||||
visible: true,
|
visible: true,
|
||||||
width: 200,
|
width: 200,
|
||||||
sort: true,
|
sort: true,
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
v-model:value="jcdt.min"
|
v-model:value="jcdt.min"
|
||||||
:format="timeFormat"
|
:format="timeFormat"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
:allow-clear="false"
|
||||||
:picker="timePicker"
|
:picker="timePicker"
|
||||||
:showTime="timeShowTime"
|
:showTime="timeShowTime"
|
||||||
placeholder="起始时间"
|
placeholder="起始时间"
|
||||||
@ -40,6 +41,7 @@
|
|||||||
:format="timeFormat"
|
:format="timeFormat"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
:picker="timePicker"
|
:picker="timePicker"
|
||||||
|
:allow-clear="false"
|
||||||
:showTime="timeShowTime"
|
:showTime="timeShowTime"
|
||||||
:disabledDate="disabledEndDate"
|
:disabledDate="disabledEndDate"
|
||||||
placeholder="结束时间"
|
placeholder="结束时间"
|
||||||
|
|||||||
@ -363,6 +363,7 @@ const displayColumns = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onSearchFinish = async (values: any) => {
|
const onSearchFinish = async (values: any) => {
|
||||||
|
// debugger
|
||||||
currentSearchParams.value = values;
|
currentSearchParams.value = values;
|
||||||
await nextTick();
|
await nextTick();
|
||||||
initTable(values);
|
initTable(values);
|
||||||
@ -438,7 +439,7 @@ const initTable = (values: any) => {
|
|||||||
: null,
|
: null,
|
||||||
values.rstcd
|
values.rstcd
|
||||||
? {
|
? {
|
||||||
field: 'rstcd',
|
field: 'stcd',
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.rstcd
|
value: values.rstcd
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
:picker="timePicker"
|
:picker="timePicker"
|
||||||
:showTime="timeShowTime"
|
:showTime="timeShowTime"
|
||||||
|
:allow-clear="false"
|
||||||
placeholder="起始时间"
|
placeholder="起始时间"
|
||||||
:showToday="false"
|
:showToday="false"
|
||||||
:showNow="false"
|
:showNow="false"
|
||||||
@ -42,6 +43,7 @@
|
|||||||
:picker="timePicker"
|
:picker="timePicker"
|
||||||
:showTime="timeShowTime"
|
:showTime="timeShowTime"
|
||||||
:disabledDate="disabledEndDate"
|
:disabledDate="disabledEndDate"
|
||||||
|
:allow-clear="false"
|
||||||
placeholder="结束时间"
|
placeholder="结束时间"
|
||||||
:showToday="false"
|
:showToday="false"
|
||||||
:showNow="false"
|
:showNow="false"
|
||||||
|
|||||||
@ -593,8 +593,7 @@ const transformData = (data: any) => {
|
|||||||
})
|
})
|
||||||
.reverse();
|
.reverse();
|
||||||
|
|
||||||
const total = data?.data?.data?.[0]?.total || 0;
|
const total = data?.data?.total || 0;
|
||||||
|
|
||||||
tableData.value = formattedData;
|
tableData.value = formattedData;
|
||||||
|
|
||||||
// 初始化图表:默认选中第一条
|
// 初始化图表:默认选中第一条
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
:picker="timePicker"
|
:picker="timePicker"
|
||||||
:showTime="timeShowTime"
|
:showTime="timeShowTime"
|
||||||
placeholder="起始时间"
|
placeholder="起始时间"
|
||||||
|
:allow-clear="false"
|
||||||
:showToday="false"
|
:showToday="false"
|
||||||
:showNow="false"
|
:showNow="false"
|
||||||
>
|
>
|
||||||
@ -43,6 +44,7 @@
|
|||||||
:showTime="timeShowTime"
|
:showTime="timeShowTime"
|
||||||
:disabledDate="disabledEndDate"
|
:disabledDate="disabledEndDate"
|
||||||
placeholder="结束时间"
|
placeholder="结束时间"
|
||||||
|
:allow-clear="false"
|
||||||
:showToday="false"
|
:showToday="false"
|
||||||
:showNow="false"
|
:showNow="false"
|
||||||
>
|
>
|
||||||
|
|||||||
@ -5,7 +5,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive, ref, nextTick } from 'vue';
|
import { onMounted, reactive, ref, nextTick, watch } from 'vue';
|
||||||
import { ElMessage, ElMessageBox, FormRules } from 'element-plus';
|
import { ElMessage, ElMessageBox, FormRules } from 'element-plus';
|
||||||
import Sortable from 'sortablejs';
|
import Sortable from 'sortablejs';
|
||||||
import { useAppStore } from '@/store/modules/app';
|
import { useAppStore } from '@/store/modules/app';
|
||||||
@ -31,6 +31,17 @@ const treedata: any = ref([]);
|
|||||||
const treeRef = ref();
|
const treeRef = ref();
|
||||||
const treeId = ref('');
|
const treeId = ref('');
|
||||||
const defaultProps = { label: 'dictName' };
|
const defaultProps = { label: 'dictName' };
|
||||||
|
// 树搜索
|
||||||
|
const treeFilterText = ref('');
|
||||||
|
|
||||||
|
function filterNode(value: string, data: any) {
|
||||||
|
if (!value) return true;
|
||||||
|
return data.dictName?.includes(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(treeFilterText, (val) => {
|
||||||
|
treeRef.value?.filter(val);
|
||||||
|
});
|
||||||
// 字典弹框
|
// 字典弹框
|
||||||
const title = ref('');
|
const title = ref('');
|
||||||
const dialogdict = ref(false);
|
const dialogdict = ref(false);
|
||||||
@ -432,6 +443,12 @@ const total = ref();
|
|||||||
/>
|
/>
|
||||||
新增字典</el-button
|
新增字典</el-button
|
||||||
>
|
>
|
||||||
|
<el-input
|
||||||
|
v-model="treeFilterText"
|
||||||
|
placeholder="请输入关键字过滤"
|
||||||
|
clearable
|
||||||
|
style="margin-bottom: 10px"
|
||||||
|
/>
|
||||||
<el-tree
|
<el-tree
|
||||||
v-loading="treeloading"
|
v-loading="treeloading"
|
||||||
ref="treeRef"
|
ref="treeRef"
|
||||||
@ -446,9 +463,10 @@ const total = ref();
|
|||||||
draggable
|
draggable
|
||||||
:highlight-current="true"
|
:highlight-current="true"
|
||||||
:props="defaultProps"
|
:props="defaultProps"
|
||||||
|
:filter-node-method="filterNode"
|
||||||
@node-click="handleNodeClick"
|
@node-click="handleNodeClick"
|
||||||
@node-drop="treenodeDrop"
|
@node-drop="treenodeDrop"
|
||||||
style="height: calc(100vh - 254px); overflow: auto"
|
style="height: calc(100vh - 304px); overflow: auto"
|
||||||
>
|
>
|
||||||
<template #default="{ node, data }">
|
<template #default="{ node, data }">
|
||||||
<span class="custom-tree-node">
|
<span class="custom-tree-node">
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import {
|
|||||||
addDept,
|
addDept,
|
||||||
renewDept,
|
renewDept,
|
||||||
deleDept,
|
deleDept,
|
||||||
assignmentPer,
|
permissionAssignmentGrouped,
|
||||||
setMenuById,
|
setMenuById,
|
||||||
setOrgscope,
|
setOrgscope,
|
||||||
postOrgscope
|
postOrgscope
|
||||||
@ -28,7 +28,8 @@ const tree = ref();
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
function gettableData() {
|
function gettableData() {
|
||||||
let params = {
|
let params = {
|
||||||
rolename: input.value
|
rolename: input.value,
|
||||||
|
tenantId: '2'
|
||||||
};
|
};
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listRolePages(params)
|
listRolePages(params)
|
||||||
@ -115,7 +116,8 @@ function confirmClick(formEl: any) {
|
|||||||
const params = {
|
const params = {
|
||||||
rolename: info.value.rolename,
|
rolename: info.value.rolename,
|
||||||
level: info.value.level,
|
level: info.value.level,
|
||||||
description: info.value.description
|
description: info.value.description,
|
||||||
|
tenantId:'2'
|
||||||
};
|
};
|
||||||
addDept(params).then(() => {
|
addDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
@ -126,7 +128,8 @@ function confirmClick(formEl: any) {
|
|||||||
rolename: info.value.rolename,
|
rolename: info.value.rolename,
|
||||||
level: info.value.level,
|
level: info.value.level,
|
||||||
description: info.value.description,
|
description: info.value.description,
|
||||||
id: info.value.id
|
id: info.value.id,
|
||||||
|
tenantId:'2'
|
||||||
};
|
};
|
||||||
renewDept(params).then(() => {
|
renewDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
@ -274,12 +277,13 @@ function assignment(row: any) {
|
|||||||
rowid.value = row.id;
|
rowid.value = row.id;
|
||||||
accessVisible.value = true;
|
accessVisible.value = true;
|
||||||
const params = {
|
const params = {
|
||||||
roleId: rowid.value
|
roleId: rowid.value,
|
||||||
|
tenantId: '2'
|
||||||
};
|
};
|
||||||
assignmentPer(params).then((res: any) => {
|
permissionAssignmentGrouped(params).then((res: any) => {
|
||||||
accessdata.value = res;
|
accessdata.value = res[0]?.menus || [];
|
||||||
let ids: any = [];
|
let ids: any = [];
|
||||||
menuChange(res, ids);
|
menuChange(res[0]?.menus, ids);
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
tree.value.setCheckedKeys(ids);
|
tree.value.setCheckedKeys(ids);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -51,6 +51,14 @@ export function assignmentPer (queryParams:any){
|
|||||||
params: queryParams
|
params: queryParams
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//获取分配权限(改动之后)
|
||||||
|
export function permissionAssignmentGrouped (queryParams:any){
|
||||||
|
return request({
|
||||||
|
url:'/system/menu/permissionAssignmentGrouped' ,
|
||||||
|
method: 'post',
|
||||||
|
params: queryParams
|
||||||
|
});
|
||||||
|
}
|
||||||
//发出分配权限
|
//发出分配权限
|
||||||
export function setMenuById (queryParams:any){
|
export function setMenuById (queryParams:any){
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const basicSearchRef = ref<any>();
|
|||||||
const btnLoading = ref<boolean>(false);
|
const btnLoading = ref<boolean>(false);
|
||||||
|
|
||||||
const initSearchData = {
|
const initSearchData = {
|
||||||
rvcd: 'all',
|
reachcd: 'all',
|
||||||
stcd: null,
|
stcd: null,
|
||||||
reportMonth: dayjs().subtract(1, 'month').format('YYYY-MM')
|
reportMonth: dayjs().subtract(1, 'month').format('YYYY-MM')
|
||||||
};
|
};
|
||||||
@ -57,7 +57,7 @@ const searchData = ref<any>({ ...initSearchData });
|
|||||||
const searchList: any = computed(() => [
|
const searchList: any = computed(() => [
|
||||||
{
|
{
|
||||||
type: 'waterStation',
|
type: 'waterStation',
|
||||||
name: 'rvcd',
|
name: 'reachcd',
|
||||||
label: '流域',
|
label: '流域',
|
||||||
fieldProps: {
|
fieldProps: {
|
||||||
allowClear: true
|
allowClear: true
|
||||||
@ -86,7 +86,7 @@ const onValuesChange = (changedValues: any, allValues: any) => {
|
|||||||
searchData.value = { ...searchData.value, ...allValues };
|
searchData.value = { ...searchData.value, ...allValues };
|
||||||
if (
|
if (
|
||||||
Object.keys(changedValues)[0] == 'rstcd' ||
|
Object.keys(changedValues)[0] == 'rstcd' ||
|
||||||
Object.keys(changedValues)[0] == 'rvcd'
|
Object.keys(changedValues)[0] == 'reachcd'
|
||||||
) {
|
) {
|
||||||
const formInstance = basicSearchRef.value?.formData;
|
const formInstance = basicSearchRef.value?.formData;
|
||||||
formInstance.stcd = null;
|
formInstance.stcd = null;
|
||||||
|
|||||||
@ -353,11 +353,11 @@ const handleDetailSearchFinish = (values: any) => {
|
|||||||
dataType: 'date',
|
dataType: 'date',
|
||||||
value: values.strdt[1] + ' 23:59:59'
|
value: values.strdt[1] + ' 23:59:59'
|
||||||
},
|
},
|
||||||
values.rvcd !== 'all' && {
|
values.reachcd !== 'all' && {
|
||||||
field: 'basinCode',
|
field: 'basinCode',
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.rvcd
|
value: values.reachcd
|
||||||
},
|
},
|
||||||
values.rstcd && {
|
values.rstcd && {
|
||||||
field: 'stationCode',
|
field: 'stationCode',
|
||||||
|
|||||||
@ -35,7 +35,7 @@ const localTypeDate = ref<string>(null);
|
|||||||
const basicSearchRef = ref<any>();
|
const basicSearchRef = ref<any>();
|
||||||
|
|
||||||
const initSearchData = {
|
const initSearchData = {
|
||||||
rvcd: "all",
|
reachcd: "all",
|
||||||
stcd: null,
|
stcd: null,
|
||||||
rstcd: null,
|
rstcd: null,
|
||||||
ftp: null,
|
ftp: null,
|
||||||
@ -52,7 +52,7 @@ const searchData = ref<any>({ ...initSearchData });
|
|||||||
const searchList: any = computed(() => [
|
const searchList: any = computed(() => [
|
||||||
{
|
{
|
||||||
type: "waterStation",
|
type: "waterStation",
|
||||||
name: "rvcd",
|
name: "reachcd",
|
||||||
label: "流域",
|
label: "流域",
|
||||||
fieldProps: {
|
fieldProps: {
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
@ -121,7 +121,7 @@ const onValuesChange = (changedValues: any, allValues: any) => {
|
|||||||
if (
|
if (
|
||||||
Object.keys(changedValues)[0] == "rstcd" ||
|
Object.keys(changedValues)[0] == "rstcd" ||
|
||||||
Object.keys(changedValues)[0] == "baseId" ||
|
Object.keys(changedValues)[0] == "baseId" ||
|
||||||
Object.keys(changedValues)[0] == "rvcd"
|
Object.keys(changedValues)[0] == "reachcd"
|
||||||
) {
|
) {
|
||||||
const formInstance = basicSearchRef.value?.formData;
|
const formInstance = basicSearchRef.value?.formData;
|
||||||
formInstance.stcd = null;
|
formInstance.stcd = null;
|
||||||
|
|||||||
@ -315,11 +315,11 @@ const handleSearchFinish = (values: any) => {
|
|||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.rstcd
|
value: values.rstcd
|
||||||
},
|
},
|
||||||
values.rvcd !== 'all' && {
|
values.reachcd !== 'all' && {
|
||||||
field: 'rvcd',
|
field: 'rvcd',
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.rvcd
|
value: values.reachcd
|
||||||
}
|
}
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
|
|||||||
@ -886,11 +886,17 @@ const handleSearchFinish = (values: any) => {
|
|||||||
value: values.rstcd
|
value: values.rstcd
|
||||||
},
|
},
|
||||||
values.reachcd !== 'all' && {
|
values.reachcd !== 'all' && {
|
||||||
field: 'reachcd',
|
field: 'rvcd',
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.reachcd
|
value: values.reachcd
|
||||||
}
|
},
|
||||||
|
// values.rvcd !== 'all' && {
|
||||||
|
// field: 'reachcd',
|
||||||
|
// operator: 'eq',
|
||||||
|
// dataType: 'string',
|
||||||
|
// value: values.reachcd
|
||||||
|
// }
|
||||||
// values.baseId !== "all" && {
|
// values.baseId !== "all" && {
|
||||||
// field: "baseId",
|
// field: "baseId",
|
||||||
// operator: "eq",
|
// operator: "eq",
|
||||||
|
|||||||
@ -30,7 +30,7 @@ const localTypeDate = ref<string>(null);
|
|||||||
const basicSearchRef = ref<any>();
|
const basicSearchRef = ref<any>();
|
||||||
|
|
||||||
const initSearchData = {
|
const initSearchData = {
|
||||||
rvcd: 'all',
|
reachcd: 'all',
|
||||||
stcd: null,
|
stcd: null,
|
||||||
rstcd: null
|
rstcd: null
|
||||||
// strdt: [
|
// strdt: [
|
||||||
@ -44,7 +44,7 @@ const searchData = ref<any>({ ...initSearchData });
|
|||||||
const searchList: any = computed(() => [
|
const searchList: any = computed(() => [
|
||||||
{
|
{
|
||||||
type: 'waterStation',
|
type: 'waterStation',
|
||||||
name: 'rvcd',
|
name: 'reachcd',
|
||||||
label: '流域',
|
label: '流域',
|
||||||
fieldProps: {
|
fieldProps: {
|
||||||
allowClear: true
|
allowClear: true
|
||||||
@ -74,7 +74,7 @@ const onValuesChange = (changedValues: any, allValues: any) => {
|
|||||||
searchData.value = { ...searchData.value, ...allValues };
|
searchData.value = { ...searchData.value, ...allValues };
|
||||||
if (
|
if (
|
||||||
Object.keys(changedValues)[0] == 'rstcd' ||
|
Object.keys(changedValues)[0] == 'rstcd' ||
|
||||||
Object.keys(changedValues)[0] == 'rvcd'
|
Object.keys(changedValues)[0] == 'reachcd'
|
||||||
) {
|
) {
|
||||||
const formInstance = basicSearchRef.value?.formData;
|
const formInstance = basicSearchRef.value?.formData;
|
||||||
formInstance.stcd = null;
|
formInstance.stcd = null;
|
||||||
|
|||||||
@ -361,11 +361,11 @@ const handleSearchFinish = (values: any) => {
|
|||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.status
|
value: values.status
|
||||||
},
|
},
|
||||||
values.rvcd !== 'all' && {
|
values.reachcd !== 'all' && {
|
||||||
field: 'rvcd',
|
field: 'rvcd',
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.rvcd
|
value: values.reachcd
|
||||||
},
|
},
|
||||||
values.stcd && {
|
values.stcd && {
|
||||||
field: 'stcd',
|
field: 'stcd',
|
||||||
@ -605,11 +605,11 @@ const handleDetailSearchFinish = (values: any) => {
|
|||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.rstcd
|
value: values.rstcd
|
||||||
},
|
},
|
||||||
values.rvcd !== 'all' && {
|
values.reachcd !== 'all' && {
|
||||||
field: 'rvcd',
|
field: 'rvcd',
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
dataType: 'string',
|
dataType: 'string',
|
||||||
value: values.rvcd
|
value: values.reachcd
|
||||||
},
|
},
|
||||||
approvalId.value && {
|
approvalId.value && {
|
||||||
field: 'approvalId', // 字段名
|
field: 'approvalId', // 字段名
|
||||||
|
|||||||
@ -61,7 +61,7 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
// 模拟 initSearchData
|
// 模拟 initSearchData
|
||||||
const initSearchData = {
|
const initSearchData = {
|
||||||
rvcd: "all",
|
reachcd: "all",
|
||||||
stcd: "",
|
stcd: "",
|
||||||
status: "",
|
status: "",
|
||||||
};
|
};
|
||||||
@ -71,7 +71,7 @@ const searchData = ref<any>({ ...initSearchData });
|
|||||||
const searchList: any = computed(() => [
|
const searchList: any = computed(() => [
|
||||||
{
|
{
|
||||||
type: "waterStation",
|
type: "waterStation",
|
||||||
name: "rvcd",
|
name: "reachcd",
|
||||||
label: "流域",
|
label: "流域",
|
||||||
fieldProps: {
|
fieldProps: {
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
name: "role",
|
name: 'role'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, nextTick } from "vue";
|
import { onMounted, ref, nextTick } from 'vue';
|
||||||
import { ElForm, ElMessage, ElMessageBox } from "element-plus";
|
import { ElForm, ElMessage, ElMessageBox } from 'element-plus';
|
||||||
import {
|
import {
|
||||||
listRolePages,
|
listRolePages,
|
||||||
isvaildTo,
|
isvaildTo,
|
||||||
addDept,
|
addDept,
|
||||||
renewDept,
|
renewDept,
|
||||||
deleDept,
|
deleDept,
|
||||||
assignmentPer,
|
permissionAssignmentGrouped,
|
||||||
setMenuById,
|
setMenuById,
|
||||||
setOrgscope,
|
setOrgscope,
|
||||||
postOrgscope,
|
postOrgscope
|
||||||
} from "@/api/role";
|
} from '@/api/role';
|
||||||
//定义表格数据
|
//定义表格数据
|
||||||
const tableData: any = ref([]);
|
const tableData: any = ref([]);
|
||||||
const multipleSelection = ref([]);
|
const multipleSelection = ref([]);
|
||||||
@ -29,10 +29,11 @@ const loading = ref(false);
|
|||||||
function gettableData() {
|
function gettableData() {
|
||||||
let params = {
|
let params = {
|
||||||
rolename: input.value,
|
rolename: input.value,
|
||||||
|
tenantId: '4'
|
||||||
};
|
};
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listRolePages(params)
|
listRolePages(params)
|
||||||
.then((result) => {
|
.then(result => {
|
||||||
tableData.value = result;
|
tableData.value = result;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
})
|
})
|
||||||
@ -46,26 +47,26 @@ function handleSelectionChange(val: any) {
|
|||||||
}
|
}
|
||||||
function switchChange(row: any) {
|
function switchChange(row: any) {
|
||||||
const elMessage = ref();
|
const elMessage = ref();
|
||||||
if (row.isvaild == "0") {
|
if (row.isvaild == '0') {
|
||||||
elMessage.value = "确定设置该角色为无效吗?";
|
elMessage.value = '确定设置该角色为无效吗?';
|
||||||
} else if (row.isvaild == "1") {
|
} else if (row.isvaild == '1') {
|
||||||
elMessage.value = "确定设置该角色为有效吗?";
|
elMessage.value = '确定设置该角色为有效吗?';
|
||||||
}
|
}
|
||||||
ElMessageBox.confirm(elMessage.value, "提示信息", {
|
ElMessageBox.confirm(elMessage.value, '提示信息', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let params = {
|
let params = {
|
||||||
isvaild: row.isvaild,
|
isvaild: row.isvaild,
|
||||||
id: row.id,
|
id: row.id
|
||||||
};
|
};
|
||||||
isvaildTo(params).then(() => {
|
isvaildTo(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
ElMessage({
|
ElMessage({
|
||||||
type: "success",
|
type: 'success',
|
||||||
message: "改变成功",
|
message: '改变成功'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -75,35 +76,35 @@ function switchChange(row: any) {
|
|||||||
}
|
}
|
||||||
const infoForm = ref();
|
const infoForm = ref();
|
||||||
//搜索内容及点击搜索按钮
|
//搜索内容及点击搜索按钮
|
||||||
const input = ref("");
|
const input = ref('');
|
||||||
//新建角色
|
//新建角色
|
||||||
const title = ref("");
|
const title = ref('');
|
||||||
const info: any = ref({
|
const info: any = ref({
|
||||||
rolename: "",
|
rolename: '',
|
||||||
level: "2",
|
level: '2',
|
||||||
description: "",
|
description: ''
|
||||||
});
|
});
|
||||||
const faultList: any = [
|
const faultList: any = [
|
||||||
{
|
{
|
||||||
value: "1",
|
value: '1',
|
||||||
label: "超级管理员",
|
label: '超级管理员'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "2",
|
value: '2',
|
||||||
label: "系统管理员",
|
label: '系统管理员'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "3",
|
value: '3',
|
||||||
label: "一般用户",
|
label: '一般用户'
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
const dialogVisible = ref(false);
|
const dialogVisible = ref(false);
|
||||||
function addClick() {
|
function addClick() {
|
||||||
title.value = "新增角色";
|
title.value = '新增角色';
|
||||||
info.value = {
|
info.value = {
|
||||||
rolename: "",
|
rolename: '',
|
||||||
level: "2",
|
level: '2',
|
||||||
description: "",
|
description: ''
|
||||||
};
|
};
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
}
|
}
|
||||||
@ -116,6 +117,7 @@ function confirmClick(formEl: any) {
|
|||||||
rolename: info.value.rolename,
|
rolename: info.value.rolename,
|
||||||
level: info.value.level,
|
level: info.value.level,
|
||||||
description: info.value.description,
|
description: info.value.description,
|
||||||
|
tenantId: '4'
|
||||||
};
|
};
|
||||||
addDept(params).then(() => {
|
addDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
@ -127,6 +129,7 @@ function confirmClick(formEl: any) {
|
|||||||
level: info.value.level,
|
level: info.value.level,
|
||||||
description: info.value.description,
|
description: info.value.description,
|
||||||
id: info.value.id,
|
id: info.value.id,
|
||||||
|
tenantId: '4'
|
||||||
};
|
};
|
||||||
renewDept(params).then(() => {
|
renewDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
@ -150,12 +153,12 @@ function handleClose() {
|
|||||||
}
|
}
|
||||||
//新建角色-rules
|
//新建角色-rules
|
||||||
const rules = ref({
|
const rules = ref({
|
||||||
rolename: [{ required: true, message: "请输入角色名称", trigger: "blur" }],
|
rolename: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
|
||||||
level: [{ required: true, message: "请选择角色级别", trigger: "change" }],
|
level: [{ required: true, message: '请选择角色级别', trigger: 'change' }]
|
||||||
});
|
});
|
||||||
//修改角色
|
//修改角色
|
||||||
function editrole(row: any) {
|
function editrole(row: any) {
|
||||||
title.value = "修改角色";
|
title.value = '修改角色';
|
||||||
info.value = JSON.parse(JSON.stringify(row));
|
info.value = JSON.parse(JSON.stringify(row));
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
}
|
}
|
||||||
@ -163,9 +166,9 @@ function editrole(row: any) {
|
|||||||
const businessVisible = ref(false);
|
const businessVisible = ref(false);
|
||||||
function businessclick() {
|
function businessclick() {
|
||||||
// businessVisible.value = true;
|
// businessVisible.value = true;
|
||||||
ElMessageBox.confirm("此模块允许用户进行定制。", "提示信息", {
|
ElMessageBox.confirm('此模块允许用户进行定制。', '提示信息', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
type: "warning",
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
businessVisible.value = false;
|
businessVisible.value = false;
|
||||||
});
|
});
|
||||||
@ -178,14 +181,14 @@ function businessclick() {
|
|||||||
//组织范围修改
|
//组织范围修改
|
||||||
const organizeVisible = ref(false);
|
const organizeVisible = ref(false);
|
||||||
const deptdata = ref();
|
const deptdata = ref();
|
||||||
const roleIda = ref("");
|
const roleIda = ref('');
|
||||||
function organizeclick(row: any) {
|
function organizeclick(row: any) {
|
||||||
organizeVisible.value = true;
|
organizeVisible.value = true;
|
||||||
roleIda.value = row.id;
|
roleIda.value = row.id;
|
||||||
const params = {
|
const params = {
|
||||||
roleId: row.id,
|
roleId: row.id
|
||||||
};
|
};
|
||||||
setOrgscope(params).then((res) => {
|
setOrgscope(params).then(res => {
|
||||||
deptdata.value = res;
|
deptdata.value = res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -194,7 +197,9 @@ function accessCheckAllChange(indexone: any) {
|
|||||||
for (var j = 0; j < deptdata.value[indexone].children.length; j++) {
|
for (var j = 0; j < deptdata.value[indexone].children.length; j++) {
|
||||||
Arrayall.value.push(deptdata.value[indexone].children[j].orgname);
|
Arrayall.value.push(deptdata.value[indexone].children[j].orgname);
|
||||||
}
|
}
|
||||||
deptdata.value[indexone].array = deptdata.value[indexone].checkinfo ? Arrayall : [];
|
deptdata.value[indexone].array = deptdata.value[indexone].checkinfo
|
||||||
|
? Arrayall
|
||||||
|
: [];
|
||||||
deptdata.value[indexone].bool = false;
|
deptdata.value[indexone].bool = false;
|
||||||
}
|
}
|
||||||
function accessCheckedCitiesChanges(indexone: any) {
|
function accessCheckedCitiesChanges(indexone: any) {
|
||||||
@ -216,31 +221,31 @@ function organizesubmit() {
|
|||||||
});
|
});
|
||||||
const params = {
|
const params = {
|
||||||
id: roleIda.value,
|
id: roleIda.value,
|
||||||
orgscope: allid.value.toString(),
|
orgscope: allid.value.toString()
|
||||||
};
|
};
|
||||||
postOrgscope(params).then(() => {
|
postOrgscope(params).then(() => {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
type: "success",
|
type: 'success',
|
||||||
message: "组织范围修改成功",
|
message: '组织范围修改成功'
|
||||||
});
|
});
|
||||||
organizeVisible.value = false;
|
organizeVisible.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//删除角色
|
//删除角色
|
||||||
function delrole(row: any) {
|
function delrole(row: any) {
|
||||||
ElMessageBox.confirm("确定删除此角色吗?", "删除提示", {
|
ElMessageBox.confirm('确定删除此角色吗?', '删除提示', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
let params = {
|
let params = {
|
||||||
id: row.id,
|
id: row.id
|
||||||
};
|
};
|
||||||
deleDept(params).then(() => {
|
deleDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
ElMessage({
|
ElMessage({
|
||||||
type: "success",
|
type: 'success',
|
||||||
message: "删除成功",
|
message: '删除成功'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -253,8 +258,8 @@ const DefaultDeployment: any = ref([]);
|
|||||||
//传参id
|
//传参id
|
||||||
const Passparameter: any = ref([]);
|
const Passparameter: any = ref([]);
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
children: "children",
|
children: 'children',
|
||||||
label: "name",
|
label: 'name'
|
||||||
};
|
};
|
||||||
const rowid = ref();
|
const rowid = ref();
|
||||||
function menuChange(data: any, ids: any) {
|
function menuChange(data: any, ids: any) {
|
||||||
@ -273,12 +278,12 @@ function assignment(row: any) {
|
|||||||
accessVisible.value = true;
|
accessVisible.value = true;
|
||||||
const params = {
|
const params = {
|
||||||
roleId: rowid.value,
|
roleId: rowid.value,
|
||||||
code: '4'
|
tenantId: '4'
|
||||||
};
|
};
|
||||||
assignmentPer(params).then((res: any) => {
|
permissionAssignmentGrouped(params).then((res: any) => {
|
||||||
accessdata.value = res;
|
accessdata.value = res[0]?.menus || [];
|
||||||
let ids: any = [];
|
let ids: any = [];
|
||||||
menuChange(res, ids);
|
menuChange(res[0]?.menus, ids);
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
tree.value.setCheckedKeys(ids);
|
tree.value.setCheckedKeys(ids);
|
||||||
});
|
});
|
||||||
@ -287,42 +292,44 @@ function assignment(row: any) {
|
|||||||
|
|
||||||
// 树形选择器
|
// 树形选择器
|
||||||
function currentChecked(_nodeObj: any, SelectedObj: any) {
|
function currentChecked(_nodeObj: any, SelectedObj: any) {
|
||||||
Passparameter.value = SelectedObj.checkedKeys.concat(SelectedObj.halfCheckedKeys);
|
Passparameter.value = SelectedObj.checkedKeys.concat(
|
||||||
|
SelectedObj.halfCheckedKeys
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// 权限范围-权限范围-确定
|
// 权限范围-权限范围-确定
|
||||||
function accesssubmit() {
|
function accesssubmit() {
|
||||||
const parans = {
|
const parans = {
|
||||||
id: rowid.value,
|
id: rowid.value,
|
||||||
menuIds: Passparameter.value.toString(),
|
menuIds: Passparameter.value.toString()
|
||||||
};
|
};
|
||||||
setMenuById(parans).then(() => {
|
setMenuById(parans).then(() => {
|
||||||
accessVisible.value = false;
|
accessVisible.value = false;
|
||||||
gettableData();
|
gettableData();
|
||||||
ElMessage({
|
ElMessage({
|
||||||
type: "success",
|
type: 'success',
|
||||||
message: "修改成功",
|
message: '修改成功'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 多选删除?
|
// 多选删除?
|
||||||
function delClick() {
|
function delClick() {
|
||||||
ElMessageBox.confirm("确定删除已选择角色吗?", "删除提示", {
|
ElMessageBox.confirm('确定删除已选择角色吗?', '删除提示', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
let id = [] as any[];
|
let id = [] as any[];
|
||||||
multipleSelection.value.forEach((item: any) => {
|
multipleSelection.value.forEach((item: any) => {
|
||||||
id.push(item.id);
|
id.push(item.id);
|
||||||
});
|
});
|
||||||
let params = {
|
let params = {
|
||||||
id: id.join(","),
|
id: id.join(',')
|
||||||
};
|
};
|
||||||
deleDept(params).then(() => {
|
deleDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "删除成功",
|
message: '删除成功',
|
||||||
type: "success",
|
type: 'success'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -333,14 +340,32 @@ function dateFormat(row: any) {
|
|||||||
var date = new Date(daterc);
|
var date = new Date(daterc);
|
||||||
var year = date.getFullYear();
|
var year = date.getFullYear();
|
||||||
var month =
|
var month =
|
||||||
date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
|
date.getMonth() + 1 < 10
|
||||||
date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
|
? '0' + (date.getMonth() + 1)
|
||||||
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
: date.getMonth() + 1;
|
||||||
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
date.getMonth() + 1 < 10
|
||||||
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
? '0' + (date.getMonth() + 1)
|
||||||
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
: date.getMonth() + 1;
|
||||||
|
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
|
||||||
|
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
|
||||||
|
var minutes =
|
||||||
|
date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
|
||||||
|
var seconds =
|
||||||
|
date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
|
||||||
// 拼接
|
// 拼接
|
||||||
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
|
return (
|
||||||
|
year +
|
||||||
|
'-' +
|
||||||
|
month +
|
||||||
|
'-' +
|
||||||
|
day +
|
||||||
|
' ' +
|
||||||
|
hours +
|
||||||
|
':' +
|
||||||
|
minutes +
|
||||||
|
':' +
|
||||||
|
seconds
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,13 +394,20 @@ onMounted(() => {
|
|||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
<el-button type="primary" style="margin-left: 10px" @click="gettableData"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
style="margin-left: 10px"
|
||||||
|
@click="gettableData"
|
||||||
>搜索</el-button
|
>搜索</el-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<el-button v-hasPerm="['add:role']" type="primary" @click="addClick">
|
<el-button v-hasPerm="['add:role']" type="primary" @click="addClick">
|
||||||
<img src="@/assets/MenuIcon/jscz_xz.png" alt="" style="margin-right: 3px" />
|
<img
|
||||||
|
src="@/assets/MenuIcon/jscz_xz.png"
|
||||||
|
alt=""
|
||||||
|
style="margin-right: 3px"
|
||||||
|
/>
|
||||||
新增</el-button
|
新增</el-button
|
||||||
>
|
>
|
||||||
<el-button
|
<el-button
|
||||||
@ -399,12 +431,24 @@ onMounted(() => {
|
|||||||
:header-cell-style="{
|
:header-cell-style="{
|
||||||
background: 'rgb(250 250 250)',
|
background: 'rgb(250 250 250)',
|
||||||
color: '#383838',
|
color: '#383838',
|
||||||
height: '50px',
|
height: '50px'
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="50" align="center"></el-table-column>
|
<el-table-column
|
||||||
<el-table-column prop="rolecode" label="角色编号" width="100"></el-table-column>
|
type="selection"
|
||||||
<el-table-column prop="rolename" label="角色名称" width="180"></el-table-column>
|
width="50"
|
||||||
|
align="center"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="rolecode"
|
||||||
|
label="角色编号"
|
||||||
|
width="100"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="rolename"
|
||||||
|
label="角色名称"
|
||||||
|
width="180"
|
||||||
|
></el-table-column>
|
||||||
<el-table-column prop="level" label="角色级别" width="116">
|
<el-table-column prop="level" label="角色级别" width="116">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span v-show="scope.row.level == '1'">超级管理员</span>
|
<span v-show="scope.row.level == '1'">超级管理员</span>
|
||||||
@ -417,7 +461,12 @@ onMounted(() => {
|
|||||||
label="角色描述"
|
label="角色描述"
|
||||||
min-width="100"
|
min-width="100"
|
||||||
></el-table-column>
|
></el-table-column>
|
||||||
<el-table-column prop="isvaild" label="是否有效" align="center" width="120">
|
<el-table-column
|
||||||
|
prop="isvaild"
|
||||||
|
label="是否有效"
|
||||||
|
align="center"
|
||||||
|
width="120"
|
||||||
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="scope.row.isvaild"
|
v-model="scope.row.isvaild"
|
||||||
@ -426,7 +475,9 @@ onMounted(() => {
|
|||||||
active-value="1"
|
active-value="1"
|
||||||
inactive-value="0"
|
inactive-value="0"
|
||||||
></el-switch>
|
></el-switch>
|
||||||
<span v-if="scope.row.isvaild == 1" style="color: #0099ff">有效</span>
|
<span v-if="scope.row.isvaild == 1" style="color: #0099ff"
|
||||||
|
>有效</span
|
||||||
|
>
|
||||||
<span v-else style="color: #d7d7d7">无效</span>
|
<span v-else style="color: #d7d7d7">无效</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -538,7 +589,9 @@ onMounted(() => {
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<el-button @click="handleClose">取 消</el-button>
|
<el-button @click="handleClose">取 消</el-button>
|
||||||
<el-button type="primary" @click="confirmClick(infoForm)">确 定</el-button>
|
<el-button type="primary" @click="confirmClick(infoForm)"
|
||||||
|
>确 定</el-button
|
||||||
|
>
|
||||||
</span>
|
</span>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -586,9 +639,12 @@ onMounted(() => {
|
|||||||
@change="accessCheckedCitiesChanges(indexone)"
|
@change="accessCheckedCitiesChanges(indexone)"
|
||||||
style="margin-left: 20px"
|
style="margin-left: 20px"
|
||||||
>
|
>
|
||||||
<el-checkbox v-for="k in item.children" :key="k.id" :label="k.orgname">{{
|
<el-checkbox
|
||||||
k.orgname
|
v-for="k in item.children"
|
||||||
}}</el-checkbox>
|
:key="k.id"
|
||||||
|
:label="k.orgname"
|
||||||
|
>{{ k.orgname }}</el-checkbox
|
||||||
|
>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -682,7 +738,7 @@ onMounted(() => {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-family: "微软雅黑";
|
font-family: '微软雅黑';
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
color: #787878;
|
color: #787878;
|
||||||
|
|||||||
@ -51,6 +51,14 @@ export function assignmentPer (queryParams:any){
|
|||||||
params: queryParams
|
params: queryParams
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//获取分配权限(改动之后)
|
||||||
|
export function permissionAssignmentGrouped (queryParams:any){
|
||||||
|
return request({
|
||||||
|
url:'/system/menu/permissionAssignmentGrouped' ,
|
||||||
|
method: 'post',
|
||||||
|
params: queryParams
|
||||||
|
});
|
||||||
|
}
|
||||||
//发出分配权限
|
//发出分配权限
|
||||||
export function setMenuById (queryParams:any){
|
export function setMenuById (queryParams:any){
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -95,9 +95,9 @@ const columns = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '创建人',
|
title: '创建人',
|
||||||
key: 'recordUser',
|
key: 'recordUserName',
|
||||||
dataIndex: 'recordUser',
|
dataIndex: 'recordUserName',
|
||||||
width: 150
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
|
|||||||
@ -13,11 +13,12 @@ import {
|
|||||||
addDept,
|
addDept,
|
||||||
renewDept,
|
renewDept,
|
||||||
deleDept,
|
deleDept,
|
||||||
assignmentPer,
|
permissionAssignmentGrouped,
|
||||||
setMenuById,
|
setMenuById,
|
||||||
setOrgscope,
|
setOrgscope,
|
||||||
postOrgscope
|
postOrgscope
|
||||||
} from '@/api/role';
|
} from '@/api/role';
|
||||||
|
import { getDictItemsByCode } from '@/api/dict';
|
||||||
//定义表格数据
|
//定义表格数据
|
||||||
const tableData: any = ref([]);
|
const tableData: any = ref([]);
|
||||||
const multipleSelection = ref([]);
|
const multipleSelection = ref([]);
|
||||||
@ -28,7 +29,8 @@ const tree = ref();
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
function gettableData() {
|
function gettableData() {
|
||||||
let params = {
|
let params = {
|
||||||
rolename: input.value
|
rolename: input.value,
|
||||||
|
tenantId:tenValue.value,
|
||||||
};
|
};
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listRolePages(params)
|
listRolePages(params)
|
||||||
@ -115,7 +117,8 @@ function confirmClick(formEl: any) {
|
|||||||
const params = {
|
const params = {
|
||||||
rolename: info.value.rolename,
|
rolename: info.value.rolename,
|
||||||
level: info.value.level,
|
level: info.value.level,
|
||||||
description: info.value.description
|
description: info.value.description,
|
||||||
|
tenantId:tenValue.value
|
||||||
};
|
};
|
||||||
addDept(params).then(() => {
|
addDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
@ -126,7 +129,8 @@ function confirmClick(formEl: any) {
|
|||||||
rolename: info.value.rolename,
|
rolename: info.value.rolename,
|
||||||
level: info.value.level,
|
level: info.value.level,
|
||||||
description: info.value.description,
|
description: info.value.description,
|
||||||
id: info.value.id
|
id: info.value.id,
|
||||||
|
tenantId:tenValue.value
|
||||||
};
|
};
|
||||||
renewDept(params).then(() => {
|
renewDept(params).then(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
@ -274,12 +278,13 @@ function assignment(row: any) {
|
|||||||
rowid.value = row.id;
|
rowid.value = row.id;
|
||||||
accessVisible.value = true;
|
accessVisible.value = true;
|
||||||
const params = {
|
const params = {
|
||||||
roleId: rowid.value
|
roleId: rowid.value,
|
||||||
|
tenantId:tenValue.value
|
||||||
};
|
};
|
||||||
assignmentPer(params).then((res: any) => {
|
permissionAssignmentGrouped(params).then((res: any) => {
|
||||||
accessdata.value = res;
|
accessdata.value = res[0]?.menus || [];
|
||||||
let ids: any = [];
|
let ids: any = [];
|
||||||
menuChange(res, ids);
|
menuChange(res[0]?.menus, ids);
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
tree.value.setCheckedKeys(ids);
|
tree.value.setCheckedKeys(ids);
|
||||||
});
|
});
|
||||||
@ -364,9 +369,13 @@ function dateFormat(row: any) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let tenValue = ref('1')
|
||||||
|
let tenOption = ref([])
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
gettableData();
|
gettableData();
|
||||||
|
getDictItemsByCode({ dictCode: 'PLATFORM_TENANT' }).then(res => {
|
||||||
|
tenOption.value = res.data;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -390,6 +399,15 @@ onMounted(() => {
|
|||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
|
<el-select v-model="tenValue" placeholder=" " style="width: 320px;margin-left: 10px">
|
||||||
|
<el-option
|
||||||
|
v-for="item in tenOption"
|
||||||
|
:key="item.itemCode"
|
||||||
|
:label="item.dictName"
|
||||||
|
:value="item.itemCode"
|
||||||
|
/>
|
||||||
|
<!-- PLATFORM_TENANT -->
|
||||||
|
</el-select>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
style="margin-left: 10px"
|
style="margin-left: 10px"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user