xiaobai
3 years ago
22 changed files with 585 additions and 179 deletions
@ -0,0 +1,39 @@ |
|||
import api from '@/utils/api' |
|||
import qs from 'qs' |
|||
|
|||
export function add(data) { |
|||
return api({ |
|||
url: '/documentArchives', |
|||
method: 'post', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
export function edit(data) { |
|||
return api({ |
|||
url: '/documentArchives', |
|||
method: 'put', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
export function del(params) { |
|||
return api({ |
|||
url: '/documentArchives', |
|||
method: 'delete', |
|||
params, |
|||
paramsSerializer: function(params) { |
|||
return qs.stringify(params, { indices: false }) |
|||
} |
|||
}) |
|||
} |
|||
|
|||
export function exportExcel(params) { |
|||
return api({ |
|||
url: '/documentArchives/exportExcel' + '?' + qs.stringify(params, { indices: false }), |
|||
method: 'get', |
|||
responseType: 'blob' |
|||
}) |
|||
} |
|||
|
|||
export default { add, edit, del, exportExcel } |
@ -0,0 +1,8 @@ |
|||
import axios from 'axios' |
|||
import qs from 'qs' |
|||
|
|||
export function exportReport(params) { |
|||
return axios |
|||
.get(process.env.VUE_APP_EXPORT_REPORT_API + '?' + qs.stringify(params, { indices: false })) |
|||
.then(response => { return response.data }) |
|||
} |
@ -0,0 +1,19 @@ |
|||
import store from '@/store' |
|||
|
|||
/** |
|||
* @param {Array} value |
|||
* @returns {Boolean} |
|||
* @example see @/views/permission/directive.vue |
|||
*/ |
|||
export function checkPermission(value) { |
|||
if (value && value instanceof Array && value.length > 0) { |
|||
const roles = store.getters && store.getters.permissions |
|||
const permissionRoles = value |
|||
return roles.some(role => { |
|||
return permissionRoles.includes(role) |
|||
}) |
|||
} else { |
|||
console.error(`need roles! Like v-permission="['admin','editor']"`) |
|||
return false |
|||
} |
|||
} |
@ -0,0 +1,166 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<!--头部选项--> |
|||
<div class="head-container"> |
|||
<div v-if="crud.props.searchToggle"> |
|||
<el-input v-model="query.filename" placeholder="请输入文件名称" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="crud.toQuery" /> |
|||
|
|||
<query :crud="crud" /> |
|||
</div> |
|||
<crud :permission="permission"> |
|||
<el-button slot="right" class="filter-item" icon="el-icon-download" type="warning" @click="exportExcel"> |
|||
上传文件 |
|||
</el-button> |
|||
</crud> |
|||
</div> |
|||
<!--表格内容--> |
|||
<CustomTable ref="customTable" :col-configs="colConfigs" :columns="columns" :crud="crud"> |
|||
<el-table-column v-if="checkPermission(permission.edit)" slot="operation" align="center" width="100" label="操作"> |
|||
<template slot-scope="scope"> |
|||
<Edit :permission="permission" :data="scope.row" :disabled-edit="false" /> |
|||
</template> |
|||
</el-table-column> |
|||
</CustomTable> |
|||
<pagination /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import CRUD, { form, header, presenter } from '@/components/Crud/crud' |
|||
import Crud from '@/components/Crud' |
|||
import Query from '@/components/Crud/Query' |
|||
import Edit from '@/components/Crud/Edit' |
|||
import CustomTable from '@/components/Crud/Table' |
|||
import Pagination from '@/components/Crud/Pagination' |
|||
import CrudDocumentArchives from '@/api/document_archives' |
|||
import { getDicDataListByTypeName } from '@/api/dic_data' |
|||
import { parseTime, downloadFile, downloadFileUrl } from '@/utils' |
|||
import { exportReport } from '@/api/export_document' |
|||
|
|||
// crud交由presenter持有 |
|||
const defaultCrud = presenter(CRUD({ |
|||
title: '检验机构体系文件管理', |
|||
url: '/documentArchives', |
|||
orderBy: ['id desc'], |
|||
crudMethod: { ...CrudDocumentArchives } |
|||
})) |
|||
|
|||
// 设置初始form |
|||
const defaultForm = form({ |
|||
id: null, |
|||
documentName: '', |
|||
examiningUnit: '', |
|||
borrower: '', |
|||
borrowedDate: '', |
|||
returnDate: '', |
|||
borrowedState: '', |
|||
remark: '' |
|||
}) |
|||
|
|||
// 自定义模板内容 |
|||
const PrefixPlusText = { |
|||
props: ['value', 'functions'], |
|||
template: ` |
|||
<el-tag v-if="functions(value) === '未归还'" type="danger" effect="dark"><span v-html="functions(value)"></span></el-tag> |
|||
<el-tag v-else type="success" effect="dark"><span v-html="functions(value)"></span></el-tag> |
|||
` |
|||
} |
|||
|
|||
export default { |
|||
name: 'DocumentArchivesList', |
|||
components: { Pagination, Query, Crud, CustomTable, Edit }, |
|||
mixins: [defaultCrud, defaultForm, header()], |
|||
data() { |
|||
return { |
|||
colConfigs: [ |
|||
{ prop: 'filename', label: '文件名', align: 'center' }, |
|||
{ prop: 'updateBy', label: '修改人', align: 'center', formatter: this.formatter.getChineseName }, |
|||
{ prop: 'createBy', label: '创建人', align: 'center' }, |
|||
{ prop: 'createTime ', label: '创建时间', align: 'center' }, |
|||
{ prop: 'jieyueTime', label: '借阅时间', align: 'center' }, |
|||
{ prop: 'suffix ', label: '文件名后缀', align: 'center', formatter: this.formatter.getChineseName }, |
|||
{ prop: 'zfState', label: '作废状态', align: 'center', component: PrefixPlusText }, |
|||
{ prop: 'updateBy', label: '修改人', align: 'center' }, |
|||
{ |
|||
prop: 'updateTime', |
|||
label: '更新时间', |
|||
align: 'center', |
|||
formatter: this.formatter.formatterDepartmentName |
|||
}, |
|||
{ slot: 'operation' } |
|||
], |
|||
permission: { |
|||
add: ['documentArchives:add'], |
|||
edit: ['documentArchives:update'], |
|||
del: ['documentArchives:delete'] |
|||
}, |
|||
rules: { |
|||
documentName: [ |
|||
{ required: true, message: '请填写报告编号', trigger: 'blur' } |
|||
], |
|||
borrower: [ |
|||
{ required: true, message: '请填写借阅人', trigger: 'blur' } |
|||
], |
|||
borrowedDate: [ |
|||
{ required: true, message: '请选择借阅时间', trigger: 'blur' } |
|||
], |
|||
agreedReturnDate: [ |
|||
{ required: true, message: '请选择归还时间', trigger: 'blur' } |
|||
], |
|||
borrowedState: [ |
|||
{ required: true, message: '请选择借阅状态', trigger: 'change' } |
|||
] |
|||
}, |
|||
reportRules: { |
|||
year: [ |
|||
{ required: true, message: '请选择年度信息', trigger: 'blur' } |
|||
], |
|||
equipmentTypeCode: [ |
|||
{ required: true, message: '请选择设备种类', trigger: 'change' } |
|||
], |
|||
category: [ |
|||
{ required: true, message: '请选择检验类别', trigger: 'change' } |
|||
] |
|||
}, |
|||
borrowedStateList: [], |
|||
dialogVisible: false, |
|||
reportForm: {}, |
|||
categoryList: [], |
|||
sedirectoryList: [] |
|||
} |
|||
}, |
|||
mounted() { |
|||
this.initDicDataList() |
|||
}, |
|||
methods: { |
|||
initDicDataList() { |
|||
// 借阅状态列表 |
|||
getDicDataListByTypeName('borrowed_state').then(data => { this.borrowedStateList = data }) |
|||
// 设备种类列表 |
|||
getDicDataListByTypeName('sedirectory_code').then(data => { this.sedirectoryList = data }) |
|||
// 检验类别列表 |
|||
getDicDataListByTypeName('inspection_category').then(data => { this.categoryList = data }) |
|||
}, |
|||
exportExcel() { |
|||
CrudDocumentArchives.exportExcel(this.crud.query).then(data => { |
|||
downloadFile(data, parseTime(new Date()) + '-' + this.crud.title + '数据', 'xlsx') |
|||
}) |
|||
}, |
|||
exportReport() { |
|||
this.$refs['reportForm'].validate((valid) => { |
|||
if (valid) { |
|||
exportReport(this.reportForm).then(data => { |
|||
downloadFileUrl(data.data, parseTime(new Date()) + '报告导出数据', 'xlsx') |
|||
this.dialogVisible = false |
|||
}) |
|||
} else { |
|||
return false |
|||
} |
|||
}) |
|||
}, |
|||
closeReportDialog() { |
|||
this.$refs['reportForm'].resetFields() |
|||
} |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue