445d83dd by 任超

结构

1 parent d742d4f1
export const httpStatus = (() => {
const status = {
OK: { code: 200, text: 'OK', description: '' },
CREATED: { code: 201, text: 'CREATED', description: '' },
DELETED: { code: 204, text: 'DELETED', description: '' },
NOT_MODIFIED: { code: 304, text: 'NOT MODIFIED', description: '' },
BAD_REQUEST: { code: 400, text: 'BAD REQUEST', description: '不正确的请求信息' },
METHOD_NOT_ALLOWED: { code: 405, text: 'METHOD NOT ALLOWED', description: '请求方法不支持' },
UNSUPPORTED_MEDIA_TYPE: { code: 415, text: 'UNSUPPORTED MEDIA TYPE', description: '媒体类型不支持' },
INTERNAL_SERVER_ERROR: { code: 500, text: 'INTERNAL SERVER_ERROR', description: '服务器内部错误' },
PAGE_NOT_FOUND: { code: 404, text: 'PAGE NOT FOUND', description: '网络资源无法访问' },
NOT_AUTHORIZED: { code: 401, text: 'NOT AUTHORIZED', description: '未经授权的访问' },
FORBIDDEN: { code: 403, text: 'FORBIDDEN', description: '禁止访问' },
UNPROCESSABLE_ENTITY: { code: 422, text: 'UNPROCESSABLE ENTITY', description: '' },
SESSION_TIME_OUT: { code: 419, text: 'SESSION_TIME_OUT', description: '会话超时' },
LOGIN_FAILURE:{ code: 11001, text: 'LOGIN_FAILURE', description: '登录失效' },
}
status.CODES = {
/**
* 成功
*/
SUCCESS: {
200: status.OK,
201: status.CREATED,
204: status.DELETED,
304: status.NOT_MODIFIED
},
/**
* 程序错误或恶意攻击
*/
PROGRAM_ERROR: {
400: status.BAD_REQUEST,
405: status.METHOD_NOT_ALLOWED,
415: status.UNSUPPORTED_MEDIA_TYPE,
500: status.INTERNAL_SERVER_ERROR
},
/**
* 网络访问错误
*/
NETWORK_ERROR: {
404: status.PAGE_NOT_FOUND
},
/**
* 权限错误
* TODO 419未确定
*/
AUTH_ERROR: {
401: status.NOT_AUTHORIZED,
403: status.FORBIDDEN,
419: status.SESSION_TIME_OUT
},
/**
* 正常交互错误
*/
COMMUNICATION_ERROR: {
422: status.UNPROCESSABLE_ENTITY
},
/**
* 登录失效
*/
LOGIN_FAILURE: {
11001: status.LOGIN_FAILURE
}
}
return status
})()
import request from '@/utils/request'
class dictionaries {
// 获取所有字典接口
async getDictionary(data){
return request({
url: '/system/sysDictionary/getDictionary',
method: 'get',
params: data,
})
}
// 获取字典根据字典标识码
async getDdicById (id) {
return request({
url: '/system/sysDictionary/getDdicById',
method: 'get',
params: {
id: id
},
})
}
//入住管理 导出
async checkexportData(data){
return request({
url:'/rent/zLiveManage/exportData',
method:'post',
data,
responseType: 'blob'
})
}
// 获取字典根据字典名称
async getDdicByMC (mc) {
return request({
url: '/system/sysDictionary/getDdicByMC',
method: 'get',
params: {
mc: mc
},
})
}
//
async getDetail () {
return request({
url: '/system/sysUser/getAddressInfo',
method: 'get',
})
}
// 根据市id,获取行政区-县区
async getDistByCity () {
return request({
url: '/xzq/getDistByCity',
method: 'get',
params: {
id: '350200000000'
},
})
}
// 行政区-县区-街道
async getXzq () {
return request({
url: '/xzq/getXzq',
method: 'get'
})
}
// 联想查询接口
async searchDepartmentByKeys () {
return request({
url: '/resource/fDepartment/searchDepartmentByKeys',
method: 'get',
})
}
async getAllDepartment(){
return request({
url:'/resource/fDepartment/getAllDepartment',
method:'get'
})
}
}
export default new dictionaries()
import request from '@/utils/request'
export function doLogin (data) {
return request({
method: 'post',
url: '/doLogin',
data
})
}
export function verifyCode () {
return request({
method: 'get',
url: '/verifyCode',
})
}
// 获取当前用户登录的信息
export function getCurrentUserInfo () {
return request({
method: 'get',
url: '/getSysUserDo',
})
}
// 忘记密码
export function forgetPassword (data) {
return request({
method: 'post',
url: '/system/sysUser/forgetPassword',
data
})
}
// 入驻
export function settle (data) {
return request({
method: 'post',
url: '/settle',
data: data
})
}
// 获取当前登录用户有权限的分店列表
export function getOrganizationUserList () {
return request({
url: '/getOrganizationUserList',
method: 'get'
})
}
// 重新设置当前登录用户信息
export function setOrganizationId (organizationId) {
return request({
url: '/setOrganizationId',
method: 'get',
params: {
organizationId: organizationId
}
})
}
import request from '@/utils/request'
export function login (data) {
return request({
url: '/doLogin',
method: 'post',
data
})
}
export function getMenuInfo () {
return request({
url: '/getWebMenuRole',
method: 'get',
})
}
export function logout () {
return request({
url: '/admin/logout',
method: 'post'
})
}
.dialogBox {
border-radius: 8px;
overflow: hidden;
background: #FFFFFF;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.10);
.dialog_title {
display: flex;
position: relative;
top: -2px;
b {
flex: 1;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
}
.el-dialog__header {
height: 50px;
background: #FCFDFD;
border-radius: 4px 4px 0 0;
position: relative;
}
.dialog_full {
position: absolute;
top: 0;
right: 6%;
}
.el-dialog__body {
max-height: 88vh;
overflow-y: scroll;
overflow-x: hidden;
}
.dialog_footer {
flex-direction: column;
.dialog_button {
margin-top: 8px;
}
}
}
.el-dialog__wrapper {
overflow: hidden;
}
\ No newline at end of file
<template>
<el-dialog :visible.sync="dialogVisible" v-dialogDrag :width="width" @close="closeDialog('ruleForm', !showEnter)"
:fullscreen="fullscreen" top="0" :append-to-body="true" :lock-scroll="true" :close-on-click-modal="false"
custom-class="dialogBox" :destroy-on-close="true" :class="[customClass]" id="dialogBox" ref="dialogBox">
<div slot="title" class="dialog_title" ref="dialogTitle">
<b>{{ title }}</b>
<div v-if="isFullscreen" class="dialog_full">
<i class="el-icon-rank" v-if="fullscreen" @click="handleFullscreen"></i>
<i class="el-icon-full-screen" v-else @click="handleFullscreen" />
</div>
</div>
<div class="dialogBox-content" :style="{ height: scrollerHeight ? scrollerHeight : 'auto' }" :key="key">
<slot></slot>
</div>
<div slot="footer" class="dialog_footer" ref="dialogFooter" v-if="isButton">
<div class="dialog_button" v-if="normal">
<el-button @click="closeDialog('ruleForm',)" v-if="isReset && !isSave && showEnter">确定</el-button>
<el-button @click="closeDialog('ruleForm', showEnter)" v-if="isReset">取消</el-button>
<el-button type="primary" plain @click="submitForm('ruleForm')" v-if="isSave" :loading="saveloding">
{{ saveButton }}</el-button>
</div>
<div class="dialog_button" v-else>
<el-button @click="closeDiaActivity(true)">确定</el-button>
<el-button @click="closeDiaActivity(false)">取消</el-button>
</div>
</div>
</el-dialog>
</template>
<script>
export default {
props: {
activity: {
type: Boolean,
default: false,
},
normal: {
type: Boolean,
default: true,
},
showEnter: {
type: Boolean,
default: true,
},
isButton: {
type: Boolean,
default: true,
},
multiple: {
type: Boolean,
default: false,
},
width: {
type: String,
default: '70%',
},
title: {
type: String,
default: '',
},
customClass: {
type: String,
default: '',
},
topHeight: {
type: String,
default: '0',
},
isFullscreen: {
type: Boolean,
default: true,
},
isSave: {
type: Boolean,
default: true,
},
saveButton: {
type: String,
default: '提交',
},
isReset: {
type: Boolean,
default: true,
},
saveloding: {
type: Boolean,
default: false,
},
},
data () {
return {
key: 0,
dialogVisible: false,
fullscreen: false,
scrollerHeight: '',
}
},
methods: {
isShow () {
this.dialogVisible = true
},
isHide () {
this.dialogVisible = false
this.key++
},
handleFullscreen () {
this.fullscreen = !this.fullscreen
let height = document.getElementById('dialogBox').clientHeight
if (!this.fullscreen) {
this.scrollerHeight = false
} else {
this.scrollerHeight = (window.innerHeight - 180) + 'px'
}
},
submitForm (ruleForm) {
if (!this.multiple) {
this.$parent.submitForm(ruleForm)
} else {
this.$emit('submitForm', ruleForm);
}
},
closeDialog (ruleForm, flag) {
console.log(456789, this.multiple)
this.key++
if (!this.multiple) {
if (this.$parent.closeDialog) {
// console.log(1)
this.$parent.closeDialog(ruleForm)
} else {
// console.log(2)
this.dialogVisible = false;
}
} else {
this.$emit('closeDialog', ruleForm, flag);
}
},
closeDiaActivity (flag) {
this.$emit('closeDialog', flag);
}
},
}
</script>
<style rel="stylesheet/scss" lang="scss" >
@import "./index.scss";
</style>
\ No newline at end of file
## 这个是弹框组件,对于element自带的组件进行封装,方便修改全局样式做统一操作
### 使用时在组件中引用
```
import dialogBox from '@/components/dialogBox/index'
<dialogBox ref="dialog" title="标题">
**在这里面写弹框内容**
</dialogBox>
*在父组件中使用 的按钮提交方法*
submitForm(ruleForm) {
}
```
##### 如果有多个弹框
```
import dialogBox from '@/components/dialogBox/index'
<dialogBox ref="dialog" @submitForm="自定义方法" title="标题" :multiple="true">
**在这里面写弹框内容**
</dialogBox>
*在父组件中使用 的按钮提交方法*
自定义方法(ruleForm) {
}
```
## 打开该dialog:
this.$refs.dialog.isShow();
## 隐藏该dialog:
this.$refs.dialog.isHide();
\ No newline at end of file
export default {
selection: {
renderHeader: (h, { store }) => {
return (
<el-checkbox
disabled={store.states.data && store.states.data.length === 0}
indeterminate={
store.states.selection.length > 0 && !store.states.isAllSelected
}
nativeOn-click={store.toggleAllSelection}
value={store.states.isAllSelected}
/>
)
},
renderCell: (h, { row, column, store, $index }) => {
return (
<el-checkbox
nativeOn-click={event => event.stopPropagation()}
value={store.isSelected(row)}
disabled={
column.selectable
? !column.selectable.call(null, row, $index)
: false
}
on-input={() => {
store.commit('rowSelectedChanged', row)
}}
/>
)
},
sortable: false,
resizable: false
},
index: {
renderHeader: (h, scope) => {
return <span>{scope.column.label || '#'}</span>
},
renderCell: (h, { $index, column }) => {
let i = $index + 1
const index = column.index
if (typeof index === 'number') {
i = $index + index
} else if (typeof index === 'function') {
i = index($index)
}
return <div>{i}</div>
},
sortable: false
},
expand: {
renderHeader: (h, scope) => {
return <span>{scope.column.label || ''}</span>
},
renderCell: (h, { row, store }, proxy) => {
const expanded = store.states.expandRows.indexOf(row) > -1
return (
<div
class={
'el-table__expand-icon ' +
(expanded ? 'el-table__expand-icon--expanded' : '')
}
on-click={e => proxy.handleExpandClick(row, e)}
>
<i class='el-icon el-icon-arrow-right' />
</div>
)
},
sortable: false,
resizable: false,
className: 'el-table__expand-column'
}
}
import lbTable from './lb-table.vue'
export default {
install:(Vue) => {
Vue.component('lbTable',lbTable);
}
}
\ No newline at end of file
/*
* FileName: lb-column.vue
* Remark: element-column
* Project: lb-element-table
* Author: 任超
* File Created: Tuesday, 19th March 2019 9:58:23 am
* Last Modified: Tuesday, 19th March 2019 10:14:42 am
* Modified By: 任超
*/
<template>
<el-table-column v-bind="$attrs"
v-on="$listeners"
:prop="column.prop"
:label="column.label"
:type="column.type"
:index="column.index"
:column-key="column.columnKey"
:width="column.width"
:min-width="setColumnWidth(column.label)"
:fixed="column.fixed"
:scoped-slot="column.renderHeader"
:sortable="column.sortable || false"
:sort-method="column.sortMethod"
:sort-by="column.sortBy"
:sort-orders="column.sortOrders"
:resizable="column.resizable || true"
:formatter="column.formatter"
:show-overflow-tooltip="column.showOverflowTooltip != null ? column.showOverflowTooltip : true"
:align="column.align!=null ? column.align : 'left'"
:header-align="column.headerAlign || headerAlign || column.align || align || 'left'"
:class-name="column.className"
:label-class-name="column.labelClassName"
:selectable="column.selectable"
:reserve-selection="column.reserveSelection || false"
:filters="column.filters"
:filter-placement="column.filterPlacement"
:filter-multiple="column.filterMultiple"
:filter-method="column.filterMethod"
:filtered-value="column.filteredValue">
<template slot="header"
slot-scope="scope">
<lb-render v-if="column.renderHeader"
:scope="scope"
:render="column.renderHeader">
</lb-render>
<span v-else>{{ scope.column.label }}</span>
</template>
<template slot-scope="scope">
<lb-render :scope="scope"
:render="column.render">
</lb-render>
</template>
<template v-if="column.children">
<lb-column v-for="(col, index) in column.children"
:key="index"
:column="col">
</lb-column>
</template>
</el-table-column>
</template>
<script>
import LbRender from './lb-render'
import forced from './forced.js'
export default {
name: 'LbColumn',
props: {
column: Object,
headerAlign: String,
align: String
},
components: {
LbRender
},
methods: {
setColumnWidth(str) {
let columnWidth = 0;
for (let char of str) {
if ((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z')) {
// 如果是英文字符,为字符分配10个单位宽度,单位宽度可根据字体大小调整
columnWidth += 10
} else if (char >= '\u4e00' && char <= '\u9fa5') {
// 如果是中文字符,为字符分配14个单位宽度,单位宽度可根据字体大小调整
columnWidth += 14
} else {
// 其他种类字符,为字符分配10个单位宽度,单位宽度可根据字体大小调整
columnWidth += 10
}
}
if (columnWidth < 120) {
// 设置最小宽度
columnWidth = 120
}
return columnWidth + 'px'
},
setColumn () {
if (this.column.type) {
this.column.renderHeader = forced[this.column.type].renderHeader
this.column.render = this.column.render || forced[this.column.type].renderCell
}
if (this.column.formatter) {
this.column.render = (h, scope) => {
return <span>{ scope.column.formatter(scope.row, scope.column, scope.row, scope.$index) }</span>
}
}
if (!this.column.render) {
this.column.render = (h, scope) => {
return <span>{ scope.row[scope.column.property] }</span>
}
}
}
},
watch: {
column: {
handler () {
this.setColumn()
},
immediate: true
}
}
}
</script>
/*
* FileName: lb-render.vue
* Remark: 自定义render
* Project: lb-element-table
* Author: 任超
* File Created: Tuesday, 19th March 2019 10:15:30 am
* Last Modified: Tuesday, 19th March 2019 10:15:32 am
* Modified By: 任超
*/
<script>
export default {
name: 'LbRender',
functional: true,
props: {
scope: Object,
render: Function
},
render: (h, ctx) => {
return ctx.props.render ? ctx.props.render(h, ctx.props.scope) : ''
}
}
</script>
/*
* FileName: lb-table.vue
* Remark: element table
* Project: lb-element-table
* Author: 任超
* File Created: Tuesday, 19th March 2019 9:55:27 am
* Last Modified: Tuesday, 19th March 2019 9:55:34 am
* Modified By: 任超
*/
<template>
<div :class="['lb-table', customClass]">
<el-table ref="elTable" :row-class-name="tableRowClassName" :show-header='showHeader'
:header-cell-style="{ background: '#F8FAFA' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners" :data="data"
style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
<lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
</lb-column>
</el-table>
<br>
<el-pagination class="lb-table-pagination" v-if="pagination" v-bind="$attrs" v-on="$listeners" background
:page-sizes="[10, 15, 20, 50]" layout="total, sizes, prev, pager, next" @current-change="paginationCurrentChange"
:style="{ 'margin-top': paginationTop, 'text-align': paginationAlign }">
</el-pagination>
</div>
</template>
<script>
import LbColumn from './lb-column'
export default {
props: {
column: Array,
data: Array,
spanMethod: Function,
pagination: {
type: Boolean,
default: true,
},
border: {
type: Boolean,
default: true,
},
showHeader: {
type: Boolean,
default: true,
},
paginationTop: {
type: String,
default: '0',
},
heightNum: {
type: Number,
default: 405,
},
heightNumSetting: {
type: Boolean,
default: false,
},
customClass: {
type: String,
default: '',
},
paginationAlign: {
type: String,
default: 'left',
},
merge: Array,
},
components: {
LbColumn,
},
data () {
return {
tableHeight: '100%',
mergeLine: {},
mergeIndex: {},
}
},
created () {
this.getMergeArr(this.data, this.merge)
this.getHeight()
},
mounted () {
},
computed: {
dataLength () {
return [] || this.data.length
},
},
methods: {
tableRowClassName ({ row, rowIndex }) {
if (rowIndex % 2 === 1) {
return 'interlaced';
}
},
getHeight () {
if (this.heightNumSetting) {
this.tableHeight = this.heightNum + 'px'
} else {
this.tableHeight = window.innerHeight - this.heightNum + 'px'
}
},
changeHeight (heightNum) {
this.tableHeight = heightNum + 'px'
},
clearSelection () {
this.$refs.elTable.clearSelection()
},
toggleRowSelection (row, selected) {
this.$refs.elTable.toggleRowSelection(row, selected)
},
toggleAllSelection () {
this.$refs.elTable.toggleAllSelection()
},
toggleRowExpansion (row, expanded) {
this.$refs.elTable.toggleRowExpansion(row, expanded)
},
setCurrentRow (row) {
this.$refs.elTable.setCurrentRow(row)
},
clearSort () {
this.$refs.elTable.clearSort()
},
clearFilter (columnKey) {
this.$refs.elTable.clearFilter(columnKey)
},
doLayout () {
this.$refs.elTable.doLayout()
},
sort (prop, order) {
this.$refs.elTable.sort(prop, order)
},
paginationCurrentChange (val) {
this.$emit('p-current-change', val)
},
getMergeArr (tableData, merge) {
if (!merge) return
this.mergeLine = {}
this.mergeIndex = {}
merge.forEach((item, k) => {
tableData.forEach((data, i) => {
if (i === 0) {
this.mergeIndex[item] = this.mergeIndex[item] || []
this.mergeIndex[item].push(1)
this.mergeLine[item] = 0
} else {
if (data[item] === tableData[i - 1][item]) {
this.mergeIndex[item][this.mergeLine[item]] += 1
this.mergeIndex[item].push(0)
} else {
this.mergeIndex[item].push(1)
this.mergeLine[item] = i
}
}
})
})
},
mergeMethod ({ row, column, rowIndex, columnIndex }) {
const index = this.merge.indexOf(column.property)
if (index > -1) {
const _row = this.mergeIndex[this.merge[index]][rowIndex]
const _col = _row > 0 ? 1 : 0
return {
rowspan: _row,
colspan: _col,
}
}
},
},
watch: {
merge () {
this.getMergeArr(this.data, this.merge)
},
dataLength () {
this.getMergeArr(this.data, this.merge)
}
},
}
</script>
<style rel="stylesheet/scss" lang="scss" >
.lb-table {
.interlaced {
background: #FCFDFD;
;
border: 1px solid #ECECEE;
}
.el-table {
border: 1px solid #ECECEE;
border-radius: 4px 4px 0 0;
}
.el-table::before {
display: none;
}
.el-table--enable-row-hover .el-table__body tr:hover>td {
background: #FBFCFD !important;
}
}
.el-table th>.cell {
padding-left: 20px;
}
.el-table .cell {
padding-left: 20px;
}
</style>
## 这是对于element-table 进行的二次封装
### 文档地址
<!-- table 已经全局注册不需要每个页面单独注册 -->
[Windows/Mac/Linux 全平台客户端](https://github.liubing.me/lb-element-table/zh/guide/)
import Vue from "vue";
/*
* 使用方法
* 将以下代码复制到一个js文件中,然后在入口文件main.js中import引入即可;
* 给elementUI的dialog上加上 v-dialogDrag 指令就可以实现弹窗的全屏和拉伸了。
* 给dialog设置 :close-on-click-modal="false" , 禁止点击遮罩层关闭弹出层
* 如果是form表单,不要将提交等按钮放置el-form-item,以免在上下拉伸时被隐藏
*/
// v-dialogDrag: 弹窗拖拽+水平方向伸缩
Vue.directive('dialogDrag', {
bind(el, binding, vnode, oldVnode) {
const dialogHeaderEl = el.querySelector('.el-dialog__header');
const dragDom = el.querySelector('.el-dialog');
//dialogHeaderEl.style.cursor = 'move';
dialogHeaderEl.style.cssText += ';cursor:move;'
dragDom.style.cssText += ';top:0px;'
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
const sty = (function () {
if (window.document.currentStyle) {
return (dom, attr) => dom.currentStyle[attr];
} else {
return (dom, attr) => getComputedStyle(dom, false)[attr];
}
})()
dialogHeaderEl.onmousedown = (e) => {
// 鼠标按下,计算当前元素距离可视区的距离
const disX = e.clientX - dialogHeaderEl.offsetLeft;
const disY = e.clientY - dialogHeaderEl.offsetTop;
const screenWidth = document.body.clientWidth; // body当前宽度
const screenHeight = document.documentElement.clientHeight; // 可见区域高度(应为body高度,可某些环境下无法获取)
const dragDomWidth = dragDom.offsetWidth; // 对话框宽度
const dragDomheight = dragDom.offsetHeight; // 对话框高度
const minDragDomLeft = dragDom.offsetLeft;
const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
const minDragDomTop = dragDom.offsetTop;
const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomheight;
// 获取到的值带px 正则匹配替换
let styL = sty(dragDom, 'left');
let styT = sty(dragDom, 'top');
// 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
if (styL.includes('%')) {
styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100);
styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100);
} else {
styL = +styL.replace(/\px/g, '');
styT = +styT.replace(/\px/g, '');
};
document.onmousemove = function (e) {
// 通过事件委托,计算移动的距离
let left = e.clientX - disX;
let top = e.clientY - disY;
// 边界处理
if (-(left) > minDragDomLeft) {
left = -(minDragDomLeft);
} else if (left > maxDragDomLeft) {
left = maxDragDomLeft;
}
if (-(top) > minDragDomTop) {
top = -(minDragDomTop);
} else if (top > maxDragDomTop) {
top = maxDragDomTop;
}
// 移动当前元素
dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
};
document.onmouseup = function (e) {
document.onmousemove = null;
document.onmouseup = null;
};
}
}
})
\ No newline at end of file
import onlyNumber from './onlyNumber'
const install = Vue => {
Vue.directive('onlyNumber', onlyNumber)
}
/*
Vue.use( plugin )
安装 Vue.js 插件。如果插件是一个对象,必须提供 install 方法。
如果插件是一个函数,它会被作为 install 方法。install 方法调用时,会将 Vue 作为参数传入。
该方法需要在调用 new Vue() 之前被调用。
当 install 方法被同一个插件多次调用,插件将只会被安装一次。
*/
if (window.Vue) {
window['onlyNumber'] = onlyNumber
Vue.use(install); // eslint-disable-line
}
onlyNumber.install = install
export default onlyNumber
\ No newline at end of file
export default {
inserted (el, vDir, vNode) {
// vDir.value 有指令的参数
let content;
//按键按下=>只允许输入 数字/小数点
el.addEventListener("keypress", event => {
let e = event || window.event;
let inputKey = String.fromCharCode(typeof e.charCode === 'number' ? e.charCode : e.keyCode);
let re = /\d|\./;
content = e.target.value;
//定义方法,阻止输入
function preventInput () {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
}
if (!re.test(inputKey) && !e.ctrlKey) {
preventInput();
} else if (content.indexOf(".") > 0 && inputKey == ".") {
//已有小数点,再次输入小数点
preventInput();
}
});
//按键弹起=>并限制最大最小
el.addEventListener("keyup", event => {
let e = event || window.event;
content = parseFloat(e.target.value);
let arg_max = "";
let arg_min = "";
if (vDir.value) {
arg_max = parseFloat(vDir.value.max);
arg_min = parseFloat(vDir.value.min);
}
if (arg_max && content > arg_max) {
e.target.value = arg_max;
content = arg_max;
}
if (arg_min && content < arg_min) {
e.target.value = arg_min;
content = arg_min;
}
if (!content) {
content = '';
}
});
//失去焦点=>保留指定位小数
el.addEventListener("keydown", event => {//此处会在 el-input 的 @change 后执行
let e = event || window.event;
let key = e.key
if (vDir.value.precision == 0) {
// 不允许输入'e'和'.'
if (key === 'e' || key === '.') {
e.returnValue = false
return false
}
}else {
if (e.target.value != '') {
let arg_precision = 0;//默认保留至整数
if (vDir.value.precision) {
arg_precision = parseFloat(vDir.value.precision);
}
let reg = new RegExp(`^\\d*(\\.?\\d{0,${arg_precision-1}})`, 'g')
e.target.value = (e.target.value.match(reg)[0]) || null
}
}
// content = parseFloat(e.target.value);
// if (!content) {
// content = 0.00;
// }
// if (e.target.value != '') {
// let arg_precision = 0;//默认保留至整数
// if (vDir.value.precision) {
// arg_precision = parseFloat(vDir.value.precision);
// }
// e.target.value = content.toFixed(arg_precision);
// }
// -- callback写法1
// vNode.data.model.callback = ()=>{
// e.target.value = content.toFixed(arg_precision)
// }
// vNode.data.model.callback();
// -- callback 写法2
// vNode.data.model.callback(
// e.target.value = content.toFixed(arg_precision)
// )
})
}
}
\ No newline at end of file
import store from '@/store'
import dictionaries from '@/api/dictionaries'
// 证件种类全局过滤器
export function cardTypeFilter (value) {
var name
if (store.getters.cardTypeOption.length == 0) {
dictionaries.getDdicByMC('证件种类').then((res) => {
store.dispatch('dictionaries/getCardType', res.result)
})
}
store.getters.cardTypeOption.map((item) => {
if (item.id == value) {
name = item.name
}
});
if (name) {
return name
} else {
return '暂无'
}
}
// 全部字典
export function stsInfo (value) {
if (store.getters.stsInfo.length == 0) {
dictionaries.getDictionary().then(res => {
store.dispatch('dictionariesAll/getDicData', res.result)
})
}
}
......
......@@ -3,14 +3,10 @@ import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import './directive/dragDialog';
import Element from 'element-ui'
import './styles/element-variables.scss'
import '@/styles/index.scss' // global css
import onlyNumber from '@/directive/el-input'; //添加此行=>自定义全局指令
import lbTable from './components/lb-table/index';
import store from './store'
import router from './router'
......@@ -18,11 +14,8 @@ import _ from 'lodash'
import './icons' // icon
import * as filters from './filters' // global filters
Vue.use(lbTable);
Vue.use(onlyNumber);
Vue.use(Element, {
size: 'small' // set element-ui default size
size: 'small'
})
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
......
import router from './router'
import store from './store'
import { getMenuInfo } from '@/api/user'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import getPageTitle from '@/utils/get-page-title'
......
import { login } from '@/api/user'
import store from '../index'
import router, { resetRouter } from '@/router'
import { Message } from "element-ui";
......