ljlong_2630
8 months ago
10 changed files with 1130 additions and 6 deletions
@ -0,0 +1,52 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface BasciYearEquipmentVO { |
|||
id: number |
|||
name: string |
|||
type: string |
|||
factoryType: string |
|||
yearIndex: Date |
|||
goal: number |
|||
actual: number |
|||
} |
|||
|
|||
// 查询首页年设备指标列表
|
|||
export const getBasciYearEquipmentPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/eam/basci-year-equipment/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/basci-year-equipment/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询首页年设备指标详情
|
|||
export const getBasciYearEquipment = async (id: number) => { |
|||
return await request.get({ url: `/eam/basci-year-equipment/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增首页年设备指标
|
|||
export const createBasciYearEquipment = async (data: BasciYearEquipmentVO) => { |
|||
return await request.post({ url: `/eam/basci-year-equipment/create`, data }) |
|||
} |
|||
|
|||
// 修改首页年设备指标
|
|||
export const updateBasciYearEquipment = async (data: BasciYearEquipmentVO) => { |
|||
return await request.put({ url: `/eam/basci-year-equipment/update`, data }) |
|||
} |
|||
|
|||
// 删除首页年设备指标
|
|||
export const deleteBasciYearEquipment = async (id: number) => { |
|||
return await request.delete({ url: `/eam/basci-year-equipment/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出首页年设备指标 Excel
|
|||
export const exportBasciYearEquipment = async (params) => { |
|||
return await request.download({ url: `/eam/basci-year-equipment/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/eam/basci-year-equipment/get-import-template' }) |
|||
} |
@ -0,0 +1,54 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface BasicMonthEquipmentVO { |
|||
id: number |
|||
name: string |
|||
type: string |
|||
factoryType: string |
|||
monthIndex: string |
|||
actual: string |
|||
siteId: string |
|||
available: string |
|||
concurrencyStamp: number |
|||
} |
|||
|
|||
// 查询首页月设备实现指标列表
|
|||
export const getBasicMonthEquipmentPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/eam/basic-month-equipment/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/basic-month-equipment/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询首页月设备实现指标详情
|
|||
export const getBasicMonthEquipment = async (id: number) => { |
|||
return await request.get({ url: `/eam/basic-month-equipment/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增首页月设备实现指标
|
|||
export const createBasicMonthEquipment = async (data: BasicMonthEquipmentVO) => { |
|||
return await request.post({ url: `/eam/basic-month-equipment/create`, data }) |
|||
} |
|||
|
|||
// 修改首页月设备实现指标
|
|||
export const updateBasicMonthEquipment = async (data: BasicMonthEquipmentVO) => { |
|||
return await request.put({ url: `/eam/basic-month-equipment/update`, data }) |
|||
} |
|||
|
|||
// 删除首页月设备实现指标
|
|||
export const deleteBasicMonthEquipment = async (id: number) => { |
|||
return await request.delete({ url: `/eam/basic-month-equipment/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出首页月设备实现指标 Excel
|
|||
export const exportBasicMonthEquipment = async (params) => { |
|||
return await request.download({ url: `/eam/basic-month-equipment/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/eam/basic-month-equipment/get-import-template' }) |
|||
} |
@ -0,0 +1,335 @@ |
|||
<!-- 导入组件 --> |
|||
<template> |
|||
<Dialog v-model="dialogVisible" title="导入" width="600" :close-on-click-modal="false"> |
|||
<el-upload |
|||
ref="uploadRef" |
|||
v-model:file-list="fileList" |
|||
:action=" |
|||
importUrl + |
|||
'?mode=' + |
|||
mode + |
|||
'&file=' + |
|||
file + |
|||
'&updatePart=' + |
|||
updatePart + |
|||
'&outFile=' + |
|||
outFile + |
|||
'&fromInventoryStatus=' + fromInventoryStatus + |
|||
'&toInventoryStatus=' + toInventoryStatus |
|||
" |
|||
:auto-upload="false" |
|||
:disabled="formLoading" |
|||
:headers="uploadHeaders" |
|||
:limit="1" |
|||
:on-error="submitFormError" |
|||
:on-exceed="handleExceed" |
|||
:on-success="submitFormSuccess" |
|||
:accept="accept" |
|||
drag |
|||
style="width: 300px; margin: 0 auto" |
|||
v-loading="formLoading" |
|||
> |
|||
<Icon icon="ep:upload-filled" color="#c0c4cc" size="60" /> |
|||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
|||
<!-- <template #tip> |
|||
<div class="el-upload__tip ml--126px mr--80px"> |
|||
<div class="flex"> |
|||
<div |
|||
class="label h-32px mr-26px color-#acaeb3 font-size-14px w-100px text-right" |
|||
style="line-height: 32px" |
|||
>导入模式</div |
|||
> |
|||
<div class=""> |
|||
<div class="radio"> |
|||
<el-radio-group v-model="mode"> |
|||
<el-radio :label="1" :disabled="updateIsDisable">更新</el-radio> |
|||
<el-radio :label="2" :disabled="appendIsDisable">追加</el-radio> |
|||
<el-radio :label="3" :disabled="coverIsDisable">覆盖</el-radio> |
|||
</el-radio-group> |
|||
</div> |
|||
|
|||
<div class="tips color-#acaeb3 font-size-14px"> |
|||
<div class="mt-2">更新:新增并修改</div> |
|||
<div class="mt-2">追加:只新增,不修改</div> |
|||
<div class="mt-2">覆盖:只修改不新增</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="flex mt-16px"> |
|||
<div |
|||
class="label h-32px mr-26px color-#acaeb3 font-size-14px w-100px text-right" |
|||
style="line-height: 32px" |
|||
>部分保存</div |
|||
> |
|||
<div class=""> |
|||
<div class="switch"> |
|||
<el-switch v-model="updatePart" /> |
|||
</div> |
|||
<div class="tips color-#acaeb3 font-size-14px"> |
|||
<div class="mt-2">部分保存:如存在错误数据,正确数据正常导入</div> |
|||
<div class="mt-2">全部保存:全部数据正确,才能导入</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="flex mt-16px" v-if="isShowOut"> |
|||
<div |
|||
class="label h-32px mr-26px color-#acaeb3 font-size-14px w-100px text-right" |
|||
style="line-height: 32px" |
|||
>是否外部资源</div |
|||
> |
|||
<div class=""> |
|||
<div class="switch"> |
|||
<el-switch v-model="outFile" /> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</template> --> |
|||
</el-upload> |
|||
<template #footer> |
|||
<div class="flex items-center"> |
|||
<div class="flex-1 text-left" > |
|||
<el-button type="primary" plain @click="importTemplate" v-if="isShow"> |
|||
<Icon icon="ep:download" /> |
|||
下载模板 |
|||
</el-button> |
|||
</div> |
|||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
|||
<el-button @click="dialogVisible = false">取 消</el-button> |
|||
</div> |
|||
</template> |
|||
</Dialog> |
|||
</template> |
|||
<script lang="ts" setup> |
|||
import { getAccessToken, getTenantId } from '@/utils/auth' |
|||
import download from '@/utils/download' |
|||
|
|||
defineOptions({ name: 'SYMonthImportForm' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
|
|||
const dialogVisible = ref(false) // 弹窗的是否展示 |
|||
const formLoading = ref(false) // 表单的加载中 |
|||
const uploadRef = ref() |
|||
const uploadHeaders = ref() // 上传 Header 头 |
|||
const fileList = ref([]) // 文件列表 |
|||
const file = ref('') |
|||
|
|||
const props = defineProps({ |
|||
importTemplateData: { |
|||
type: Object, |
|||
required: true |
|||
}, |
|||
// 可以导入的文件类型 |
|||
accept: { |
|||
type: String, |
|||
required: false, |
|||
default: '.xlsx,.xls' |
|||
}, |
|||
// 是否更新已经存在的用户数据.默认值是1 |
|||
mode: { |
|||
type: Number, |
|||
required: false, |
|||
default: 1 |
|||
}, |
|||
// 更新是否禁用,默认值不禁用 |
|||
updateIsDisable: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 追加是否禁用,默认值不禁用 |
|||
appendIsDisable: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 覆盖是否禁用,默认值不禁用 |
|||
coverIsDisable: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 是否部门保存,默认是 |
|||
updatePart: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
url: { |
|||
type: String, |
|||
required: false |
|||
}, |
|||
// 显示是否外部资源 |
|||
isShowOut: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 是否显示下载模板按钮 |
|||
isShow: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: true |
|||
}, |
|||
outFile: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 库存修改 扩展额外属性 |
|||
fromInventoryStatus: { |
|||
type: String, |
|||
required: false, |
|||
default: '' |
|||
}, |
|||
// 库存修改 扩展额外属性 |
|||
toInventoryStatus: { |
|||
type: String, |
|||
required: false, |
|||
default: '' |
|||
} |
|||
}) |
|||
const importTemplateData = ref(props.importTemplateData) |
|||
const accept = ref(props.accept) |
|||
const mode = ref(props.mode) //是否更新已经存在的用户数据.默认值是1 |
|||
const updateIsDisable = ref(props.updateIsDisable) //更新是否禁用,默认值不禁用 |
|||
const appendIsDisable = ref(props.appendIsDisable) //追加是否禁用,默认值不禁用 |
|||
const coverIsDisable = ref(props.coverIsDisable) //覆盖是否禁用,默认值不禁用 |
|||
const updatePart = ref(props.updatePart) //是否部门保存 |
|||
const outFile = ref(props.outFile) //是否引入外部资源 |
|||
|
|||
const importUrl = import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + props.url |
|||
|
|||
/** 打开弹窗 */ |
|||
const open = () => { |
|||
dialogVisible.value = true |
|||
resetForm() |
|||
} |
|||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|||
|
|||
/** 提交表单 */ |
|||
const submitForm = async () => { |
|||
if (fileList.value.length == 0) { |
|||
message.error('请上传文件') |
|||
return |
|||
} |
|||
file.value = fileList.value[0].name |
|||
// 提交请求 |
|||
uploadHeaders.value = { |
|||
Authorization: 'Bearer ' + getAccessToken(), |
|||
'tenant-id': getTenantId() |
|||
} |
|||
formLoading.value = true |
|||
uploadRef.value!.submit() |
|||
} |
|||
|
|||
/** 文件上传成功 */ |
|||
const emits = defineEmits(['success']) |
|||
const submitFormSuccess = (response: any) => { |
|||
formLoading.value = true |
|||
console.log(response) |
|||
if (response) { |
|||
if (response.code == 500) { |
|||
uploadRef.value!.clearFiles() |
|||
message.error('导入失败') |
|||
formLoading.value = false |
|||
return |
|||
} else if (response.code == 0) { |
|||
if (response.data.errorCount > 0) { |
|||
message.confirm('文件中有部分数据导入失败,是否下载失败数据?').then(() => { |
|||
// download.excel(file, 'file_' + new Date().getTime()) |
|||
// 通过url下载文件 |
|||
// const downloadElement = document.createElement('a') |
|||
// console.log(172, import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/' + response.data.errorFile) |
|||
// console.log(172, import.meta.env.VITE_BASE_URL + '/admin-api/opt/profile/' + response.data.errorFile) |
|||
window.open( |
|||
import.meta.env.VITE_BASE_URL + '/admin-api' + response.data.errorFile, |
|||
'222' |
|||
) |
|||
// downloadElement.setAttribute('href', import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + response.data.errorFile ) |
|||
// 点击下载 |
|||
// downloadElement.click() |
|||
}) |
|||
} else { |
|||
message.success('导入成功') |
|||
} |
|||
} |
|||
} |
|||
|
|||
// if (response.code !== 0) { |
|||
// message.error(response.msg) |
|||
// formLoading.value = false |
|||
// return |
|||
// } |
|||
// // 拼接提示语 |
|||
// const data = response.data |
|||
// const create = response.data.importResult[0] |
|||
// const update = response.data.importResult[1] |
|||
// const failure = response.data.importResult[2] |
|||
// let text = '上传成功数量:' + data[create].length + ';' |
|||
// for (let name of data[create]) { |
|||
// text += '< ' + name + ' >' |
|||
// } |
|||
// text += '更新成功数量:' + data[update].length + ';' |
|||
// for (const name of data[update]) { |
|||
// text += '< ' + name + ' >' |
|||
// } |
|||
// text += '更新失败数量:' + Object.keys(data[failure]).length + ';' |
|||
// for (const name in data[failure]) { |
|||
// text += '< ' + name + ': ' + data[failure][name] + ' >' |
|||
// } |
|||
// message.alert(text) |
|||
|
|||
// 发送操作成功的事件 |
|||
|
|||
formLoading.value = false |
|||
emits('success') |
|||
dialogVisible.value = false |
|||
} |
|||
/** 上传错误提示 */ |
|||
const submitFormError = (): void => { |
|||
message.error('上传失败,请您重新上传!') |
|||
formLoading.value = false |
|||
} |
|||
|
|||
/** 重置表单 */ |
|||
const resetForm = () => { |
|||
// 重置上传状态和文件 |
|||
formLoading.value = false |
|||
uploadRef.value?.clearFiles() |
|||
fileList.value = [] |
|||
} |
|||
|
|||
/** 文件数超出提示 */ |
|||
const handleExceed = (): void => { |
|||
message.error('最多只能上传一个文件!') |
|||
} |
|||
|
|||
/** 下载模板操作 */ |
|||
const importTemplate = () => { |
|||
const res = importTemplateData.value.templateUrl |
|||
download.excel(res, importTemplateData.value.templateTitle) |
|||
} |
|||
</script> |
|||
|
|||
<style scoped lang="scss"> |
|||
.tips { |
|||
div { |
|||
position: relative; |
|||
padding-left: 22px; |
|||
|
|||
&::before { |
|||
width: 4px; |
|||
height: 4px; |
|||
border-radius: 50%; |
|||
content: ''; |
|||
background: #c2c2c2; |
|||
position: absolute; |
|||
top: 50%; |
|||
margin-top: -2px; |
|||
left: 4px; |
|||
} |
|||
} |
|||
} |
|||
</style> |
@ -0,0 +1,98 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
|
|||
// 表单校验
|
|||
export const BasciYearEquipmentRules = reactive({ |
|||
// name: [required],
|
|||
type: [required], |
|||
factoryType: [required], |
|||
yearIndex: [required], |
|||
goal: [required] |
|||
}) |
|||
|
|||
export const BasciYearEquipment = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
{ |
|||
label: 'id', |
|||
field: 'id', |
|||
sort: 'custom', |
|||
isForm: false, |
|||
isTable:false |
|||
}, |
|||
// {
|
|||
// label: '名称',
|
|||
// field: 'name',
|
|||
// sort: 'custom',
|
|||
// form:{
|
|||
// componentProps:{disabled:true},//属性
|
|||
// // component:'Select' 展示什么类型输入框之类的
|
|||
// }
|
|||
// },
|
|||
{ |
|||
label: '类型名称', |
|||
field: 'type', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.EQUIPMENT_INDEX_NAME, |
|||
dictClass: 'string', |
|||
form: { |
|||
component: 'Select' |
|||
} |
|||
}, |
|||
{ |
|||
label: '厂区类型', |
|||
field: 'factoryType', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.FACTORY_TYPE, |
|||
dictClass: 'string', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'Select' |
|||
} |
|||
}, |
|||
{ |
|||
label: '年指标', |
|||
field: 'yearIndex', |
|||
sort: 'custom', |
|||
form:{ |
|||
component:'DatePicker', |
|||
componentProps:{ |
|||
valueFormat:'YYYY',//格式化后端数据年
|
|||
format:'YYYY'//格式化显示时间为年
|
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '目标值', |
|||
field: 'goal', |
|||
sort: 'custom', |
|||
form:{ |
|||
component:'InputNumber', |
|||
|
|||
} |
|||
}, |
|||
{ |
|||
label: '实际值', |
|||
field: 'actual', |
|||
sort: 'custom', |
|||
form: { |
|||
componentProps:{ |
|||
disabled:true |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '创建时间', |
|||
field: 'createTime', |
|||
sort: 'custom', |
|||
formatter: dateFormatter, |
|||
isForm: false |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
@ -0,0 +1,270 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search |
|||
:schema="BasciYearEquipment.allSchemas.searchSchema" |
|||
@search="setSearchParams" |
|||
@reset="setSearchParams" |
|||
/> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="BasciYearEquipment.allSchemas" |
|||
/> |
|||
|
|||
<!-- 列表 --> |
|||
<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 #goal="{ row }"> |
|||
<span>{{ row.goal }}</span> |
|||
</template> --> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event, row)" /> |
|||
</template> |
|||
<template #goal="{ row }"> |
|||
<span>{{ row.goal+"%" }}</span> |
|||
</template> |
|||
<template #actual="{ row }"> |
|||
<span>{{ row.goal==null?"":row.goal+"%" }}</span> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="BasciYearEquipmentRules" |
|||
:formAllSchemas="BasciYearEquipment.allSchemas" |
|||
:apiUpdate="BasciYearEquipmentApi.updateBasciYearEquipment" |
|||
:apiCreate="BasciYearEquipmentApi.createBasciYearEquipment" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="BasciYearEquipment.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<!-- <ImportForm |
|||
ref="importFormRef" |
|||
url="/eam/basci-year-equipment/import" |
|||
:importTemplateData="importTemplateData" |
|||
@success="importSuccess" |
|||
/> --> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { BasciYearEquipment, BasciYearEquipmentRules } from './basciYearEquipment.data' |
|||
import * as BasciYearEquipmentApi from '@/api/eam/basic/basciYearEquipment' |
|||
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' |
|||
|
|||
defineOptions({ name: 'BasciYearEquipment' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(BasciYearEquipment.allSchemas.tableColumns) |
|||
|
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
nextTick(() => { |
|||
const setV = {} |
|||
setV[formField] = val[0][searchField] |
|||
formRef.setValues(setV) |
|||
}) |
|||
} |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: BasciYearEquipmentApi.getBasciYearEquipmentPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultAddBtn(null), // 新增 |
|||
// defaultButtons.defaultImportBtn(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) |
|||
} |
|||
} |
|||
|
|||
// 列表-操作按钮 |
|||
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) |
|||
} |
|||
} |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = (type: string, row?: any) => { |
|||
if (type == 'update') { |
|||
console.log("123",BasciYearEquipment.allSchemas.formSchema); |
|||
BasciYearEquipment.allSchemas.formSchema.find(item => item.field == 'factoryType').componentProps.disabled = true//编辑置灰 |
|||
// BasciYearEquipment.allSchemas.formSchema.find(item => item.field == 'factory_type').componentProps.disabled = true//编辑置灰 |
|||
//BasciYearEquipment.allSchemas.formSchema.find(item => item.field == 'year_index').componentProps.disabled = true//编辑置灰 |
|||
} |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType, data) => { |
|||
var isHave = BasciYearEquipment.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 |
|||
} |
|||
} |
|||
if (data.activeTime == 0) data.activeTime = null |
|||
if (data.expireTime == 0) data.expireTime = null |
|||
if (formType === 'create') { |
|||
await BasciYearEquipmentApi.createBasciYearEquipment(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await BasciYearEquipmentApi.updateBasciYearEquipment(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, 'basicBasciYearEquipment') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await BasciYearEquipmentApi.deleteBasciYearEquipment(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
} catch {} |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await BasciYearEquipmentApi.exportBasciYearEquipment(tableObject.params) |
|||
download.excel(data, '首页年设备指标.xlsx') |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
} |
|||
|
|||
/** 导入 */ |
|||
const importFormRef = ref() |
|||
const handleImport = () => { |
|||
importFormRef.value.open() |
|||
} |
|||
// 导入附件弹窗所需的参数 |
|||
const importTemplateData = reactive({ |
|||
templateUrl: '', |
|||
templateTitle: '首页年设备指标导入模版.xlsx' |
|||
}) |
|||
// 导入成功之后 |
|||
const importSuccess = () => { |
|||
getList() |
|||
} |
|||
|
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
} |
|||
getList() // 刷新当前列表 |
|||
} |
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
//importTemplateData.templateUrl = await BasciYearEquipmentApi.importTemplate() |
|||
}) |
|||
</script> |
@ -0,0 +1,71 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
|
|||
// 表单校验
|
|||
export const BasicMonthEquipmentRules = reactive({ |
|||
type: [required], |
|||
factoryType: [required], |
|||
monthIndex: [required], |
|||
}) |
|||
|
|||
export const BasicMonthEquipment = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
{ |
|||
label: 'id', |
|||
field: 'id', |
|||
sort: 'custom', |
|||
isTable: false, |
|||
isForm: false, |
|||
}, |
|||
// {
|
|||
// label: '名称',
|
|||
// field: 'name',
|
|||
// sort: 'custom',
|
|||
// },
|
|||
{ |
|||
label: '类型', |
|||
field: 'type', |
|||
dictType: DICT_TYPE.EQUIPMENT_INDEX_NAME, |
|||
dictClass: 'string', |
|||
sort: 'custom', |
|||
form: { |
|||
component: 'Select' |
|||
}, |
|||
}, |
|||
{ |
|||
label: '厂区', |
|||
field: 'factoryType', |
|||
dictType: DICT_TYPE.FACTORY_TYPE, |
|||
dictClass: 'string', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'Select' |
|||
}, |
|||
}, |
|||
{ |
|||
label: '年月', |
|||
field: 'monthIndex', |
|||
sort: 'custom', |
|||
}, |
|||
{ |
|||
label: '实际值', |
|||
field: 'actual', |
|||
sort: 'custom', |
|||
}, |
|||
{ |
|||
label: '创建时间', |
|||
field: 'createTime', |
|||
sort: 'custom', |
|||
formatter: dateFormatter, |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
@ -0,0 +1,242 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="BasicMonthEquipment.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="BasicMonthEquipment.allSchemas" |
|||
/> |
|||
|
|||
<!-- 列表 --> |
|||
<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 #actual="{row}"> |
|||
<span>{{ row.type=='0'?row.actual+"%":row.actual }}</span> |
|||
</template> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="BasicMonthEquipmentRules" |
|||
:formAllSchemas="BasicMonthEquipment.allSchemas" |
|||
:apiUpdate="BasicMonthEquipmentApi.updateBasicMonthEquipment" |
|||
:apiCreate="BasicMonthEquipmentApi.createBasicMonthEquipment" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="BasicMonthEquipment.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<SYMonthImportForm ref="importFormRef" url="/eam/basic-month-equipment/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { BasicMonthEquipment,BasicMonthEquipmentRules } from './basicMonthEquipment.data' |
|||
import * as BasicMonthEquipmentApi from '@/api/eam/basic/basicMonthEquipment' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
// import TableHead from '@/components/TableHead/src/TableHead.vue' |
|||
import SYMonthImportForm from '@/components/ImportForm/src/SYMonthImportForm.vue' |
|||
// import Detail from '@/components/Detail/src/Detail.vue' |
|||
|
|||
defineOptions({ name: 'BasicMonthEquipment' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(BasicMonthEquipment.allSchemas.tableColumns) |
|||
|
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
nextTick(() => { |
|||
const setV = {} |
|||
setV[formField] = val[0][searchField] |
|||
formRef.setValues(setV) |
|||
}) |
|||
} |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: BasicMonthEquipmentApi.getBasicMonthEquipmentPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
//defaultButtons.defaultAddBtn(null), // 新增 |
|||
defaultButtons.defaultImportBtn(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) |
|||
} |
|||
} |
|||
|
|||
// 列表-操作按钮 |
|||
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) |
|||
} |
|||
} |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = (type: string, row?: any) => { |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType,data) => { |
|||
var isHave =BasicMonthEquipment.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; |
|||
} |
|||
} |
|||
if(data.activeTime==0)data.activeTime = null; |
|||
if(data.expireTime==0)data.expireTime = null; |
|||
if (formType === 'create') { |
|||
await BasicMonthEquipmentApi.createBasicMonthEquipment(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await BasicMonthEquipmentApi.updateBasicMonthEquipment(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, 'basicBasicMonthEquipment') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await BasicMonthEquipmentApi.deleteBasicMonthEquipment(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
} catch {} |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await BasicMonthEquipmentApi.exportBasicMonthEquipment(tableObject.params) |
|||
download.excel(data, '首页月设备实现指标.xlsx') |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
} |
|||
|
|||
/** 导入 */ |
|||
const importFormRef = ref() |
|||
const handleImport = () => { |
|||
importFormRef.value.open() |
|||
} |
|||
// 导入附件弹窗所需的参数 |
|||
const importTemplateData = reactive({ |
|||
templateUrl: '', |
|||
templateTitle: '首页月设备实现指标导入模版.xlsx' |
|||
}) |
|||
// 导入成功之后 |
|||
const importSuccess = () => { |
|||
getList() |
|||
} |
|||
|
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
} |
|||
getList() // 刷新当前列表 |
|||
} |
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
importTemplateData.templateUrl = await BasicMonthEquipmentApi.importTemplate() |
|||
}) |
|||
|
|||
</script> |
Loading…
Reference in new issue