ljlong_2630 8 months ago
parent
commit
7fbb5a1167
  1. 8
      .env.production
  2. 4
      nginx.conf
  3. 52
      src/api/eam/basic/basciYearEquipment/index.ts
  4. 54
      src/api/eam/basic/basicMonthEquipment/index.ts
  5. 335
      src/components/ImportForm/src/SYMonthImportForm.vue
  6. 2
      src/utils/dict.ts
  7. 98
      src/views/eam/basic/basciYearEquipment/basciYearEquipment.data.ts
  8. 270
      src/views/eam/basic/basciYearEquipment/index.vue
  9. 71
      src/views/eam/basic/basicMonthEquipment/basicMonthEquipment.data.ts
  10. 242
      src/views/eam/basic/basicMonthEquipment/index.vue

8
.env.production

@ -4,10 +4,10 @@ NODE_ENV=test
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://10.62.193.15:25100/api'
VITE_BASE_URL='http://10.62.139.32:80/api'
# 上传路径
VITE_UPLOAD_URL='http://10.62.193.15:25100/api/admin-api/infra/file/upload'
VITE_UPLOAD_URL='http://10.62.139.32:80/api/admin-api/infra/file/upload'
# 接口前缀
VITE_API_BASEPATH=
@ -31,7 +31,7 @@ VITE_BASE_PATH=/
VITE_OUT_DIR=eam
# 自定义接口路径
VITE_INTERFACE_URL='http://10.62.193.15:25110/magic/web/index.html'
VITE_INTERFACE_URL='http://10.62.139.32:80/magic/web/index.html'
# 积木报表请求路径
VITE_JMREPORT_BASE_URL='http://10.62.193.15:25110'
VITE_JMREPORT_BASE_URL='http://10.62.139.32:80'

4
nginx.conf

@ -27,10 +27,10 @@ http {
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
upstream eam {
server localhost:25210 weight=10 max_fails=3 fail_timeout=10s;
server localhost:90 weight=10 max_fails=3 fail_timeout=10s;
}
server {
listen 25200;
listen 80;
server_name_in_redirect off;
server_name dev.ccwin-in.com;
location /api/ {

52
src/api/eam/basic/basciYearEquipment/index.ts

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

54
src/api/eam/basic/basicMonthEquipment/index.ts

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

335
src/components/ImportForm/src/SYMonthImportForm.vue

@ -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>

2
src/utils/dict.ts

@ -302,5 +302,7 @@ export enum DICT_TYPE {
ITEM_SUBJECT = 'item_subject', //备件的科目
TURN_TYPE = 'turn_type', //转移类型
ORDER_COMPLETE_RESULT = 'order_complete_result', //维修工单完成结果
FACTORY_TYPE = 'factory_type',//厂区类别
EQUIPMENT_INDEX_NAME = 'equipment_index_name'//设备年度目标指标名称分类字段
}

98
src/views/eam/basic/basciYearEquipment/basciYearEquipment.data.ts

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

270
src/views/eam/basic/basciYearEquipment/index.vue

@ -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>

71
src/views/eam/basic/basicMonthEquipment/basicMonthEquipment.data.ts

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

242
src/views/eam/basic/basicMonthEquipment/index.vue

@ -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…
Cancel
Save