| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <template>
- <el-card
- :shadow="element.options.shadow"
- :body-style="{
- padding: element.options.padding
- }"
- :style="{
- width: element.options.width,
- 'border-width': element.options.bordered ? '1px' : '0px',
- '--padding': padding
- }"
- :class="{
- [element.options?.customClass]: element.options?.customClass ? true: false
- }"
- v-if="elementDisplay"
- >
- <div >
- <template v-for="item in element.list">
- <generate-col-item
- v-if="item.type == 'grid'"
- :key="item.key"
- :model="dataModels"
- :rules="rules"
- :element="item"
- :remote="remote"
- :blanks="blanks"
- :display="display"
- :sub-hide-fields="subHideFields"
- :sub-disabled-fields="subDisabledFields"
- :edit="edit"
- :remote-option="remoteOption"
- :platform="platform"
- :preview="preview"
- :container-key="containerKey"
- :data-source-value="dataSourceValue"
- :event-function="eventFunction"
- :print-read="printRead"
- :is-subform="isSubform"
- :row-index="rowIndex"
- :sub-name="subName"
- :is-dialog="isDialog"
- :dialog-name="dialogName"
- :is-group="isGroup"
- :group="group"
- :field-node="fieldNode"
- >
- <template v-slot:[blank.name]="scope" v-for="blank in blanks">
- <slot :name="blank.name" :model="scope.model"></slot>
- </template>
- </generate-col-item>
- <generate-tab-item
- v-else-if="item.type == 'tabs'"
- :key="item.key"
- :model="dataModels"
- :rules="rules"
- :element="item"
- :remote="remote"
- :blanks="blanks"
- :display="display"
- :sub-hide-fields="subHideFields"
- :sub-disabled-fields="subDisabledFields"
- :edit="edit"
- :remote-option="remoteOption"
- :platform="platform"
- :preview="preview"
- :container-key="containerKey"
- :data-source-value="dataSourceValue"
- :event-function="eventFunction"
- :print-read="printRead"
- :is-subform="isSubform"
- :row-index="rowIndex"
- :sub-name="subName"
- :is-dialog="isDialog"
- :dialog-name="dialogName"
- :is-group="isGroup"
- :group="group"
- :field-node="fieldNode"
- >
- <template v-slot:[blank.name]="scope" v-for="blank in blanks">
- <slot :name="blank.name" :model="scope.model"></slot>
- </template>
- </generate-tab-item>
- <generate-collapse
- v-else-if="item.type == 'collapse'"
- :key="item.key"
- :model="dataModels"
- :rules="rules"
- :element="item"
- :remote="remote"
- :blanks="blanks"
- :display="display"
- :sub-hide-fields="subHideFields"
- :sub-disabled-fields="subDisabledFields"
- :edit="edit"
- :remote-option="remoteOption"
- :platform="platform"
- :preview="preview"
- :container-key="containerKey"
- :data-source-value="dataSourceValue"
- :event-function="eventFunction"
- :print-read="printRead"
- :is-subform="isSubform"
- :row-index="rowIndex"
- :sub-name="subName"
- :is-dialog="isDialog"
- :dialog-name="dialogName"
- :is-group="isGroup"
- :group="group"
- :field-node="fieldNode"
- >
- <template v-slot:[blank.name]="scope" v-for="blank in blanks">
- <slot :name="blank.name" :model="scope.model"></slot>
- </template>
- </generate-collapse>
- <generate-report
- v-else-if="item.type == 'report'"
- :key="item.key"
- :model="dataModels"
- :rules="rules"
- :element="item"
- :remote="remote"
- :blanks="blanks"
- :display="display"
- :sub-hide-fields="subHideFields"
- :sub-disabled-fields="subDisabledFields"
- :edit="edit"
- :remote-option="remoteOption"
- :platform="platform"
- :preview="preview"
- :container-key="containerKey"
- :data-source-value="dataSourceValue"
- :event-function="eventFunction"
- :print-read="printRead"
- :is-subform="isSubform"
- :row-index="rowIndex"
- :sub-name="subName"
- :is-dialog="isDialog"
- :dialog-name="dialogName"
- :is-group="isGroup"
- :group="group"
- :field-node="fieldNode"
- >
- <template v-slot:[blank.name]="scope" v-for="blank in blanks">
- <slot :name="blank.name" :model="scope.model"></slot>
- </template>
- </generate-report>
- <generate-inline
- v-else-if="item.type == 'inline'"
- :key="item.key"
- :model="dataModels"
- :rules="rules"
- :element="item"
- :remote="remote"
- :blanks="blanks"
- :display="display"
- :sub-hide-fields="subHideFields"
- :sub-disabled-fields="subDisabledFields"
- :edit="edit"
- :remote-option="remoteOption"
- :platform="platform"
- :preview="preview"
- :container-key="containerKey"
- :data-source-value="dataSourceValue"
- :event-function="eventFunction"
- :print-read="printRead"
- :is-subform="isSubform"
- :row-index="rowIndex"
- :sub-name="subName"
- :is-dialog="isDialog"
- :dialog-name="dialogName"
- :is-group="isGroup"
- :group="group"
- :field-node="fieldNode"
- >
- <template v-slot:[blank.name]="scope" v-for="blank in blanks">
- <slot :name="blank.name" :model="scope.model"></slot>
- </template>
- </generate-inline>
- <generate-card
- v-else-if="item.type == 'card'"
- :key="item.key"
- :model="dataModels"
- :rules="rules"
- :element="item"
- :remote="remote"
- :blanks="blanks"
- :display="display"
- :sub-hide-fields="subHideFields"
- :sub-disabled-fields="subDisabledFields"
- :edit="edit"
- :remote-option="remoteOption"
- :platform="platform"
- :preview="preview"
- :container-key="containerKey"
- :data-source-value="dataSourceValue"
- :event-function="eventFunction"
- :print-read="printRead"
- :is-subform="isSubform"
- :row-index="rowIndex"
- :sub-name="subName"
- :is-dialog="isDialog"
- :dialog-name="dialogName"
- :is-group="isGroup"
- :group="group"
- :field-node="fieldNode"
- >
- <template v-slot:[blank.name]="scope" v-for="blank in blanks">
- <slot :name="blank.name" :model="scope.model"></slot>
- </template>
- </generate-card>
- <generate-form-item
- v-else
- :key="item.key"
- :models="dataModels"
- :rules="rules"
- :widget="item"
- :remote="remote"
- :blanks="blanks"
- :display="display"
- :sub-hide-fields="subHideFields"
- :sub-disabled-fields="subDisabledFields"
- :edit="edit"
- :remote-option="remoteOption"
- :platform="platform"
- :preview="preview"
- :container-key="containerKey"
- :data-source-value="dataSourceValue"
- :event-function="eventFunction"
- :print-read="printRead"
- :is-subform="isSubform"
- :row-index="rowIndex"
- :sub-name="subName"
- :is-dialog="isDialog"
- :dialog-name="dialogName"
- :is-group="isGroup"
- :group="group"
- :field-node="fieldNode"
- >
- <template v-slot:[blank.name]="scope" v-for="blank in blanks">
- <slot :name="blank.name" :model="scope.model"></slot>
- </template>
- </generate-form-item>
- </template>
- </div>
- <template #header v-if="element.options.showHeader">
- <div>
- <span>{{element.options.title}}</span>
- </div>
- </template>
- </el-card>
- </template>
- <script>
- import GenerateFormItem from './GenerateFormItem.vue'
- import GenerateInline from './GenerateInline.vue'
- import {executeExpression, isExpression, extractExpression} from '../util/expression'
- export default {
- name: 'generate-card',
- components: {
- GenerateFormItem,
- GenerateInline,
- GenerateReport: () => import('./GenerateReport.vue'),
- GenerateTabItem: () => import('./GenerateTabItem.vue'),
- GenerateCollapse: () => import('./GenerateCollapse.vue'),
- GenerateColItem: () => import('./GenerateColItem.vue'),
- },
- props: ['element', 'model', 'rules', 'remote', 'blanks', 'display', 'edit', 'remoteOption', 'platform', 'preview', 'containerKey', 'dataSourceValue', 'eventFunction', 'printRead', 'isSubform', 'rowIndex', 'subName', 'subHideFields', 'subDisabledFields', 'isDialog', 'dialogName', 'group', 'fieldNode', 'isGroup'],
- data () {
- return {
- dataModels: this.model
- }
- },
- inject: ['generateComponentInstance', 'deleteComponentInstance', 'dynamicHideFields', 'formContext'],
- mounted () {
- this.generateComponentInstance && this.generateComponentInstance(this.fieldNode ? `${this.fieldNode}.${this.element.model}` : this.element.model, this)
- },
- beforeUnmount () {
- this.deleteComponentInstance && this.deleteComponentInstance(this.fieldNode ? `${this.fieldNode}.${this.element.model}` : this.element.model)
- },
- computed: {
- padding () {
- return this.element.options.padding || '20px'
- },
- currentOptions () {
- if (this.isSubform) {
- return {
- fieldNode: this.fieldNode ? `${this.fieldNode}.${this.element.model}` : this.element.model,
- rowIndex: this.rowIndex,
- row: this.model
- }
- } else {
- return {
- fieldNode: this.fieldNode ? `${this.fieldNode}.${this.element.model}` : this.element.model,
- }
- }
- },
- elementDisplay () {
- let curFullField = this.fieldNode ? this.fieldNode + '.' + this.element.model : this.element.model
- let curField = this.group ? this.group + '.' + this.element.model : this.element.model
- if (this.dynamicHideFields[curFullField] != undefined) {
- return !this.dynamicHideFields[curFullField]
- }
- if (this.dynamicHideFields[curField] != undefined) {
- return !this.dynamicHideFields[curField]
- }
- if (typeof this.element.options.hidden === 'boolean') {
- return !this.element.options.hidden
- } else {
- if (isExpression(this.element.options.hidden)) {
- return !executeExpression(extractExpression(this.element.options.hidden), this.currentOptions, this.formContext)
- }
- }
- return true
- }
- },
- methods: {
- },
- watch: {
- model: {
- deep: true,
- handler (val) {
- this.dataModels = val
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .fm-form{
- .el-card__header{
- padding: var(--padding)
- }
- }
- </style>
|