Commit 1933e8b9 authored by jiaxu.yan's avatar jiaxu.yan

feat: 完善组件

parent 77ecd1bc
...@@ -9,14 +9,15 @@ const props = defineProps({ ...@@ -9,14 +9,15 @@ const props = defineProps({
const value = ref(""); const value = ref("");
const input = () => { const input = () => {
console.log(props.items);
mitter.emit("changeVal", { name: props.prop, value: value.value }); mitter.emit("changeVal", { name: props.prop, value: value.value });
}; };
</script> </script>
<template> <template>
<div> <el-date-picker
<el-date-picker v-bind="items" v-model="value" @input="input" /> v-bind="items"
</div> style="width: 100%"
v-model="value"
@input="input"
/>
</template> </template>
...@@ -9,14 +9,10 @@ const props = defineProps({ ...@@ -9,14 +9,10 @@ const props = defineProps({
const value = ref(""); const value = ref("");
const input = () => { const input = () => {
console.log(props.items);
mitter.emit("changeVal", { name: props.prop, value: value.value }); mitter.emit("changeVal", { name: props.prop, value: value.value });
}; };
</script> </script>
<template> <template>
<div> <el-input v-bind="items" v-model="value" style="width: 100%" @input="input" />
<el-input v-bind="items" v-model="value" @input="input" />
</div>
</template> </template>
...@@ -15,11 +15,10 @@ const onChangeFirstValue = (val) => { ...@@ -15,11 +15,10 @@ const onChangeFirstValue = (val) => {
</script> </script>
<template> <template>
<div>
<el-select <el-select
v-model="value" v-model="value"
:v-bind="items" :v-bind="items"
style="width: 240px" style="width: 100%;"
@change="onChangeFirstValue(value)" @change="onChangeFirstValue(value)"
> >
<el-option <el-option
...@@ -29,5 +28,4 @@ const onChangeFirstValue = (val) => { ...@@ -29,5 +28,4 @@ const onChangeFirstValue = (val) => {
:value="item.value" :value="item.value"
/> />
</el-select> </el-select>
</div>
</template> </template>
\ No newline at end of file
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
<div class="annual-param-container"> <div class="annual-param-container">
<el-card> <el-card>
<div class="search-add-wrapper"> <div class="search-add-wrapper">
<el-form ref="searchForm" :inline="true" label-suffix=":"> <el-form ref="searchForm" label-suffix=":">
<el-row :gutter="10"> <el-row :gutter="20" justify="space-evenly">
<el-col <el-col
v-for="(item, index) in props.schemas" v-for="(item, index) in props.schemas"
:key="index" :key="index"
:span="20" v-bind="item.colProps"
> >
<el-form-item :label="item.label" :prop="item.prop"> <el-form-item :label="item.label" :prop="item.prop">
<component <component
...@@ -15,13 +15,16 @@ ...@@ -15,13 +15,16 @@
:prop="item.prop" :prop="item.prop"
:items="item.componentProps" :items="item.componentProps"
></component> ></component>
<!-- <el-input v-model="queryPrarms" placeholder="请选择" /> -->
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
</div>
<div class="btn-list">
<div> <div>
<slot name="btns"></slot>
</div>
<div style="margin-right: -10px">
<el-button type="primary" class="add-search-btn" @click="handleSearch" <el-button type="primary" class="add-search-btn" @click="handleSearch"
>查询</el-button >查询</el-button
> >
...@@ -39,20 +42,39 @@ ...@@ -39,20 +42,39 @@
:header-cell-class-name="tableHeaderClass" :header-cell-class-name="tableHeaderClass"
:row-class-name="tableBodyClass" :row-class-name="tableBodyClass"
> >
<el-table-column label="序号" align="center" width="100" />
<el-table-column <el-table-column
v-for="(column, key) in columns" v-for="(column, key) in props.columns"
:key="key" :key="key"
:v-bind="column" :prop="column.prop"
></el-table-column> :label="column.label"
:width="column.width"
:align="column.align"
>
</el-table-column>
</el-table> </el-table>
<div class="pagination">
<el-pagination
background
v-model:current-page="PagePrarms.page"
v-model:page-size="PagePrarms.limit"
:page-sizes="[30, 40, 50, 100, 200, 300]"
:small="true"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="getData"
@current-change="getData"
/>
</div>
</div> </div>
</el-card> </el-card>
</div> </div>
</template> </template>
<script setup> <script setup>
import { defineProps, reactive, watch } from "vue"; import { defineProps, reactive, watch, ref } from "vue";
import mitter from "@/utils/mitter"; import mitter from "@/utils/mitter";
import components from "@/components/FormComponents/index"; // 将所有组件引入 import components from "@/components/FormComponents/index"; // 将所有组件引入
import http from "@/api/http";
const emit = defineEmits(["DataChange"]); const emit = defineEmits(["DataChange"]);
const props = defineProps({ const props = defineProps({
schemas: { schemas: {
...@@ -72,18 +94,40 @@ const props = defineProps({ ...@@ -72,18 +94,40 @@ const props = defineProps({
default: [], default: [],
}, },
}); });
const PagePrarms = reactive({
page: 1,
limit: 10,
});
const loading = ref(false);
const data = reactive([]); const data = reactive([]);
const total = ref(0);
const searchForm = reactive({}); const searchForm = reactive({});
const getData = () => {
let params = {
...PagePrarms,
...props.formData,
};
http
.post(props.api, params)
.then((res) => {
console.log(res);
if (res.data !== null) {
}
})
.catch(function (error) {
console.log(error);
});
};
getData();
const handleSearch = () => { const handleSearch = () => {
console.log(handleSearch); PagePrarms.page = 1;
getData();
}; };
const handleReset = () => { const handleReset = () => {
console.log(handleReset); console.log(handleReset);
}; };
// 监听chageVal // 监听chageVal
mitter.on("changeVal", (data) => { mitter.on("changeVal", (data) => {
console.log(data);
const { name, value } = data; const { name, value } = data;
if (name) { if (name) {
props.formData[name] = value; props.formData[name] = value;
...@@ -101,20 +145,26 @@ defineExpose({ formData: props.formData }); ...@@ -101,20 +145,26 @@ defineExpose({ formData: props.formData });
<style scoped lang="less"> <style scoped lang="less">
.annual-param-container { .annual-param-container {
width: 100%; width: 100%;
margin: 4px; margin: 8px;
position: relative;
clear: both;
.el-card {
width: 100%;
}
} }
.search-add-wrapper { .search-add-wrapper {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: start; justify-content: start;
.el-form {
margin-bottom: -10px;
width: 100%;
}
} }
.search-add-wrapper .el-row { .search-add-wrapper .el-row {
border: none; border: none;
display: flex;
align-items: center;
margin: 5px 10px 5px 5px;
} }
.add-search-btn { .add-search-btn {
...@@ -167,28 +217,18 @@ defineExpose({ formData: props.formData }); ...@@ -167,28 +217,18 @@ defineExpose({ formData: props.formData });
border-right: 1px solid #a6c3e9; border-right: 1px solid #a6c3e9;
border-bottom: 1px solid #a6c3e9; border-bottom: 1px solid #a6c3e9;
width: 100%; width: 100%;
height: 35px; .el-form-item {
color: #124362; width: 100%;
margin-bottom: 10px;
}
} }
.btn-list {
.el-col[col-label] {
display: flex; display: flex;
justify-content: end; justify-content: space-between;
align-items: center;
border-right: 1px solid #a6c3e9;
background-color: #f2f6f8;
padding-right: 5px;
} }
.pagination{
.el-col[col-value] {
display: flex; display: flex;
justify-content: start; justify-content: center;
align-items: center; margin-top: 10px;
padding-left: 5px;
}
.el-input {
color: black;
height: 24px;
} }
</style> </style>
...@@ -5,10 +5,21 @@ ...@@ -5,10 +5,21 @@
:columns="columns" :columns="columns"
:formData="formData" :formData="formData"
@DataChange="formDataChange" @DataChange="formDataChange"
></PageData> >
<template v-slot:bnts>
<el-row>
<el-col :span="1.5">
<el-button type="primary" class="add-search-btn" @click="handleSearch"
>查询</el-button
>
</el-col>
<el-col :span="1.5"></el-col>
</el-row>
</template>
</PageData>
</template> </template>
<script setup> <script setup>
import { computed, onMounted, reactive, ref } from "vue"; import { ref } from "vue";
import PageData from "@/components/PageData.vue"; import PageData from "@/components/PageData.vue";
import { columns, schemas } from "./formSchems"; import { columns, schemas } from "./formSchems";
const formData = ref({ const formData = ref({
......
...@@ -4,34 +4,48 @@ export const columns = ref([ ...@@ -4,34 +4,48 @@ export const columns = ref([
label: "设备名称", label: "设备名称",
prop: "name", prop: "name",
align: "center", align: "center",
with: 200, width: "200",
}, },
{ {
label: "设备名称", label: "设备名称",
prop: "name", prop: "name",
align: "center", align: "center",
with: 200, width: "200",
}, },
{ {
label: "设备名称", label: "设备名称",
prop: "name", prop: "name",
align: "center", align: "center",
with: 200, width: "200",
}, },
]); ]);
export const schemas = ref([ export const schemas = ref([
{ {
label: "设备名称", // label: "设备名称",
prop: "name", prop: "name",
type: "input", type: "input",
colProps: {
xs: 12,
sm: 12,
md: 12,
lg: 6,
xl: 6,
},
componentProps: { componentProps: {
placeholder: "请输入设备名称", placeholder: "请输入设备名称",
}, },
}, },
{ {
label: "设备编号", // label: "设备编号",
prop: "code", prop: "code",
type: "select", type: "select",
colProps: {
xs: 12,
sm: 12,
md: 12,
lg: 6,
xl: 6,
},
componentProps: { componentProps: {
options: [ options: [
{ label: "11111", value: 1 }, { label: "11111", value: 1 },
...@@ -41,13 +55,38 @@ export const schemas = ref([ ...@@ -41,13 +55,38 @@ export const schemas = ref([
}, },
}, },
{ {
label: "设备名称", // label: "开始日期",
prop: "date", prop: "date",
type: "dateTimePicker", type: "dateTimePicker",
colProps: {
xs: 12,
sm: 12,
md: 12,
lg: 6,
xl: 6,
},
componentProps: {
type: "datetime",
placeholder: "开始日期",
format: "YYYY-MM-DD HH:mm:ss",
datFormat: "YYYY/MM/DD",
timeFormat: "HH:mm:ss",
},
},
{
// label: "结束日起",
prop: "date",
type: "dateTimePicker",
colProps: {
xs: 12,
sm: 12,
md: 12,
lg: 6,
xl: 6,
},
componentProps: { componentProps: {
type: "datetimerange", type: "datetime",
startPlaceholder: "开始日起", placeholder: "结束日期",
endPlaceholder: "结束日期",
format: "YYYY-MM-DD HH:mm:ss", format: "YYYY-MM-DD HH:mm:ss",
datFormat: "YYYY/MM/DD", datFormat: "YYYY/MM/DD",
timeFormat: "HH:mm:ss", timeFormat: "HH:mm:ss",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment