Browse Source

更新代码

master
ljlong_2630 10 months ago
parent
commit
b8876b0390
  1. 3
      .gitignore
  2. 3
      nginx.conf
  3. 10
      src/api/eam/item/applicationRecordMain/index.ts
  4. 84
      src/api/system/sysconfig/index.ts
  5. 574
      src/components/Detail/src/approveDetail.vue
  6. 30
      src/utils/disposition/defaultButtons.ts
  7. 21
      src/views/eam/item/applicationRecord/index.vue
  8. 2
      src/views/infra/codegen/index.vue
  9. 100
      src/views/system/sysconfig/config.data.ts
  10. 498
      src/views/system/sysconfig/index.vue

3
.gitignore

@ -9,3 +9,6 @@ pnpm-debug
auto-*.d.ts auto-*.d.ts
.idea .idea
.history .history
/eam/
/eam
eam

3
nginx.conf

@ -57,5 +57,4 @@ http {
index index.html index.htm; index index.html index.htm;
} }
} }
} }

10
src/api/eam/item/applicationRecordMain/index.ts

@ -46,6 +46,16 @@ export const deleteApplicationRecordMain = async (id: number) => {
return await request.delete({ url: `/eam/item-apply-main/delete?id=` + id }) return await request.delete({ url: `/eam/item-apply-main/delete?id=` + id })
} }
// 审批通过备件申领记录主
export const agreeApplicationRecordMain = async (id: number) => {
return await request.delete({ url: `/eam/item-apply-main/agree?id=` + id })
}
// 审批驳回备件申领记录主
export const disAgreeApplicationRecordMain = async (id: number) => {
return await request.delete({ url: `/eam/item-apply-main/disAgree?id=` + id })
}
// 导出备件申领记录主 Excel // 导出备件申领记录主 Excel
export const exportApplicationRecordMain = async (params) => { export const exportApplicationRecordMain = async (params) => {
return await request.download({ url: `/eam/item-apply-main/export-excel`, params }) return await request.download({ url: `/eam/item-apply-main/export-excel`, params })

84
src/api/system/sysconfig/index.ts

@ -1,60 +1,50 @@
import request from '@/utils/request' import request from '@/config/axios'
// 查询参数列表 export interface ConfigVO {
export function listConfig(query) { configName: string
return request({ configKey: string
url: '/system/config/list', configValue: string
method: 'get', configType: string
params: query 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 function getConfig(configId) { export const getConfig = async (id: number) => {
return request({ return await request.get({ url: `/sys/config/get?id=` + id })
url: '/system/config/' + configId,
method: 'get'
})
} }
// 根据参数键名查询参数值 // 新增系统参数
export function getConfigKey(configKey) { export const createConfig = async (data: ConfigVO) => {
return request({ return await request.post({ url: `/sys/config/create`, data })
url: '/system/config/configKey/' + configKey,
method: 'get'
})
} }
// 新增参数配置 // 修改系统参数
export function addConfig(data) { export const updateConfig = async (data: ConfigVO) => {
return request({ return await request.put({ url: `/sys/config/update`, data })
url: '/system/config',
method: 'post',
data: data
})
} }
// 修改参数配置 // 删除系统参数
export function updateConfig(data) { export const deleteConfig = async (id: number) => {
return request({ return await request.delete({ url: `/sys/config/delete?id=` + id })
url: '/system/config',
method: 'put',
data: data
})
} }
// 删除参数配置 // 导出系统参数 Excel
export function delConfig(configId) { export const exportConfig = async (params) => {
return request({ return await request.download({ url: `/sys/config/export-excel`, params })
url: '/system/config/' + configId,
method: 'delete'
})
} }
// 刷新参数缓存 // 下载用户导入模板
export function refreshCache() { export const importTemplate = () => {
return request({ return request.download({ url: '/sys/config/get-import-template' })
url: '/system/config/refreshCache',
method: 'delete'
})
} }

574
src/components/Detail/src/approveDetail.vue

@ -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) // 12
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>

30
src/utils/disposition/defaultButtons.ts

@ -788,6 +788,32 @@ export function chooseDeviceBtn(option:any) {
}) })
} }
// 审批通过按钮
export function agree(option:any) {
return __defaultBtnOption(option,{
label: '通过',
name: 'agree',
hide: false,
type: 'primary',
// icon: 'ep:plus',
color: 'green',
hasPermi: ''
})
}
// 审批驳回按钮
export function disAgree(option:any) {
return __defaultBtnOption(option,{
label: '驳回',
name: 'disAgree',
hide: false,
type: 'primary',
// icon: 'ep:plus',
color: 'red',
hasPermi: ''
})
}
// 主列表-撤销 // 主列表-撤销
export function backoutBtn(option:any) { export function backoutBtn(option:any) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{
@ -892,10 +918,6 @@ export function finishOrderBtn(option:any) {
}) })
} }
// 默认按钮规则 // 默认按钮规则
function __defaultBtnOption(option:any,specific:any){ function __defaultBtnOption(option:any,specific:any){
return { return {

21
src/views/eam/item/applicationRecord/index.vue

@ -44,7 +44,13 @@
:apiPage="ApplicationRecordDetailApi.getApplicationRecordDetailPage" :apiPage="ApplicationRecordDetailApi.getApplicationRecordDetailPage"
:apiDelete="ApplicationRecordDetailApi.deleteApplicationRecordDetail" :apiDelete="ApplicationRecordDetailApi.deleteApplicationRecordDetail"
@searchTableSuccessDetail="searchTableSuccessDetail" /> @searchTableSuccessDetail="searchTableSuccessDetail" />
<!-- 审批详情 -->
<approveDetail ref="detailRef1" :isBasic="false" :allSchemas="ApplicationRecordMain.allSchemas"
:detailAllSchemas="ApplicationRecordDetail.allSchemas" :detailAllSchemasRules="ApplicationRecordDetailRules"
:apiAgree="ApplicationRecordMainApi.agreeApplicationRecordMain"
:apiDisAgree="ApplicationRecordMainApi.disAgreeApplicationRecordMain"
:apiPage="ApplicationRecordDetailApi.getApplicationRecordDetailPage"
@searchTableSuccessDetail="searchTableSuccessDetail" />
<!-- 导入 --> <!-- 导入 -->
<ImportForm ref="importFormRef" url="/wms/purchase-main/import" :importTemplateData="importTemplateData" <ImportForm ref="importFormRef" url="/wms/purchase-main/import" :importTemplateData="importTemplateData"
@success="importSuccess" :isShowOut="true" :updateIsDisable="true" :coverIsDisable="true" :mode="2" /> @success="importSuccess" :isShowOut="true" :updateIsDisable="true" :coverIsDisable="true" :mode="2" />
@ -58,6 +64,7 @@
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue' import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import approveDetail from '@/components/Detail/src/approveDetail.vue'
// //
defineOptions({ name: 'ApplicationRecord' }) defineOptions({ name: 'ApplicationRecord' })
@ -163,8 +170,8 @@
// - // -
const butttondata = (row) => { const butttondata = (row) => {
return [ return [
defaultButtons.approveBtn({ hide: isShowMainButton(row, ['0']) }), // defaultButtons.approveBtn({ hide: isShowMainButton(row, ['0']) }), //
// defaultButtons.mainListEditBtn(null), // defaultButtons.mainListEditBtn(null), //
// defaultButtons.mainListDeleteBtn(null), // // defaultButtons.mainListDeleteBtn(null), //
] ]
} }
@ -173,8 +180,8 @@
const buttonTableClick = async (val, row) => { const buttonTableClick = async (val, row) => {
if (val == 'edit') { // if (val == 'edit') { //
openForm('update', row) openForm('update', row)
}else if (val == 'approve') { // } else if (val == 'approve') { //
// handleDelete(row.id) handleApprove(row, '单据号', row.number)
} else if (val == 'delete') { // } else if (val == 'delete') { //
handleDelete(row.id) handleDelete(row.id)
} }
@ -192,6 +199,10 @@
const openDetail = (row : any, titleName : any, titleValue : any) => { const openDetail = (row : any, titleName : any, titleValue : any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicApplicationRecordMain') detailRef.value.openDetail(row, titleName, titleValue, 'basicApplicationRecordMain')
} }
const detailRef1 = ref()
const handleApprove = (row : any, titleName : any, titleValue : any) => {
detailRef1.value.openDetail(row, titleName, titleValue, 'basicApplicationRecordMain')
}
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id : number) => { const handleDelete = async (id : number) => {

2
src/views/infra/codegen/index.vue

@ -156,7 +156,7 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import * as CodegenApi from '@/api/infra/codegen' import * as CodegenApi from '@/api/infra/codegen'
import * as DataSourceConfigApi from '@/api/infra/dataSourceConfig' import * as DataSourceConfigApi from '@/api/infra/dataSourceConfig'
import ImportTable from './ImportTable.vue' import ImportTable from './importTable.vue'
import PreviewCode from './PreviewCode.vue' import PreviewCode from './PreviewCode.vue'
defineOptions({ name: 'InfraCodegen' }) defineOptions({ name: 'InfraCodegen' })

100
src/views/system/sysconfig/config.data.ts

@ -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'
}
}
]))

498
src/views/system/sysconfig/index.vue

@ -1,307 +1,243 @@
<template> <template>
<div class="app-container"> <ContentWrap>
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> <!-- 搜索工作栏 -->
<el-form-item label="参数名称" prop="configName"> <Search :schema="Config.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
<el-input </ContentWrap>
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>
<el-row :gutter="10" class="mb8"> <!-- 列表头部 -->
<el-col :span="1.5"> <TableHead
<el-button :HeadButttondata="HeadButttondata"
type="success" @button-base-click="buttonBaseClick"
icon="Plus" :routeName="routeName"
@click="handleAdd" @updataTableColumns="updataTableColumns"
>新增</el-button> @searchFormClick="searchFormClick"
</el-col> :allSchemas="Config.allSchemas"
<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>
<el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange"> <!-- 列表 -->
<el-table-column type="selection" width="55" align="center" /> <ContentWrap>
<el-table-column label="参数主键" align="center" prop="configId" /> <Table
<el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" /> :columns="tableColumns"
<el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" /> :data="tableObject.tableList"
<el-table-column label="参数键值" align="center" prop="configValue" /> :loading="tableObject.loading"
<el-table-column label="系统内置" align="center" prop="configType" width="100"> :pagination="{
<template #default="scope"> total: tableObject.total
<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" /> --> v-model:pageSize="tableObject.pageSize"
</template> v-model:currentPage="tableObject.currentPage"
</el-table-column> v-model:sort="tableObject.sort"
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> >
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <template #code="{row}">
<template #default="scope"> <el-button type="primary" link @click="openDetail(row, '代码', row.code)">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ row.code }}</span>
</template> </el-button>
</el-table-column> </template>
<el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width"> <template #action="{ row }">
<template #default="scope"> <ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" />
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button> </template>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button> </Table>
</template> </ContentWrap>
</el-table-column>
</el-table>
<pagination <!-- 表单弹窗添加/修改 -->
v-show="total > 0" <BasicForm
:total="total" ref="basicFormRef"
v-model:page="queryParams.pageNum" @success="formsSuccess"
v-model:limit="queryParams.pageSize" :rules="ConfigRules"
@pagination="getList" :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> <Detail ref="detailRef" :isBasic="true" :allSchemas="Config.allSchemas" />
<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>
</template>
<script setup name="Config"> <!-- 导入 -->
import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config"; <ImportForm ref="importFormRef" url="/sys/config/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
const { proxy } = getCurrentInstance(); <script setup lang="ts">
const { sys_yes_no } = proxy.useDict("sys_yes_no"); 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 configList = ref([]); defineOptions({ name: 'SysConfig' })
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 data = reactive({ const message = useMessage() //
form: {}, const { t } = useI18n() //
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 { queryParams, form, rules } = toRefs(data); const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(Config.allSchemas.tableColumns)
/** 查询参数列表 */ //
function getList() { const searchTableSuccess = (formField, searchField, val, formRef) => {
loading.value = true; nextTick(() => {
listConfig(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { const setV = {}
configList.value = response.rows; setV[formField] = val[0][searchField]
total.value = response.total; formRef.setValues(setV)
loading.value = false; })
});
}
/** 取消按钮 */
function cancel() {
open.value = false;
reset();
} }
/** 表单重置 */
function reset() { //
form.value = { const updataTableColumns = (val) => {
configId: undefined, tableColumns.value = val
configName: undefined,
configKey: undefined,
configValue: undefined,
configType: "Y",
remark: undefined
};
proxy.resetForm("configRef");
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
} }
/** 重置按钮操作 */
function resetQuery() { const { tableObject, tableMethods } = useTable({
dateRange.value = []; getListApi: ConfigApi.getConfigPage //
proxy.resetForm("queryRef"); })
handleQuery();
//
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 handleSelectionChange(selection) { // -
ids.value = selection.map(item => item.configId); const butttondata = [
single.value = selection.length != 1; defaultButtons.mainListEditBtn(null), //
multiple.value = !selection.length; defaultButtons.mainListDeleteBtn(null), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
} }
/** 新增按钮操作 */
function handleAdd() { /** 添加/修改操作 */
reset(); const basicFormRef = ref()
open.value = true; const openForm = (type: string, row?: any) => {
title.value = "添加参数"; basicFormRef.value.open(type, row)
} }
/** 修改按钮操作 */
function handleUpdate(row) { // form
reset(); const formsSuccess = async (formType,data) => {
const configId = row.configId || ids.value; var isHave =Config.allSchemas.formSchema.some(function (item) {
getConfig(configId).then(response => { return item.field === 'activeTime' || item.field === 'expireTime';
form.value = response.data;
open.value = true;
title.value = "修改参数";
}); });
} if(isHave){
/** 提交按钮 */ if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
function submitForm() { message.error('失效时间要大于生效时间')
proxy.$refs["configRef"].validate(valid => { return;
if (valid) {
if (form.value.configId != undefined) {
updateConfig(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addConfig(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 {
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 handleDelete = async (id: number) => {
const configIds = row.configId || ids.value; try {
proxy.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function () { //
return delConfig(configIds); await message.delConfirm()
}).then(() => { //
getList(); await ConfigApi.deleteConfig(id)
proxy.$modal.msgSuccess("删除成功"); message.success(t('common.delSuccess'))
}).catch(() => {}); //
await getList()
} catch {}
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
function handleExport() { const exportLoading = ref(false) //
proxy.download("system/config/export", { const handleExport = async () => {
...queryParams.value try {
}, `config_${new Date().getTime()}.xlsx`); //
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(() => { const importFormRef = ref()
proxy.$modal.msgSuccess("刷新缓存成功"); const handleImport = () => {
}); importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '系统参数导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
} }
getList(); //
</script> const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() //
}
<!-- <style lang="scss" scoped> /** 初始化 **/
.blue{ onMounted(async () => {
background: #79bbff; getList()
color: white; importTemplateData.templateUrl = await ConfigApi.importTemplate()
border-radius: 6px; })
}
.red{ </script>
background: #f56c6c;
color: white;
border-radius: 6px;
}
</style> -->

Loading…
Cancel
Save