Skip to content

Commit 3ade49d

Browse files
committed
feat: 更新demo示例
1 parent 59c963a commit 3ade49d

File tree

6 files changed

+89
-27
lines changed

6 files changed

+89
-27
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "element-pro-crud",
3-
"version": "0.8.6-6",
3+
"version": "0.8.6-8",
44
"author": "BoBo<[email protected]>",
55
"main": "lib/ProCrud.umd.min.js",
66
"files": [

src/component/crud-table/src/CrudTable.vue

+1
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ export default defineComponent({
640640
background: white;
641641
padding: 10px;
642642
position: relative;
643+
width: 100%;
643644
h4 {
644645
margin: 2px 30px 0px 0px;
645646
padding-left: 15px;

src/component/form-designer/src/components/AvatarUpload/AvatarUpload.vue

+16-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
:show-file-list="false"
2222
:on-success="handleAvatarSuccess"
2323
>
24-
<img v-if="imageUrl" :src="imageUrl" class="avatar" />
24+
<img v-if="hasImage" :src="imageUrl" class="avatar" />
2525
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
2626
</el-upload>
2727
</template>
@@ -35,7 +35,8 @@ export default {
3535
},
3636
data() {
3737
return {
38-
imageUrl: this.value,
38+
hasImage: false,
39+
prefix: window.__HOST__URL__ + window.__PREFIX__URL__,
3940
};
4041
},
4142
props: {
@@ -57,20 +58,27 @@ export default {
5758
default: false,
5859
},
5960
},
61+
created() {
62+
if (this.value) {
63+
this.hasImage = true;
64+
}
65+
},
6066
computed: {
67+
imageUrl() {
68+
return this.prefix + this.value;
69+
},
6170
action() {
62-
const __GLOBAL__URL__ = window.__HOST__URL__ + window.__PREFIX__URL__;
63-
return __GLOBAL__URL__ + this.widget.options.uploadUrl;
71+
return this.prefix + this.widget.options.uploadUrl;
6472
},
6573
headers() {
6674
return { Authorization: sessionStorage.getItem('token') };
6775
},
6876
},
6977
methods: {
7078
handleAvatarSuccess(res, file) {
71-
const __GLOBAL__URL__ = window.__HOST__URL__ + window.__PREFIX__URL__;
72-
this.imageUrl = URL.createObjectURL(file.raw);
73-
this.$emit('change', __GLOBAL__URL__ + res.data);
79+
// this.imageUrl = URL.createObjectURL(file.raw);
80+
this.hasImage = true;
81+
this.$emit('change', res.data);
7482
},
7583
beforeUpload() {
7684
// 只读时禁止上传
@@ -88,6 +96,7 @@ export default {
8896
border-radius: 6px;
8997
cursor: pointer;
9098
position: relative;
99+
margin: 0 auto;
91100
overflow: hidden;
92101
}
93102
.avatar-uploader .el-upload:hover {

src/component/form-designer/src/styles/table-form.scss

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
height: 100%;
4545
margin-left: 0px !important;
4646
flex: 1;
47+
display: flex;
48+
align-items: center;
4749
padding: 10px 0;
4850
.el-checkbox-group{
4951
padding-left:10px;
@@ -52,9 +54,6 @@
5254
border:none;
5355
}
5456
}
55-
.el-select,.el-input{
56-
height:100%;
57-
}
5857
input,
5958
textarea {
6059
border: none;

src/demo/component/PersonCrudTable.vue

+24-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
<template>
99
<CrudTable ref="table" tableName="person" tableTitle="员工管理" fullHeight orderCondition="timestamp desc" :visibleList="visibleList" v-bind="$attrs" v-on="$listeners">
1010
<template #columnFormatter="{row,prop}">
11-
<el-tag v-if="prop === 'jobno'">{{ row.jobno }}</el-tag>
12-
<span v-if="prop === 'personname'"><i class="el-icon el-icon-user" style="color: red"></i>{{ row.personname }}</span>
13-
</template>
11+
<el-tag v-if="prop === 'jobno'">{{ row.jobno }}</el-tag>
12+
<span v-if="prop === 'personname'"><i class="el-icon el-icon-user" style="color: red"></i>{{ row.personname }}</span>
13+
<el-image style="width: 50px; height: 50px" fit="fill" v-if="prop === 'avatar'" :src="getAvatarUrl(row)" :preview-src-list="[getAvatarUrl(row)]">
14+
<div slot="error" style="height: 100%">
15+
<div class="error"><i class="el-icon-picture-outline"></i></div>
16+
</div>
17+
</el-image>
18+
</template>
1419
<template #btnCustom="{row}">
1520
<el-button size="mini" @click="getRowData(row)">自定义</el-button>
1621
</template>
@@ -30,5 +35,21 @@ export default class PersonTable extends Vue {
3035
getRowData(row) {
3136
this.$alert(JSON.stringify(row));
3237
}
38+
39+
getAvatarUrl(row) {
40+
return window.__HOST__URL__ + row.avatar;
41+
}
3342
}
3443
</script>
44+
<style lang="scss" scoped>
45+
.error {
46+
display: flex;
47+
justify-content: center;
48+
align-items: center;
49+
width: 100%;
50+
height: 100%;
51+
background: #f5f7fa;
52+
color: #909399;
53+
font-size: 30px;
54+
}
55+
</style>

src/demo/component/PersonProTable.vue

+45-13
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77

88
<template>
99
<ProTable ref="table" :request="request" :columns="columns" tableTitle="员工管理" fullHeight orderCondition="timestamp desc" v-bind="$attrs" v-on="$listeners">
10-
<template #columnFormatter="{row,prop}">
11-
<el-tag v-if="prop === 'jobno'">{{ row.jobno }}</el-tag>
12-
<span v-if="prop === 'personname'"><i class="el-icon el-icon-user" style="color: red"></i>{{ row.personname }}</span>
13-
</template>
10+
<template #columnFormatter="{row,prop}">
11+
<el-tag v-if="prop === 'jobno'">{{ row.jobno }}</el-tag>
12+
<span v-if="prop === 'personname'"><i class="el-icon el-icon-user" style="color: red"></i>{{ row.personname }}</span>
13+
<el-image style="width: 50px; height: 50px" fit="fill" v-if="prop === 'avatar'" :src="getAvatarUrl(row)" :preview-src-list="[getAvatarUrl(row)]">
14+
<div slot="error" style="height: 100%">
15+
<div class="error"><i class="el-icon-picture-outline"></i></div>
16+
</div>
17+
</el-image>
18+
</template>
1419
</ProTable>
1520
</template>
1621

@@ -23,29 +28,38 @@ import { Vue, Component, Prop } from 'vue-property-decorator';
2328
})
2429
export default class PersonProTable extends Vue {
2530
columns = {
26-
name: 'person',
27-
position: '人员信息列表',
2831
columns: [
32+
{
33+
prop: 'avatar',
34+
label: '照片',
35+
align: 'center',
36+
headerAlign: 'center',
37+
showOverflowTooltip: true,
38+
minWidth: 140,
39+
sortable: 'custom',
40+
searchable: true,
41+
slotName: 'columnFormatter',
42+
},
2943
{
3044
prop: 'jobno',
3145
label: '工号',
32-
minWidth: 140,
46+
minWidth: '100',
3347
align: 'center',
3448
headerAlign: 'center',
3549
showOverflowTooltip: true,
3650
sortable: 'custom',
37-
slotName: '',
51+
slotName: 'columnFormatter',
3852
searchable: true,
3953
},
4054
{
4155
prop: 'personname',
4256
label: '姓名',
43-
minWidth: 140,
57+
minWidth: '70',
4458
align: 'center',
4559
headerAlign: 'center',
4660
showOverflowTooltip: true,
4761
sortable: 'custom',
48-
slotName: '',
62+
slotName: 'columnFormatter',
4963
searchable: true,
5064
},
5165
{
@@ -62,7 +76,7 @@ export default class PersonProTable extends Vue {
6276
{
6377
prop: 'deptname',
6478
label: '所在部门',
65-
minWidth: 140,
79+
minWidth: '100',
6680
align: 'center',
6781
headerAlign: 'center',
6882
showOverflowTooltip: true,
@@ -73,7 +87,7 @@ export default class PersonProTable extends Vue {
7387
{
7488
prop: 'post',
7589
label: '岗位',
76-
minWidth: 140,
90+
minWidth: '100',
7791
align: 'center',
7892
headerAlign: 'center',
7993
showOverflowTooltip: true,
@@ -84,7 +98,7 @@ export default class PersonProTable extends Vue {
8498
{
8599
prop: 'level',
86100
label: '职级',
87-
minWidth: 140,
101+
minWidth: '100',
88102
align: 'center',
89103
headerAlign: 'center',
90104
showOverflowTooltip: true,
@@ -104,6 +118,8 @@ export default class PersonProTable extends Vue {
104118
searchable: true,
105119
},
106120
],
121+
name: 'person',
122+
position: '员工管理',
107123
}
108124

109125
async request(axiosParams: Params): Promise<DataSource> {
@@ -113,5 +129,21 @@ export default class PersonProTable extends Vue {
113129
total: res.data.total,
114130
};
115131
}
132+
133+
getAvatarUrl(row) {
134+
return window.__HOST__URL__ + row.avatar;
135+
}
116136
}
117137
</script>
138+
<style lang="scss" scoped>
139+
.error {
140+
display: flex;
141+
justify-content: center;
142+
align-items: center;
143+
width: 100%;
144+
height: 100%;
145+
background: #f5f7fa;
146+
color: #909399;
147+
font-size: 30px;
148+
}
149+
</style>

0 commit comments

Comments
 (0)