Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
committed
Sep 19, 2019
1 parent
30d335e
commit f99ad57
Showing
14 changed files
with
409 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
app/views/form-generator/aside-panel/module/row-select.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<template> | ||
<section> | ||
<div class="row-select" v-if="type === 'deleteRow'"> | ||
<el-button type="primary" size="mini" icon="el-icon-plus" circle @click="$emit('deleteRow')"></el-button> | ||
<div class="row-select__des">{{des}}</div> | ||
</div> | ||
<el-dropdown trigger="click" @command="handleCommand" v-else> | ||
<div class="row-select"> | ||
<el-button type="primary" size="mini" icon="el-icon-plus" circle></el-button> | ||
<div class="row-select__des">{{des}}</div> | ||
</div> | ||
<el-dropdown-menu slot="dropdown"> | ||
<div style="overflow-y:auto;max-height:200px"> | ||
<el-dropdown-item | ||
v-for="(layout, index) in activeRowLayouts" | ||
:key="index" | ||
:command="layout"> | ||
<svg fill="#BEC9D6" height="26"> | ||
<template v-for="(item, idx) in layout"> | ||
<rect | ||
:key="idx" | ||
:width="`${getRectWidth(layout)}%`" | ||
height="20" | ||
y="5" | ||
rx="5" | ||
ry="5" | ||
:x="idx === 0 ? '0%' : `${(getRectWidth(layout) + 3) * idx}%`" | ||
/> | ||
</template> | ||
</svg> | ||
</el-dropdown-item> | ||
</div> | ||
</el-dropdown-menu> | ||
</el-dropdown> | ||
</section> | ||
</template> | ||
|
||
<script> | ||
import isEqual from 'lodash.isequal' | ||
export default { | ||
inject: ['fg'], | ||
props: { | ||
type: { | ||
type: String // addRow editRow deleteRow | ||
}, | ||
activeLayOut: { // 当前活跃的状态 | ||
type: Array | ||
} | ||
}, | ||
data () { | ||
return { | ||
rowLayouts: [ | ||
[24], | ||
[12, 12], | ||
[8, 8, 8], | ||
[6, 6, 6, 6], | ||
[5, 5, 5, 5, 5], | ||
[4, 4, 4, 4, 4, 4], | ||
[9, 15], | ||
[15, 9], | ||
[8, 16], | ||
[16, 8], | ||
[6, 18], | ||
[18, 6], | ||
[6, 12, 6], | ||
[4, 16, 4], | ||
[6, 6, 12], | ||
[12, 6, 6], | ||
[4, 4, 16], | ||
[16, 4, 4], | ||
[4, 4, 4, 12], | ||
[12, 4, 4, 4] | ||
] | ||
} | ||
}, | ||
computed: { | ||
des () { | ||
let _des = { addRow: '新增行', editRow: '编辑列', deleteRow: '删除行' } | ||
return _des[this.type] | ||
}, | ||
activeRowLayouts () { | ||
if (!this.activeLayOut) return this.rowLayouts | ||
return this.rowLayouts.filter(item => !isEqual(item, this.activeLayOut)) | ||
} | ||
}, | ||
methods: { | ||
getRectWidth (item) { | ||
const len = item.length | ||
return (100 - len * 3) / len | ||
}, | ||
handleCommand (data) { | ||
this.$emit('editRow', data) | ||
}, | ||
onDelete () { | ||
console.log('执行') | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.row-select{ | ||
display: inline-block; | ||
text-align: center; | ||
padding: 0 5px; | ||
&__des{ | ||
font-size:12px; | ||
margin-top:8px; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.