【modify】使用ESLint格式化代码
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
import { disabledAuthFilter } from "@/utils/authFilter"
|
||||
import { disabledAuthFilter } from '@/utils/authFilter'
|
||||
|
||||
export const DisabledAuthFilterMixin = {
|
||||
props: ['formData'],
|
||||
data(){
|
||||
data () {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
isDisabledAuth(code){
|
||||
return disabledAuthFilter(code,this.formData);
|
||||
},
|
||||
methods: {
|
||||
isDisabledAuth (code) {
|
||||
return disabledAuthFilter(code, this.formData)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ export const JEditableTableMixin = {
|
||||
components: {
|
||||
JEditableTable
|
||||
},
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
title: '操作',
|
||||
visible: false,
|
||||
@@ -26,16 +26,16 @@ export const JEditableTableMixin = {
|
||||
methods: {
|
||||
|
||||
/** 获取所有的editableTable实例 */
|
||||
getAllTable() {
|
||||
getAllTable () {
|
||||
if (!(this.refKeys instanceof Array)) {
|
||||
throw this.throwNotArray('refKeys')
|
||||
}
|
||||
let values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
const values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
return Promise.all(values)
|
||||
},
|
||||
|
||||
/** 遍历所有的JEditableTable实例 */
|
||||
eachAllTable(callback) {
|
||||
eachAllTable (callback) {
|
||||
// 开始遍历
|
||||
this.getAllTable().then(tables => {
|
||||
tables.forEach((item, index) => {
|
||||
@@ -47,11 +47,11 @@ export const JEditableTableMixin = {
|
||||
},
|
||||
|
||||
/** 当点击新增按钮时调用此方法 */
|
||||
add() {
|
||||
//update-begin-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
add () {
|
||||
// update-begin-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
return new Promise((resolve) => {
|
||||
this.tableReset();
|
||||
resolve();
|
||||
this.tableReset()
|
||||
resolve()
|
||||
}).then(() => {
|
||||
if (typeof this.addBefore === 'function') {
|
||||
this.addBefore()
|
||||
@@ -68,12 +68,12 @@ export const JEditableTableMixin = {
|
||||
if (typeof this.addAfter === 'function') this.addAfter(this.model)
|
||||
this.edit({})
|
||||
})
|
||||
//update-end-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
// update-end-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
},
|
||||
/** 当点击了编辑(修改)按钮时调用此方法 */
|
||||
edit(record) {
|
||||
if(record && '{}'!=JSON.stringify(record)){
|
||||
this.tableReset();
|
||||
edit (record) {
|
||||
if (record && JSON.stringify(record) != '{}') {
|
||||
this.tableReset()
|
||||
}
|
||||
if (typeof this.editBefore === 'function') this.editBefore(record)
|
||||
this.visible = true
|
||||
@@ -83,21 +83,21 @@ export const JEditableTableMixin = {
|
||||
if (typeof this.editAfter === 'function') this.editAfter(this.model)
|
||||
},
|
||||
/** 关闭弹窗,并将所有JEditableTable实例回归到初始状态 */
|
||||
close() {
|
||||
close () {
|
||||
this.visible = false
|
||||
this.$emit('close')
|
||||
},
|
||||
//清空子表table的数据
|
||||
tableReset(){
|
||||
// 清空子表table的数据
|
||||
tableReset () {
|
||||
this.eachAllTable((item) => {
|
||||
item.clearRow()
|
||||
})
|
||||
},
|
||||
/** 查询某个tab的数据 */
|
||||
requestSubTableData(url, params, tab, success) {
|
||||
requestSubTableData (url, params, tab, success) {
|
||||
tab.loading = true
|
||||
getAction(url, params).then(res => {
|
||||
let { result } = res
|
||||
const { result } = res
|
||||
let dataSource = []
|
||||
if (result) {
|
||||
if (Array.isArray(result)) {
|
||||
@@ -113,8 +113,8 @@ export const JEditableTableMixin = {
|
||||
})
|
||||
},
|
||||
/** 发起请求,自动判断是执行新增还是修改操作 */
|
||||
request(formData) {
|
||||
let url = this.url.add, method = 'post'
|
||||
request (formData) {
|
||||
let url = this.url.add; let method = 'post'
|
||||
if (this.model.id) {
|
||||
url = this.url.edit
|
||||
method = 'put'
|
||||
@@ -136,18 +136,18 @@ export const JEditableTableMixin = {
|
||||
/* --- handle 事件 --- */
|
||||
|
||||
/** ATab 选项卡切换事件 */
|
||||
handleChangeTabs(key) {
|
||||
handleChangeTabs (key) {
|
||||
// 自动重置scrollTop状态,防止出现白屏
|
||||
getRefPromise(this, key).then(editableTable => {
|
||||
editableTable.resetScrollTop()
|
||||
})
|
||||
},
|
||||
/** 关闭按钮点击事件 */
|
||||
handleCancel() {
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
/** 确定按钮点击事件 */
|
||||
handleOk() {
|
||||
handleOk () {
|
||||
/** 触发表单验证 */
|
||||
this.getAllTable().then(tables => {
|
||||
/** 一次性验证主表和所有的次表 */
|
||||
@@ -156,7 +156,7 @@ export const JEditableTableMixin = {
|
||||
if (typeof this.classifyIntoFormData !== 'function') {
|
||||
throw this.throwNotFunction('classifyIntoFormData')
|
||||
}
|
||||
let formData = this.classifyIntoFormData(allValues)
|
||||
const formData = this.classifyIntoFormData(allValues)
|
||||
// 发起请求
|
||||
return this.request(formData)
|
||||
}).catch(e => {
|
||||
@@ -172,14 +172,14 @@ export const JEditableTableMixin = {
|
||||
/* --- throw --- */
|
||||
|
||||
/** not a function */
|
||||
throwNotFunction(name) {
|
||||
throwNotFunction (name) {
|
||||
return `${name} 未定义或不是一个函数`
|
||||
},
|
||||
|
||||
/** not a array */
|
||||
throwNotArray(name) {
|
||||
throwNotArray (name) {
|
||||
return `${name} 未定义或不是一个数组`
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import JEditableTable from '@/components/jero/JEditableTable'
|
||||
import { VALIDATE_NO_PASSED, getRefPromise,validateFormModelAndTables} from '@/utils/JEditableTableUtil'
|
||||
import { VALIDATE_NO_PASSED, getRefPromise, validateFormModelAndTables } from '@/utils/JEditableTableUtil'
|
||||
import { httpAction, getAction } from '@/api/manage'
|
||||
|
||||
export const JEditableTableModelMixin = {
|
||||
components: {
|
||||
JEditableTable
|
||||
},
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
title: '操作',
|
||||
visible: false,
|
||||
confirmLoading: false,
|
||||
model:{},
|
||||
model: {},
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 6 }
|
||||
@@ -25,16 +25,16 @@ export const JEditableTableModelMixin = {
|
||||
methods: {
|
||||
|
||||
/** 获取所有的editableTable实例 */
|
||||
getAllTable() {
|
||||
getAllTable () {
|
||||
if (!(this.refKeys instanceof Array)) {
|
||||
throw this.throwNotArray('refKeys')
|
||||
}
|
||||
let values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
const values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
return Promise.all(values)
|
||||
},
|
||||
|
||||
/** 遍历所有的JEditableTable实例 */
|
||||
eachAllTable(callback) {
|
||||
eachAllTable (callback) {
|
||||
// 开始遍历
|
||||
this.getAllTable().then(tables => {
|
||||
tables.forEach((item, index) => {
|
||||
@@ -45,13 +45,13 @@ export const JEditableTableModelMixin = {
|
||||
})
|
||||
},
|
||||
/** 当点击新增按钮时调用此方法 */
|
||||
add() {
|
||||
//update-begin-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
add () {
|
||||
// update-begin-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
return new Promise((resolve) => {
|
||||
this.tableReset();
|
||||
resolve();
|
||||
this.tableReset()
|
||||
resolve()
|
||||
}).then(() => {
|
||||
if (typeof this.addBefore === 'function'){
|
||||
if (typeof this.addBefore === 'function') {
|
||||
this.addBefore()
|
||||
}
|
||||
// 默认新增空数据
|
||||
@@ -66,12 +66,12 @@ export const JEditableTableModelMixin = {
|
||||
if (typeof this.addAfter === 'function') this.addAfter(this.model)
|
||||
this.edit(this.model)
|
||||
})
|
||||
//update-end-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
// update-end-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
|
||||
},
|
||||
/** 当点击了编辑(修改)按钮时调用此方法 */
|
||||
edit(record) {
|
||||
if(record && '{}'!=JSON.stringify(record)&&record.id){
|
||||
this.tableReset();
|
||||
edit (record) {
|
||||
if (record && JSON.stringify(record) != '{}' && record.id) {
|
||||
this.tableReset()
|
||||
}
|
||||
if (typeof this.editBefore === 'function') this.editBefore(record)
|
||||
this.visible = true
|
||||
@@ -81,21 +81,21 @@ export const JEditableTableModelMixin = {
|
||||
if (typeof this.editAfter === 'function') this.editAfter(this.model)
|
||||
},
|
||||
/** 关闭弹窗,并将所有JEditableTable实例回归到初始状态 */
|
||||
close() {
|
||||
close () {
|
||||
this.visible = false
|
||||
this.$emit('close')
|
||||
},
|
||||
//清空子表table的数据
|
||||
tableReset(){
|
||||
// 清空子表table的数据
|
||||
tableReset () {
|
||||
this.eachAllTable((item) => {
|
||||
item.clearRow()
|
||||
})
|
||||
},
|
||||
/** 查询某个tab的数据 */
|
||||
requestSubTableData(url, params, tab, success) {
|
||||
requestSubTableData (url, params, tab, success) {
|
||||
tab.loading = true
|
||||
getAction(url, params).then(res => {
|
||||
let { result } = res
|
||||
const { result } = res
|
||||
let dataSource = []
|
||||
if (result) {
|
||||
if (Array.isArray(result)) {
|
||||
@@ -111,8 +111,8 @@ export const JEditableTableModelMixin = {
|
||||
})
|
||||
},
|
||||
/** 发起请求,自动判断是执行新增还是修改操作 */
|
||||
request(formData) {
|
||||
let url = this.url.add, method = 'post'
|
||||
request (formData) {
|
||||
let url = this.url.add; let method = 'post'
|
||||
if (this.model.id) {
|
||||
url = this.url.edit
|
||||
method = 'put'
|
||||
@@ -134,22 +134,22 @@ export const JEditableTableModelMixin = {
|
||||
/* --- handle 事件 --- */
|
||||
|
||||
/** ATab 选项卡切换事件 */
|
||||
handleChangeTabs(key) {
|
||||
handleChangeTabs (key) {
|
||||
// 自动重置scrollTop状态,防止出现白屏
|
||||
getRefPromise(this, key).then(editableTable => {
|
||||
editableTable.resetScrollTop()
|
||||
})
|
||||
},
|
||||
/** 关闭按钮点击事件 */
|
||||
handleCancel() {
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
/** 确定按钮点击事件 */
|
||||
handleOk() {
|
||||
handleOk () {
|
||||
/** 触发表单验证 */
|
||||
this.getAllTable().then(tables => {
|
||||
/** 一次性验证主表和所有的次表 */
|
||||
return validateFormModelAndTables(this.$refs.form,this.model, tables)
|
||||
return validateFormModelAndTables(this.$refs.form, this.model, tables)
|
||||
}).then(allValues => {
|
||||
/** 一次性验证一对一的所有子表 */
|
||||
return this.validateSubForm(allValues)
|
||||
@@ -157,22 +157,22 @@ export const JEditableTableModelMixin = {
|
||||
if (typeof this.classifyIntoFormData !== 'function') {
|
||||
throw this.throwNotFunction('classifyIntoFormData')
|
||||
}
|
||||
let formData = this.classifyIntoFormData(allValues)
|
||||
const formData = this.classifyIntoFormData(allValues)
|
||||
// 发起请求
|
||||
return this.request(formData)
|
||||
}).catch(e => {
|
||||
if (e.error === VALIDATE_NO_PASSED) {
|
||||
// 如果有未通过表单验证的子表,就自动跳转到它所在的tab
|
||||
//update--begin--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
|
||||
this.activeKey = e.index == null ? this.activeKey : (e.paneKey?e.paneKey:this.refKeys[e.index])
|
||||
//update--end--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
|
||||
// update--begin--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
|
||||
this.activeKey = e.index == null ? this.activeKey : (e.paneKey ? e.paneKey : this.refKeys[e.index])
|
||||
// update--end--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
|
||||
} else {
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
//校验所有子表表单
|
||||
validateSubForm(allValues){
|
||||
// 校验所有子表表单
|
||||
validateSubForm (allValues) {
|
||||
return new Promise((resolve) => {
|
||||
resolve(allValues)
|
||||
})
|
||||
@@ -180,14 +180,14 @@ export const JEditableTableModelMixin = {
|
||||
/* --- throw --- */
|
||||
|
||||
/** not a function */
|
||||
throwNotFunction(name) {
|
||||
throwNotFunction (name) {
|
||||
return `${name} 未定义或不是一个函数`
|
||||
},
|
||||
|
||||
/** not a array */
|
||||
throwNotArray(name) {
|
||||
throwNotArray (name) {
|
||||
return `${name} 未定义或不是一个数组`
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { VALIDATE_FAILED, getRefPromise, validateFormAndTables} from '@/components/jero/JVxeTable/utils/vxeUtils.js'
|
||||
import { VALIDATE_FAILED, getRefPromise, validateFormAndTables } from '@/components/jero/JVxeTable/utils/vxeUtils.js'
|
||||
import { httpAction, getAction } from '@/api/manage'
|
||||
|
||||
export const JVxeTableMixin = {
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
title: '操作',
|
||||
visible: false,
|
||||
@@ -23,16 +23,16 @@ export const JVxeTableMixin = {
|
||||
methods: {
|
||||
|
||||
/** 获取所有的JVxeTable实例 */
|
||||
getAllTable() {
|
||||
getAllTable () {
|
||||
if (!(this.refKeys instanceof Array)) {
|
||||
throw this.throwNotArray('refKeys')
|
||||
}
|
||||
let values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
const values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
return Promise.all(values)
|
||||
},
|
||||
|
||||
/** 遍历所有的JVxeTable实例 */
|
||||
eachAllTable(callback) {
|
||||
eachAllTable (callback) {
|
||||
// 开始遍历
|
||||
this.getAllTable().then(tables => {
|
||||
tables.forEach((item, index) => {
|
||||
@@ -44,7 +44,7 @@ export const JVxeTableMixin = {
|
||||
},
|
||||
|
||||
/** 当点击新增按钮时调用此方法 */
|
||||
add() {
|
||||
add () {
|
||||
if (typeof this.addBefore === 'function') this.addBefore()
|
||||
// 默认新增空数据
|
||||
let rowNum = this.addDefaultRowNum
|
||||
@@ -53,7 +53,7 @@ export const JVxeTableMixin = {
|
||||
console.warn('由于你没有在 data 中定义 addDefaultRowNum 或 addDefaultRowNum 不是数字,所以默认添加一条空数据,如果不想默认添加空数据,请将定义 addDefaultRowNum 为 0')
|
||||
}
|
||||
this.eachAllTable((item) => {
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
item.addRows()
|
||||
}, 30)
|
||||
})
|
||||
@@ -61,7 +61,7 @@ export const JVxeTableMixin = {
|
||||
this.edit({})
|
||||
},
|
||||
/** 当点击了编辑(修改)按钮时调用此方法 */
|
||||
edit(record) {
|
||||
edit (record) {
|
||||
if (typeof this.editBefore === 'function') this.editBefore(record)
|
||||
this.visible = true
|
||||
this.activeKey = this.refKeys[0]
|
||||
@@ -70,7 +70,7 @@ export const JVxeTableMixin = {
|
||||
if (typeof this.editAfter === 'function') this.editAfter(this.model)
|
||||
},
|
||||
/** 关闭弹窗,并将所有JVxeTable实例回归到初始状态 */
|
||||
close() {
|
||||
close () {
|
||||
this.visible = false
|
||||
this.eachAllTable((item) => {
|
||||
item._remove()
|
||||
@@ -79,10 +79,10 @@ export const JVxeTableMixin = {
|
||||
},
|
||||
|
||||
/** 查询某个tab的数据 */
|
||||
requestSubTableData(url, params, tab, success) {
|
||||
requestSubTableData (url, params, tab, success) {
|
||||
tab.loading = true
|
||||
getAction(url, params).then(res => {
|
||||
let { result } = res
|
||||
const { result } = res
|
||||
let dataSource = []
|
||||
if (result) {
|
||||
if (Array.isArray(result)) {
|
||||
@@ -98,14 +98,14 @@ export const JVxeTableMixin = {
|
||||
})
|
||||
},
|
||||
/** 发起请求,自动判断是执行新增还是修改操作 */
|
||||
request(formData) {
|
||||
let url = this.url.add, method = 'post'
|
||||
request (formData) {
|
||||
let url = this.url.add; let method = 'post'
|
||||
if (this.model.id) {
|
||||
url = this.url.edit
|
||||
method = 'put'
|
||||
}
|
||||
this.confirmLoading = true
|
||||
console.log("formData===>",formData);
|
||||
console.log('formData===>', formData)
|
||||
httpAction(url, formData, method).then((res) => {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
@@ -122,18 +122,18 @@ export const JVxeTableMixin = {
|
||||
/* --- handle 事件 --- */
|
||||
|
||||
/** ATab 选项卡切换事件 */
|
||||
handleChangeTabs(key) {
|
||||
handleChangeTabs (key) {
|
||||
// 自动重置scrollTop状态,防止出现白屏
|
||||
getRefPromise(this, key).then(vxeTable => {
|
||||
vxeTable.resetScrollTop()
|
||||
})
|
||||
},
|
||||
/** 关闭按钮点击事件 */
|
||||
handleCancel() {
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
/** 确定按钮点击事件 */
|
||||
handleOk() {
|
||||
handleOk () {
|
||||
/** 触发表单验证 */
|
||||
this.getAllTable().then(tables => {
|
||||
/** 一次性验证主表和所有的次表 */
|
||||
@@ -142,7 +142,7 @@ export const JVxeTableMixin = {
|
||||
if (typeof this.classifyIntoFormData !== 'function') {
|
||||
throw this.throwNotFunction('classifyIntoFormData')
|
||||
}
|
||||
let formData = this.classifyIntoFormData(allValues)
|
||||
const formData = this.classifyIntoFormData(allValues)
|
||||
// 发起请求
|
||||
return this.request(formData)
|
||||
}).catch(e => {
|
||||
@@ -158,14 +158,14 @@ export const JVxeTableMixin = {
|
||||
/* --- throw --- */
|
||||
|
||||
/** not a function */
|
||||
throwNotFunction(name) {
|
||||
throwNotFunction (name) {
|
||||
return `${name} 未定义或不是一个函数`
|
||||
},
|
||||
|
||||
/** not a array */
|
||||
throwNotArray(name) {
|
||||
throwNotArray (name) {
|
||||
return `${name} 未定义或不是一个数组`
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { VALIDATE_FAILED, getRefPromise, validateFormAndTables,validateFormModelAndTables} from '@/components/jero/JVxeTable/utils/vxeUtils.js'
|
||||
import { VALIDATE_FAILED, getRefPromise, validateFormAndTables, validateFormModelAndTables } from '@/components/jero/JVxeTable/utils/vxeUtils.js'
|
||||
import { httpAction, getAction } from '@/api/manage'
|
||||
|
||||
export const JVxeTableModelMixin = {
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
title: '操作',
|
||||
visible: false,
|
||||
@@ -22,19 +22,19 @@ export const JVxeTableModelMixin = {
|
||||
methods: {
|
||||
|
||||
/** 获取所有的JVxeTable实例 */
|
||||
getAllTable() {
|
||||
getAllTable () {
|
||||
if (!(this.refKeys instanceof Array)) {
|
||||
throw this.throwNotArray('refKeys')
|
||||
}
|
||||
let values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
const values = this.refKeys.map(key => getRefPromise(this, key))
|
||||
return Promise.all(values)
|
||||
},
|
||||
|
||||
/** 遍历所有的JVxeTable实例 */
|
||||
eachAllTable(callback) {
|
||||
eachAllTable (callback) {
|
||||
// 开始遍历
|
||||
this.getAllTable().then(tables => {
|
||||
console.log("tables",tables)
|
||||
console.log('tables', tables)
|
||||
tables.forEach((item, index) => {
|
||||
if (typeof callback === 'function') {
|
||||
callback(item, index)
|
||||
@@ -44,7 +44,7 @@ export const JVxeTableModelMixin = {
|
||||
},
|
||||
|
||||
/** 当点击新增按钮时调用此方法 */
|
||||
add() {
|
||||
add () {
|
||||
if (typeof this.addBefore === 'function') this.addBefore()
|
||||
// 默认新增空数据
|
||||
let rowNum = this.addDefaultRowNum
|
||||
@@ -53,17 +53,17 @@ export const JVxeTableModelMixin = {
|
||||
console.warn('由于你没有在 data 中定义 addDefaultRowNum 或 addDefaultRowNum 不是数字,所以默认添加一条空数据,如果不想默认添加空数据,请将定义 addDefaultRowNum 为 0')
|
||||
}
|
||||
this.eachAllTable((item) => {
|
||||
//update-begin-author:taoyan date:20210315 for: 一对多jvex 默认几行不好使了 LOWCOD-1349
|
||||
setTimeout(()=>{
|
||||
// update-begin-author:taoyan date:20210315 for: 一对多jvex 默认几行不好使了 LOWCOD-1349
|
||||
setTimeout(() => {
|
||||
item.addRows()
|
||||
}, 30)
|
||||
//update-end-author:taoyan date:20210315 for: 一对多jvex 默认几行不好使了 LOWCOD-1349
|
||||
// update-end-author:taoyan date:20210315 for: 一对多jvex 默认几行不好使了 LOWCOD-1349
|
||||
})
|
||||
if (typeof this.addAfter === 'function') this.addAfter(this.model)
|
||||
this.edit(this.model)
|
||||
},
|
||||
/** 当点击了编辑(修改)按钮时调用此方法 */
|
||||
edit(record) {
|
||||
edit (record) {
|
||||
if (typeof this.editBefore === 'function') this.editBefore(record)
|
||||
this.visible = true
|
||||
this.activeKey = this.refKeys[0]
|
||||
@@ -72,7 +72,7 @@ export const JVxeTableModelMixin = {
|
||||
if (typeof this.editAfter === 'function') this.editAfter(this.model)
|
||||
},
|
||||
/** 关闭弹窗,并将所有JVxeTable实例回归到初始状态 */
|
||||
close() {
|
||||
close () {
|
||||
this.visible = false
|
||||
this.eachAllTable((item) => {
|
||||
item._remove()
|
||||
@@ -81,10 +81,10 @@ export const JVxeTableModelMixin = {
|
||||
},
|
||||
|
||||
/** 查询某个tab的数据 */
|
||||
requestSubTableData(url, params, tab, success) {
|
||||
requestSubTableData (url, params, tab, success) {
|
||||
tab.loading = true
|
||||
getAction(url, params).then(res => {
|
||||
let { result } = res
|
||||
const { result } = res
|
||||
let dataSource = []
|
||||
if (result) {
|
||||
if (Array.isArray(result)) {
|
||||
@@ -100,14 +100,14 @@ export const JVxeTableModelMixin = {
|
||||
})
|
||||
},
|
||||
/** 发起请求,自动判断是执行新增还是修改操作 */
|
||||
request(formData) {
|
||||
let url = this.url.add, method = 'post'
|
||||
request (formData) {
|
||||
let url = this.url.add; let method = 'post'
|
||||
if (this.model.id) {
|
||||
url = this.url.edit
|
||||
method = 'put'
|
||||
}
|
||||
this.confirmLoading = true
|
||||
console.log("formData===>",formData);
|
||||
console.log('formData===>', formData)
|
||||
httpAction(url, formData, method).then((res) => {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
@@ -124,22 +124,22 @@ export const JVxeTableModelMixin = {
|
||||
/* --- handle 事件 --- */
|
||||
|
||||
/** ATab 选项卡切换事件 */
|
||||
handleChangeTabs(key) {
|
||||
handleChangeTabs (key) {
|
||||
// 自动重置scrollTop状态,防止出现白屏
|
||||
getRefPromise(this, key).then(vxeTable => {
|
||||
vxeTable.resetScrollTop()
|
||||
})
|
||||
},
|
||||
/** 关闭按钮点击事件 */
|
||||
handleCancel() {
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
/** 确定按钮点击事件 */
|
||||
handleOk() {
|
||||
handleOk () {
|
||||
/** 触发表单验证 */
|
||||
this.getAllTable().then(tables => {
|
||||
/** 一次性验证主表和所有的次表 */
|
||||
return validateFormModelAndTables(this.$refs.form,this.model, tables)
|
||||
return validateFormModelAndTables(this.$refs.form, this.model, tables)
|
||||
}).then(allValues => {
|
||||
/** 一次性验证一对一的所有子表 */
|
||||
return this.validateSubForm(allValues)
|
||||
@@ -147,7 +147,7 @@ export const JVxeTableModelMixin = {
|
||||
if (typeof this.classifyIntoFormData !== 'function') {
|
||||
throw this.throwNotFunction('classifyIntoFormData')
|
||||
}
|
||||
let formData = this.classifyIntoFormData(allValues)
|
||||
const formData = this.classifyIntoFormData(allValues)
|
||||
// 发起请求
|
||||
return this.request(formData)
|
||||
}).catch(e => {
|
||||
@@ -159,8 +159,8 @@ export const JVxeTableModelMixin = {
|
||||
}
|
||||
})
|
||||
},
|
||||
//校验所有子表表单
|
||||
validateSubForm(allValues){
|
||||
// 校验所有子表表单
|
||||
validateSubForm (allValues) {
|
||||
return new Promise((resolve) => {
|
||||
resolve(allValues)
|
||||
})
|
||||
@@ -168,14 +168,14 @@ export const JVxeTableModelMixin = {
|
||||
/* --- throw --- */
|
||||
|
||||
/** not a function */
|
||||
throwNotFunction(name) {
|
||||
throwNotFunction (name) {
|
||||
return `${name} 未定义或不是一个函数`
|
||||
},
|
||||
|
||||
/** not a array */
|
||||
throwNotArray(name) {
|
||||
throwNotArray (name) {
|
||||
return `${name} 未定义或不是一个数组`
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,315 +3,313 @@
|
||||
* 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal
|
||||
* data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
|
||||
*/
|
||||
import { filterObj } from '@/utils/util';
|
||||
import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage'
|
||||
import { filterObj } from '@/utils/util'
|
||||
import { deleteAction, getAction, downFile, getFileAccessHttpUrl } from '@/api/manage'
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types"
|
||||
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
|
||||
import store from '@/store'
|
||||
|
||||
export const JeroListMixin = {
|
||||
data(){
|
||||
data () {
|
||||
return {
|
||||
/* 查询条件-请不要在queryParam中声明非字符串值的属性 */
|
||||
queryParam: {},
|
||||
/* 数据源 */
|
||||
dataSource:[],
|
||||
dataSource: [],
|
||||
/* 分页参数 */
|
||||
ipagination:{
|
||||
ipagination: {
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
pageSizeOptions: ['10', '20', '30'],
|
||||
showTotal: (total, range) => {
|
||||
return range[0] + "-" + range[1] + " 共" + total + "条"
|
||||
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
||||
},
|
||||
showQuickJumper: true,
|
||||
showSizeChanger: true,
|
||||
total: 0
|
||||
},
|
||||
/* 排序参数 */
|
||||
isorter:{
|
||||
isorter: {
|
||||
column: 'createTime',
|
||||
order: 'desc',
|
||||
order: 'desc'
|
||||
},
|
||||
/* 筛选参数 */
|
||||
filters: {},
|
||||
/* table加载状态 */
|
||||
loading:false,
|
||||
/* table选中keys*/
|
||||
loading: false,
|
||||
/* table选中keys */
|
||||
selectedRowKeys: [],
|
||||
/* table选中records*/
|
||||
/* table选中records */
|
||||
selectionRows: [],
|
||||
/* 查询折叠 */
|
||||
toggleSearchStatus:false,
|
||||
toggleSearchStatus: false,
|
||||
/* 高级查询条件生效状态 */
|
||||
superQueryFlag:false,
|
||||
superQueryFlag: false,
|
||||
/* 高级查询条件 */
|
||||
superQueryParams: '',
|
||||
/** 高级查询拼接方式 */
|
||||
superQueryMatchType: 'and',
|
||||
superQueryMatchType: 'and'
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if(!this.disableMixinCreated){
|
||||
this.loadData();
|
||||
//初始化字典配置 在自己页面定义
|
||||
this.initDictConfig();
|
||||
}
|
||||
created () {
|
||||
if (!this.disableMixinCreated) {
|
||||
this.loadData()
|
||||
// 初始化字典配置 在自己页面定义
|
||||
this.initDictConfig()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
//token header
|
||||
tokenHeader(){
|
||||
let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)}
|
||||
let tenantid = Vue.ls.get(TENANT_ID)
|
||||
if(tenantid){
|
||||
// token header
|
||||
tokenHeader () {
|
||||
const head = { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) }
|
||||
const tenantid = Vue.ls.get(TENANT_ID)
|
||||
if (tenantid) {
|
||||
head['tenant-id'] = tenantid
|
||||
}
|
||||
return head;
|
||||
return head
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
loadData(arg) {
|
||||
if(!this.url.list){
|
||||
this.$message.error("请设置url.list属性!")
|
||||
methods: {
|
||||
loadData (arg) {
|
||||
if (!this.url.list) {
|
||||
this.$message.error('请设置url.list属性!')
|
||||
return
|
||||
}
|
||||
//加载数据 若传入参数1则加载第一页的内容
|
||||
// 加载数据 若传入参数1则加载第一页的内容
|
||||
if (arg === 1) {
|
||||
this.ipagination.current = 1;
|
||||
this.ipagination.current = 1
|
||||
}
|
||||
var params = this.getQueryParams();//查询条件
|
||||
this.loading = true;
|
||||
var params = this.getQueryParams()// 查询条件
|
||||
this.loading = true
|
||||
getAction(this.url.list, params).then((res) => {
|
||||
if (res.success) {
|
||||
//update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
||||
this.dataSource = res.result.records||res.result;
|
||||
if(res.result.total)
|
||||
{
|
||||
this.ipagination.total = res.result.total;
|
||||
}else{
|
||||
this.ipagination.total = 0;
|
||||
// update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
||||
this.dataSource = res.result.records || res.result
|
||||
if (res.result.total) {
|
||||
this.ipagination.total = res.result.total
|
||||
} else {
|
||||
this.ipagination.total = 0
|
||||
}
|
||||
//update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
||||
}else{
|
||||
// update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
initDictConfig(){
|
||||
initDictConfig () {
|
||||
|
||||
},
|
||||
handleSuperQuery(params, matchType) {
|
||||
//高级查询方法
|
||||
if(!params){
|
||||
this.superQueryParams=''
|
||||
handleSuperQuery (params, matchType) {
|
||||
// 高级查询方法
|
||||
if (!params) {
|
||||
this.superQueryParams = ''
|
||||
this.superQueryFlag = false
|
||||
}else{
|
||||
} else {
|
||||
this.superQueryFlag = true
|
||||
this.superQueryParams=JSON.stringify(params)
|
||||
this.superQueryParams = JSON.stringify(params)
|
||||
this.superQueryMatchType = matchType
|
||||
}
|
||||
this.loadData(1)
|
||||
},
|
||||
getQueryParams() {
|
||||
//获取查询条件
|
||||
let sqp = {}
|
||||
if(this.superQueryParams){
|
||||
sqp['superQueryParams']=encodeURI(this.superQueryParams)
|
||||
sqp['superQueryMatchType'] = this.superQueryMatchType
|
||||
getQueryParams () {
|
||||
// 获取查询条件
|
||||
const sqp = {}
|
||||
if (this.superQueryParams) {
|
||||
sqp.superQueryParams = encodeURI(this.superQueryParams)
|
||||
sqp.superQueryMatchType = this.superQueryMatchType
|
||||
}
|
||||
var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
|
||||
param.field = this.getQueryField();
|
||||
param.pageNo = this.ipagination.current;
|
||||
param.pageSize = this.ipagination.pageSize;
|
||||
return filterObj(param);
|
||||
var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters)
|
||||
param.field = this.getQueryField()
|
||||
param.pageNo = this.ipagination.current
|
||||
param.pageSize = this.ipagination.pageSize
|
||||
return filterObj(param)
|
||||
},
|
||||
getQueryField() {
|
||||
//TODO 字段权限控制
|
||||
var str = "id,";
|
||||
getQueryField () {
|
||||
// TODO 字段权限控制
|
||||
var str = 'id,'
|
||||
this.columns.forEach(function (value) {
|
||||
str += "," + value.dataIndex;
|
||||
});
|
||||
return str;
|
||||
str += ',' + value.dataIndex
|
||||
})
|
||||
return str
|
||||
},
|
||||
|
||||
onSelectChange(selectedRowKeys, selectionRows) {
|
||||
this.selectedRowKeys = selectedRowKeys;
|
||||
this.selectionRows = selectionRows;
|
||||
onSelectChange (selectedRowKeys, selectionRows) {
|
||||
this.selectedRowKeys = selectedRowKeys
|
||||
this.selectionRows = selectionRows
|
||||
},
|
||||
onClearSelected() {
|
||||
this.selectedRowKeys = [];
|
||||
this.selectionRows = [];
|
||||
onClearSelected () {
|
||||
this.selectedRowKeys = []
|
||||
this.selectionRows = []
|
||||
},
|
||||
searchQuery() {
|
||||
this.loadData(1);
|
||||
searchQuery () {
|
||||
this.loadData(1)
|
||||
// 点击查询清空列表选中行
|
||||
this.selectedRowKeys = []
|
||||
this.selectionRows = []
|
||||
},
|
||||
superQuery() {
|
||||
this.$refs.superQueryModal.show();
|
||||
superQuery () {
|
||||
this.$refs.superQueryModal.show()
|
||||
},
|
||||
searchReset() {
|
||||
searchReset () {
|
||||
this.queryParam = {}
|
||||
this.loadData(1);
|
||||
this.loadData(1)
|
||||
},
|
||||
batchDel: function () {
|
||||
if(!this.url.deleteBatch){
|
||||
this.$message.error("请设置url.deleteBatch属性!")
|
||||
if (!this.url.deleteBatch) {
|
||||
this.$message.error('请设置url.deleteBatch属性!')
|
||||
return
|
||||
}
|
||||
if (this.selectedRowKeys.length <= 0) {
|
||||
this.$message.warning('请选择一条记录!');
|
||||
return;
|
||||
this.$message.warning('请选择一条记录!')
|
||||
} else {
|
||||
var ids = "";
|
||||
var ids = ''
|
||||
for (var a = 0; a < this.selectedRowKeys.length; a++) {
|
||||
ids += this.selectedRowKeys[a] + ",";
|
||||
ids += this.selectedRowKeys[a] + ','
|
||||
}
|
||||
var that = this;
|
||||
var that = this
|
||||
this.$confirm({
|
||||
title: "确认删除",
|
||||
content: "是否删除选中数据?",
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据?',
|
||||
onOk: function () {
|
||||
that.loading = true;
|
||||
deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
|
||||
if (res.success){
|
||||
//重新计算分页问题
|
||||
that.loading = true
|
||||
deleteAction(that.url.deleteBatch, { ids: ids }).then((res) => {
|
||||
if (res.success) {
|
||||
// 重新计算分页问题
|
||||
that.reCalculatePage(that.selectedRowKeys.length)
|
||||
that.$message.success(res.message);
|
||||
that.loadData();
|
||||
that.onClearSelected();
|
||||
that.$message.success(res.message)
|
||||
that.loadData()
|
||||
that.onClearSelected()
|
||||
} else {
|
||||
that.$message.warning(res.message);
|
||||
that.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
that.loading = false;
|
||||
});
|
||||
that.loading = false
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
handleDelete: function (id) {
|
||||
if(!this.url.delete){
|
||||
this.$message.error("请设置url.delete属性!")
|
||||
if (!this.url.delete) {
|
||||
this.$message.error('请设置url.delete属性!')
|
||||
return
|
||||
}
|
||||
var that = this;
|
||||
deleteAction(that.url.delete, {id: id}).then((res) => {
|
||||
var that = this
|
||||
deleteAction(that.url.delete, { id: id }).then((res) => {
|
||||
if (res.success) {
|
||||
//重新计算分页问题
|
||||
// 重新计算分页问题
|
||||
that.reCalculatePage(1)
|
||||
that.$message.success(res.message);
|
||||
that.loadData();
|
||||
that.$message.success(res.message)
|
||||
that.loadData()
|
||||
} else {
|
||||
that.$message.warning(res.message);
|
||||
that.$message.warning(res.message)
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
reCalculatePage(count){
|
||||
//总数量-count
|
||||
let total=this.ipagination.total-count;
|
||||
//获取删除后的分页数
|
||||
let currentIndex=Math.ceil(total/this.ipagination.pageSize);
|
||||
//删除后的分页数<所在当前页
|
||||
if(currentIndex<this.ipagination.current){
|
||||
this.ipagination.current=currentIndex;
|
||||
reCalculatePage (count) {
|
||||
// 总数量-count
|
||||
const total = this.ipagination.total - count
|
||||
// 获取删除后的分页数
|
||||
const currentIndex = Math.ceil(total / this.ipagination.pageSize)
|
||||
// 删除后的分页数<所在当前页
|
||||
if (currentIndex < this.ipagination.current) {
|
||||
this.ipagination.current = currentIndex
|
||||
}
|
||||
console.log('currentIndex',currentIndex)
|
||||
console.log('currentIndex', currentIndex)
|
||||
},
|
||||
handleEdit: function (record) {
|
||||
this.$refs.modalForm.edit(record);
|
||||
this.$refs.modalForm.title = "编辑";
|
||||
this.$refs.modalForm.disableSubmit = false;
|
||||
this.$refs.modalForm.edit(record)
|
||||
this.$refs.modalForm.title = '编辑'
|
||||
this.$refs.modalForm.disableSubmit = false
|
||||
},
|
||||
handleAdd: function () {
|
||||
this.$refs.modalForm.add();
|
||||
this.$refs.modalForm.title = "新增";
|
||||
this.$refs.modalForm.disableSubmit = false;
|
||||
this.$refs.modalForm.add()
|
||||
this.$refs.modalForm.title = '新增'
|
||||
this.$refs.modalForm.disableSubmit = false
|
||||
},
|
||||
handleTableChange(pagination, filters, sorter) {
|
||||
//分页、排序、筛选变化时触发
|
||||
handleTableChange (pagination, filters, sorter) {
|
||||
// 分页、排序、筛选变化时触发
|
||||
if (Object.keys(sorter).length > 0) {
|
||||
this.isorter.column = sorter.field;
|
||||
this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
|
||||
this.isorter.column = sorter.field
|
||||
this.isorter.order = sorter.order == 'ascend' ? 'asc' : 'desc'
|
||||
}
|
||||
this.ipagination = pagination;
|
||||
this.loadData();
|
||||
this.ipagination = pagination
|
||||
this.loadData()
|
||||
},
|
||||
handleToggleSearch(){
|
||||
this.toggleSearchStatus = !this.toggleSearchStatus;
|
||||
handleToggleSearch () {
|
||||
this.toggleSearchStatus = !this.toggleSearchStatus
|
||||
},
|
||||
// 给popup查询使用(查询区域不支持回填多个字段,限制只返回一个字段)
|
||||
getPopupField(fields){
|
||||
getPopupField (fields) {
|
||||
return fields.split(',')[0]
|
||||
},
|
||||
modalFormOk() {
|
||||
modalFormOk () {
|
||||
// 新增/修改 成功时,重载列表
|
||||
this.loadData();
|
||||
//清空列表选中
|
||||
this.loadData()
|
||||
// 清空列表选中
|
||||
this.onClearSelected()
|
||||
},
|
||||
handleDetail:function(record){
|
||||
this.$refs.modalForm.edit(record);
|
||||
this.$refs.modalForm.title="详情";
|
||||
this.$refs.modalForm.disableSubmit = true;
|
||||
handleDetail: function (record) {
|
||||
this.$refs.modalForm.edit(record)
|
||||
this.$refs.modalForm.title = '详情'
|
||||
this.$refs.modalForm.disableSubmit = true
|
||||
},
|
||||
/* 导出 */
|
||||
handleExportXls2(){
|
||||
let paramsStr = encodeURI(JSON.stringify(this.getQueryParams()));
|
||||
let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
|
||||
window.location.href = url;
|
||||
handleExportXls2 () {
|
||||
const paramsStr = encodeURI(JSON.stringify(this.getQueryParams()))
|
||||
const url = `${window._CONFIG.domianURL}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`
|
||||
window.location.href = url
|
||||
},
|
||||
handleExportXls(fileName){
|
||||
if(!fileName || typeof fileName != "string"){
|
||||
fileName = "导出文件"
|
||||
handleExportXls (fileName) {
|
||||
if (!fileName || typeof fileName !== 'string') {
|
||||
fileName = '导出文件'
|
||||
}
|
||||
let param = this.getQueryParams();
|
||||
if(this.selectedRowKeys && this.selectedRowKeys.length>0){
|
||||
param['selections'] = this.selectedRowKeys.join(",")
|
||||
const param = this.getQueryParams()
|
||||
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
|
||||
param.selections = this.selectedRowKeys.join(',')
|
||||
}
|
||||
console.log("导出参数",param)
|
||||
downFile(this.url.exportXlsUrl,param).then((data)=>{
|
||||
console.log('导出参数', param)
|
||||
downFile(this.url.exportXlsUrl, param).then((data) => {
|
||||
if (!data) {
|
||||
this.$message.warning("文件下载失败")
|
||||
this.$message.warning('文件下载失败')
|
||||
return
|
||||
}
|
||||
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
||||
window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
|
||||
}else{
|
||||
let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
|
||||
let link = document.createElement('a')
|
||||
window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
|
||||
} else {
|
||||
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
|
||||
const link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = url
|
||||
link.setAttribute('download', fileName+'.xls')
|
||||
link.setAttribute('download', fileName + '.xls')
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link); //下载完成移除元素
|
||||
window.URL.revokeObjectURL(url); //释放掉blob对象
|
||||
document.body.removeChild(link) // 下载完成移除元素
|
||||
window.URL.revokeObjectURL(url) // 释放掉blob对象
|
||||
}
|
||||
})
|
||||
},
|
||||
/* 导入 */
|
||||
handleImportExcel(info){
|
||||
this.loading = true;
|
||||
handleImportExcel (info) {
|
||||
this.loading = true
|
||||
if (info.file.status !== 'uploading') {
|
||||
console.log(info.file, info.fileList);
|
||||
console.log(info.file, info.fileList)
|
||||
}
|
||||
if (info.file.status === 'done') {
|
||||
this.loading = false;
|
||||
this.loading = false
|
||||
if (info.file.response.success) {
|
||||
// this.$message.success(`${info.file.name} 文件上传成功`);
|
||||
if (info.file.response.code === 201) {
|
||||
let { message, result: { msg, fileUrl, fileName } } = info.file.response
|
||||
let href = window._CONFIG['domianURL'] + fileUrl
|
||||
const { message, result: { msg, fileUrl, fileName } } = info.file.response
|
||||
const href = window._CONFIG.domianURL + fileUrl
|
||||
this.$warning({
|
||||
title: message,
|
||||
content: (<div>
|
||||
<span>{msg}</span><br/>
|
||||
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
|
||||
</div>
|
||||
<span>{msg}</span><br/>
|
||||
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
} else {
|
||||
@@ -319,14 +317,14 @@ export const JeroListMixin = {
|
||||
}
|
||||
this.loadData()
|
||||
} else {
|
||||
this.$message.error(`${info.file.name} ${info.file.response.message}.`);
|
||||
this.$message.error(`${info.file.name} ${info.file.response.message}.`)
|
||||
}
|
||||
} else if (info.file.status === 'error') {
|
||||
this.loading = false;
|
||||
this.loading = false
|
||||
if (info.file.response.status === 500) {
|
||||
let data = info.file.response
|
||||
const data = info.file.response
|
||||
const token = Vue.ls.get(ACCESS_TOKEN)
|
||||
if (token && data.message.includes("Token失效")) {
|
||||
if (token && data.message.includes('Token失效')) {
|
||||
this.error({
|
||||
title: '登录已过期',
|
||||
content: '很抱歉,登录已过期,请重新登录',
|
||||
@@ -335,36 +333,36 @@ export const JeroListMixin = {
|
||||
onOk: () => {
|
||||
store.dispatch('Logout').then(() => {
|
||||
Vue.ls.remove(ACCESS_TOKEN)
|
||||
window.location.reload();
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.$message.error(`文件上传失败: ${info.file.msg} `);
|
||||
this.$message.error(`文件上传失败: ${info.file.msg} `)
|
||||
}
|
||||
}
|
||||
},
|
||||
/* 图片预览 */
|
||||
getImgView(text){
|
||||
if(text && text.indexOf(",")>0){
|
||||
text = text.substring(0,text.indexOf(","))
|
||||
getImgView (text) {
|
||||
if (text && text.indexOf(',') > 0) {
|
||||
text = text.substring(0, text.indexOf(','))
|
||||
}
|
||||
return getFileAccessHttpUrl(text)
|
||||
},
|
||||
/* 文件下载 */
|
||||
// update--autor:lvdandan-----date:20200630------for:修改下载文件方法名uploadFile改为downloadFile------
|
||||
downloadFile(text){
|
||||
if(!text){
|
||||
this.$message.warning("未知的文件")
|
||||
return;
|
||||
downloadFile (text) {
|
||||
if (!text) {
|
||||
this.$message.warning('未知的文件')
|
||||
return
|
||||
}
|
||||
if(text.indexOf(",")>0){
|
||||
text = text.substring(0,text.indexOf(","))
|
||||
if (text.indexOf(',') > 0) {
|
||||
text = text.substring(0, text.indexOf(','))
|
||||
}
|
||||
let url = getFileAccessHttpUrl(text)
|
||||
window.open(url);
|
||||
},
|
||||
const url = getFileAccessHttpUrl(text)
|
||||
window.open(url)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,26 +3,26 @@ import Area from '@/components/_util/Area'
|
||||
import { postAction } from '@/api/manage'
|
||||
|
||||
const onlUtil = {
|
||||
data(){
|
||||
data () {
|
||||
return {
|
||||
mixin_pca:'',
|
||||
mixin_pca: '',
|
||||
flowCodePre: 'onl_'
|
||||
}
|
||||
},
|
||||
created(){
|
||||
created () {
|
||||
this.mixin_pca = new Area(this.$Jpcaa)
|
||||
},
|
||||
methods:{
|
||||
simpleDateFormat(millisecond, format){
|
||||
methods: {
|
||||
simpleDateFormat (millisecond, format) {
|
||||
return formatDate(millisecond, format)
|
||||
},
|
||||
getPcaText(code){
|
||||
return this.mixin_pca.getText(code);
|
||||
getPcaText (code) {
|
||||
return this.mixin_pca.getText(code)
|
||||
},
|
||||
getPcaCode(text){
|
||||
getPcaCode (text) {
|
||||
return this.mixin_pca.getCode(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { onlUtil }
|
||||
export { onlUtil }
|
||||
|
||||
@@ -3,61 +3,61 @@ import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import Vue from 'vue'
|
||||
|
||||
export const WebsocketMixin = {
|
||||
mounted() {
|
||||
this.initWebSocket();
|
||||
mounted () {
|
||||
this.initWebSocket()
|
||||
},
|
||||
destroyed: function () {
|
||||
// 离开页面生命周期函数
|
||||
this.websocketOnclose();
|
||||
this.websocketOnclose()
|
||||
},
|
||||
methods:{
|
||||
methods: {
|
||||
initWebSocket: function () {
|
||||
let token = Vue.ls.get(ACCESS_TOKEN)
|
||||
console.log("------------WebSocket连接成功");
|
||||
const token = Vue.ls.get(ACCESS_TOKEN)
|
||||
console.log('------------WebSocket连接成功')
|
||||
// WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
|
||||
var userId = store.getters.userInfo.id;
|
||||
if(!this.socketUrl.startsWith('/')){
|
||||
var userId = store.getters.userInfo.id
|
||||
if (!this.socketUrl.startsWith('/')) {
|
||||
this.socketUrl = '/' + this.socketUrl
|
||||
}
|
||||
if(!this.socketUrl.endsWith('/')){
|
||||
if (!this.socketUrl.endsWith('/')) {
|
||||
this.socketUrl = this.socketUrl + '/'
|
||||
}
|
||||
var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://") + this.socketUrl + userId + "/" + token;
|
||||
this.websock = new WebSocket(url);
|
||||
this.websock.onopen = this.websocketOnopen;
|
||||
this.websock.onerror = this.websocketOnerror;
|
||||
this.websock.onmessage = this.websocketOnmessage;
|
||||
this.websock.onclose = this.websocketOnclose;
|
||||
var url = window._CONFIG.domianURL.replace('https://', 'wss://').replace('http://', 'ws://') + this.socketUrl + userId + '/' + token
|
||||
this.websock = new WebSocket(url)
|
||||
this.websock.onopen = this.websocketOnopen
|
||||
this.websock.onerror = this.websocketOnerror
|
||||
this.websock.onmessage = this.websocketOnmessage
|
||||
this.websock.onclose = this.websocketOnclose
|
||||
},
|
||||
websocketOnopen: function () {
|
||||
console.log("WebSocket连接成功");
|
||||
console.log('WebSocket连接成功')
|
||||
},
|
||||
websocketOnerror: function (e) {
|
||||
console.log("WebSocket连接发生错误");
|
||||
this.reconnect();
|
||||
console.log('WebSocket连接发生错误')
|
||||
this.reconnect()
|
||||
},
|
||||
websocketOnclose: function (e) {
|
||||
this.reconnect();
|
||||
this.reconnect()
|
||||
},
|
||||
websocketSend(text) {
|
||||
websocketSend (text) {
|
||||
// 数据发送
|
||||
try {
|
||||
this.websock.send(text);
|
||||
this.websock.send(text)
|
||||
} catch (err) {
|
||||
console.log("send failed (" + err.code + ")");
|
||||
console.log('send failed (' + err.code + ')')
|
||||
}
|
||||
},
|
||||
reconnect() {
|
||||
var that = this;
|
||||
if(that.lockReconnect) return;
|
||||
that.lockReconnect = true;
|
||||
//没连接上会一直重连,设置延迟避免请求过多
|
||||
reconnect () {
|
||||
var that = this
|
||||
if (that.lockReconnect) return
|
||||
that.lockReconnect = true
|
||||
// 没连接上会一直重连,设置延迟避免请求过多
|
||||
setTimeout(function () {
|
||||
console.info("尝试重连...");
|
||||
that.initWebSocket();
|
||||
that.lockReconnect = false;
|
||||
}, 5000);
|
||||
},
|
||||
console.info('尝试重连...')
|
||||
that.initWebSocket()
|
||||
that.lockReconnect = false
|
||||
}, 5000)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user