解决冲突 frontend/src/api/index.ts
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind='dialogMiddle' @close="close">
|
||||
|
||||
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' class='form-two'>
|
||||
<el-divider >基础数据</el-divider>
|
||||
<el-form-item label='数据模型' :label-width='140' prop='dataType'>
|
||||
@@ -167,7 +166,6 @@
|
||||
import { addDictPq, updateDictPq } from '@/api/system/dictionary/dictPq'
|
||||
import { computed, type Ref, ref } from 'vue';
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { el } from 'element-plus/es/locale';
|
||||
const dictStore = useDictStore()
|
||||
const selectedStatMethods = ref<string[]>([])
|
||||
// 定义弹出组件元信息
|
||||
@@ -230,26 +228,13 @@ import { el } from 'element-plus/es/locale';
|
||||
if (valid) {
|
||||
formContent.value.statMethod = selectedStatMethods.value.join(',')
|
||||
if (formContent.value.id) {
|
||||
const result = await updateDictPq(formContent.value);
|
||||
|
||||
if(result.code != 'A0000'){
|
||||
ElMessage.error({ message: result.message})
|
||||
}else{
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
}
|
||||
|
||||
await updateDictPq(formContent.value);
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
|
||||
} else {
|
||||
const result = await addDictPq(formContent.value);
|
||||
|
||||
if(result.code != 'A0000'){
|
||||
ElMessage.error({ message: result.message})
|
||||
}else{
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
}
|
||||
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
}
|
||||
//ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
|
||||
close()
|
||||
// 刷新表格
|
||||
await props.refreshTable!()
|
||||
@@ -264,7 +249,6 @@ import { el } from 'element-plus/es/locale';
|
||||
const open = (sign: string, data: Dict.ResDictPq) => {
|
||||
titleType.value = sign
|
||||
dialogVisible.value = true
|
||||
//console.log(dictStore)
|
||||
selectedStatMethods.value = data.statMethod ? data.statMethod.split(',') : []
|
||||
if (data.id) {
|
||||
formContent.value = { ...data }
|
||||
|
||||
@@ -1,207 +1,178 @@
|
||||
<template>
|
||||
<div class='table-box' ref='popupBaseView'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:request-api='getDictPqList'
|
||||
>
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
@click='batchDelete(scope.selectedListIds)'>
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
<PqPopup :refresh-table='proTable?.getTableList' ref='pqPopup'/>
|
||||
</template>
|
||||
|
||||
<script setup lang='tsx' name='dict'>
|
||||
import {CirclePlus, Delete, EditPen, Download, View} from '@element-plus/icons-vue'
|
||||
import {type Dict} from '@/api/system/dictionary/interface'
|
||||
import {ProTableInstance, ColumnProps} from '@/components/ProTable/interface'
|
||||
import PqPopup from '@/views/system/dictionary/dictPq/components/pqPopup.vue'
|
||||
import {useDictStore} from '@/stores/modules/dict'
|
||||
import {useHandleData} from '@/hooks/useHandleData'
|
||||
import {
|
||||
getDictPqList,
|
||||
deleteDictPq,
|
||||
} from '@/api/system/dictionary/dictPq'
|
||||
import { reactive, ref } from 'vue'
|
||||
<div class='table-box' ref='popupBaseView'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:request-api='getDictPqList'
|
||||
>
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
@click='batchDelete(scope.selectedListIds)'>
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
const dictStore = useDictStore()
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
<PqPopup :refresh-table='proTable?.getTableList' ref='pqPopup' />
|
||||
</template>
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const pqPopup = ref()
|
||||
|
||||
|
||||
<script setup lang='tsx' name='dict'>
|
||||
import { CirclePlus, Delete, EditPen } from '@element-plus/icons-vue'
|
||||
import { type Dict } from '@/api/system/dictionary/interface'
|
||||
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import PqPopup from '@/views/system/dictionary/dictPq/components/pqPopup.vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import {
|
||||
getDictPqList,
|
||||
deleteDictPq,
|
||||
} from '@/api/system/dictionary/dictPq'
|
||||
import { reactive, ref } from 'vue'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const pqPopup = ref()
|
||||
|
||||
const columns = reactive<ColumnProps<Dict.ResDictPq>[]>([
|
||||
{type: 'selection', fixed: 'left', width: 70},
|
||||
{type: 'index', fixed: 'left', width: 70, label: '序号'},
|
||||
{
|
||||
prop: 'dataType',
|
||||
label: '数据模型',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('Cs_Data_Type'),
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '指标名称',
|
||||
width: 180,
|
||||
search: {
|
||||
el: 'input',
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'otherName',
|
||||
label: '别名',
|
||||
minWidth: 300,
|
||||
search: {
|
||||
el: 'input',
|
||||
},
|
||||
render: (scope) => {
|
||||
const codes = scope.row.otherName;
|
||||
return codes || '/';
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'showName',
|
||||
label: '显示名称',
|
||||
width: 180,
|
||||
search: {
|
||||
el: 'input',
|
||||
},
|
||||
render: (scope) => {
|
||||
const codes = scope.row.showName;
|
||||
return codes || '/';
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'phase',
|
||||
label: '相别',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('phase'),
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
},
|
||||
{
|
||||
prop: 'unit',
|
||||
label: '单位',
|
||||
width: 180,
|
||||
render: (scope) => {
|
||||
const codes = scope.row.unit;
|
||||
return codes || '/';
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '指标数据类型',
|
||||
width: 180,
|
||||
render: (scope) => {
|
||||
const codes = scope.row.type;
|
||||
return codes || '/';
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'harmStart',
|
||||
label: '数据谐波次数',
|
||||
width: 180,
|
||||
render: (scope) => {
|
||||
return (scope.row.harmStart && scope.row.harmEnd)
|
||||
? `${scope.row.harmStart}-${scope.row.harmEnd}`
|
||||
: '/'; // 如果 harmStart 或 harmEnd 为空,返回 '/'
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'statMethod',
|
||||
label: '数据统计类型',
|
||||
width: 250,
|
||||
enum: dictStore.getDictData('Stat_Method'),
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
render: (scope) => {
|
||||
// 假设 statMethod 是一个数组,包含多个 'code' 值
|
||||
const codes = scope.row.statMethod; // 获取当前行的 statMethod 字段
|
||||
//console.log('codes',codes)
|
||||
if (!codes) {
|
||||
return '/'; // 如果 statMethod 为 undefined 或 null,返回 '/'
|
||||
}
|
||||
// 确保 codes 是一个字符串
|
||||
const codeString = Array.isArray(codes) ? codes.join(',') : codes;
|
||||
const codeArray = codeString.split(',');
|
||||
if (codeArray.length > 1) {
|
||||
// 查找与每个 code 值匹配的 name,然后拼接成逗号分割的字符串
|
||||
//console.log('codeArray',codeArray)
|
||||
const names = codeArray.map(code => {
|
||||
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === code);
|
||||
return dictItem ? dictItem.name : ''; // 如果找到匹配的项,返回对应的 name
|
||||
});
|
||||
//console.log('names',names)
|
||||
return names.join(', '); // 用逗号连接所有的 name
|
||||
}
|
||||
// 查找单个 code 对应的 name
|
||||
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === codeArray[0]);
|
||||
return dictItem ? dictItem.name : ''; // 如果找到匹配的项,返回对应的 name
|
||||
const columns = reactive<ColumnProps<Dict.ResDictPq>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'dataType',
|
||||
label: '数据模型',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('Cs_Data_Type'),
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'classId',
|
||||
label: '数据表表名',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('Data'),
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
|
||||
{
|
||||
prop: 'name',
|
||||
label: '指标名称',
|
||||
width: 180,
|
||||
search: {
|
||||
el: 'input',
|
||||
},
|
||||
{
|
||||
prop: 'resourcesId',
|
||||
label: '报表数据来源',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('Data_Day'),
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
render: (scope) => {
|
||||
const codes = scope.row.resourcesId;
|
||||
return codes || '/';
|
||||
},
|
||||
{
|
||||
prop: 'otherName',
|
||||
label: '别名',
|
||||
minWidth: 300,
|
||||
search: {
|
||||
el: 'input',
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'showName',
|
||||
label: '显示名称',
|
||||
width: 180,
|
||||
search: {
|
||||
el: 'input',
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'phase',
|
||||
label: '相别',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('phase'),
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
},
|
||||
{
|
||||
prop: 'unit',
|
||||
label: '单位',
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '指标数据类型',
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
prop: 'harmStart',
|
||||
label: '数据谐波次数',
|
||||
width: 180,
|
||||
render: (scope) => {
|
||||
return (scope.row.harmStart && scope.row.harmEnd)
|
||||
? `${scope.row.harmStart}-${scope.row.harmEnd}`
|
||||
: '/' // 如果 harmStart 或 harmEnd 为空,返回 '/'
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'statMethod',
|
||||
label: '数据统计类型',
|
||||
width: 250,
|
||||
enum: dictStore.getDictData('Stat_Method'),
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
render: (scope) => {
|
||||
// 假设 statMethod 是一个数组,包含多个 'code' 值
|
||||
const codes = scope.row.statMethod // 获取当前行的 statMethod 字段
|
||||
if (!codes) {
|
||||
return '/'
|
||||
}
|
||||
// 确保 codes 是一个字符串
|
||||
const codeString = Array.isArray(codes) ? codes.join(',') : codes
|
||||
const codeArray = codeString.split(',')
|
||||
if (codeArray.length > 1) {
|
||||
console.log('多个 code', codeString)
|
||||
// 查找与每个 code 值匹配的 name,然后拼接成逗号分割的字符串
|
||||
const names = codeArray.map(code => {
|
||||
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === code)
|
||||
return dictItem ? dictItem.name : '' // 如果找到匹配的项,返回对应的 name
|
||||
})
|
||||
return names.join(', ') // 用逗号连接所有的 name
|
||||
}
|
||||
// 查找单个 code 对应的 name
|
||||
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === codeArray[0])
|
||||
return dictItem ? dictItem.name : '' // 如果找到匹配的项,返回对应的 name
|
||||
},
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
minWidth: 200,
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = (titleType: string, row: Partial<Dict.ResDictPq> = {}) => {
|
||||
pqPopup.value?.open(titleType, row)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 批量删除字典类型
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deleteDictPq, id, '删除所选字典类型')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
// 删除字典类型
|
||||
const handleDelete = async (params: Dict.ResDictPq) => {
|
||||
await useHandleData(deleteDictPq, [params.id], `删除【${params.name}】指标字典类型`)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'classId',
|
||||
label: '数据表表名',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('Data'),
|
||||
fieldNames: { label: 'name', value: 'code' },
|
||||
|
||||
|
||||
</script>
|
||||
},
|
||||
{
|
||||
prop: 'resourcesId',
|
||||
label: '报表数据来源',
|
||||
width: 180,
|
||||
enum: dictStore.getDictData('Data_Day'),
|
||||
fieldNames: { label: 'name', value: 'code' }
|
||||
},
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
minWidth: 200,
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = (titleType: string, row: Partial<Dict.ResDictPq> = {}) => {
|
||||
pqPopup.value?.open(titleType, row)
|
||||
|
||||
}
|
||||
|
||||
// 批量删除字典类型
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deleteDictPq, id, '删除所选字典类型')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
// 删除字典类型
|
||||
const handleDelete = async (params: Dict.ResDictPq) => {
|
||||
await useHandleData(deleteDictPq, [params.id], `删除【${params.name}】指标字典类型`)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
<el-input v-model='formContent.code' placeholder='请输入' autocomplete='off' />
|
||||
</el-form-item>
|
||||
<el-form-item label="开启等级" :label-width="100">
|
||||
<el-radio-group v-model="formContent.openLevel" size="medium">
|
||||
<el-radio-group v-model="formContent.openLevel" >
|
||||
<el-radio-button label="开启" :value="1"></el-radio-button>
|
||||
<el-radio-button label="关闭" :value="0"></el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="开启描述" :label-width="100">
|
||||
<el-radio-group v-model="formContent.openDescribe" size="medium">
|
||||
<el-radio-group v-model="formContent.openDescribe" >
|
||||
<el-radio-button label="开启" :value="1"></el-radio-button>
|
||||
<el-radio-button label="关闭" :value="0"></el-radio-button>
|
||||
</el-radio-group>
|
||||
|
||||
@@ -30,13 +30,11 @@ import { CirclePlus, Delete, Download, EditPen, View } from '@element-plus/icons
|
||||
import { Dict } from '@/api/system/dictionary/interface'
|
||||
import { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import DictData from '@/views/system/dictionary/dictData/index.vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import { useViewSize } from '@/hooks/useViewSize'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
import { deleteDictType, getDictTypeList, exportDictType } from '@/api/system/dictionary/dictType'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
@@ -57,7 +55,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
|
||||
{
|
||||
prop: 'code',
|
||||
label: '类型编码',
|
||||
minWidth: 200,
|
||||
minWidth: 220,
|
||||
search: {
|
||||
el: 'input',
|
||||
},
|
||||
@@ -65,7 +63,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
|
||||
{
|
||||
prop: 'remark',
|
||||
label: '描述',
|
||||
minWidth: 300,
|
||||
minWidth: 250,
|
||||
},
|
||||
{
|
||||
prop: 'sort',
|
||||
@@ -81,7 +79,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
minWidth: 300,
|
||||
minWidth: 250,
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user