【modify】使用ESLint格式化代码

This commit is contained in:
zer0Black
2023-03-01 09:33:58 +08:00
parent 694855ae8b
commit 63369b8b87
400 changed files with 42942 additions and 43132 deletions
@@ -62,278 +62,276 @@
</template>
<script>
import {filterObj} from '@/utils/util'
import {queryDepartTreeList, getUserList, queryUserByDepId, queryDepartTreeSync} from '@/api/api'
import { getAction } from '@/api/manage'
import { filterObj } from '@/utils/util'
import { queryDepartTreeList, getUserList, queryUserByDepId, queryDepartTreeSync } from '@/api/api'
import { getAction } from '@/api/manage'
export default {
name: 'JSelectUserByDepModal',
components: {},
props: ['modalWidth', 'multi', 'userIds', 'store', 'text'],
data() {
return {
queryParam: {
username: "",
realname: ""
export default {
name: 'JSelectUserByDepModal',
components: {},
props: ['modalWidth', 'multi', 'userIds', 'store', 'text'],
data () {
return {
queryParam: {
username: '',
realname: ''
},
columns: [
{
title: '用户账号',
align: 'center',
dataIndex: 'username'
},
columns: [
{
title: '用户账号',
align: 'center',
dataIndex: 'username'
},
{
title: '用户姓名',
align: 'center',
dataIndex: 'realname'
},
{
title: '性别',
align: 'center',
dataIndex: 'sex_dictText'
},
{
title: '电话',
align: 'center',
dataIndex: 'phone'
},
{
title: '部门',
align: 'center',
dataIndex: 'orgCodeTxt'
}
],
scrollTrigger: {},
dataSource: [],
selectedRowKeys: [],
selectUserRows: [],
selectUserIds: [],
title: '根据部门选择用户',
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
{
title: '用户姓名',
align: 'center',
dataIndex: 'realname'
},
isorter: {
column: 'createTime',
order: 'desc'
{
title: '性别',
align: 'center',
dataIndex: 'sex_dictText'
},
selectedDepIds: [],
departTree: [],
visible: false,
form: this.$form.createForm(this),
loading: false,
expandedKeys: [],
}
},
computed: {
// 计算属性的 getter
getType: function () {
return this.multi == true ? 'checkbox' : 'radio';
}
},
watch: {
userIds: {
immediate: true,
handler() {
this.initUserNames()
{
title: '电话',
align: 'center',
dataIndex: 'phone'
},
{
title: '部门',
align: 'center',
dataIndex: 'orgCodeTxt'
}
],
scrollTrigger: {},
dataSource: [],
selectedRowKeys: [],
selectUserRows: [],
selectUserIds: [],
title: '根据部门选择用户',
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
},
created() {
// 该方法触发屏幕自适应
this.resetScreenSize();
this.loadData()
},
methods: {
initUserNames() {
if (this.userIds) {
// 这里最后加一个 , 的原因是因为无论如何都要使用 in 查询,防止后台进行了模糊匹配,导致查询结果不准确
let values = this.userIds.split(',') + ','
let param = {[this.store]: values}
getAction('/sys/user/getMultiUser', param).then((list)=>{
this.selectionRows = []
let selectedRowKeys = []
let textArray = []
if(list && list.length>0){
for(let user of list){
textArray.push(user[this.text])
selectedRowKeys.push(user['id'])
this.selectionRows.push(user)
}
}
this.selectedRowKeys = selectedRowKeys
this.$emit('initComp', textArray.join(','))
})
} else {
// JSelectUserByDep组件bug issues/I16634
this.$emit('initComp', '')
// 前端用户选择单选无法置空的问题 #2610
this.selectedRowKeys = []
}
isorter: {
column: 'createTime',
order: 'desc'
},
async loadData(arg) {
if (arg === 1) {
this.ipagination.current = 1;
}
if (this.selectedDepIds && this.selectedDepIds.length > 0) {
await this.initQueryUserByDepId(this.selectedDepIds)
} else {
this.loading = true
let params = this.getQueryParams()//查询条件
await getUserList(params).then((res) => {
if (res.success) {
this.dataSource = res.result.records
this.ipagination.total = res.result.total
}
}).finally(() => {
this.loading = false
})
}
},
// 触发屏幕自适应
resetScreenSize() {
let screenWidth = document.body.clientWidth;
if (screenWidth < 500) {
this.scrollTrigger = {x: 800};
} else {
this.scrollTrigger = {};
}
},
showModal() {
this.visible = true;
this.queryDepartTree();
selectedDepIds: [],
departTree: [],
visible: false,
form: this.$form.createForm(this),
loading: false,
expandedKeys: []
}
},
computed: {
// 计算属性的 getter
getType: function () {
return this.multi == true ? 'checkbox' : 'radio'
}
},
watch: {
userIds: {
immediate: true,
handler () {
this.initUserNames()
this.loadData();
this.form.resetFields();
},
getQueryParams() {
let param = Object.assign({}, this.queryParam, this.isorter);
param.field = this.getQueryField();
param.pageNo = this.ipagination.current;
param.pageSize = this.ipagination.pageSize;
return filterObj(param);
},
getQueryField() {
let str = 'id,';
for (let a = 0; a < this.columns.length; a++) {
str += ',' + this.columns[a].dataIndex;
}
return str;
},
searchReset(num) {
let that = this;
if (num !== 0) {
that.queryParam = {};
that.loadData(1);
}
that.selectedRowKeys = [];
that.selectUserIds = [];
that.selectedDepIds = [];
},
close() {
this.searchReset(0);
this.visible = false;
},
handleTableChange(pagination, filters, sorter) {
//TODO 筛选
if (Object.keys(sorter).length > 0) {
this.isorter.column = sorter.field;
this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc';
}
this.ipagination = pagination;
this.loadData();
},
handleSubmit() {
let that = this;
this.getSelectUserRows();
that.$emit('ok', that.selectUserRows);
that.searchReset(0)
that.close();
},
//获取选择用户信息
getSelectUserRows(rowId) {
let dataSource = this.dataSource;
let userIds = "";
this.selectUserRows = [];
for (let i = 0, len = dataSource.length; i < len; i++) {
if (this.selectedRowKeys.includes(dataSource[i].id)) {
this.selectUserRows.push(dataSource[i]);
userIds = userIds + "," + dataSource[i].username
}
}
},
created () {
// 该方法触发屏幕自适应
this.resetScreenSize()
this.loadData()
},
methods: {
initUserNames () {
if (this.userIds) {
// 这里最后加一个 , 的原因是因为无论如何都要使用 in 查询,防止后台进行了模糊匹配,导致查询结果不准确
const values = this.userIds.split(',') + ','
const param = { [this.store]: values }
getAction('/sys/user/getMultiUser', param).then((list) => {
this.selectionRows = []
const selectedRowKeys = []
const textArray = []
if (list && list.length > 0) {
for (const user of list) {
textArray.push(user[this.text])
selectedRowKeys.push(user.id)
this.selectionRows.push(user)
}
}
}
this.selectUserIds = userIds.substring(1);
},
// 点击树节点,筛选出对应的用户
onDepSelect(selectedDepIds) {
if (selectedDepIds[0] != null) {
this.initQueryUserByDepId(selectedDepIds); // 调用方法根据选选择的id查询用户信息
if (this.selectedDepIds[0] !== selectedDepIds[0]) {
this.selectedDepIds = [selectedDepIds[0]];
}
}
},
onSelectChange(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys;
this.selectionRows = selectionRows;
},
onSearch() {
this.loadData(1);
},
// 根据选择的id来查询用户信息
initQueryUserByDepId(selectedDepIds) {
this.selectedRowKeys = selectedRowKeys
this.$emit('initComp', textArray.join(','))
})
} else {
// JSelectUserByDep组件bug issues/I16634
this.$emit('initComp', '')
// 前端用户选择单选无法置空的问题 #2610
this.selectedRowKeys = []
}
},
async loadData (arg) {
if (arg === 1) {
this.ipagination.current = 1
}
if (this.selectedDepIds && this.selectedDepIds.length > 0) {
await this.initQueryUserByDepId(this.selectedDepIds)
} else {
this.loading = true
return queryUserByDepId({id: selectedDepIds.toString()}).then((res) => {
const params = this.getQueryParams()// 查询条件
await getUserList(params).then((res) => {
if (res.success) {
this.dataSource = res.result;
this.ipagination.total = res.result.length;
this.dataSource = res.result.records
this.ipagination.total = res.result.total
}
}).finally(() => {
this.loading = false
})
},
queryDepartTree() {
//update-begin-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196
this.expandedKeys = []
this.departTree = []
queryDepartTreeSync().then((res) => {
}
},
// 触发屏幕自适应
resetScreenSize () {
const screenWidth = document.body.clientWidth
if (screenWidth < 500) {
this.scrollTrigger = { x: 800 }
} else {
this.scrollTrigger = {}
}
},
showModal () {
this.visible = true
this.queryDepartTree()
this.initUserNames()
this.loadData()
this.form.resetFields()
},
getQueryParams () {
const param = Object.assign({}, this.queryParam, this.isorter)
param.field = this.getQueryField()
param.pageNo = this.ipagination.current
param.pageSize = this.ipagination.pageSize
return filterObj(param)
},
getQueryField () {
let str = 'id,'
for (let a = 0; a < this.columns.length; a++) {
str += ',' + this.columns[a].dataIndex
}
return str
},
searchReset (num) {
const that = this
if (num !== 0) {
that.queryParam = {}
that.loadData(1)
}
that.selectedRowKeys = []
that.selectUserIds = []
that.selectedDepIds = []
},
close () {
this.searchReset(0)
this.visible = false
},
handleTableChange (pagination, filters, sorter) {
// TODO 筛选
if (Object.keys(sorter).length > 0) {
this.isorter.column = sorter.field
this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
}
this.ipagination = pagination
this.loadData()
},
handleSubmit () {
const that = this
this.getSelectUserRows()
that.$emit('ok', that.selectUserRows)
that.searchReset(0)
that.close()
},
// 获取选择用户信息
getSelectUserRows (rowId) {
const dataSource = this.dataSource
let userIds = ''
this.selectUserRows = []
for (let i = 0, len = dataSource.length; i < len; i++) {
if (this.selectedRowKeys.includes(dataSource[i].id)) {
this.selectUserRows.push(dataSource[i])
userIds = userIds + ',' + dataSource[i].username
}
}
this.selectUserIds = userIds.substring(1)
},
// 点击树节点,筛选出对应的用户
onDepSelect (selectedDepIds) {
if (selectedDepIds[0] != null) {
this.initQueryUserByDepId(selectedDepIds) // 调用方法根据选选择的id查询用户信息
if (this.selectedDepIds[0] !== selectedDepIds[0]) {
this.selectedDepIds = [selectedDepIds[0]]
}
}
},
onSelectChange (selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys
this.selectionRows = selectionRows
},
onSearch () {
this.loadData(1)
},
// 根据选择的id来查询用户信息
initQueryUserByDepId (selectedDepIds) {
this.loading = true
return queryUserByDepId({ id: selectedDepIds.toString() }).then((res) => {
if (res.success) {
this.dataSource = res.result
this.ipagination.total = res.result.length
}
}).finally(() => {
this.loading = false
})
},
queryDepartTree () {
// update-begin-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196
this.expandedKeys = []
this.departTree = []
queryDepartTreeSync().then((res) => {
if (res.success) {
for (let i = 0; i < res.result.length; i++) {
const temp = res.result[i]
this.departTree.push(temp)
}
}
})
},
onLoadDepartment (treeNode) {
return new Promise(resolve => {
queryDepartTreeSync({ pid: treeNode.dataRef.id }).then((res) => {
if (res.success) {
for (let i = 0; i < res.result.length; i++) {
let temp = res.result[i]
this.departTree.push(temp)
// 判断chidlren是否为空,并修改isLeaf属性值
if (res.result.length == 0) {
treeNode.dataRef.isLeaf = true
} else {
treeNode.dataRef.children = res.result
}
}
})
},
onLoadDepartment(treeNode){
return new Promise(resolve => {
queryDepartTreeSync({pid:treeNode.dataRef.id}).then((res) => {
if (res.success) {
//判断chidlren是否为空,并修改isLeaf属性值
if(res.result.length == 0){
treeNode.dataRef['isLeaf']=true
return;
}else{
treeNode.dataRef['children']= res.result;
}
}
})
resolve();
});
},
//update-end-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196
modalFormOk() {
this.loadData();
}
resolve()
})
},
// update-end-author:taoyan date:20211202 for: 异步加载部门树 https://github.com/jeecgboot/jeecg-boot/issues/3196
modalFormOk () {
this.loadData()
}
}
}
</script>
<style scoped>
@@ -349,4 +347,4 @@
cursor: pointer;
transition: color .3s;
}
</style>
</style>