|
@@ -55,18 +55,18 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, toRefs } from 'vue';
|
|
|
-import type { Ref } from 'vue';
|
|
|
-import _ from 'lodash';
|
|
|
+import { ref, toRefs } from 'vue'
|
|
|
+import type { Ref } from 'vue'
|
|
|
+import _ from 'lodash'
|
|
|
interface fieldsItem {
|
|
|
- model: string;
|
|
|
- type: string;
|
|
|
+ model: string
|
|
|
+ type: string
|
|
|
// readonly: string;
|
|
|
- options: object;
|
|
|
- custom: string;
|
|
|
+ options: object
|
|
|
+ custom: string
|
|
|
// required: string;
|
|
|
// limit: number | undefined;
|
|
|
- isSearch: boolean;
|
|
|
+ isSearch: boolean
|
|
|
}
|
|
|
const props = defineProps({
|
|
|
is_title: { type: Boolean, default: true },
|
|
@@ -76,44 +76,44 @@ const props = defineProps({
|
|
|
title: { type: String },
|
|
|
tip: { type: String },
|
|
|
remark: { type: String }
|
|
|
-});
|
|
|
-const { is_title } = toRefs(props);
|
|
|
-const { is_search } = toRefs(props);
|
|
|
-const { is_back } = toRefs(props);
|
|
|
-const { fields } = toRefs(props);
|
|
|
-const { title } = toRefs(props);
|
|
|
-const { tip } = toRefs(props);
|
|
|
-const { remark } = toRefs(props);
|
|
|
+})
|
|
|
+const { is_title } = toRefs(props)
|
|
|
+const { is_search } = toRefs(props)
|
|
|
+const { is_back } = toRefs(props)
|
|
|
+const { fields } = toRefs(props)
|
|
|
+const { title } = toRefs(props)
|
|
|
+const { tip } = toRefs(props)
|
|
|
+const { remark } = toRefs(props)
|
|
|
|
|
|
-let form: Ref<{}> = ref({});
|
|
|
-const emit = defineEmits(['search', 'toReset', 'toBack', 'dataChange']);
|
|
|
+let form: Ref<{}> = ref({})
|
|
|
+const emit = defineEmits(['search', 'toReset', 'toBack', 'dataChange'])
|
|
|
const toSubmit = () => {
|
|
|
- const obj = _.pickBy(form.value);
|
|
|
- emit('search', { ...obj });
|
|
|
-};
|
|
|
+ const obj = _.pickBy(form.value)
|
|
|
+ emit('search', { ...obj })
|
|
|
+}
|
|
|
// 重置
|
|
|
const toReset = () => {
|
|
|
- form.value = {};
|
|
|
- emit('search', form.value);
|
|
|
-};
|
|
|
+ form.value = {}
|
|
|
+ emit('search', form.value)
|
|
|
+}
|
|
|
// 文字描述
|
|
|
const getField = (item: any, data: any) => {
|
|
|
- let res = _.get(data, item, null);
|
|
|
- if (item === 'type') res = res === null ? `text` : res;
|
|
|
- if (item === 'place') res = res === null ? `请输入${data.label}` : res;
|
|
|
- if (item === 'required') res = res === null ? false : res;
|
|
|
- if (item === `error`) res = res === null ? `${data.label}错误` : res;
|
|
|
- return res;
|
|
|
-};
|
|
|
+ let res = _.get(data, item, null)
|
|
|
+ if (item === 'type') res = res === null ? `text` : res
|
|
|
+ if (item === 'place') res = res === null ? `请输入${data.label}` : res
|
|
|
+ if (item === 'required') res = res === null ? false : res
|
|
|
+ if (item === `error`) res = res === null ? `${data.label}错误` : res
|
|
|
+ return res
|
|
|
+}
|
|
|
// 获取输入值
|
|
|
const dataChange = (model: string) => {
|
|
|
- const value = form.value[model];
|
|
|
- emit('dataChange', { model, value });
|
|
|
-};
|
|
|
+ const value = form.value[model]
|
|
|
+ emit('dataChange', { model, value })
|
|
|
+}
|
|
|
// 返回
|
|
|
const toBack = () => {
|
|
|
- emit('toBack');
|
|
|
-};
|
|
|
+ emit('toBack')
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|