• Element UI Form 每行显示两列,即多个 el-form-item


    <template>
      <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="会商主题" prop="arrangeName">
            <el-input
              v-model="queryParams.arrangeName"
              placeholder="请输入会商主题"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="主持人" prop="arrangeHoster">
            <el-input
              v-model="queryParams.arrangeHoster"
              placeholder="请输入主持人"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="紧急程度" prop="arrangeUrgency">
            <el-select v-model="queryParams.arrangeUrgency" placeholder="请选择紧急程度" clearable size="small">
              <el-option
                v-for="dict in arrangeUrgencyOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="状态" prop="arrangeState">
            <el-select v-model="queryParams.arrangeState" placeholder="请选择状态" clearable size="small">
              <el-option
                v-for="dict in arrangeStateOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
    
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['event:arrange:add']"
            >新增
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['event:arrange:edit']"
            >修改
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['event:arrange:remove']"
            >删除
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['event:arrange:export']"
            >导出
            </el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
    
        <el-table v-loading="loading" :data="arrangeList" border @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center"/>
          <el-table-column label="主键" align="center" prop="id" v-if="false"/>
          <el-table-column label="会商主题" align="center" prop="arrangeName"/>
          <el-table-column label="主持人" align="center" prop="arrangeHoster"/>
          <el-table-column label="会商地点" align="center" prop="arrangePlace" v-if="false"/>
          <el-table-column label="紧急程度" align="center" prop="arrangeUrgency" :formatter="arrangeUrgencyFormat"/>
          <el-table-column label="联系人" align="center" prop="arrangeContact"/>
          <el-table-column label="联系人电话" align="center" prop="arrangePhone"/>
          <el-table-column label="会商内容" align="center" prop="arrangeContent" v-if="false"/>
          <el-table-column label="状态" align="center" prop="arrangeState" :formatter="arrangeStateFormat"/>
          <el-table-column label="开始时间" align="center" prop="arrangeStarttime" width="180" v-if="false">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.arrangeStarttime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="结束时间" align="center" prop="arrangeEndtime" width="180" v-if="false">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.arrangeEndtime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="短信内容" align="center" prop="arrangeSmscontent" v-if="false"/>
          <el-table-column label="接收对象主键" align="center" prop="arrangeReceiverids" v-if="false"/>
          <el-table-column label="事件id" align="center" prop="eventId" v-if="false"/>
          <el-table-column label="接收对象名称" align="center" prop="arrangeReceivernames" v-if="false"/>
          <el-table-column label="备注" align="center" prop="remark" v-if="false"/>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['event:arrange:edit']"
              >修改
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['event:arrange:remove']"
              >删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
    
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
    
        <!-- 添加或修改会商安排对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
          <el-form ref="form" :model="form" :rules="rules" label-width="80px">
            <el-col :span="12">
              <el-form-item label="会商主题" prop="arrangeName">
                <el-input v-model="form.arrangeName" placeholder="请输入会商主题"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="主持人" prop="arrangeHoster">
                <el-input v-model="form.arrangeHoster" placeholder="请输入主持人"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="会商地点" prop="arrangePlace">
                <el-input v-model="form.arrangePlace" placeholder="请输入会商地点"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="紧急程度" prop="arrangeUrgency">
                <el-select v-model="form.arrangeUrgency" placeholder="请选择紧急程度">
                  <el-option
                    v-for="dict in arrangeUrgencyOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="联系人" prop="arrangeContact">
                <el-input v-model="form.arrangeContact" placeholder="请输入联系人"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="联系人电话" prop="arrangePhone">
                <el-input v-model="form.arrangePhone" placeholder="请输入联系人电话"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="会商内容">
                <editor v-model="form.arrangeContent" :min-height="192"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="状态" prop="arrangeState">
                <el-select v-model="form.arrangeState" placeholder="请选择状态">
                  <el-option
                    v-for="dict in arrangeStateOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="开始时间" prop="arrangeStarttime">
                <el-date-picker clearable size="small"
                                v-model="form.arrangeStarttime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择开始时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="结束时间" prop="arrangeEndtime">
    
                <el-date-picker clearable size="small"
                                v-model="form.arrangeEndtime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择结束时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="短信内容">
                <editor v-model="form.arrangeSmscontent" :min-height="192"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="接收对象主键" prop="arrangeReceiverids">
                <el-input v-model="form.arrangeReceiverids" type="textarea" placeholder="请输入内容"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="事件id" prop="eventId">
                <el-input v-model="form.eventId" placeholder="请输入事件id"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="接收对象名称" prop="arrangeReceivernames">
                <el-input v-model="form.arrangeReceivernames" type="textarea" placeholder="请输入内容"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
              </el-form-item>
            </el-col>
    
    
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </el-dialog>
      </div>
    </template>
    
    <script>
    import {listArrange, getArrange, delArrange, addArrange, updateArrange} from "@/api/event/arrange";
    import Editor from '@/components/Editor';
    
    export default {
      name: "Arrange",
      components: {
        Editor,
      },
      data() {
        return {
          // 遮罩层
          loading: true,
          // 选中数组
          ids: [],
          // 非单个禁用
          single: true,
          // 非多个禁用
          multiple: true,
          // 显示搜索条件
          showSearch: true,
          // 总条数
          total: 0,
          // 会商安排表格数据
          arrangeList: [],
          // 弹出层标题
          title: "",
          // 是否显示弹出层
          open: false,
          // 紧急程度字典
          arrangeUrgencyOptions: [],
          // 状态字典
          arrangeStateOptions: [],
          // 查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            arrangeName: null,
            arrangeHoster: null,
            arrangePlace: null,
            arrangeUrgency: null,
            arrangeContact: null,
            arrangePhone: null,
            arrangeContent: null,
            arrangeState: null,
            arrangeStarttime: null,
            arrangeEndtime: null,
            arrangeSmscontent: null,
            arrangeReceiverids: null,
            eventId: null,
            arrangeReceivernames: null,
            createName: null,
            updateName: null,
          },
          // 表单参数
          form: {},
          // 表单校验
          rules: {
            arrangeName: [
              {required: true, message: "会商主题不能为空", trigger: "blur"}
            ],
            arrangeHoster: [
              {required: true, message: "主持人不能为空", trigger: "blur"}
            ],
            arrangePlace: [
              {required: true, message: "会商地点不能为空", trigger: "blur"}
            ],
            arrangeUrgency: [
              {required: true, message: "紧急程度不能为空", trigger: "change"}
            ],
            arrangeContact: [
              {required: true, message: "联系人不能为空", trigger: "blur"}
            ],
            arrangePhone: [
              {required: true, message: "联系人电话不能为空", trigger: "blur"}
            ],
            arrangeContent: [
              {required: true, message: "会商内容不能为空", trigger: "blur"}
            ],
            arrangeState: [
              {required: true, message: "状态不能为空", trigger: "change"}
            ],
            arrangeSmscontent: [
              {required: true, message: "短信内容不能为空", trigger: "blur"}
            ],
            arrangeReceiverids: [
              {required: true, message: "接收对象主键不能为空", trigger: "blur"}
            ],
            eventId: [
              {required: true, message: "事件id不能为空", trigger: "blur"}
            ],
            arrangeReceivernames: [
              {required: true, message: "接收对象名称不能为空", trigger: "blur"}
            ],
          }
        };
      },
      created() {
        this.getList();
        this.getDicts("evn_arrange_urgency").then(response => {
          this.arrangeUrgencyOptions = response.data;
        });
        this.getDicts("evn_arrange_state").then(response => {
          this.arrangeStateOptions = response.data;
        });
      },
      methods: {
        /** 查询会商安排列表 */
        getList() {
          this.loading = true;
          listArrange(this.queryParams).then(response => {
            this.arrangeList = response.rows;
            this.total = response.total;
            this.loading = false;
          });
        },
        // 紧急程度字典翻译
        arrangeUrgencyFormat(row, column) {
          return this.selectDictLabel(this.arrangeUrgencyOptions, row.arrangeUrgency);
        },
        // 状态字典翻译
        arrangeStateFormat(row, column) {
          return this.selectDictLabel(this.arrangeStateOptions, row.arrangeState);
        },
        // 取消按钮
        cancel() {
          this.open = false;
          this.reset();
        },
        // 表单重置
        reset() {
          this.form = {
            id: null,
            arrangeName: null,
            arrangeHoster: null,
            arrangePlace: null,
            arrangeUrgency: null,
            arrangeContact: null,
            arrangePhone: null,
            arrangeContent: null,
            arrangeState: null,
            arrangeStarttime: null,
            arrangeEndtime: null,
            arrangeSmscontent: null,
            arrangeReceiverids: null,
            eventId: null,
            arrangeReceivernames: null,
            remark: null,
            createBy: null,
            createName: null,
            createTime: null,
            updateBy: null,
            updateName: null,
            updateTime: null,
            delFlag: null
          };
          this.resetForm("form");
        },
        /** 搜索按钮操作 */
        handleQuery() {
          this.queryParams.pageNum = 1;
          this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
          this.resetForm("queryForm");
          this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
          this.ids = selection.map(item => item.id)
          this.single = selection.length !== 1
          this.multiple = !selection.length
        },
        /** 新增按钮操作 */
        handleAdd() {
          this.reset();
          this.open = true;
          this.title = "添加会商安排";
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
          this.reset();
          const id = row.id || this.ids
          getArrange(id).then(response => {
            this.form = response.data;
            this.open = true;
            this.title = "修改会商安排";
          });
        },
        /** 提交按钮 */
        submitForm() {
          this.$refs["form"].validate(valid => {
            if (valid) {
              if (this.form.id != null) {
                updateArrange(this.form).then(response => {
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                });
              } else {
                addArrange(this.form).then(response => {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
                });
              }
            }
          });
        },
        /** 删除按钮操作 */
        handleDelete(row) {
          const ids = row.id || this.ids;
          this.$confirm('是否确认删除会商安排编号为"' + ids + '"的数据项?', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(function () {
            return delArrange(ids);
          }).then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          }).catch(() => {
          })
        },
        /** 导出按钮操作 */
        handleExport() {
          this.download('event/arrange/export', {
            ...this.queryParams
          }, `event_arrange.xlsx`)
        }
      }
    };
    </script>
    <el-col :span="12">
    </el-col>
  • 相关阅读:
    Git 分支[转]
    监听键盘的输入事件[转]
    github for windows的初步使用
    限制一个form被同时打开的数量 Limite The Number of Forms Opened at the same time
    android内存检测工具
    面试 9.26 总结
    canvas path paint 的使用(游戏必备)
    android知识点
    android查缺补漏
    AIDL的使用
  • 原文地址:https://www.cnblogs.com/Jeely/p/14865686.html
Copyright © 2020-2023  润新知