首次提交

This commit is contained in:
2023-06-04 20:01:58 +08:00
parent 00c64c53bb
commit 587f078d21
560 changed files with 106725 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
<!--
- MineAdmin is committed to providing solutions for quickly building web applications
- Please view the LICENSE file that was distributed with this source code,
- For the full copyright and license information.
- Thank you very much for using MineAdmin.
-
- @Author X.Mo<root@imoi.cn>
- @Link https://gitee.com/xmo/mineadmin-vue
-->
<template>
<ma-form-item
v-if="typeof props.component.display == 'undefined' || props.component.display === true"
:component="props.component"
:custom-field="props.customField"
>
<slot :name="`form-${props.component.dataIndex}`" v-bind="props.component">
<ma-resource
v-if="(props.component.type ?? 'preview') == 'preview'"
v-model="value"
:multiple="props.component.multiple"
:onlyData="props.component.onlyData"
:returnType="props.component.returnType"
/>
<ma-resource-button
v-else
v-model="value"
:multiple="props.component.multiple"
:onlyData="props.component.onlyData"
:returnType="props.component.returnType"
/>
</slot>
</ma-form-item>
</template>
<script setup>
import { ref, inject, onMounted, watch } from "vue"
import { get, set } from "lodash"
import MaResource from "@/components/ma-resource/index.vue"
import MaResourceButton from "@/components/ma-resource/button.vue"
import MaFormItem from "./form-item.vue"
import { maEvent } from "../js/formItemMixin.js"
const props = defineProps({
component: Object,
customField: { type: String, default: undefined }
})
const formModel = inject("formModel")
const index = props.customField ?? props.component.dataIndex
const value = ref(get(formModel.value, index))
watch(
() => get(formModel.value, index),
(vl) => (value.value = vl)
)
watch(
() => value.value,
(v) => {
set(formModel.value, index, v)
index.indexOf(".") > -1 && delete formModel.value[index]
}
)
if (props.component.multiple && !value.value) {
value.value = []
}
maEvent.handleCommonEvent(props.component, "onCreated")
onMounted(() => {
maEvent.handleCommonEvent(props.component, "onMounted")
})
</script>