|
|
@@ -1,7 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ElMessage, ElMessageBox, type FormProps } from 'element-plus'
|
|
|
import type { PropType } from 'vue'
|
|
|
-import type { BasicForm, BasicFormItem } from '@/types/form'
|
|
|
+import type { AdvancedForm, BasicForm, BasicFormItem } from '@/types/form'
|
|
|
import router from '@/router'
|
|
|
import type { RouteLocationNormalized } from 'vue-router'
|
|
|
|
|
|
@@ -26,14 +26,23 @@ const props = defineProps({
|
|
|
default: true
|
|
|
},
|
|
|
form: {
|
|
|
- type: Object as PropType<BasicForm>,
|
|
|
+ type: Object as PropType<BasicForm | AdvancedForm>,
|
|
|
required: true
|
|
|
}
|
|
|
})
|
|
|
|
|
|
// ============== 查询部分开始 ===============
|
|
|
const query = ref<any>({})
|
|
|
-const searchList = computed(() => props?.form.formItems.filter(item => item.search))
|
|
|
+// const searchList = computed(() =>
|
|
|
+// props.form.formItems.filter((item: any) => {
|
|
|
+// if (item.group) {
|
|
|
+// } else {
|
|
|
+// item.search
|
|
|
+// }
|
|
|
+// })
|
|
|
+// )
|
|
|
+const searchList = ref<any>([])
|
|
|
+
|
|
|
const handleQuery = () => {
|
|
|
curPage.value = 1
|
|
|
getTableData()
|
|
|
@@ -41,6 +50,13 @@ const handleQuery = () => {
|
|
|
const handleReset = () => {
|
|
|
query.value = {}
|
|
|
}
|
|
|
+const placeholder = (item: BasicFormItem) => {
|
|
|
+ if (['select'].includes(item.type)) {
|
|
|
+ return '请选择' + item.label
|
|
|
+ } else {
|
|
|
+ return '请输入' + item.label
|
|
|
+ }
|
|
|
+}
|
|
|
// ============== 查询部分结束 ===============
|
|
|
|
|
|
// ============== 表格部分开始 ===============
|
|
|
@@ -78,7 +94,7 @@ const handleCreate = () => {
|
|
|
if (formRoute) {
|
|
|
router.push(formRoute)
|
|
|
} else {
|
|
|
- dialogTitle.value = '新增'
|
|
|
+ formData.value = {}
|
|
|
dialogVisible.value = true
|
|
|
}
|
|
|
}
|
|
|
@@ -86,8 +102,6 @@ const handleUpdate = (row: any) => {
|
|
|
if (formRoute) {
|
|
|
router.push(formRoute)
|
|
|
} else {
|
|
|
- dialogTitle.value = '编辑'
|
|
|
- dialogVisible.value = true
|
|
|
if (props.crud?.getRecord) {
|
|
|
props.crud.getRecord({ id: row.id }).then((res: any) => {
|
|
|
formData.value = res.data
|
|
|
@@ -95,6 +109,7 @@ const handleUpdate = (row: any) => {
|
|
|
} else {
|
|
|
formData.value = row
|
|
|
}
|
|
|
+ dialogVisible.value = true
|
|
|
}
|
|
|
}
|
|
|
const handleDelete = (id: string | number) => {
|
|
|
@@ -115,31 +130,8 @@ const handlePatchDelete = () => {}
|
|
|
|
|
|
// ============== 表单部分开始 ===============
|
|
|
const formData = ref<any>({})
|
|
|
-const formRef = ref()
|
|
|
-const dialogTitle = ref('新增')
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
|
-props.form?.formItems.forEach(item => {
|
|
|
- formData.value[item.name] = item.value
|
|
|
-})
|
|
|
-
|
|
|
-const placeholder = (item: BasicFormItem) => {
|
|
|
- if (['select'].includes(item.type)) {
|
|
|
- return '请选择' + item.label
|
|
|
- } else {
|
|
|
- return '请输入' + item.label
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-const closeDialog = () => {
|
|
|
- dialogVisible.value = false
|
|
|
- formData.value = {}
|
|
|
-}
|
|
|
-
|
|
|
-const submit = () => {
|
|
|
- formRef.value.submit().then(() => closeDialog())
|
|
|
-}
|
|
|
-
|
|
|
// ============== 表单部分结束 ===============
|
|
|
</script>
|
|
|
|
|
|
@@ -198,21 +190,14 @@ const submit = () => {
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
- <el-dialog
|
|
|
- draggable
|
|
|
- :title="dialogTitle"
|
|
|
+ <dialog-form
|
|
|
v-model="dialogVisible"
|
|
|
- width="1200px"
|
|
|
- @close="closeDialog"
|
|
|
- :close-on-click-modal="false"
|
|
|
- >
|
|
|
- <pro-form :form="form" :formData="formData" ref="formRef" :create="crud.create" :update="crud?.update"></pro-form>
|
|
|
-
|
|
|
- <template #footer>
|
|
|
- <el-button @click="dialogVisible = false">取消</el-button>
|
|
|
- <el-button type="primary" @click="submit">保存</el-button>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
+ :form="form"
|
|
|
+ :formData="formData"
|
|
|
+ :create="crud.create"
|
|
|
+ :update="crud.update"
|
|
|
+ v-if="dialogVisible"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|