zhang_li
8 months ago
8 changed files with 260 additions and 199 deletions
@ -1,231 +1,269 @@ |
|||||
<template> |
<template> |
||||
<ContentWrap> |
<ContentWrap> |
||||
<!-- 搜索工作栏 --> |
<!-- 搜索工作栏 --> |
||||
<Search :schema="ProblemSolving.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
<Search |
||||
|
:schema="ProblemSolving.allSchemas.searchSchema" |
||||
|
@search="setSearchParams" |
||||
|
@reset="setSearchParams" |
||||
|
/> |
||||
</ContentWrap> |
</ContentWrap> |
||||
|
|
||||
<!-- 列表头部 --> |
<!-- 列表头部 --> |
||||
<TableHead :HeadButttondata="HeadButttondata" @button-base-click="buttonBaseClick" :routeName="routeName" |
<TableHead |
||||
@updataTableColumns="updataTableColumns" @searchFormClick="searchFormClick" |
:HeadButttondata="HeadButttondata" |
||||
:allSchemas="ProblemSolving.allSchemas" /> |
@button-base-click="buttonBaseClick" |
||||
|
:routeName="routeName" |
||||
|
@updataTableColumns="updataTableColumns" |
||||
|
@searchFormClick="searchFormClick" |
||||
|
:allSchemas="ProblemSolving.allSchemas" |
||||
|
/> |
||||
|
|
||||
<!-- 列表 --> |
<!-- 列表 --> |
||||
<ContentWrap> |
<ContentWrap> |
||||
<Table :columns="tableColumns" :data="tableObject.tableList" :loading="tableObject.loading" :pagination="{ |
<Table |
||||
|
:columns="tableColumns" |
||||
|
:data="tableObject.tableList" |
||||
|
:loading="tableObject.loading" |
||||
|
:pagination="{ |
||||
total: tableObject.total |
total: tableObject.total |
||||
}" v-model:pageSize="tableObject.pageSize" v-model:currentPage="tableObject.currentPage" |
}" |
||||
v-model:sort="tableObject.sort"> |
v-model:pageSize="tableObject.pageSize" |
||||
<template #code="{row}"> |
v-model:currentPage="tableObject.currentPage" |
||||
|
v-model:sort="tableObject.sort" |
||||
|
> |
||||
|
<template #code="{ row }"> |
||||
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
||||
<span>{{ row.code }}</span> |
<span>{{ row.code }}</span> |
||||
</el-button> |
</el-button> |
||||
</template> |
</template> |
||||
<template #action="{ row }"> |
<template #action="{ row }"> |
||||
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event, row)" /> |
||||
</template> |
</template> |
||||
</Table> |
</Table> |
||||
</ContentWrap> |
</ContentWrap> |
||||
|
|
||||
<!-- 表单弹窗:添加/修改 --> |
<!-- 表单弹窗:添加/修改 --> |
||||
<BasicForm ref="basicFormRef" @success="formsSuccess" :rules="ProblemSolvingRules" |
<BasicForm |
||||
:formAllSchemas="ProblemSolving.allSchemas" :apiUpdate="ProblemSolvingApi.updateProblemSolving" |
ref="basicFormRef" |
||||
:apiCreate="ProblemSolvingApi.createProblemSolving" @searchTableSuccess="searchTableSuccess" :isBusiness="false" /> |
@success="formsSuccess" |
||||
|
:rules="ProblemSolvingRules" |
||||
|
:formAllSchemas="ProblemSolving.allSchemas" |
||||
|
:apiUpdate="ProblemSolvingApi.updateProblemSolving" |
||||
|
:apiCreate="ProblemSolvingApi.createProblemSolving" |
||||
|
@searchTableSuccess="searchTableSuccess" |
||||
|
:isBusiness="false" |
||||
|
/> |
||||
|
|
||||
<!-- 详情 --> |
<!-- 详情 --> |
||||
<Detail ref="detailRef" :isBasic="true" :allSchemas="ProblemSolving.allSchemas" /> |
<Detail ref="detailRef" :isBasic="true" :allSchemas="ProblemSolving.allSchemas" /> |
||||
|
|
||||
<!-- 导入 --> |
<!-- 导入 --> |
||||
<ImportForm ref="importFormRef" url="/eam/item-accounts/import" :importTemplateData="importTemplateData" |
<ImportForm |
||||
@success="importSuccess" /> |
ref="importFormRef" |
||||
|
url="/eam/item-accounts/import" |
||||
|
:importTemplateData="importTemplateData" |
||||
|
@success="importSuccess" |
||||
|
/> |
||||
</template> |
</template> |
||||
|
|
||||
<script setup lang="ts"> |
<script setup lang="ts"> |
||||
import download from '@/utils/download' |
import download from '@/utils/download' |
||||
import { ProblemSolving, ProblemSolvingRules } from './problemSolving.data' |
import { ProblemSolving, ProblemSolvingRules } from './problemSolving.data' |
||||
import * as ProblemSolvingApi from '@/api/eam/device/problemSolving' |
import * as ProblemSolvingApi from '@/api/eam/device/problemSolving' |
||||
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 Detail from '@/components/Detail/src/Detail.vue' |
import Detail from '@/components/Detail/src/Detail.vue' |
||||
|
|
||||
defineOptions({ name: 'ProblemSolving' }) |
|
||||
|
|
||||
const message = useMessage() // 消息弹窗 |
|
||||
const { t } = useI18n() // 国际化 |
|
||||
|
|
||||
const route = useRoute() // 路由信息 |
|
||||
const routeName = ref() |
|
||||
routeName.value = route.name |
|
||||
const tableColumns = ref(ProblemSolving.allSchemas.tableColumns) |
|
||||
|
|
||||
// 查询页面返回 |
|
||||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|
||||
nextTick(() => { |
|
||||
const setV = {} |
|
||||
setV[formField] = val[0][searchField] |
|
||||
formRef.setValues(setV) |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 字段设置 更新主列表字段 |
defineOptions({ name: 'ProblemSolving' }) |
||||
const updataTableColumns = (val) => { |
|
||||
tableColumns.value = val |
const message = useMessage() // 消息弹窗 |
||||
} |
const { t } = useI18n() // 国际化 |
||||
|
|
||||
const { tableObject, tableMethods } = useTable({ |
const route = useRoute() // 路由信息 |
||||
getListApi: ProblemSolvingApi.getProblemSolvingPage // 分页接口 |
const routeName = ref() |
||||
|
routeName.value = route.name |
||||
|
const tableColumns = ref(ProblemSolving.allSchemas.tableColumns) |
||||
|
|
||||
|
// 查询页面返回 |
||||
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
||||
|
nextTick(() => { |
||||
|
const setV = {} |
||||
|
setV[formField] = val[0][searchField] |
||||
|
formRef.setValues(setV) |
||||
}) |
}) |
||||
|
} |
||||
|
|
||||
// 获得表格的各种操作 |
// 字段设置 更新主列表字段 |
||||
const { getList, setSearchParams } = tableMethods |
const updataTableColumns = (val) => { |
||||
|
tableColumns.value = val |
||||
// 列表头部按钮 |
} |
||||
const HeadButttondata = [ |
|
||||
defaultButtons.defaultAddBtn(null), // 新增 |
const { tableObject, tableMethods } = useTable({ |
||||
// { |
getListApi: ProblemSolvingApi.getProblemSolvingPage // 分页接口 |
||||
// label: '自定义扩展按钮', |
}) |
||||
// name: 'zdy', |
|
||||
// hide: false, |
// 获得表格的各种操作 |
||||
// type: 'primary', |
const { getList, setSearchParams } = tableMethods |
||||
// icon: 'Select', |
|
||||
// color: '' |
// 列表头部按钮 |
||||
// }, |
const HeadButttondata = [ |
||||
] |
defaultButtons.defaultAddBtn(null) // 新增 |
||||
|
// { |
||||
// 头部按钮事件 |
// label: '自定义扩展按钮', |
||||
const buttonBaseClick = (val, item) => { |
// name: 'zdy', |
||||
if (val == 'add') { // 新增 |
// hide: false, |
||||
openForm('create') |
// type: 'primary', |
||||
} else if (val == 'import') { // 导入 |
// icon: 'Select', |
||||
handleImport() |
// color: '' |
||||
} else if (val == 'export') { // 导出 |
// }, |
||||
handleExport() |
] |
||||
} else if (val == 'refresh') { // 刷新 |
|
||||
getList() |
// 头部按钮事件 |
||||
} else if (val == 'filtrate') { // 筛选 |
const buttonBaseClick = (val, item) => { |
||||
} else { // 其他按钮 |
if (val == 'add') { |
||||
console.log('其他按钮', item) |
// 新增 |
||||
} |
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 = [ |
const butttondata = [ |
||||
defaultButtons.mainListEditBtn(null), // 编辑 |
defaultButtons.mainListEditBtn(null), // 编辑 |
||||
defaultButtons.mainListDeleteBtn(null), // 删除 |
defaultButtons.mainListDeleteBtn(null) // 删除 |
||||
] |
] |
||||
|
|
||||
// 列表-操作按钮事件 |
// 列表-操作按钮事件 |
||||
const buttonTableClick = async (val, row) => { |
const buttonTableClick = async (val, row) => { |
||||
if (val == 'edit') { // 编辑 |
if (val == 'edit') { |
||||
openForm('update', row) |
// 编辑 |
||||
} else if (val == 'delete') { // 删除 |
openForm('update', row) |
||||
handleDelete(row.id) |
} else if (val == 'delete') { |
||||
} |
// 删除 |
||||
|
handleDelete(row.id) |
||||
} |
} |
||||
|
} |
||||
|
|
||||
/** 添加/修改操作 */ |
/** 添加/修改操作 */ |
||||
const basicFormRef = ref() |
const basicFormRef = ref() |
||||
const openForm = (type : string, row ?: any) => { |
const openForm = (type: string, row?: any) => { |
||||
// console.log(99,row) |
// console.log(99,row) |
||||
row.filePathListView = row.filePathList.map(item=>{ |
console.log(row) |
||||
|
if (row&&row.filePathList && row.filePathList.length > 0) { |
||||
|
row.filePathListView = row.filePathList.map((item) => { |
||||
return { |
return { |
||||
name:item, |
name: item, |
||||
url:item |
url: item |
||||
} |
} |
||||
}) |
}) |
||||
basicFormRef.value.open(type, row) |
|
||||
} |
} |
||||
|
basicFormRef.value.open(type, row) |
||||
|
} |
||||
|
|
||||
// form表单提交 |
// form表单提交 |
||||
const formsSuccess = async (formType, data) => { |
const formsSuccess = async (formType, data) => { |
||||
var isHave = ProblemSolving.allSchemas.formSchema.some(function (item) { |
var isHave = ProblemSolving.allSchemas.formSchema.some(function (item) { |
||||
return item.field === 'activeTime' || item.field === 'expireTime'; |
return item.field === 'activeTime' || item.field === 'expireTime' |
||||
}); |
}) |
||||
if (isHave) { |
if (isHave) { |
||||
if (data.activeTime && data.expireTime && data.activeTime >= data.expireTime) { |
if (data.activeTime && data.expireTime && data.activeTime >= data.expireTime) { |
||||
message.error('失效时间要大于生效时间') |
message.error('失效时间要大于生效时间') |
||||
return; |
return |
||||
} |
|
||||
} |
|
||||
if (data.activeTime == 0) data.activeTime = null; |
|
||||
if (data.expireTime == 0) data.expireTime = null; |
|
||||
data.filePathList=[]; |
|
||||
for (let i = 0; i < data.filePathListView.length; i++) { |
|
||||
data.filePathList.push(data.filePathListView[i].url); |
|
||||
} |
|
||||
if (formType === 'create') { |
|
||||
await ProblemSolvingApi.createProblemSolving(data) |
|
||||
message.success(t('common.createSuccess')) |
|
||||
} else { |
|
||||
await ProblemSolvingApi.createProblemSolving(data) |
|
||||
message.success(t('common.updateSuccess')) |
|
||||
} |
} |
||||
basicFormRef.value.dialogVisible = false |
|
||||
getList() |
|
||||
} |
} |
||||
|
if (data.activeTime == 0) data.activeTime = null |
||||
/** 详情操作 */ |
if (data.expireTime == 0) data.expireTime = null |
||||
const detailRef = ref() |
data.filePathList = [] |
||||
const openDetail = (row : any, titleName : any, titleValue : any) => { |
for (let i = 0; i < data.filePathListView.length; i++) { |
||||
detailRef.value.openDetail(row, titleName, titleValue, 'basicProblemSolving') |
data.filePathList.push(data.filePathListView[i].url) |
||||
} |
} |
||||
|
if (formType === 'create') { |
||||
/** 删除按钮操作 */ |
await ProblemSolvingApi.createProblemSolving(data) |
||||
const handleDelete = async (id : number) => { |
message.success(t('common.createSuccess')) |
||||
try { |
} else { |
||||
// 删除的二次确认 |
await ProblemSolvingApi.createProblemSolving(data) |
||||
await message.delConfirm() |
message.success(t('common.updateSuccess')) |
||||
// 发起删除 |
|
||||
await ProblemSolvingApi.deleteProblemSolving(id) |
|
||||
message.success(t('common.delSuccess')) |
|
||||
// 刷新列表 |
|
||||
await getList() |
|
||||
} catch { } |
|
||||
} |
} |
||||
|
basicFormRef.value.dialogVisible = false |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
/** 导出按钮操作 */ |
/** 详情操作 */ |
||||
const exportLoading = ref(false) // 导出的加载中 |
const detailRef = ref() |
||||
const handleExport = async () => { |
const openDetail = (row: any, titleName: any, titleValue: any) => { |
||||
try { |
detailRef.value.openDetail(row, titleName, titleValue, 'basicProblemSolving') |
||||
// 导出的二次确认 |
} |
||||
await message.exportConfirm() |
|
||||
// 发起导出 |
|
||||
exportLoading.value = true |
|
||||
const data = await ProblemSolvingApi.exportProblemSolving(tableObject.params) |
|
||||
download.excel(data, '备件台账.xlsx') |
|
||||
} catch { |
|
||||
} finally { |
|
||||
exportLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** 导入 */ |
/** 删除按钮操作 */ |
||||
const importFormRef = ref() |
const handleDelete = async (id: number) => { |
||||
const handleImport = () => { |
try { |
||||
importFormRef.value.open() |
// 删除的二次确认 |
||||
} |
await message.delConfirm() |
||||
// 导入附件弹窗所需的参数 |
// 发起删除 |
||||
const importTemplateData = reactive({ |
await ProblemSolvingApi.deleteProblemSolving(id) |
||||
templateUrl: '', |
message.success(t('common.delSuccess')) |
||||
templateTitle: '备件台账导入模版.xlsx' |
// 刷新列表 |
||||
}) |
await getList() |
||||
// 导入成功之后 |
} catch {} |
||||
const importSuccess = () => { |
} |
||||
getList() |
|
||||
|
/** 导出按钮操作 */ |
||||
|
const exportLoading = ref(false) // 导出的加载中 |
||||
|
const handleExport = async () => { |
||||
|
try { |
||||
|
// 导出的二次确认 |
||||
|
await message.exportConfirm() |
||||
|
// 发起导出 |
||||
|
exportLoading.value = true |
||||
|
const data = await ProblemSolvingApi.exportProblemSolving(tableObject.params) |
||||
|
download.excel(data, '备件台账.xlsx') |
||||
|
} catch { |
||||
|
} finally { |
||||
|
exportLoading.value = false |
||||
} |
} |
||||
|
} |
||||
|
|
||||
// 筛选提交 |
/** 导入 */ |
||||
const searchFormClick = (searchData) => { |
const importFormRef = ref() |
||||
tableObject.params = { |
const handleImport = () => { |
||||
isSearch: true, |
importFormRef.value.open() |
||||
filters: searchData.filters |
} |
||||
} |
// 导入附件弹窗所需的参数 |
||||
getList() // 刷新当前列表 |
const importTemplateData = reactive({ |
||||
|
templateUrl: '', |
||||
|
templateTitle: '备件台账导入模版.xlsx' |
||||
|
}) |
||||
|
// 导入成功之后 |
||||
|
const importSuccess = () => { |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
// 筛选提交 |
||||
|
const searchFormClick = (searchData) => { |
||||
|
tableObject.params = { |
||||
|
isSearch: true, |
||||
|
filters: searchData.filters |
||||
} |
} |
||||
|
getList() // 刷新当前列表 |
||||
|
} |
||||
|
|
||||
/** 初始化 **/ |
/** 初始化 **/ |
||||
onMounted(async () => { |
onMounted(async () => { |
||||
getList() |
getList() |
||||
importTemplateData.templateUrl = await ProblemSolvingApi.importTemplate() |
importTemplateData.templateUrl = await ProblemSolvingApi.importTemplate() |
||||
}) |
}) |
||||
</script> |
</script> |
||||
|
Loading…
Reference in new issue