ljlong_2630
10 months ago
10 changed files with 985 additions and 340 deletions
@ -1,60 +1,50 @@ |
|||
import request from '@/utils/request' |
|||
|
|||
// 查询参数列表
|
|||
export function listConfig(query) { |
|||
return request({ |
|||
url: '/system/config/list', |
|||
method: 'get', |
|||
params: query |
|||
}) |
|||
} |
|||
|
|||
// 查询参数详细
|
|||
export function getConfig(configId) { |
|||
return request({ |
|||
url: '/system/config/' + configId, |
|||
method: 'get' |
|||
}) |
|||
} |
|||
|
|||
// 根据参数键名查询参数值
|
|||
export function getConfigKey(configKey) { |
|||
return request({ |
|||
url: '/system/config/configKey/' + configKey, |
|||
method: 'get' |
|||
}) |
|||
} |
|||
|
|||
// 新增参数配置
|
|||
export function addConfig(data) { |
|||
return request({ |
|||
url: '/system/config', |
|||
method: 'post', |
|||
data: data |
|||
}) |
|||
} |
|||
|
|||
// 修改参数配置
|
|||
export function updateConfig(data) { |
|||
return request({ |
|||
url: '/system/config', |
|||
method: 'put', |
|||
data: data |
|||
}) |
|||
} |
|||
|
|||
// 删除参数配置
|
|||
export function delConfig(configId) { |
|||
return request({ |
|||
url: '/system/config/' + configId, |
|||
method: 'delete' |
|||
}) |
|||
} |
|||
|
|||
// 刷新参数缓存
|
|||
export function refreshCache() { |
|||
return request({ |
|||
url: '/system/config/refreshCache', |
|||
method: 'delete' |
|||
}) |
|||
import request from '@/config/axios' |
|||
|
|||
export interface ConfigVO { |
|||
configName: string |
|||
configKey: string |
|||
configValue: string |
|||
configType: string |
|||
createBy: string |
|||
} |
|||
|
|||
// 查询系统参数列表
|
|||
export const getConfigPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/sys/config/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/sys/config/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询系统参数详情
|
|||
export const getConfig = async (id: number) => { |
|||
return await request.get({ url: `/sys/config/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增系统参数
|
|||
export const createConfig = async (data: ConfigVO) => { |
|||
return await request.post({ url: `/sys/config/create`, data }) |
|||
} |
|||
|
|||
// 修改系统参数
|
|||
export const updateConfig = async (data: ConfigVO) => { |
|||
return await request.put({ url: `/sys/config/update`, data }) |
|||
} |
|||
|
|||
// 删除系统参数
|
|||
export const deleteConfig = async (id: number) => { |
|||
return await request.delete({ url: `/sys/config/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出系统参数 Excel
|
|||
export const exportConfig = async (params) => { |
|||
return await request.download({ url: `/sys/config/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/sys/config/get-import-template' }) |
|||
} |
@ -0,0 +1,574 @@ |
|||
<template> |
|||
<div> |
|||
<Dialog v-model="isShowDrawer" title="审批详情" direction="rtl" size="80%" v-loading="detailLoading"> |
|||
<template #header> |
|||
<div class="font-size-18px"> |
|||
{{ titleValueRef }} <span class="ml-20px font-size-16px">{{ titleNameRef }}</span> |
|||
</div> |
|||
</template> |
|||
<ContentWrap v-if="!isBasic"> |
|||
<Descriptions :data="detailData" labelClassName="label-class-name" label-align="left" direction="vertical" |
|||
:column="8" :schema="allSchemas.detailSchema" :columns="2" width="200px" /> |
|||
</ContentWrap> |
|||
|
|||
<Tabs :tabsList="tabsList" :current="current" @change="change" /> |
|||
<div class="flex"> |
|||
<!-- 详情 --> |
|||
<ContentWrap class="w-[100%]"> |
|||
<!-- 列表头部 --> |
|||
<!-- <TableHead |
|||
v-if="!isBasic" |
|||
:HeadButttondata="HeadButttondata" |
|||
:number="masterParmas.maintenanceNumber" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="detailAllSchemas" |
|||
/> --> |
|||
<!-- 默认单表展现 --> |
|||
<Descriptions v-if="isBasic && !tabsExtend" :data="detailData" :schema="allSchemas.detailSchema" |
|||
:columns="2" /> |
|||
<!-- 单表切换tabs 展现table --> |
|||
<Table v-if="isBasic && tabsExtend" :columns="detailAllSchemasRef.tableColumns" |
|||
:data="tableObjectRef.tableList" :loading="tableObjectRef.loading" |
|||
:pagination="{ total: tableObjectRef.total }" v-model:pageSize="tableObjectRef.pageSize" |
|||
v-model:currentPage="tableObjectRef.currentPage"> |
|||
<!-- <template #action="{ row }"> |
|||
<ButtonBase |
|||
:Butttondata="buttondata" |
|||
@button-base-click="buttonTableClick($event, row)" |
|||
/> |
|||
</template> --> |
|||
</Table> |
|||
<Table v-if="!isBasic && fromeWhere != 'countPlan'" :columns="detailAllSchemasRef.tableColumns" |
|||
:data="tableObjectRef.tableList" :loading="tableObjectRef.loading" |
|||
:pagination="{ total: tableObjectRef.total }" v-model:pageSize="tableObjectRef.pageSize" |
|||
v-model:currentPage="tableObjectRef.currentPage"> |
|||
<template #photos="{ row }"> |
|||
<div v-for="(item, index) in row.photos.split(',')" :key="index" style="color: #409eff; cursor: pointer" |
|||
@click="openImage(item)">{{ item }}</div> |
|||
</template> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="buttondata" @button-base-click="buttonTableClick($event, row)" /> |
|||
</template> |
|||
</Table> |
|||
<DetailTable v-if="!isBasic && fromeWhere == 'countPlan' && isShowDrawer" |
|||
:columns="detailAllSchemasRef.tableColumns" :data="tableObjectRef.tableList" :allList="allList" |
|||
:countScopeType="countScopeType" :key="updateKey"> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="buttondata" @button-base-click="buttonTableClick($event, row)" /> |
|||
</template> |
|||
</DetailTable> |
|||
</ContentWrap> |
|||
</div> |
|||
<template #footer> |
|||
<ButtonBase :Butttondata="Butttondata" @button-base-click="buttonBaseClick" /> |
|||
</template> |
|||
</Dialog> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import Tabs from '@/components/Tabs/src/Tabs.vue' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import BasicForm from '@/components/BasicForm/src/BasicForm.vue' |
|||
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|||
import DetailTable from '@/components/DetailTable/src/DetailTable.vue' |
|||
import { isString } from '@/utils/is' |
|||
import { Console } from 'console' |
|||
|
|||
defineOptions({ name: 'Detail' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
routeName.value = routeName.value.substring(0, routeName.value.length - 4) + 'Detail' |
|||
const updateKey = ref(0) |
|||
|
|||
const props = defineProps({ |
|||
// 标签参数 |
|||
tabs: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 是否是基础数据 展现详情顶部表单 |
|||
isBasic: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 表单,列表 相关信息 |
|||
allSchemas: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 明细列表相关信息 |
|||
detailAllSchemas: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 明细验证 |
|||
detailAllSchemasRules: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 子表新增API |
|||
apiCreate: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子表编辑API |
|||
apiUpdate: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子表分页列表API |
|||
apiPage: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子表删除API |
|||
apiDelete: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
|
|||
|
|||
// 审批通过API |
|||
apiAgree: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
|
|||
|
|||
// 驳回通过API |
|||
apiDisAgree: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
|
|||
|
|||
// 子表新增修改校验 |
|||
detailValidate: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 来源 countPlan盘点计划进入 |
|||
fromeWhere: { |
|||
type: String, |
|||
required: false, |
|||
default: '' |
|||
}, |
|||
// 获取接口列表集合 |
|||
allList: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 盘点范围类型 |
|||
countScopeType: { |
|||
type: Array, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
//盘点详情子表新增的时候判断盘点范围值显示输入框还是下拉框 |
|||
formTypeDetail: { |
|||
type: String, |
|||
required: false, |
|||
default: 'InputString' |
|||
}, |
|||
//盘点详情子表新增的时候判断盘点范围值的下拉列表 |
|||
countPlanAllList: { |
|||
type: Array, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 详情列表扩展操作按钮 |
|||
buttondataTable: { |
|||
type: Array, |
|||
required: false, |
|||
default: () => { |
|||
return [] |
|||
} |
|||
}, |
|||
// 针对基础数据tabs扩展 显示table列表 默认false |
|||
tabsExtend: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// tableObject 数据过滤条件 针对 详情扩展标签页 传入不同条件 |
|||
tableObjectExtend: { |
|||
type: Array, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子列表 新增 编辑 删除的展示与隐藏,默认展示 |
|||
detailButtonIsShow: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 是否是选择备件列表 |
|||
isSearchTableItem: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
|
|||
|
|||
|
|||
|
|||
}) |
|||
const isShowDrawer = ref(false) |
|||
const detailLoading = ref(false) |
|||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|||
const tabsList = ref(JSON.parse(JSON.stringify(props.tabs ? props.tabs : ''))) |
|||
|
|||
if (props.isBasic == true) { |
|||
if (tabsList.value && tabsList.value.length > 0) { |
|||
tabsList.value.unshift({ |
|||
label: '详情', |
|||
prop: 'Detail' |
|||
}) |
|||
} |
|||
} else { |
|||
if (tabsList.value && tabsList.value.length > 0) { |
|||
} else { |
|||
tabsList.value = [ |
|||
{ |
|||
label: '明细', |
|||
prop: 'Detail' |
|||
} |
|||
] |
|||
} |
|||
} |
|||
if (tabsList.value) { |
|||
} |
|||
|
|||
// Tabs当前选择 |
|||
const current = ref(0) |
|||
const change = (item, index) => { |
|||
current.value = index |
|||
emit('changeTabs', item) |
|||
} |
|||
|
|||
//主表所需的参数 |
|||
const masterParmas = ref({ |
|||
maintenanceNumber: '' //主表id |
|||
// number: '', //主表单据号 |
|||
// status: '' //主表状态 用于控制子表新增编辑按钮显示情况 |
|||
}) |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = ref() |
|||
// 列表-操作按钮 |
|||
const buttondata = ref() |
|||
|
|||
/** 打开弹窗 */ |
|||
const detailData = ref() |
|||
const titleNameRef = ref() |
|||
const titleValueRef = ref() |
|||
const openDetail = async (row : any, titleName : any, titleValue : any, tableName : any) => { |
|||
titleNameRef.value = titleName |
|||
titleValueRef.value = titleValue |
|||
// 加载明细列表 |
|||
if (!props.isBasic) { |
|||
// 设置主表id |
|||
masterParmas.value.maintenanceNumber = row.number |
|||
// masterParmas.value.number = row.number |
|||
// masterParmas.value.status = row.status |
|||
tableObjectRef.value.params = { |
|||
maintenanceNumber: row.number |
|||
} |
|||
await getList() |
|||
} |
|||
isShowDrawer.value = true |
|||
if (row) { |
|||
detailLoading.value = true |
|||
try { |
|||
detailData.value = row |
|||
setBeiJian() |
|||
|
|||
let detailButtonAdd : any = [] |
|||
detailButtonAdd = [ |
|||
defaultButtons.defaultAddBtn({ |
|||
hide: isShowMainButton(row, ['1']) |
|||
}) |
|||
] |
|||
HeadButttondata.value = [...detailButtonAdd] |
|||
} finally { |
|||
detailLoading.value = false |
|||
} |
|||
} |
|||
} |
|||
// 设置备件回显 |
|||
const setBeiJian = () => { |
|||
let isItemNUmbersTrue = false |
|||
isItemNUmbersTrue = detailAllSchemasRef.value.tableColumns.some( |
|||
(item) => item.field == 'itemNumbers1' |
|||
) |
|||
if (!isItemNUmbersTrue) return |
|||
tableObjectRef.value.tableList.forEach((item) => { |
|||
if (item.itemNumbers?.length > 0) { |
|||
let str = '' |
|||
item.itemNumbers.forEach((element) => { |
|||
str += element.name + ':' + element.qty + ',' |
|||
}) |
|||
item.itemNumbers1 = str.substring(0, str.length - 1) |
|||
} |
|||
}) |
|||
} |
|||
const tableObjectRef = ref() |
|||
const tableMethodsRef = ref() |
|||
const detailAllSchemasRef = ref() |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: props.apiPage // 分页接口 |
|||
}) |
|||
|
|||
tableObjectRef.value = tableObject |
|||
tableMethodsRef.value = tableMethods |
|||
detailAllSchemasRef.value = props.detailAllSchemas |
|||
|
|||
// 根据状态返回该按钮是否显示 |
|||
const isShowMainButton = (row, val) => { |
|||
return false |
|||
} |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList } = tableMethodsRef.value |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'add') { |
|||
// 新增 |
|||
openForm('create') |
|||
} else if (val == 'import') { |
|||
// 导入 |
|||
handleImport() |
|||
} else if (val == 'export') { |
|||
// 导出 |
|||
handleExport() |
|||
} else if (val == 'refresh') { |
|||
// 刷新 |
|||
getList() |
|||
} else if (val == 'filtrate') { |
|||
// 筛选 |
|||
} |
|||
else if (val == 'agree') { |
|||
// 同意按钮 |
|||
agree() |
|||
} |
|||
|
|||
else if (val == 'disAgree') { |
|||
// 同意按钮 |
|||
disAgree() |
|||
} |
|||
// else if (val == 'disagree') { |
|||
// // 驳回按钮 |
|||
// disagree() |
|||
// } |
|||
else { |
|||
// 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
} |
|||
|
|||
/** 审批通过按钮操作 */ |
|||
const agree = async (id : number) => { |
|||
try { |
|||
// 通过的二次确认 |
|||
await message.confirm("是否确认审批通过该数据项?") |
|||
// 发起通过 |
|||
await props.apiAgree(id) |
|||
message.success(t('common.success')) |
|||
// 刷新列表 |
|||
await getList() |
|||
updateKey.value += 1 |
|||
setBeiJian() |
|||
} catch { } |
|||
} |
|||
|
|||
|
|||
/** 审批驳回按钮操作 */ |
|||
const disAgree = async (id : number) => { |
|||
try { |
|||
// 驳回的二次确认 |
|||
await message.confirm("是否确认审批驳回该数据项?") |
|||
// 发起驳回 |
|||
await props.apiDisAgree(id) |
|||
message.success(t('common.success')) |
|||
// 刷新列表 |
|||
await getList() |
|||
updateKey.value += 1 |
|||
setBeiJian() |
|||
} catch { } |
|||
} |
|||
|
|||
|
|||
|
|||
// 字段设置 更新主列表字段 |
|||
// const updataTableColumns = (val) => { |
|||
// detailAllSchemas.tableColumns.value = val |
|||
// } |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { |
|||
// 编辑 |
|||
openForm('update', row) |
|||
emit('detailOpenForm', row) |
|||
} else if (val == 'delete') { |
|||
// 删除 |
|||
handleDelete(row.id) |
|||
} else { |
|||
emit('tableFormButton', val, row) |
|||
} |
|||
} |
|||
/** 添加/修改操作 */ |
|||
const formRef = ref() |
|||
const openForm = async (type : string, row ?: number) => { |
|||
if (row) { |
|||
if (detailAllSchemasRef.value?.tableColumns?.length > 0) { |
|||
let isTrue = false |
|||
let isItemNUmbersTrue = false |
|||
isTrue = detailAllSchemasRef.value.tableColumns.some((item) => item.field == 'maintenances') |
|||
isItemNUmbersTrue = detailAllSchemasRef.value.tableColumns.some( |
|||
(item) => item.field == 'itemNumbers' |
|||
) |
|||
if (isTrue) { |
|||
if (row.maintenances && isString(row.maintenances)) { |
|||
row.maintenances = row.maintenances.split(',').map(Number) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
formRef.value.open(type, row, masterParmas.value) |
|||
} |
|||
// form 提交 |
|||
const submitForm = async (formType, data) => { |
|||
try { |
|||
emit('detailSubmitForm', formType, data, getList, formRef.value) |
|||
} finally { |
|||
// formRef.value.formLoading = false |
|||
} |
|||
} |
|||
|
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
emit('searchTableSuccessDetail', formField, searchField, val, formRef) |
|||
} |
|||
// 传递给父类 |
|||
const emit = defineEmits([ |
|||
'searchTableSuccessDetail', |
|||
'changeTabs', |
|||
'selectChangeDetail', |
|||
'detailOpenForm', |
|||
'tableFormButton', |
|||
'openImage', |
|||
'detailSubmitForm' |
|||
]) |
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id : number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await props.apiDelete(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
updateKey.value += 1 |
|||
setBeiJian() |
|||
} catch { } |
|||
} |
|||
// 筛选提交 |
|||
const searchFormClick = async (searchData) => { |
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: props.apiPage // 分页接口 |
|||
}) |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
? searchData.filters |
|||
: [{ column: 'number', action: '==', value: masterParmas.value.maintenanceNumber }] |
|||
} |
|||
detailAllSchemasRef.value = props.detailAllSchemas |
|||
tableObjectRef.value = tableObject |
|||
tableMethodsRef.value = tableMethods |
|||
tableObjectRef.value.tableList = [] |
|||
const { getList } = tableMethods |
|||
await getList() |
|||
updateKey.value += 1 |
|||
// tableObjectRef.value.params = { |
|||
// isSearch: true, |
|||
// filters: searchData.filters |
|||
// ? searchData.filters |
|||
// : [{ column: 'masterId', action: '==', value: masterParmas.value.masterId }] |
|||
// } |
|||
// getList() // 刷新当前列表 |
|||
} |
|||
// 选择盘点类型的时候针对限值的操作 |
|||
const selectChangeDetail = (field, val) => { |
|||
emit('selectChangeDetail', field, val) |
|||
} |
|||
// 打开图片 |
|||
const openImage = (item) => { |
|||
emit('openImage', item) |
|||
} |
|||
|
|||
/** 弹窗按钮 */ |
|||
const Butttondata = [ |
|||
defaultButtons.agree(null), // 同意 |
|||
defaultButtons.disAgree(null) // 驳回 |
|||
] |
|||
|
|||
defineExpose({ openDetail, tableObject }) // 提供 open 方法,用于打开弹窗 |
|||
//监视属性 |
|||
watch( |
|||
() => props.apiPage, |
|||
() => { |
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: props.apiPage // 分页接口 |
|||
}) |
|||
tableObject.params.maintenanceNumber = masterParmas.value.maintenanceNumber |
|||
detailAllSchemasRef.value = props.detailAllSchemas |
|||
if (props.tableObjectExtend) { |
|||
props.tableObjectExtend.forEach((item) => { |
|||
tableObject.params[item.key] = item.value |
|||
}) |
|||
} |
|||
tableObjectRef.value = tableObject |
|||
tableMethodsRef.value = tableMethods |
|||
const { getList } = tableMethods |
|||
getList() |
|||
} |
|||
) |
|||
</script> |
|||
<style lang="scss"> |
|||
.el-drawer__body { |
|||
background: #f5f5f5 !important; |
|||
} |
|||
|
|||
::v-deep(.label-class-name) { |
|||
color: #dedede; |
|||
} |
|||
</style> |
|||
<style scoped lang="scss"></style> |
@ -0,0 +1,100 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
|
|||
// 表单校验
|
|||
export const ConfigRules = reactive({ |
|||
}) |
|||
|
|||
export const Config = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
{ |
|||
label: '参数主键', |
|||
field: 'configId', |
|||
sort: 'custom', |
|||
isTable: false, |
|||
isSearch: false, |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '参数名称', |
|||
field: 'configName', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
}, |
|||
{ |
|||
label: '参数键名', |
|||
field: 'configKey', |
|||
sort: 'custom', |
|||
isSearch: false, |
|||
}, |
|||
{ |
|||
label: '参数键值', |
|||
field: 'configValue', |
|||
sort: 'custom', |
|||
isSearch: false, |
|||
}, |
|||
// {
|
|||
// label: '系统内置(Y是 N否)',
|
|||
// field: 'configType',
|
|||
// sort: 'custom',
|
|||
// isSearch: false,
|
|||
// form: {
|
|||
// component: 'Select'
|
|||
// },
|
|||
// },
|
|||
{ |
|||
label: '系统内置', |
|||
field: 'isConstant', |
|||
dictType: DICT_TYPE.TRUE_FALSE, |
|||
dictClass: 'string', |
|||
isSearch: false, |
|||
isTable: true, |
|||
sort: 'custom', |
|||
table: { |
|||
width:110, |
|||
}, |
|||
tableForm: { |
|||
type: 'Select', |
|||
inactiveValue: 'FALSE', |
|||
disabled: true |
|||
}, |
|||
form: { |
|||
component: 'Switch', |
|||
value: 'TRUE', |
|||
componentProps: { |
|||
inactiveValue: 'FALSE', |
|||
activeValue: 'TRUE' |
|||
} |
|||
} |
|||
}, |
|||
// {
|
|||
// label: '创建者',
|
|||
// field: 'creator',
|
|||
// sort: 'custom',
|
|||
// isSearch: false,
|
|||
// },
|
|||
{ |
|||
label: '创建时间', |
|||
field: 'createTime', |
|||
sort: 'custom', |
|||
formatter: dateFormatter, |
|||
isSearch: false, |
|||
search: { |
|||
component: 'DatePicker', |
|||
componentProps: { |
|||
valueFormat: 'YYYY-MM-DD HH:mm:ss', |
|||
type: 'daterange', |
|||
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] |
|||
} |
|||
}, |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
@ -1,307 +1,243 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> |
|||
<el-form-item label="参数名称" prop="configName"> |
|||
<el-input |
|||
v-model="queryParams.configName" |
|||
placeholder="请输入参数名称" |
|||
clearable |
|||
style="width: 240px" |
|||
@keyup.enter="handleQuery" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item label="参数键名" prop="configKey"> |
|||
<el-input |
|||
v-model="queryParams.configKey" |
|||
placeholder="请输入参数键名" |
|||
clearable |
|||
style="width: 240px" |
|||
@keyup.enter="handleQuery" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item label="系统内置" prop="configType"> |
|||
<el-select v-model="queryParams.configType" placeholder="系统内置" clearable> |
|||
<el-option |
|||
v-for="dict in sys_yes_no" |
|||
:key="dict.value" |
|||
:label="dict.label" |
|||
:value="dict.value" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="创建时间" style="width: 308px;"> |
|||
<el-date-picker |
|||
v-model="dateRange" |
|||
value-format="YYYY-MM-DD" |
|||
type="daterange" |
|||
range-separator="-" |
|||
start-placeholder="开始日期" |
|||
end-placeholder="结束日期" |
|||
></el-date-picker> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
|||
<el-button type="info" plain icon="Refresh" @click="resetQuery">重置</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="Config.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|||
</ContentWrap> |
|||
|
|||
<el-row :gutter="10" class="mb8"> |
|||
<el-col :span="1.5"> |
|||
<el-button |
|||
type="success" |
|||
icon="Plus" |
|||
@click="handleAdd" |
|||
>新增</el-button> |
|||
</el-col> |
|||
<el-col :span="1.5"> |
|||
<el-button |
|||
type="success" |
|||
icon="Edit" |
|||
@click="handleUpdate" |
|||
>修改</el-button> |
|||
</el-col> |
|||
<el-col :span="1.5"> |
|||
<el-button |
|||
type="success" |
|||
icon="Delete" |
|||
@click="handleDelete" |
|||
>删除</el-button> |
|||
</el-col> |
|||
<el-col :span="1.5"> |
|||
<el-button |
|||
type="warning" |
|||
icon="Download" |
|||
@click="handleExport" |
|||
>导出</el-button> |
|||
</el-col> |
|||
<el-col :span="1.5"> |
|||
<el-button |
|||
type="warning" |
|||
icon="Refresh" |
|||
@click="handleRefreshCache" |
|||
>刷新缓存</el-button> |
|||
</el-col> |
|||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
|||
</el-row> |
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="Config.allSchemas" |
|||
/> |
|||
|
|||
<el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange"> |
|||
<el-table-column type="selection" width="55" align="center" /> |
|||
<el-table-column label="参数主键" align="center" prop="configId" /> |
|||
<el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" /> |
|||
<el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" /> |
|||
<el-table-column label="参数键值" align="center" prop="configValue" /> |
|||
<el-table-column label="系统内置" align="center" prop="configType" width="100"> |
|||
<template #default="scope"> |
|||
<div :class="scope.row.configType == 'Y' ? 'z-blue':'z-red'">{{scope.row.configType == 'Y' ? '是' : '否'}}</div> |
|||
<!-- <dict-tag :options="sys_yes_no" :value="scope.row.configType" /> --> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
|||
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
|||
<template #default="scope"> |
|||
<span>{{ parseTime(scope.row.createTime) }}</span> |
|||
<!-- 列表 --> |
|||
<ContentWrap> |
|||
<Table |
|||
:columns="tableColumns" |
|||
:data="tableObject.tableList" |
|||
:loading="tableObject.loading" |
|||
:pagination="{ |
|||
total: tableObject.total |
|||
}" |
|||
v-model:pageSize="tableObject.pageSize" |
|||
v-model:currentPage="tableObject.currentPage" |
|||
v-model:sort="tableObject.sort" |
|||
> |
|||
<template #code="{row}"> |
|||
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
|||
<span>{{ row.code }}</span> |
|||
</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width"> |
|||
<template #default="scope"> |
|||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button> |
|||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<pagination |
|||
v-show="total > 0" |
|||
:total="total" |
|||
v-model:page="queryParams.pageNum" |
|||
v-model:limit="queryParams.pageSize" |
|||
@pagination="getList" |
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="ConfigRules" |
|||
:formAllSchemas="Config.allSchemas" |
|||
:apiUpdate="ConfigApi.updateConfig" |
|||
:apiCreate="ConfigApi.createConfig" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 添加或修改参数配置对话框 --> |
|||
<el-dialog :title="title" v-model="open" width="500px" append-to-body draggable> |
|||
<el-form ref="configRef" :model="form" :rules="rules" label-width="80px"> |
|||
<el-form-item label="参数名称" prop="configName"> |
|||
<el-input v-model="form.configName" placeholder="请输入参数名称" /> |
|||
</el-form-item> |
|||
<el-form-item label="参数键名" prop="configKey"> |
|||
<el-input v-model="form.configKey" placeholder="请输入参数键名" /> |
|||
</el-form-item> |
|||
<el-form-item label="参数键值" prop="configValue"> |
|||
<el-input v-model="form.configValue" placeholder="请输入参数键值" /> |
|||
</el-form-item> |
|||
<el-form-item label="系统内置" prop="configType"> |
|||
<el-radio-group v-model="form.configType"> |
|||
<el-radio |
|||
v-for="dict in sys_yes_no" |
|||
:key="dict.value" |
|||
:label="dict.value" |
|||
>{{ dict.label }}</el-radio> |
|||
</el-radio-group> |
|||
</el-form-item> |
|||
<el-form-item label="备注" prop="remark"> |
|||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template #footer> |
|||
<div class="dialog-footer"> |
|||
<el-button type="primary" @click="submitForm">确 定</el-button> |
|||
<el-button @click="cancel">取 消</el-button> |
|||
</div> |
|||
</template> |
|||
</el-dialog> |
|||
</div> |
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="Config.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<ImportForm ref="importFormRef" url="/sys/config/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|||
</template> |
|||
|
|||
<script setup name="Config"> |
|||
import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config"; |
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { Config,ConfigRules } from './config.data' |
|||
import * as ConfigApi from '@/api/system/sysconfig' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|||
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|||
import Detail from '@/components/Detail/src/Detail.vue' |
|||
|
|||
const { proxy } = getCurrentInstance(); |
|||
const { sys_yes_no } = proxy.useDict("sys_yes_no"); |
|||
defineOptions({ name: 'SysConfig' }) |
|||
|
|||
const configList = ref([]); |
|||
const open = ref(false); |
|||
const loading = ref(true); |
|||
const showSearch = ref(true); |
|||
const ids = ref([]); |
|||
const single = ref(true); |
|||
const multiple = ref(true); |
|||
const total = ref(0); |
|||
const title = ref(""); |
|||
const dateRange = ref([]); |
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const data = reactive({ |
|||
form: {}, |
|||
queryParams: { |
|||
pageNum: 1, |
|||
pageSize: 10, |
|||
configName: undefined, |
|||
configKey: undefined, |
|||
configType: undefined |
|||
}, |
|||
rules: { |
|||
configName: [{ required: true, message: "参数名称不能为空", trigger: "blur" }], |
|||
configKey: [{ required: true, message: "参数键名不能为空", trigger: "blur" }], |
|||
configValue: [{ required: true, message: "参数键值不能为空", trigger: "blur" }] |
|||
} |
|||
}); |
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(Config.allSchemas.tableColumns) |
|||
|
|||
const { queryParams, form, rules } = toRefs(data); |
|||
|
|||
/** 查询参数列表 */ |
|||
function getList() { |
|||
loading.value = true; |
|||
listConfig(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { |
|||
configList.value = response.rows; |
|||
total.value = response.total; |
|||
loading.value = false; |
|||
}); |
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
nextTick(() => { |
|||
const setV = {} |
|||
setV[formField] = val[0][searchField] |
|||
formRef.setValues(setV) |
|||
}) |
|||
} |
|||
/** 取消按钮 */ |
|||
function cancel() { |
|||
open.value = false; |
|||
reset(); |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
/** 表单重置 */ |
|||
function reset() { |
|||
form.value = { |
|||
configId: undefined, |
|||
configName: undefined, |
|||
configKey: undefined, |
|||
configValue: undefined, |
|||
configType: "Y", |
|||
remark: undefined |
|||
}; |
|||
proxy.resetForm("configRef"); |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: ConfigApi.getConfigPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultAddBtn(null), // 新增 |
|||
defaultButtons.defaultExportBtn(null), // 导出 |
|||
defaultButtons.defaultFreshBtn(null), // 刷新 |
|||
defaultButtons.defaultFilterBtn(null), // 筛选 |
|||
defaultButtons.defaultSetBtn(null), // 设置 |
|||
// { |
|||
// label: '自定义扩展按钮', |
|||
// name: 'zdy', |
|||
// hide: false, |
|||
// type: 'primary', |
|||
// icon: 'Select', |
|||
// color: '' |
|||
// }, |
|||
] |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'add') { // 新增 |
|||
openForm('create') |
|||
} else if (val == 'import') { // 导入 |
|||
handleImport() |
|||
} else if (val == 'export') { // 导出 |
|||
handleExport() |
|||
} else if (val == 'refresh') { // 刷新 |
|||
getList() |
|||
} else if (val == 'filtrate') { // 筛选 |
|||
} else { // 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
/** 搜索按钮操作 */ |
|||
function handleQuery() { |
|||
queryParams.value.pageNum = 1; |
|||
getList(); |
|||
} |
|||
/** 重置按钮操作 */ |
|||
function resetQuery() { |
|||
dateRange.value = []; |
|||
proxy.resetForm("queryRef"); |
|||
handleQuery(); |
|||
|
|||
// 列表-操作按钮 |
|||
const butttondata = [ |
|||
defaultButtons.mainListEditBtn(null), // 编辑 |
|||
defaultButtons.mainListDeleteBtn(null), // 删除 |
|||
] |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { // 编辑 |
|||
openForm('update', row) |
|||
} else if (val == 'delete') { // 删除 |
|||
handleDelete(row.id) |
|||
} |
|||
/** 多选框选中数据 */ |
|||
function handleSelectionChange(selection) { |
|||
ids.value = selection.map(item => item.configId); |
|||
single.value = selection.length != 1; |
|||
multiple.value = !selection.length; |
|||
} |
|||
/** 新增按钮操作 */ |
|||
function handleAdd() { |
|||
reset(); |
|||
open.value = true; |
|||
title.value = "添加参数"; |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = (type: string, row?: any) => { |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
/** 修改按钮操作 */ |
|||
function handleUpdate(row) { |
|||
reset(); |
|||
const configId = row.configId || ids.value; |
|||
getConfig(configId).then(response => { |
|||
form.value = response.data; |
|||
open.value = true; |
|||
title.value = "修改参数"; |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType,data) => { |
|||
var isHave =Config.allSchemas.formSchema.some(function (item) { |
|||
return item.field === 'activeTime' || item.field === 'expireTime'; |
|||
}); |
|||
if(isHave){ |
|||
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|||
message.error('失效时间要大于生效时间') |
|||
return; |
|||
} |
|||
/** 提交按钮 */ |
|||
function submitForm() { |
|||
proxy.$refs["configRef"].validate(valid => { |
|||
if (valid) { |
|||
if (form.value.configId != undefined) { |
|||
updateConfig(form.value).then(response => { |
|||
proxy.$modal.msgSuccess("修改成功"); |
|||
open.value = false; |
|||
getList(); |
|||
}); |
|||
} |
|||
if(data.activeTime==0)data.activeTime = null; |
|||
if(data.expireTime==0)data.expireTime = null; |
|||
if (formType === 'create') { |
|||
await ConfigApi.createConfig(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
addConfig(form.value).then(response => { |
|||
proxy.$modal.msgSuccess("新增成功"); |
|||
open.value = false; |
|||
getList(); |
|||
}); |
|||
await ConfigApi.updateConfig(data) |
|||
message.success(t('common.updateSuccess')) |
|||
} |
|||
basicFormRef.value.dialogVisible = false |
|||
getList() |
|||
} |
|||
}); |
|||
|
|||
/** 详情操作 */ |
|||
const detailRef = ref() |
|||
const openDetail = (row: any, titleName: any, titleValue: any) => { |
|||
detailRef.value.openDetail(row, titleName, titleValue, 'basicConfig') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
function handleDelete(row) { |
|||
const configIds = row.configId || ids.value; |
|||
proxy.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function () { |
|||
return delConfig(configIds); |
|||
}).then(() => { |
|||
getList(); |
|||
proxy.$modal.msgSuccess("删除成功"); |
|||
}).catch(() => {}); |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await ConfigApi.deleteConfig(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
} catch {} |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
function handleExport() { |
|||
proxy.download("system/config/export", { |
|||
...queryParams.value |
|||
}, `config_${new Date().getTime()}.xlsx`); |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await ConfigApi.exportConfig(tableObject.params) |
|||
download.excel(data, '系统参数.xlsx') |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
/** 刷新缓存按钮操作 */ |
|||
function handleRefreshCache() { |
|||
refreshCache().then(() => { |
|||
proxy.$modal.msgSuccess("刷新缓存成功"); |
|||
}); |
|||
} |
|||
|
|||
getList(); |
|||
</script> |
|||
/** 导入 */ |
|||
const importFormRef = ref() |
|||
const handleImport = () => { |
|||
importFormRef.value.open() |
|||
} |
|||
// 导入附件弹窗所需的参数 |
|||
const importTemplateData = reactive({ |
|||
templateUrl: '', |
|||
templateTitle: '系统参数导入模版.xlsx' |
|||
}) |
|||
// 导入成功之后 |
|||
const importSuccess = () => { |
|||
getList() |
|||
} |
|||
|
|||
<!-- <style lang="scss" scoped> |
|||
.blue{ |
|||
background: #79bbff; |
|||
color: white; |
|||
border-radius: 6px; |
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
} |
|||
.red{ |
|||
background: #f56c6c; |
|||
color: white; |
|||
border-radius: 6px; |
|||
getList() // 刷新当前列表 |
|||
} |
|||
</style> --> |
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
importTemplateData.templateUrl = await ConfigApi.importTemplate() |
|||
}) |
|||
|
|||
</script> |
|||
|
Loading…
Reference in new issue