diff --git a/src/api/certificate.js b/src/api/certificate.js index cbc1e4e..1c8ab18 100644 --- a/src/api/certificate.js +++ b/src/api/certificate.js @@ -1,5 +1,6 @@ import api from '@/utils/api' import qs from 'qs' +import preview from '@/utils/preview' export function add(data) { return api({ @@ -35,9 +36,9 @@ export function getList(params) { }) } -export function exportExcel(params, exportOptions) { - return api({ - url: '/certificate/exportExcel' + '?' + qs.stringify(params, { indices: false }), +export function exportExcel(exportOptions) { + return preview({ + url: '/download/certificate', method: 'get', params: { exportOptions: exportOptions diff --git a/src/api/common.js b/src/api/common.js index 0dfb026..ce4dd91 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -188,4 +188,14 @@ export function getAssetTreeFn() { url: '/asset/tree', method: 'get' }) +} +export function addBorrowFn(params) { + return api({ + url: '/borrowing', + method: 'post', + data: params, + paramsSerializer: function(data) { + return require('qs').stringify(data, { indices: false }) + } + }) } diff --git a/src/api/dic_muti_level_directory.js b/src/api/dic_muti_level_directory.js index eca8a6f..4686628 100644 --- a/src/api/dic_muti_level_directory.js +++ b/src/api/dic_muti_level_directory.js @@ -39,7 +39,7 @@ export function get(params) { export function getTreeList(params) { return api({ - url: rootUrl + '/getTreeList', + url: rootUrl + '/tree', method: 'get', params }) diff --git a/src/api/document_archives.js b/src/api/document_archives.js new file mode 100644 index 0000000..0d02350 --- /dev/null +++ b/src/api/document_archives.js @@ -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 } diff --git a/src/api/export_document.js b/src/api/export_document.js new file mode 100644 index 0000000..49b3000 --- /dev/null +++ b/src/api/export_document.js @@ -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 }) +} diff --git a/src/components/Crud/Edit/index.vue b/src/components/Crud/Edit/index.vue index 7892b1a..9c80023 100644 --- a/src/components/Crud/Edit/index.vue +++ b/src/components/Crud/Edit/index.vue @@ -1,5 +1,8 @@ @@ -15,6 +18,15 @@ export default { disabledEdit: { type: Boolean, default: false + }, + flag: { + type: Boolean, + defalut: false + } + }, + methods: { + editFn() { + this.$emit('editFn', this.data) } } } diff --git a/src/components/Crud/crud.js b/src/components/Crud/crud.js index 474d8cb..a4407a3 100644 --- a/src/components/Crud/crud.js +++ b/src/components/Crud/crud.js @@ -24,8 +24,8 @@ function CRUD(options) { form: {}, // 重置表单 defaultForm: () => {}, - // 排序规则,默认 id 降序, 支持多字段排序 ['id,desc', 'createTime,asc'] - orderBy: ['id,desc'], + // 排序规则,默认 id 降序, 支持多字段排序 ['id desc', 'createTime asc'] + orderBy: ['id desc'], // 等待时间 time: 50, // CRUD Method @@ -250,10 +250,13 @@ function CRUD(options) { * 执行编辑 */ doEdit() { + console.log(581222) if (!callVmHook(crud, CRUD.HOOK.beforeSubmit)) { return } + console.log(crud.crudMethod, crud.form) crud.status.edit = CRUD.STATUS.PROCESSING + crud.crudMethod.edit(crud.form).then(() => { crud.status.edit = CRUD.STATUS.NORMAL crud.getDataStatus(crud.form.id).edit = CRUD.STATUS.NORMAL diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 55791b0..8f67003 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -37,6 +37,11 @@ 个人中心 + + + 证书信息 + + 关于我们 diff --git a/src/main.js b/src/main.js index e3c9db6..90906f1 100644 --- a/src/main.js +++ b/src/main.js @@ -30,6 +30,7 @@ import permission from './directive/permission' import adaptive from './directive/el-table' import vueqr from 'vue-qr' import JSONView from 'vue-json-viewer' +import { checkPermission } from './utils/permission' Vue.use(JSONView) Vue.use(permission) @@ -51,6 +52,7 @@ Vue.use(Col) Vue.use(ElementUI, { locale }) // 全局的常量 +Vue.prototype.checkPermission = checkPermission Vue.prototype.api = api Vue.prototype.apibjd = apibjd Vue.prototype.apisjse = apisjse diff --git a/src/utils/formatter.js b/src/utils/formatter.js index 7ba949c..8ed3430 100644 --- a/src/utils/formatter.js +++ b/src/utils/formatter.js @@ -38,18 +38,32 @@ export default { return null } }, + getNowTime() { + let dateTime = '' + const yy = new Date().getFullYear() + const mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1 + const dd = new Date().getDate() < 10 ? '0' + new Date().getDate() + : new Date().getDate() + const hh = new Date().getHours() + const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() + : new Date().getMinutes() + const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() + : new Date().getSeconds() + dateTime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss + return dateTime + }, /** - * 格式化日期 - * 对Date的扩展,将 Date 转化为指定格式的String - * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, - * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) - * 例子: - * dateFormat("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 - * dateFormat("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 - * @param fmt - * @param date - * @returns {*} - */ + * 格式化日期 + * 对Date的扩展,将 Date 转化为指定格式的String + * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, + * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) + * 例子: + * dateFormat("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 + * dateFormat("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 + * @param fmt + * @param date + * @returns {*} + */ dateFormat(fmt, date) { if (!date) { date = new Date() @@ -81,23 +95,23 @@ export default { // 格式化 let name = '' switch (cellValue) { - case '3000' : + case '3000': name = '电梯' break - case '4000' : - case '5000' : + case '4000': + case '5000': name = '起重' break - case '1000' : + case '1000': name = jylb === 'ZJ' ? '锅炉监检' : '锅炉定检' break - case '2000' : + case '2000': name = jylb === 'ZJ' ? '容器监检' : '容器定检' break - case '8000' : + case '8000': name = '压力管道' break - case '7000' : + case '7000': name = '安全阀' break } diff --git a/src/utils/index.js b/src/utils/index.js index 8e6c2e0..2ad4b6c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,3 +1,5 @@ +import store from '../store' + /* eslint-disable one-var */ /** * Created by jiachenpan on 16/11/18. @@ -48,7 +50,27 @@ export function parseTime(time, cFormat) { }) return time_str } - +// 根据字典类型名称获取字典数据列表 +export function getDicDataListByTypeName(typeName) { + // 所有字典类型信息 + const allDicTypeList = store.getters.dicTypeList + // 所有字典数据信息 + const allDicDataList = store.getters.dicDataList + let data = [] + allDicTypeList.filter(dicType => dicType.typeName === typeName).filter(dicType => { + data = allDicDataList.filter(dicData => dicType.id === dicData.typeId) + }) + return data +} +/** + * 根据年月获取当前月的最后一天 + * @param date 例如:2020-01 + * @returns {*} + */ +export function getLastDayByDate(date) { + date = date.split('-') + return date.join('-') + '-' + new Date(date[0], date[1], 0).getDate() +} export function formatTime(time, option) { time = +time * 1000 const d = new Date(time) @@ -118,7 +140,7 @@ export function param(json) { return cleanArray(Object.keys(json).map(key => { if (json[key] === undefined) return '' return encodeURIComponent(key) + '=' + - encodeURIComponent(json[key]) + encodeURIComponent(json[key]) })).join('&') } @@ -138,7 +160,7 @@ export function html2Text(val) { export function objectMerge(target, source) { /* Merges two objects, - giving the last one precedence */ + giving the last one precedence */ if (typeof target !== 'object') { target = {} @@ -184,40 +206,39 @@ export function toggleClass(element, className) { element.className = classString } -export const pickerOptions = [ - { - text: '今天', - onClick(picker) { - const end = new Date() - const start = new Date(new Date().toDateString()) - end.setTime(start.getTime()) - picker.$emit('pick', [start, end]) - } - }, { - text: '最近一周', - onClick(picker) { - const end = new Date(new Date().toDateString()) - const start = new Date() - start.setTime(end.getTime() - 3600 * 1000 * 24 * 7) - picker.$emit('pick', [start, end]) - } - }, { - text: '最近一个月', - onClick(picker) { - const end = new Date(new Date().toDateString()) - const start = new Date() - start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) - picker.$emit('pick', [start, end]) - } - }, { - text: '最近三个月', - onClick(picker) { - const end = new Date(new Date().toDateString()) - const start = new Date() - start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) - picker.$emit('pick', [start, end]) - } - }] +export const pickerOptions = [{ + text: '今天', + onClick(picker) { + const end = new Date() + const start = new Date(new Date().toDateString()) + end.setTime(start.getTime()) + picker.$emit('pick', [start, end]) + } +}, { + text: '最近一周', + onClick(picker) { + const end = new Date(new Date().toDateString()) + const start = new Date() + start.setTime(end.getTime() - 3600 * 1000 * 24 * 7) + picker.$emit('pick', [start, end]) + } +}, { + text: '最近一个月', + onClick(picker) { + const end = new Date(new Date().toDateString()) + const start = new Date() + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) + picker.$emit('pick', [start, end]) + } +}, { + text: '最近三个月', + onClick(picker) { + const end = new Date(new Date().toDateString()) + const start = new Date() + start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) + picker.$emit('pick', [start, end]) + } +}] export function getTime(type) { if (type === 'start') { diff --git a/src/utils/permission.js b/src/utils/permission.js new file mode 100644 index 0000000..419ad3a --- /dev/null +++ b/src/utils/permission.js @@ -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 + } +} diff --git a/src/views/archive/archive_scan.vue b/src/views/archive/archive_scan.vue index 2f8e543..c714e43 100644 --- a/src/views/archive/archive_scan.vue +++ b/src/views/archive/archive_scan.vue @@ -117,8 +117,8 @@ export default { */ getYsjlByBgbh() { // 先去18版承压类进行查询 - this.server({ - url: '/archive/ysjl/getYsjlByBgbh/' + this.baogaobianhao, + this.api({ + url: '/archive/getYsjlByBgbh?bgbh=' + this.baogaobianhao, method: 'get' }).then(data => { if (data != null && data !== '') { @@ -159,7 +159,7 @@ export default { this.archive.archiveUser = this.$store.getters.nickname this.archive.archiveCount = this.paramList.length - this.server({ + this.api({ url: '/archive', method: 'post', data: { diff --git a/src/views/borrow/borrowing-history.vue b/src/views/borrow/borrow-history.vue similarity index 87% rename from src/views/borrow/borrowing-history.vue rename to src/views/borrow/borrow-history.vue index 0dbfd20..f758aef 100644 --- a/src/views/borrow/borrowing-history.vue +++ b/src/views/borrow/borrow-history.vue @@ -9,20 +9,6 @@ placeholder="选择借阅日期" @change="crud.toQuery" /> - - - @@ -51,13 +37,13 @@ :row-class-name="getTableRowClassName" > -