<template>
<el-form
:inline="true"
style="display: flex; flex-direction: row; flex-wrap: wrap;flex: 1;"
class="formClass"
label-width="90px"
>
<el-form-item
v-for="(item, index) in this.selectInline"
:key="index"
:label="item.label"
style="margin:10px 10px 0 0;"
>
<el-input
size="small"
v-model="item.value"
v-if="item.type == 'input'"
:placeholder="item.label"
></el-input>
<el-select
v-else-if="item.type == 'select'"
size="small"
v-model="item.value"
:placeholder="item.label"
collapse-tags
@change="SelectHandle(index)"
filterable
:multiple="item.multi"
>
<el-option
v-for="(option, optionIndex) in item.options"
:key="optionIndex"
:label="option.ITEM_NAME"
:value="option.ITEM_NAME"
></el-option>
</el-select>
<el-date-picker
v-else-if="item.type == 'time'"
v-model="item.value"
type="datetimerange"
style="width:350px;"
:picker-options="timeOptions"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
size="small"
align="right"
></el-date-picker>
</el-form-item>
<!-- <el-form-item label="子设备类型:" style="margin:10px 8px 0 0;">
<el-select
v-model="selectInline[2].plcType"
size="small"
:placeholder="'请选择'"
autocomplete="off"
>
<el-option label="Pump" value="0" />
<el-option label="Heater" value="1" />
<el-option label="Scrubber" value="2" />
</el-select>
</el-form-item>-->
<!-- <el-form-item label="厂商名称:" style="margin:10px 8px 0 0;">
<el-select
v-model="selectInline[2].factoryName"
size="small"
:placeholder="'请选择'"
autocomplete="off"
>
<el-option label="Pump" value="0" />
<el-option label="Heater" value="1" />
<el-option label="Scrubber" value="2" />
</el-select>
</el-form-item>-->
<!-- <el-form-item label="部门:" style="margin:10px 8px 0 0;">
<el-select
v-model="selectInline[2].factoryName"
size="small"
:placeholder="'请选择'"
autocomplete="off"
>
<el-option label="Pump" value="0" />
<el-option label="Heater" value="1" />
<el-option label="Scrubber" value="2" />
</el-select>
</el-form-item>-->
<!-- <el-form-item label="科室:" style="margin:10px 20px 0 0;">
<el-select
v-model="selectInline[2].factoryName"
size="small"
:placeholder="'请选择'"
autocomplete="off"
>
<el-option label="Pump" value="0" />
<el-option label="Heater" value="1" />
<el-option label="Scrubber" value="2" />
</el-select>
</el-form-item>-->
<el-form-item style="margin:10px 0 0 90px;">
<el-button
v-if="isaddWork"
type="primary"
icon="el-icon-plus"
@click="addWorkFn"
size="small"
v-has="{name:'子设备v-has管理',value:'添v-has加'}"
>添加</el-button>
<el-button type="primary" @click="onSubmit" size="small" icon="el-icon-search">查询</el-button>
<el-button type="primary" @click="onReset" size="small" icon="el-icon-refresh">重置</el-button>
<el-button v-if="isdownload" type="primary" @click="onSubmit" size="small">下载</el-button>
</el-form-item>
</el-form>
</template>
<script>
export default {
name: "toolbar",
props: {
selectInline: {
type: Array
},
inline: {
type: Boolean
},
isdownload: {
default: false,
type: Boolean
},
isaddWork: {
default: false,
type: Boolean
},
data_fields: {
type: Object
},
data_execl: {
type: Array
},
excel_Alltitle: {
type: String
}
},
data () {
return {
timeOptions: {
shortcuts: [
{
text: "最近一周",
onClick (picker) {
const end = new Date()
const start = new Date()
start.setTime(
start.getTime() - 3600 * 1000 * 24 * 7
)
picker.$emit("pick", [start, end])
}
},
{
text: "最近一个月",
onClick (picker) {
const end = new Date()
const start = new Date()
start.setTime(
start.getTime() - 3600 * 1000 * 24 * 30
)
picker.$emit("pick", [start, end])
}
},
{
text: "最近三个月",
onClick (picker) {
const end = new Date()
const start = new Date()
start.setTime(
start.getTime() - 3600 * 1000 * 24 * 90
)
picker.$emit("pick", [start, end])
}
}
]
}
}
},
watch: {
data_fields (s1, s2) {
console.log("s1", s1)
console.log("s2", s2)
},
immediate: true,
deep: true
},
methods: {
// 添加工单
addWorkFn () {
this.$emit("addWorkFn", this.selectInline)
},
onSubmit () {
this.$emit("onSubmit", this.selectInline)
},
SelectHandle (index) {
this.$emit("SelectHandle", index)
},
downLoadAllData () {
this.$emit("downLoadAllData")
},
onReset () {
this.$emit("onReset")
}
}
};
</script> <style scoped>
.formClass {
/* display: flex; */
/* flex-direction: column; */
/* justify-content: space-between; */
}
</style>

使用组件的时候:

   <tool-bar
:isaddWork="true"
:inline="true"
:selectInline="this.selectInline"
@onSubmit="OnSubmit"
@SelectHandle="SelectHandle"
@onReset="onReset"
@addWorkFn="addHandle"
></tool-bar>
selectInline 的数据格式:
   selectInline: [
{
field: "eqpName",
label: "部门",
type: "select",
value: "",
options: [],
},
{
field: "chamberName",
label: "科室",
type: "select",
value: "",
multi: false,
options: [],
},
{
field: "plcName",
label: "设备类型",
type: "select",
value: "",
options: [],
plcType: '',
factoryName: '',
},
{
field: "plcName",
label: "厂商",
type: "select",
value: "",
options: [],
plcType: '',
factoryName: '',
},
{
field: "plcName",
label: "子设备名称",
type: "select",
value: "",
options: [],
plcType: '',
factoryName: '',
},
],

element+vue2的查询form表单封装成组件复用的更多相关文章

  1. jquery自动将form表单封装成json的具体实现

    前端页面:<span style="font-size:14px;"> <form action="" method="post&q ...

  2. vue+element 表单封成组件(1)

    作为一名刚接触vue不到一个月的菜鸟,思想还没有从操作DOM转变为数据驱动,看vue的代码处处别扭.组里为了让我熟悉vue交给了我一个将element 表单封装成组件的练手任务.由于开发过程中遇到的表 ...

  3. Element Ui使用技巧——Form表单的校验规则rules详细说明

    Element UI中对Form表单验证的使用介绍: Form 组件提供了表单验证的功能,只需要通过 rules 属性传入约定的验证规则,并将 Form-Item的 prop 属性设置为需校验的字段名 ...

  4. vue+element创建动态的form表单.以及动态生成表格的行和列

    动态创建form表单,网上有插件 (form-create) 不过我不知道它怎么用,没有使用成功,如果你使用成功了,欢迎下方留言. 最后我使用了笨方法,针对各个表单写好通用的组件,然后根据type用v ...

  5. form表单数据封装成json格式并提交给服务器

    1.jsp代码,form表单: <form action="#" id="costForm"> <input type="hidde ...

  6. js使用工具将表单封装成json字符串传到后台,js截取字符串(学生笔记)

    <script src="js/jquery.min.js"></script> <script src="https://cdn.boot ...

  7. vue+element 表单封成组件(2)

    今天我们继续把时间选择器,多选框和单选框加上 父组件(在昨天的基础上增加): <template> <el-form :model="ruleForm" ref= ...

  8. jQuery将form表单的数据封装成json对象

    /** * 自动将form表单封装成json对象 */ $.fn.serializeObject = function() { var o = {}; var a = this.serializeAr ...

  9. vue3 element-plus 配置json快速生成form表单组件,提升生产力近600%(已在公司使用,持续优化中)

    ️本文为博客园社区首发文章,未获授权禁止转载 大家好,我是aehyok,一个住在深圳城市的佛系码农‍♀️,如果你喜欢我的文章,可以通过点赞帮我聚集灵力️. 个人github仓库地址: https:gi ...

  10. 封装Vue Element的form表单组件

    前两天封装了一个基于vue和Element的table表格组件,阅读的人还是很多的,看来大家都是很认同组件化.高复用这种开发模式的,毕竟开发效率高,代码优雅,逼格高嘛.虽然这两天我的心情很糟糕,就像& ...

随机推荐

  1. HPA* (Near Optimal hierarchical Path-finding)算法的效果图

    本文中的图全部来自: https://mohitsharma0690.blogspot.com/2016/01/hierarchical-pathfinding.html 图的说明: Here is ...

  2. 国产AI训练卡,对标美国NVIDIA公司的A100,华为昇腾Atlas 300T A2(Ascend 910B4)高性能GPU/NPU/AI推理/国产计算/信创训练卡 —— 电商平台已开售

    China has successfully achieved the localization of AI chips, breaking through the technological res ...

  3. 台式机,华硕主板z390ws,cpu为i7-9700k 安装Ubuntu18.04系统 使用独立显卡工作 (但是显示器HDMI线缆插在主板的HDMI插槽)开机进入系统运行几分钟后自动重启,此时主板显示错误码为AMI错误

    如题: 手上有这样一台新的工作站,配置为华硕主板z390ws,cpu为i7-9700k ,独立显卡为技嘉2060super, 安装Ubuntu18.04系统 . 在主板bios中进行设置(设置使用 P ...

  4. 【转载】 关于Numpy数据类型对象(dtype)使用详解

    原文地址: https://www.cnblogs.com/dreamboy2000/p/15350478.html ========================================= ...

  5. 【转载】Ubuntu20.04安装Bazel

    原文地址: https://zhuanlan.zhihu.com/p/311406177 ====================================== sudo apt install ...

  6. C# Cefsharp 设置代理方法

    前提条件 为了实现在cefsharp里面设置代理,首先在创建一个ChromiumWebBrowser的时候,检查是否使用了以下代码 settings.CefCommandLineArgs.Add(&q ...

  7. Apache SeaTunnel 及 Web 功能部署指南(小白版)

    在大数据处理领域,Apache SeaTunnel 已成为一款备受青睐的开源数据集成平台,它不仅可以基于Apache Spark和Flink,而且还有社区单独开发专属数据集成的Zeta引擎,提供了强大 ...

  8. 美化一下WPF自带得ToolTip

    对照一下原版和美化以后得版本 原版: ---------- 新版: 新增了 圆角 和 阴影效果; 第一步:新建项,最下面有一个自定义控件,取名为CornerToolTip. 第二步:系统会创建一个Co ...

  9. 基于druid和spring的动态数据库以及读写分离 转

    spring与druid可以实现动态数据源,夸库查询,读写分离等功能.现在说一下配置: 1.需要配置多个spring数据源 spring-data.xml <!-- 动态数据源 --> & ...

  10. 使用 onNuxtReady 进行异步初始化

    title: 使用 onNuxtReady 进行异步初始化 date: 2024/8/16 updated: 2024/8/16 author: cmdragon excerpt: 摘要:本文详细介绍 ...