j-date是JeecgBoot基于a-date-picker封装的时间组件
<template>
<a-card :bordered="false">
<j-date v-model="dateStr" placeholder="请选择">j-date>
a-card>
template>
<script>
<!-- 局部组件引入JDate-->
import JDate from '@/components/jeecg/JDate'
export default {
name: 'List',
components:{
JDate
},
data(){
return{
dateStr:null
}
}
}
script>
<style scoped>
style>
j-date源码
<template>
<a-date-picker
dropdownClassName="j-date-picker"
:disabled="disabled || readOnly"
:placeholder="placeholder"
@change="handleDateChange"
:value="momVal"
:showTime="showTime"
:format="dateFormat"
:getCalendarContainer="getCalendarContainer"
v-bind="$attrs"/>
template>
<script>
import moment from 'moment'
export default {
name: 'JDate',
props: {
placeholder:{
type: String,
default: '',
required: false
},
value:{
type: String,
required: false
},
dateFormat:{
type: String,
default: 'YYYY-MM-DD',
required: false
},
//此属性可以被废弃了
triggerChange:{
type: Boolean,
required: false,
default: false
},
readOnly:{
type: Boolean,
required: false,
default: false
},
disabled:{
type: Boolean,
required: false,
default: false
},
showTime:{
type: Boolean,
required: false,
default: false
},
getCalendarContainer: {
type: Function,
default: (node) => node.parentNode
}
},
data () {
let dateStr = this.value;
return {
decorator:"",
momVal:!dateStr?null:moment(dateStr,this.dateFormat)
}
},
watch: {
value (val) {
if(!val){
this.momVal = null
}else{
this.momVal = moment(val,this.dateFormat)
}
}
},
methods: {
moment,
handleDateChange(mom,dateStr){
this.$emit('change', dateStr);
console.log(dateStr)
}
},
//2.2新增 在组件内定义 指定父组件调用时候的传值属性和事件类型 这个牛逼
model: {
prop: 'value',
event: 'change'
}
}
script>
<template>
<a-card :bordered="false">
<j-date v-model="dateStr" placeholder="请选择">j-date>
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
dateStr:null
}
}
}
script>
<style scoped>
style>
官网介绍
官网介绍
<template>
<a-card :bordered="false">
<div>
<a-input v-model="str" @change="showStr" allowClear placeholder="请输入" />
{{str}}
div>
<div>
<a-input allowClear placeholder="请输入" :default-value="defaultStr" />
div>
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
str:null,
defaultStr:'123'
}
},
methods:{
showStr(e){
console.log('改变的值')
console.log(e.target.value)
this.str = e.target.value
}
}
}
script>
<style scoped>
style>
官网介绍
<template>
<a-card :bordered="false">
<a-select default-value="lucy" style="width: 120px" @change="handleChange">
<a-select-option value="jack">
Jack
a-select-option>
<a-select-option value="lucy">
Lucy
a-select-option>
<a-select-option value="disabled" disabled>
Disabled
a-select-option>
<a-select-option value="Yiminghe">
yiminghe
a-select-option>
a-select>
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
}
},
methods:{
handleChange(value) {
console.log(`selected ${value}`);
},
}
}
script>
<style scoped>
style>
<template>
<a-card :bordered="false">
<a-select style="width: 120px" @change="handleChange" allowClear >
<a-select-option v-for="(item,index) in options" :key="index" :value="item.value">{{item.text}}a-select-option>
a-select>
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
options:[]
}
},
mounted() {
this.loadOptions()
},
methods:{
loadOptions(){
this.options=[
{
text:'Jack',
value:'Jack'
},
{
text:'Linda',
value:'Linda'
},
{
text:'Lucy',
value:'Lucy'
}
]
},
handleChange(value) {
console.log(`selected ${value}`);
},
}
}
script>
<style scoped>
style>
<template>
<a-card :bordered="false">
<a-select style="width: 120px" @change="handleChange" allowClear v-model="selectVal" >
<a-select-option v-for="(item,index) in options" :key="index" :value="item.value">{{item.text}}a-select-option>
a-select>
我是被选中的value:{{selectVal}}
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
options:[],
selectVal:null,
}
},
mounted() {
this.loadOptions()
},
methods:{
loadOptions(){
this.options=[
{
text:'Jack',
value:'Jack'
},
{
text:'Linda',
value:'Linda'
},
{
text:'Lucy',
value:'Lucy'
}
]
},
handleChange(value) {
console.log(`selected ${value}`);
},
}
}
script>
<style scoped>
style>
<template>
<a-card :bordered="false">
<a-select style="width: 120px" @change="handleChange" allowClear v-model="selectVal" disabled>
<a-select-option v-for="(item,index) in options" :key="index" :value="item.value">{{item.text}}a-select-option>
a-select>
我是被选中的value:{{selectVal}}
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
options:[],
selectVal:null,
}
},
mounted() {
this.loadOptions()
},
methods:{
loadOptions(){
this.options=[
{
text:'Jack',
value:'Jack'
},
{
text:'Linda',
value:'Linda'
},
{
text:'Lucy',
value:'Lucy'
}
]
},
handleChange(value) {
console.log(`selected ${value}`);
},
}
}
script>
<style scoped>
style>
<template>
<a-card :bordered="false">
<a-select style="width: 120px" @change="handleChange" allowClear :defaultValue="defaultValue">
<a-select-option v-for="(item,index) in options" :key="index" :value="item.value">{{item.text}}a-select-option>
a-select>
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
options:[],
defaultValue:'Jack'
}
},
mounted() {
this.loadOptions()
},
methods:{
loadOptions(){
this.options=[
{
text:'Jack',
value:'Jack'
},
{
text:'Linda',
value:'Linda'
},
{
text:'Lucy',
value:'Lucy'
}
]
},
handleChange(value) {
console.log(`selected ${value}`);
},
}
}
script>
<style scoped>
style>
下拉选支持多选
官网介绍
<template>
<a-card :bordered="false">
<a-select style="width: 120px" @change="handleChange" allowClear mode="multiple" v-model="str">
<a-select-option v-for="(item,index) in options" :key="index" :value="item.value">{{item.text}}a-select-option>
a-select>
a-card>
template>
<script>
export default {
name: 'List',
data(){
return{
options:[],
str:''
}
},
mounted() {
this.loadOptions()
},
methods:{
loadOptions(){
this.options=[
{
text:'Jack',
value:'Jack'
},
{
text:'Linda',
value:'Linda'
},
{
text:'Lucy',
value:'Lucy'
}
]
},
handleChange(value) {
console.log(`selected ${value}`);
},
}
}
script>
<style scoped>
style>
官网介绍
change事件,文件上传中、完成、失败都会调用
table表格
表格分页参数
<template>
<a-card :bordered="false">
<a-table border ref="testTable" rowKey="id" :columns="columns" :data-source="dataSource" :pagination="page"
size="middle" :scroll="{ x: 1500, y: 300 }">
<template slot="avatarslot" slot-scope="text, record, index">
<div class="anty-img-wrap">
<a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>
div>
template>
a-table>
a-card>
template>
<script>
import { getUserList,getFileAccessHttpUrl } from '@/api/manage'
import { filterObj } from '@/utils/util'
export default {
name: 'List',
data() {
return {
dataSource:[],//表格数据
/* 排序参数 */
isorter: {
column: 'createTime',
order: 'desc'
},
description: '这是测试表格',
queryParam: {},//查询参数
page: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30', '50'],//每页分页参数选项
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' 共' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},//表格分页
columns: [// 自定义列
{
title: '#',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
fixed:'left',// 固定列
customRender: function(t, r, index) {
return parseInt(index) + 1
}
},
{
title: '用户账号',
align: 'center',
dataIndex: 'username',
width: 120,
sorter: true
},
{
title: '头像',
align: 'center',
width: 120,
dataIndex: 'avatar',
scopedSlots: { customRender: 'avatarslot' }
},
{
title: '性别',
align: 'center',
width: 80,
dataIndex: 'sex_dictText',// sex_dictText字典表中的code
sorter: true
},
{
title: '生日',
align: 'center',
width: 100,
dataIndex: 'birthday'
},
{
title: '手机号码',
align: 'center',
width: 100,
dataIndex: 'phone'
},
{
title: '部门',
align: 'center',
width: 180,
dataIndex: 'orgCodeTxt'
},
{
title: '负责部门',
align: 'center',
width: 180,
dataIndex: 'departIds_dictText'
},
{
title: '状态',
align: 'center',
width: 80,
dataIndex: 'status_dictText'
},
{
title: '操作',
dataIndex: 'action',
scopedSlots: { customRender: 'action' },
align: 'center',
width: 170
}
]
}
},
mounted() {
this.loadData(1)
},
methods: {
getAvatarView: function (avatar) {
return getFileAccessHttpUrl(avatar)
},
getQueryField() {
var str = 'id,'
this.columns.forEach(function(value) {
str += ',' + value.dataIndex
})
return str
},
//获取查询参数
getQueryParams() {
let param = Object.assign({}, this.queryParam, this.isorter)
param.field = this.getQueryField()
param.current = this.page.current
param.pageSize = this.page.pageSize
return filterObj(param)
},
//加载表格数据
loadData(arg) {
if (arg == 1) {
this.page.current = 1
}
let parmas = this.getQueryParams()//查询参数
getUserList(parmas).then((res) => {
console.log('返回参数')
console.log(res)
if (res.status==200) {
const {result}=res
this.dataSource = result.data
this.page.total = result.totalCount
}
})
}
}
}
script>
<style scoped>
style>
Modal官网介绍
官网介绍
// 复制对象属性从this.model中,复制username,password等属性的值
let fieldValue=pick(this.model,'username','password')
jeecg前端图表使用的是Viser-vue
jeecg前端集成echarts步骤
import echarts from 'echarts'
Vue.prototype.$echarts=echarts
<template>
<a-card :bordered="false">
<div id="myChart" :style="{width:'600px',height:'300px'}">div>
a-card>
template>
<script>
export default {
name: 'List',
data() {
return {}
},
mounted() {
this.drawLine()
},
methods: {
drawLine() {
let myChart = this.$echarts.init(document.getElementById('myChart'))
myChart.setOption({
title: { text: 'xxx商品销量统计' },
tooltip: {},
xAxis: {
data: ['水果', '酸奶']
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [105, 50]
}]
})
}
}
}
script>
<style scoped>
style>
<j-dict-select-tag v-model="queryParam.sex" placeholder="请输入用户性别" dictCode="sex"/>
import {initDictOptions, filterDictText} from '@/components/dict/JDictSelectUtil'
//初始化字典配置
this.initDictConfig();
initDictConfig() {
//初始化字典 - 性别
initDictOptions('sex').then((res) => {
if (res.success) {
this.sexDictOptions = res.result;
}
});
},
customRender: (text, record, index) => {
//字典值替换通用方法
return filterDictText(this.sexDictOptions, text);
}
columns: [
/*{
title: '#',
dataIndex: '',
key:'rowIndex',
width:60,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},*/
{
title: '用户账号',
align: "center",
dataIndex: 'username',
width: 120,
sorter: true
},
{
title: '用户姓名',
align: "center",
width: 100,
dataIndex: 'realname',
},
{
title: '头像',
align: "center",
width: 120,
dataIndex: 'avatar',
scopedSlots: {customRender: "avatarslot"}
},
{
title: '性别',
align: "center",
width: 80,
dataIndex: 'sex',
sorter: true,
customRender: (text, record, index) => {
//字典值替换通用方法
return filterDictText(this.sexDictOptions, text);
}
},
{
title: '生日',
align: "center",
width: 100,
dataIndex: 'birthday'
},
{
title: '手机号码',
align: "center",
width: 100,
dataIndex: 'phone'
},
{
title: '部门',
align: "center",
width: 180,
dataIndex: 'orgCodeTxt'
},
{
title: '负责部门',
align: "center",
width: 180,
dataIndex: 'departIds_dictText'
},
{
title: '状态',
align: "center",
width: 80,
dataIndex: 'status_dictText'
},
{
title: '操作',
dataIndex: 'action',
scopedSlots: {customRender: 'action'},
align: "center",
width: 170
}
],