This commit is contained in:
不做码农 2021-11-29 21:58:24 +08:00
parent e83550aa9c
commit 33a12c0c53

View File

@ -2,7 +2,7 @@
<div class="app-container">
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
${vueQueryFormHtml}
{vueQueryFormHtml}
<el-row class="mb8" style="text-align:center">
<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>
@ -12,13 +12,13 @@ ${vueQueryFormHtml}
<!-- 工具区域 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" v-hasPermi="['${Permission}:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
<el-button type="primary" v-hasPermi="['{Permission}:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" :disabled="single" v-hasPermi="['${Permission}:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
<el-button type="success" :disabled="single" v-hasPermi="['{Permission}:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" :disabled="multiple" v-hasPermi="['${Permission}:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
<el-button type="danger" :disabled="multiple" v-hasPermi="['{Permission}:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -26,12 +26,12 @@ ${vueQueryFormHtml}
<!-- 数据区域 -->
<el-table :data="dataList" ref="table" border @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" />
${VueViewListContent}
{VueViewListContent}
<el-table-column label="操作" align="center" width="200">
<template slot-scope="scope">
<el-button v-hasPermi="['${Permission}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button v-hasPermi="['{Permission}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
<el-popconfirm title="确定删除吗?" @confirm="handleDelete(scope.row)" style="margin-left:10px">
<el-button slot="reference" v-hasPermi="['${Permission}:delete']" type="text" icon="el-icon-delete">删除</el-button>
<el-button slot="reference" v-hasPermi="['{Permission}:delete']" type="text" icon="el-icon-delete">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
@ -42,7 +42,7 @@ ${VueViewListContent}
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open" >
<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
<el-row>
${VueViewFormContent}
{VueViewFormContent}
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
@ -55,20 +55,23 @@ ${VueViewFormContent}
</template>
<script>
import {
list${ModelTypeName},
add${ModelTypeName},
del${ModelTypeName},
update${ModelTypeName},
get${ModelTypeName}
} from '@/api/${fileClassName}.js';
list{ModelTypeName},
add{ModelTypeName},
del{ModelTypeName},
update{ModelTypeName},
get{ModelTypeName}
} from '@/api/{fileClassName}.js';
{VueComponentImport}
export default {
name: "${ModelTypeName}",
name: "{ModelTypeName}",
components: { {VueComponent} },
data() {
return {
labelWidth: "100px",
formLabelWidth:"100px",
// 选中${PrimaryKey}数组
// 选中{PrimaryKey}数组
ids: [],
// 非单个禁用
single: true,
@ -88,7 +91,7 @@ export default {
form: {},
// 时间范围数组
timeRange: [],
${VueDataContent}
{VueDataContent}
// 数据列表
dataList: [],
// 总记录数
@ -97,7 +100,7 @@ export default {
btnSubmitVisible: true,
// 表单校验
rules: {
${VueViewEditFormRuleContent}
{VueViewEditFormRuleContent}
},
};
},
@ -105,13 +108,13 @@ ${VueViewEditFormRuleContent}
// 列表数据查询
this.getList();
${MountedMethod}
{MountedMethod}
},
methods: {
// 查询数据
getList() {
console.log(JSON.stringify(this.queryParams));
list${ModelTypeName}(this.addDateRange(this.queryParams, this.timeRange)).then(res => {
list{ModelTypeName}(this.addDateRange(this.queryParams, this.timeRange)).then(res => {
if (res.code == 200) {
this.dataList = res.data.result;
this.total = res.data.totalNum;
@ -126,7 +129,7 @@ ${MountedMethod}
// 重置数据表单
reset() {
this.form = {
${VueViewFormResetHtml}
{VueViewFormResetHtml}
//TODO 根据实际内容调整
};
this.resetForm("form");
@ -144,7 +147,7 @@ ${VueViewFormResetHtml}
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.${PrimaryKey});
this.ids = selection.map((item) => item.{PrimaryKey});
this.single = selection.length != 1
this.multiple = !selection.length;
},
@ -160,8 +163,8 @@ ${VueViewFormResetHtml}
},
/** 删除按钮操作 */
handleDelete(row) {
const ${PrimaryKey}s = row.${PrimaryKey} || this.ids;
del${ModelTypeName}(${PrimaryKey}s.toString()).then((res) => {
const {PrimaryKey}s = row.{PrimaryKey} || this.ids;
del{ModelTypeName}({PrimaryKey}s.toString()).then((res) => {
this.msgSuccess("删除成功");
this.handleQuery();
});
@ -169,8 +172,8 @@ ${VueViewFormResetHtml}
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const ${PrimaryKey} = row.${PrimaryKey} || this.ids;
get${ModelTypeName}(${PrimaryKey}).then((res) => {
const {PrimaryKey} = row.{PrimaryKey} || this.ids;
get{ModelTypeName}({PrimaryKey}).then((res) => {
if (res.code == 200) {
this.form = res.data;
this.open = true;
@ -178,15 +181,15 @@ ${VueViewFormResetHtml}
}
});
},
{vueJsMethod}
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
console.log(JSON.stringify(this.form));
if (this.form.${PrimaryKey} != undefined || this.title === "修改数据") {
update${ModelTypeName}(this.form).then((res) => {
if (this.form.{PrimaryKey} != undefined || this.title === "修改数据") {
update{ModelTypeName}(this.form).then((res) => {
if (!res.data) {
this.msgError("修改失败");
return;
@ -196,7 +199,7 @@ ${VueViewFormResetHtml}
this.getList();
});
} else {
add${ModelTypeName}(this.form).then((res) => {
add{ModelTypeName}(this.form).then((res) => {
if (!res.data) {
this.msgError("新增失败");
return;