123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- <template>
- <div
- :class="{
- 'layout-width': ['grid', 'table', 'card', 'divider', 'html'].includes(
- record.type
- )
- }"
- >
-
- <template v-if="record.type === 'batch'">
- <div
- class="batch-box"
- :class="{ active: record.key === selectItem.key }"
- @click.stop="handleSelectItem(record)"
- >
- <a-form-item
- :label="!record.options.showLabel ? '' : record.label"
- :label-col="
- config.layout === 'horizontal' && record.options.showLabel
- ? config.labelLayout === 'flex'
- ? { style: `width:${config.labelWidth}px` }
- : config.labelCol
- : {}
- "
- :wrapper-col="
- config.layout === 'horizontal' && record.options.showLabel
- ? config.labelLayout === 'flex'
- ? { style: 'width:auto;flex:1' }
- : config.wrapperCol
- : {}
- "
- :style="
- config.layout === 'horizontal' &&
- config.labelLayout === 'flex' &&
- record.options.showLabel
- ? { display: 'flex' }
- : {}
- "
- >
- <draggable
- tag="div"
- class="draggable-box"
- v-bind="{
- group: insertAllowed ? 'form-draggable' : '',
- ghostClass: 'moving',
- animation: 180,
- handle: '.drag-move'
- }"
- v-model="record.list"
- @start="$emit('dragStart', $event, record.list)"
- @add="$emit('handleColAdd', $event, record.list)"
- >
- <transition-group tag="div" name="list" class="list-main">
- <formNode
- v-for="item in record.list"
- :key="item.key"
- class="drag-move"
- :selectItem.sync="selectItem"
- :record="item"
- :hideModel="hideModel"
- :config="config"
- @handleSelectItem="handleSelectItem"
- @handleColAdd="handleColAdd"
- @handleCopy="$emit('handleCopy')"
- @handleShowRightMenu="handleShowRightMenu"
- @handleDelete="$emit('handleDelete')"
- />
- </transition-group>
- </draggable>
- </a-form-item>
- <div
- class="copy"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleCopy')"
- >
- <a-icon type="copy" />
- </div>
- <div
- class="delete"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleDelete')"
- >
- <a-icon type="delete" />
- </div>
- </div>
- </template>
-
-
- <template v-else-if="record.type === 'selectInputList'">
- <div
- class="select-input-list-box"
- :class="{ active: record.key === selectItem.key }"
- @click.stop="handleSelectItem(record)"
- >
- <a-form-item
- :label="!record.options.showLabel ? '' : record.label"
- :label-col="
- config.layout === 'horizontal' && record.options.showLabel
- ? config.labelLayout === 'flex'
- ? { style: `width:${config.labelWidth}px` }
- : config.labelCol
- : {}
- "
- :wrapper-col="
- config.layout === 'horizontal' && record.options.showLabel
- ? config.labelLayout === 'flex'
- ? { style: 'width:auto;flex:1' }
- : config.wrapperCol
- : {}
- "
- :style="
- config.layout === 'horizontal' &&
- config.labelLayout === 'flex' &&
- record.options.showLabel
- ? { display: 'flex' }
- : {}
- "
- >
- <div
- class="column-box"
- v-for="(column, index) in record.columns"
- :key="index"
- >
- <div class="check-box">
- <a-checkbox v-if="record.options.multiple" disabled>
- {{ column.label }}
- </a-checkbox>
- <a-radio-group v-else disabled name="radio">
- <a-radio :value="column.value">{{ column.label }}</a-radio>
- </a-radio-group>
- </div>
- <draggable
- tag="div"
- class="draggable-box"
- v-bind="{
- group: insertAllowed ? 'form-draggable' : '',
- ghostClass: 'moving',
- animation: 180,
- handle: '.drag-move'
- }"
- v-model="column.list"
- @start="$emit('dragStart', $event, column.list)"
- @add="$emit('handleColAdd', $event, column.list)"
- >
- <transition-group tag="div" name="list" class="list-main">
- <formNode
- v-for="item in column.list"
- :key="item.key"
- class="drag-move"
- :selectItem.sync="selectItem"
- :record="item"
- :hideModel="hideModel"
- :config="config"
- @handleSelectItem="handleSelectItem"
- @handleColAdd="handleColAdd"
- @handleCopy="$emit('handleCopy')"
- @handleShowRightMenu="handleShowRightMenu"
- @handleDelete="$emit('handleDelete')"
- />
- </transition-group>
- </draggable>
- </div>
- </a-form-item>
- <div
- class="copy"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleCopy')"
- >
- <a-icon type="copy" />
- </div>
- <div
- class="delete"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleDelete')"
- >
- <a-icon type="delete" />
- </div>
- </div>
- </template>
-
-
- <template v-else-if="record.type === 'tabs'">
- <div
- class="grid-box"
- :class="{ active: record.key === selectItem.key }"
- @click.stop="handleSelectItem(record)"
- >
- <a-tabs
- class="grid-row"
- :default-active-key="0"
- :tabBarGutter="record.options.tabBarGutter || null"
- :type="record.options.type"
- :size="record.options.size"
- :tabPosition="record.options.tabPosition"
- :animated="record.options.animated"
- >
- <a-tab-pane
- v-for="(tabItem, index) in record.columns"
- :key="index"
- :tab="tabItem.label"
- >
- <div class="grid-col">
- <draggable
- tag="div"
- class="draggable-box"
- v-bind="{
- group: 'form-draggable',
- ghostClass: 'moving',
- animation: 180,
- handle: '.drag-move'
- }"
- v-model="tabItem.list"
- @start="$emit('dragStart', $event, tabItem.list)"
- @add="$emit('handleColAdd', $event, tabItem.list)"
- >
- <transition-group tag="div" name="list" class="list-main">
- <layoutItem
- class="drag-move"
- v-for="item in tabItem.list"
- :key="item.key"
- :selectItem.sync="selectItem"
- :startType="startType"
- :insertAllowedType="insertAllowedType"
- :record="item"
- :hideModel="hideModel"
- :config="config"
- @handleSelectItem="handleSelectItem"
- @handleColAdd="handleColAdd"
- @handleCopy="$emit('handleCopy')"
- @handleShowRightMenu="handleShowRightMenu"
- @handleDelete="$emit('handleDelete')"
- />
- </transition-group>
- </draggable>
- </div>
- </a-tab-pane>
- </a-tabs>
- <div
- class="copy"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleCopy')"
- >
- <a-icon type="copy" />
- </div>
- <div
- class="delete"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleDelete')"
- >
- <a-icon type="delete" />
- </div>
- </div>
- </template>
-
-
- <template v-else-if="record.type === 'grid'">
- <div
- class="grid-box"
- :class="{ active: record.key === selectItem.key }"
- @click.stop="handleSelectItem(record)"
- >
- <a-row class="grid-row" :gutter="record.options.gutter">
- <a-col
- class="grid-col"
- v-for="(colItem, idnex) in record.columns"
- :key="idnex"
- :span="colItem.span || 0"
- >
- <draggable
- tag="div"
- class="draggable-box"
- v-bind="{
- group: 'form-draggable',
- ghostClass: 'moving',
- animation: 180,
- handle: '.drag-move'
- }"
- v-model="colItem.list"
- @start="$emit('dragStart', $event, colItem.list)"
- @add="$emit('handleColAdd', $event, colItem.list)"
- >
- <transition-group tag="div" name="list" class="list-main">
- <layoutItem
- class="drag-move"
- v-for="item in colItem.list"
- :key="item.key"
- :selectItem.sync="selectItem"
- :startType="startType"
- :insertAllowedType="insertAllowedType"
- :record="item"
- :hideModel="hideModel"
- :config="config"
- @handleSelectItem="handleSelectItem"
- @handleColAdd="handleColAdd"
- @handleCopy="$emit('handleCopy')"
- @handleShowRightMenu="handleShowRightMenu"
- @handleDelete="$emit('handleDelete')"
- />
- </transition-group>
- </draggable>
- </a-col>
- </a-row>
- <div
- class="copy"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleCopy')"
- >
- <a-icon type="copy" />
- </div>
- <div
- class="delete"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleDelete')"
- >
- <a-icon type="delete" />
- </div>
- </div>
- </template>
-
-
- <template v-else-if="record.type === 'card'">
- <div
- class="grid-box"
- :class="{ active: record.key === selectItem.key }"
- @click.stop="handleSelectItem(record)"
- >
- <a-card class="grid-row" :title="record.label">
- <div class="grid-col">
- <draggable
- tag="div"
- class="draggable-box"
- v-bind="{
- group: 'form-draggable',
- ghostClass: 'moving',
- animation: 180,
- handle: '.drag-move'
- }"
- v-model="record.list"
- @start="$emit('dragStart', $event, record.list)"
- @add="$emit('handleColAdd', $event, record.list)"
- >
- <transition-group tag="div" name="list" class="list-main">
- <layoutItem
- class="drag-move"
- v-for="item in record.list"
- :key="item.key"
- :selectItem.sync="selectItem"
- :startType="startType"
- :insertAllowedType="insertAllowedType"
- :record="item"
- :hideModel="hideModel"
- :config="config"
- @handleSelectItem="handleSelectItem"
- @handleColAdd="handleColAdd"
- @handleCopy="$emit('handleCopy')"
- @handleShowRightMenu="handleShowRightMenu"
- @handleDelete="$emit('handleDelete')"
- />
- </transition-group>
- </draggable>
- </div>
- </a-card>
- <div
- class="copy"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleCopy')"
- >
- <a-icon type="copy" />
- </div>
- <div
- class="delete"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleDelete')"
- >
- <a-icon type="delete" />
- </div>
- </div>
- </template>
-
-
- <template v-else-if="record.type === 'table'">
- <div
- class="table-box"
- :class="{ active: record.key === selectItem.key }"
- @click.stop="handleSelectItem(record)"
- >
- <table
- class="table-layout kk-table-9136076486841527"
- :class="{
- bright: record.options.bright,
- small: record.options.small,
- bordered: record.options.bordered
- }"
- :style="record.options.customStyle"
- >
- <tr v-for="(trItem, trIndex) in record.trs" :key="trIndex">
- <td
- class="table-td"
- v-for="(tdItem, tdIndex) in trItem.tds"
- v-show="tdItem.colspan && tdItem.rowspan"
- :key="tdIndex"
- :colspan="tdItem.colspan"
- :rowspan="tdItem.rowspan"
- @contextmenu.prevent="
- $emit('handleShowRightMenu', $event, record, trIndex, tdIndex)
- "
- >
- <draggable
- tag="div"
- class="draggable-box"
- v-bind="{
- group: 'form-draggable',
- ghostClass: 'moving',
- animation: 180,
- handle: '.drag-move'
- }"
- v-model="tdItem.list"
- @start="$emit('dragStart', $event, tdItem.list)"
- @add="$emit('handleColAdd', $event, tdItem.list)"
- >
- <transition-group tag="div" name="list" class="list-main">
- <layoutItem
- class="drag-move"
- v-for="item in tdItem.list"
- :key="item.key"
- :selectItem.sync="selectItem"
- :startType="startType"
- :insertAllowedType="insertAllowedType"
- :record="item"
- :hideModel="hideModel"
- :config="config"
- @handleSelectItem="handleSelectItem"
- @handleColAdd="handleColAdd"
- @handleCopy="$emit('handleCopy')"
- @handleShowRightMenu="handleShowRightMenu"
- @handleDelete="$emit('handleDelete')"
- />
- </transition-group>
- </draggable>
- </td>
- </tr>
- </table>
- <div
- class="copy"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleCopy')"
- >
- <a-icon type="copy" />
- </div>
- <div
- class="delete"
- :class="record.key === selectItem.key ? 'active' : 'unactivated'"
- @click.stop="$emit('handleDelete')"
- >
- <a-icon type="delete" />
- </div>
- </div>
- </template>
-
- <template v-else>
- <formNode
- :key="record.key"
- :selectItem.sync="selectItem"
- :record="record"
- :config="config"
- :hideModel="hideModel"
- @handleSelectItem="handleSelectItem"
- @handleCopy="$emit('handleCopy')"
- @handleDelete="$emit('handleDelete')"
- @handleShowRightMenu="$emit('handleShowRightMenu')"
- />
- </template>
- </div>
- </template>
- <script>
- import draggable from "vuedraggable";
- import formNode from "./formNode";
- export default {
- name: "layoutItem",
- props: {
- record: {
- type: Object,
- required: true
- },
- selectItem: {
- type: Object,
- required: true
- },
- config: {
- type: Object,
- required: true
- },
- startType: {
- type: String,
- required: true
- },
- insertAllowedType: {
- type: Array,
- required: true
- },
- hideModel: {
- type: Boolean,
- default: false
- }
- },
- computed: {
- insertAllowed() {
- return this.insertAllowedType.includes(this.startType);
- }
- },
- components: {
- formNode,
- draggable
- },
- methods: {
- handleShowRightMenu(e, record, trIndex, tdIndex) {
- this.$emit("handleShowRightMenu", e, record, trIndex, tdIndex);
- },
- handleSelectItem(record) {
- this.$emit("handleSelectItem", record);
- },
- handleColAdd(e, list) {
- this.$emit("handleColAdd", e, list);
- }
- }
- };
- </script>
|