<template>
|
<div class="search">
|
<Card>
|
<%
|
if(searchSize>0&&!hideSearch){
|
%>
|
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
|
<Form ref="searchForm" :model="searchForm" inline :label-width="70">
|
<%
|
for(item in fields){
|
if(item.searchable){
|
%>
|
<%
|
if(item.searchType=="text"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<Input type="text" v-model="searchForm.${item.field}" placeholder="请输入${item.name}" clearable style="width: 200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="select"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<Select v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px">
|
<Option value="0">请自行编辑下拉菜单</Option>
|
</Select>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="date"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<DatePicker type="date" v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px"></DatePicker>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="daterange"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<DatePicker :options="options" v-model="selectDate" type="daterange" format="yyyy-MM-dd" clearable @on-change="selectDateRange" placeholder="选择起始时间" style="width: 200px"></DatePicker>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="area"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<al-cascader v-model="searchForm.${item.field}" data-type="name" level="${item.searchLevel}" style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="dict"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<dict v-model="searchForm.${item.field}" dict="${item.searchDictType}" transfer style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="customList"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<customList v-model="searchForm.${item.field}" url="${item.searchCustomUrl}" transfer style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
}
|
}
|
%>
|
<FormItem style="margin-left:-35px;" class="br">
|
<Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
|
<Button @click="handleReset">重置</Button>
|
</FormItem>
|
</Form>
|
</Row>
|
<%
|
}
|
%>
|
<%
|
if(searchSize>0&&hideSearch){
|
%>
|
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
|
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
|
<%
|
for(item in firstTwo){
|
%>
|
<%
|
if(item.searchType=="text"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<Input type="text" v-model="searchForm.${item.field}" placeholder="请输入${item.name}" clearable style="width: 200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="select"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<Select v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px">
|
<Option value="0">请自行编辑下拉菜单</Option>
|
</Select>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="date"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<DatePicker type="date" v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px"></DatePicker>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="daterange"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<DatePicker :options="options" v-model="selectDate" type="daterange" format="yyyy-MM-dd" clearable @on-change="selectDateRange" placeholder="选择起始时间" style="width: 200px"></DatePicker>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="area"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<al-cascader v-model="searchForm.${item.field}" data-type="name" level="${item.searchLevel}" style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="dict"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<dict v-model="searchForm.${item.field}" dict="${item.searchDictType}" transfer style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="customList"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<customList v-model="searchForm.${item.field}" url="${item.searchCustomUrl}" transfer style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
}
|
%>
|
<span v-if="drop">
|
<%
|
for(item in rest){
|
%>
|
<%
|
if(item.searchType=="text"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<Input type="text" v-model="searchForm.${item.field}" placeholder="请输入${item.name}" clearable style="width: 200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="select"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<Select v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px">
|
<Option value="0">请自行编辑下拉菜单</Option>
|
</Select>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="date"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<DatePicker type="date" v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px"></DatePicker>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="daterange"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<DatePicker :options="options" v-model="selectDate" type="daterange" format="yyyy-MM-dd" clearable @on-change="selectDateRange" placeholder="选择起始时间" style="width: 200px"></DatePicker>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="area"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<al-cascader v-model="searchForm.${item.field}" data-type="name" level="${item.searchLevel}" style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="dict"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<dict v-model="searchForm.${item.field}" dict="${item.searchDictType}" transfer style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
if(item.searchType=="customList"){
|
%>
|
<FormItem label="${item.name}" prop="${item.field}">
|
<customList v-model="searchForm.${item.field}" url="${item.searchCustomUrl}" transfer style="width:200px"/>
|
</FormItem>
|
<%
|
}
|
%>
|
<%
|
}
|
%>
|
</span>
|
<FormItem style="margin-left:-35px;" class="br">
|
<Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
|
<Button @click="handleReset">重置</Button>
|
<a class="drop-down" @click="dropDown">
|
{{dropDownContent}}
|
<Icon :type="dropDownIcon"></Icon>
|
</a>
|
</FormItem>
|
</Form>
|
</Row>
|
<%
|
}
|
%>
|
<Row class="operation">
|
<Button @click="add" type="primary" icon="md-add">添加</Button>
|
<Button @click="delAll" icon="md-trash">批量删除</Button>
|
<Button @click="getDataList" icon="md-refresh">刷新</Button>
|
<% if(searchSize>0){ %>
|
<Button type="dashed" @click="openSearch=!openSearch">{{openSearch ? "关闭搜索" : "开启搜索"}}</Button>
|
<% } %>
|
<Button type="dashed" @click="openTip=!openTip">{{openTip ? "关闭提示" : "开启提示"}}</Button>
|
</Row>
|
<Alert show-icon v-show="openTip">
|
已选择 <span class="select-count">{{selectList.length}}</span> 项
|
<a class="select-clear" @click="clearSelectAll">清空</a>
|
</Alert>
|
<Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect"></Table>
|
<Row type="flex" justify="end" class="page">
|
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
|
</Row>
|
</Card>
|
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable='false' :width="${modalWidth}">
|
<Form ref="form" :model="form" :rules="formValidate" <% if(labelPosition=="left"){ %>:label-width="100"<% } %> label-position="${labelPosition}">
|
<%
|
var curr = 1;
|
for(var i=0; i<totalRow; i++){
|
%>
|
<% if(labelPosition!="left"){ %>
|
<Row :gutter="32">
|
<% } %>
|
<%
|
for(var j=0; j<rowNum; j++){
|
if(fields.~size==0||curr>fields.~size){
|
break;
|
}
|
var item = fields[curr-1];
|
while(!item.editable && curr <= fields.~size){
|
curr++;
|
item = fields[curr-1];
|
}
|
curr++;
|
var spanData = span;
|
if(item.type=="editor"||item.type=="textarea"){
|
spanData = 24;
|
}
|
%>
|
<% if(labelPosition!="left"){ %>
|
<Col span="${spanData}">
|
<% } %>
|
<FormItem label="${item.name}" prop="${item.field}" <% if(item.type=="upload"){ %>class="form-noheight"<% } %>>
|
<%
|
if(item.type=="text"){
|
%>
|
<Input v-model="form.${item.field}" clearable/>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="textarea"){
|
%>
|
<Input v-model="form.${item.field}" type="textarea" :rows="4" maxlength="250" show-word-limit/>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="select"){
|
%>
|
<Select v-model="form.${item.field}" clearable>
|
<Option value="0">请自行编辑下拉菜单</Option>
|
</Select>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="switch"){
|
%>
|
<i-switch v-model="form.${item.field}"></i-switch>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="radio"){
|
%>
|
<RadioGroup v-model="form.${item.field}">
|
<Radio label="0">请自行编辑单选框</Radio>
|
<Radio label="1">请自行编辑单选框</Radio>
|
</RadioGroup>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="number"){
|
%>
|
<InputNumber v-model="form.${item.field}" style="width:100%"></InputNumber>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="date"){
|
%>
|
<DatePicker type="date" v-model="form.${item.field}" clearable style="width:100%"></DatePicker>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="datetime"){
|
%>
|
<DatePicker type="datetime" v-model="form.${item.field}" clearable transfer style="width: 100%"></DatePicker>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="daterange"){
|
%>
|
<DatePicker type="daterange" v-model="form.${item.field}" clearable style="width:100%"></DatePicker>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="time"){
|
%>
|
<TimePicker type="time" v-model="form.${item.field}" clearable style="width:100%"></TimePicker>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="area"){
|
%>
|
<al-cascader v-model="form.${item.field}" data-type="name" level="${item.level}"/>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="slider"){
|
%>
|
<Slider v-model="form.${item.field}"></Slider>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="upload"){
|
%>
|
<upload-pic-input v-model="form.${item.field}"></upload-pic-input>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="uploadThumb"){
|
%>
|
<uploadThumb v-model="form.${item.field}" multiple></uploadThumb>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="editor"){
|
%>
|
<editor id="editor-${i}-${j}" v-model="form.${item.field}"></editor>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="password"){
|
%>
|
<password v-model="form.${item.field}"></password>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="dict"){
|
%>
|
<dict v-model="form.${item.field}" dict="${item.dictType}" transfer></dict>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="customList"){
|
%>
|
<customList v-model="form.${item.field}" url="${item.customUrl}" transfer></customList>
|
<%
|
}
|
%>
|
<%
|
if(item.type=="fileUpload"){
|
%>
|
<fileUpload v-model="form.${item.field}"></fileUpload>
|
<%
|
}
|
%>
|
</FormItem>
|
<% if(labelPosition!="left"){ %>
|
</Col>
|
<% } %>
|
<%
|
}
|
%>
|
<% if(labelPosition!="left"){ %>
|
</Row>
|
<% } %>
|
<%
|
}
|
%>
|
</Form>
|
<div slot="footer">
|
<Button type="text" @click="modalVisible=false">取消</Button>
|
<Button type="primary" :loading="submitLoading" @click="handleSubmit">提交</Button>
|
</div>
|
</Modal>
|
</div>
|
</template>
|
|
<script>
|
<%
|
if(api){
|
%>
|
// 根据你的实际请求api.js位置路径修改
|
import { get${apiName}List, add${apiName}, edit${apiName}, delete${apiName} } from "@/api/index";
|
<%
|
}
|
%>
|
<%
|
if(fileUpload){
|
%>
|
import fileUpload from "@/views/my-components/xboot/file-upload";
|
<%
|
}
|
%>
|
<%
|
if(upload){
|
%>
|
import uploadPicInput from "@/views/my-components/xboot/upload-pic-input";
|
<%
|
}
|
%>
|
<%
|
if(uploadThumb){
|
%>
|
import uploadThumb from "@/views/my-components/xboot/upload-pic-thumb";
|
<%
|
}
|
%>
|
<%
|
if(editor){
|
%>
|
import editor from "@/views/my-components/xboot/editor";
|
<%
|
}
|
%>
|
<%
|
if(password){
|
%>
|
import password from "@/views/my-components/xboot/set-password";
|
<%
|
}
|
%>
|
<%
|
if(dict||searchDict){
|
%>
|
import dict from "@/views/my-components/xboot/dict";
|
<%
|
}
|
%>
|
<%
|
if(customList||searchCustomList){
|
%>
|
import customList from "@/views/my-components/xboot/custom-list";
|
<%
|
}
|
%>
|
import { shortcuts } from "@/libs/shortcuts";
|
export default {
|
name: "${vueName}",
|
components: {
|
<%
|
if(fileUpload){
|
%>
|
fileUpload,
|
<%
|
}
|
%>
|
<%
|
if(upload){
|
%>
|
uploadPicInput,
|
<%
|
}
|
%>
|
<%
|
if(uploadThumb){
|
%>
|
uploadThumb,
|
<%
|
}
|
%>
|
<%
|
if(editor){
|
%>
|
editor,
|
<%
|
}
|
%>
|
<%
|
if(password){
|
%>
|
password,
|
<%
|
}
|
%>
|
<%
|
if(dict||searchDict){
|
%>
|
dict,
|
<%
|
}
|
%>
|
<%
|
if(customList||searchCustomList){
|
%>
|
customList,
|
<%
|
}
|
%>
|
},
|
data() {
|
return {
|
<% if(searchSize>0){ %>
|
openSearch: true, // 显示搜索
|
<% }%>
|
openTip: true, // 显示提示
|
loading: true, // 表单加载状态
|
modalType: 0, // 添加或编辑标识
|
modalVisible: false, // 添加或编辑显示
|
modalTitle: "", // 添加或编辑标题
|
<% if(hideSearch) { %>
|
drop: false,
|
dropDownContent: "展开",
|
dropDownIcon: "ios-arrow-down",
|
<% } %>
|
searchForm: { // 搜索框初始化对象
|
pageNumber: 1, // 当前页数
|
pageSize: 10, // 页面大小
|
sort: "createTime", // 默认排序字段
|
order: "desc", // 默认排序方式
|
<% if(daterangeSearch){ %>
|
startDate: "", // 起始时间
|
endDate: "", // 终止时间
|
<% } %>
|
<%
|
for(item in fields){
|
if(item.searchable && item.searchType=="area"){
|
%>
|
${item.field}: [],
|
<%
|
}
|
}
|
%>
|
},
|
<% if(daterangeSearch){ %>
|
selectDate: null,
|
options: {
|
shortcuts: shortcuts,
|
},
|
<% } %>
|
form: { // 添加或编辑表单对象初始化数据
|
<%
|
for(item in fields){
|
if(item.editable){
|
%>
|
<% if(item.type=="switch"){ %>
|
${item.field}: true,
|
<% }else if(item.type=="number"||item.type=="slider"){ %>
|
${item.field}: 0,
|
<% }else if(item.type=="daterange"||item.type=="area"||item.type=="uploadThumb"){ %>
|
${item.field}: [],
|
<% }else{ %>
|
${item.field}: "",
|
<% } %>
|
<%
|
}
|
}
|
%>
|
},
|
// 表单验证规则
|
formValidate: {
|
<%
|
for(item in fields){
|
if(item.editable&&item.validate){
|
%>
|
<% if(item.type=="area"||item.type=="uploadThumb"){ %>
|
${item.field}: [{ type: "array", required: true, message: "不能为空", trigger: "change" }],
|
<% }else if(item.type=="date"||item.type=="datetime"){ %>
|
${item.field}: [{ type: "date", required: true, message: "不能为空", trigger: "change" }],
|
<% }else if(item.type=="daterange"){ %>
|
${item.field}: [{ type: "array", required: true, trigger: "change", fields: { 0: { type: "date", message: "起始日期不能为空", required: true }, 1: { type: "date", message: "结束日期不能为空", required: true } }, }],
|
<% }else if(item.type=="number"||item.type=="slider"){ %>
|
${item.field}: [{ type: "number", required: true, message: "不能为空", trigger: "change" }],
|
<% }else if(item.type=="switch"){ %>
|
${item.field}: [{ type: "boolean", required: true, message: "不能为空", trigger: "change" }],
|
<% }else{ %>
|
${item.field}: [{ required: true, message: "不能为空", trigger: "change" }],
|
<% } %>
|
<%
|
}
|
}
|
%>
|
},
|
submitLoading: false, // 添加或编辑提交状态
|
selectList: [], // 多选数据
|
columns: [
|
// 表头
|
{
|
type: "selection",
|
width: 60,
|
align: "center"
|
},
|
{
|
type: "index",
|
width: 60,
|
align: "center"
|
},
|
<%
|
for(item in fields){
|
if(item.tableShow){
|
%>
|
{
|
title: "${item.name}",
|
key: "${item.field}",
|
minWidth: 120,
|
<%
|
if(item.sortable){
|
%>
|
sortable: true,
|
<%
|
}else{
|
%>
|
sortable: false,
|
<%
|
}
|
%>
|
<%
|
if(item.defaultSort){
|
%>
|
sortType: "${item.defaultSortType}"
|
<%
|
}
|
%>
|
},
|
<%
|
}
|
}
|
%>
|
{
|
title: "操作",
|
key: "action",
|
align: "center",
|
width: 150,
|
render: (h, params) => {
|
return h("div", [
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.edit(params.row);
|
}
|
}
|
},
|
"编辑"
|
),
|
h("Divider", {
|
props: {
|
type: "vertical",
|
},
|
}),
|
h(
|
"a",
|
{
|
on: {
|
click: () => {
|
this.remove(params.row);
|
}
|
}
|
},
|
"删除"
|
)
|
]);
|
}
|
}
|
],
|
data: [], // 表单数据
|
total: 0 // 表单数据总数
|
};
|
},
|
methods: {
|
init() {
|
this.getDataList();
|
},
|
changePage(v) {
|
this.searchForm.pageNumber = v;
|
this.getDataList();
|
this.clearSelectAll();
|
},
|
changePageSize(v) {
|
this.searchForm.pageSize = v;
|
this.getDataList();
|
},
|
<% if(searchSize>0){ %>
|
handleSearch() {
|
this.searchForm.pageNumber = 1;
|
this.searchForm.pageSize = 10;
|
this.getDataList();
|
},
|
<% } %>
|
handleReset() {
|
this.$refs.searchForm.resetFields();
|
this.searchForm.pageNumber = 1;
|
this.searchForm.pageSize = 10;
|
<% if(daterangeSearch){ %>
|
this.selectDate = null;
|
this.searchForm.startDate = "";
|
this.searchForm.endDate = "";
|
<% } %>
|
// 重新加载数据
|
this.getDataList();
|
},
|
changeSort(e) {
|
this.searchForm.sort = e.key;
|
this.searchForm.order = e.order;
|
if (e.order === "normal") {
|
this.searchForm.order = "";
|
}
|
this.getDataList();
|
},
|
clearSelectAll() {
|
this.$refs.table.selectAll(false);
|
},
|
changeSelect(e) {
|
this.selectList = e;
|
},
|
<% if(daterangeSearch){ %>
|
selectDateRange(v) {
|
if (v) {
|
this.searchForm.startDate = v[0];
|
this.searchForm.endDate = v[1];
|
}
|
},
|
<% } %>
|
<% if(hideSearch){ %>
|
dropDown() {
|
if (this.drop) {
|
this.dropDownContent = "展开";
|
this.dropDownIcon = "ios-arrow-down";
|
} else {
|
this.dropDownContent = "收起";
|
this.dropDownIcon = "ios-arrow-up";
|
}
|
this.drop = !this.drop;
|
},
|
<% } %>
|
getDataList() {
|
this.loading = true;
|
<%
|
if(api){
|
%>
|
get${apiName}List(this.searchForm).then(res => {
|
this.loading = false;
|
if (res.success) {
|
this.data = res.result.content;
|
this.total = res.result.totalElements;
|
if (this.data.length == 0 && this.searchForm.pageNumber > 1) {
|
this.searchForm.pageNumber -= 1;
|
this.getDataList();
|
}
|
}
|
});
|
<%
|
} else {
|
%>
|
// 带多条件搜索参数获取表单数据 请自行修改接口
|
// this.getRequest("请求路径", this.searchForm).then(res => {
|
// this.loading = false;
|
// if (res.success) {
|
// this.data = res.result.content;
|
// this.total = res.result.totalElements;
|
// if (this.data.length == 0 && this.searchForm.pageNumber > 1) {
|
// this.searchForm.pageNumber -= 1;
|
// this.getDataList();
|
// }
|
// }
|
// });
|
// 以下为模拟数据
|
//this.data = [
|
//];
|
this.total = this.data.length;
|
this.loading = false;
|
<%
|
}
|
%>
|
},
|
handleSubmit() {
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
<%
|
for(item in fields){
|
if(item.editable&&item.type=="date"){
|
%>
|
if (typeof this.form.${item.field} == "object") {
|
this.form.${item.field} = this.format(this.form.${item.field}, "yyyy-MM-dd");
|
}
|
<%
|
}else if(item.editable&&item.type=="datetime"){
|
%>
|
if (typeof this.form.${item.field} == "object") {
|
this.form.${item.field} = this.format(this.form.${item.field}, "yyyy-MM-dd HH:mm:ss");
|
}
|
<%
|
}
|
}
|
%>
|
this.submitLoading = true;
|
if (this.modalType === 0) {
|
// 添加 避免编辑后传入id等数据 记得删除
|
delete this.form.id;
|
<%
|
if(api){
|
%>
|
add${apiName}(this.form).then(res => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.modalVisible = false;
|
}
|
});
|
<%
|
} else {
|
%>
|
// this.postRequest("请求地址", this.form).then(res => {
|
// this.submitLoading = false;
|
// if (res.success) {
|
// this.$Message.success("操作成功");
|
// this.getDataList();
|
// this.modalVisible = false;
|
// }
|
// });
|
// 模拟请求成功
|
this.submitLoading = false;
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.modalVisible = false;
|
<%
|
}
|
%>
|
} else {
|
// 编辑
|
<%
|
if(api){
|
%>
|
edit${apiName}(this.form).then(res => {
|
this.submitLoading = false;
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.modalVisible = false;
|
}
|
});
|
<%
|
} else {
|
%>
|
// this.postRequest("请求地址", this.form).then(res => {
|
// this.submitLoading = false;
|
// if (res.success) {
|
// this.$Message.success("操作成功");
|
// this.getDataList();
|
// this.modalVisible = false;
|
// }
|
// });
|
// 模拟请求成功
|
this.submitLoading = false;
|
this.$Message.success("操作成功");
|
this.getDataList();
|
this.modalVisible = false;
|
<%
|
}
|
%>
|
}
|
}
|
});
|
},
|
add() {
|
this.modalType = 0;
|
this.modalTitle = "添加";
|
this.$refs.form.resetFields();
|
delete this.form.id;
|
this.modalVisible = true;
|
},
|
edit(v) {
|
this.modalType = 1;
|
this.modalTitle = "编辑";
|
this.$refs.form.resetFields();
|
// 转换null为""
|
for (let attr in v) {
|
if (v[attr] === null) {
|
v[attr] = "";
|
}
|
}
|
let str = JSON.stringify(v);
|
let data = JSON.parse(str);
|
this.form = data;
|
this.modalVisible = true;
|
},
|
remove(v) {
|
this.$Modal.confirm({
|
title: "确认删除",
|
// 记得确认修改此处
|
content: "您确认要删除该条数据?",
|
loading: true,
|
onOk: () => {
|
// 删除
|
<%
|
if(api){
|
%>
|
delete${apiName}({ids: v.id}).then(res => {
|
this.$Modal.remove();
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.clearSelectAll();
|
this.getDataList();
|
}
|
});
|
<%
|
} else {
|
%>
|
// this.deleteRequest("请求地址,如/deleteByIds/" + v.id).then(res => {
|
// this.$Modal.remove();
|
// if (res.success) {
|
// this.$Message.success("操作成功");
|
// this.clearSelectAll();
|
// this.getDataList();
|
// }
|
// });
|
// 模拟请求成功
|
this.$Message.success("操作成功");
|
this.clearSelectAll();
|
this.$Modal.remove();
|
this.getDataList();
|
<%
|
}
|
%>
|
}
|
});
|
},
|
delAll() {
|
if (this.selectList.length <= 0) {
|
this.$Message.warning("您还未选择要删除的数据");
|
return;
|
}
|
this.$Modal.confirm({
|
title: "确认删除",
|
content: "您确认要删除所选的 " + this.selectList.length + " 条数据?",
|
loading: true,
|
onOk: () => {
|
let ids = "";
|
this.selectList.forEach(function(e) {
|
ids += e.id + ",";
|
});
|
ids = ids.substring(0, ids.length - 1);
|
// 批量删除
|
<%
|
if(api){
|
%>
|
delete${apiName}({ids: ids}).then(res => {
|
this.$Modal.remove();
|
if (res.success) {
|
this.$Message.success("操作成功");
|
this.clearSelectAll();
|
this.getDataList();
|
}
|
});
|
<%
|
} else {
|
%>
|
// this.deleteRequest("请求地址,如/deleteByIds/" + ids).then(res => {
|
// this.$Modal.remove();
|
// if (res.success) {
|
// this.$Message.success("操作成功");
|
// this.clearSelectAll();
|
// this.getDataList();
|
// }
|
// });
|
// 模拟请求成功
|
this.$Message.success("操作成功");
|
this.$Modal.remove();
|
this.clearSelectAll();
|
this.getDataList();
|
<%
|
}
|
%>
|
}
|
});
|
}
|
},
|
mounted() {
|
this.init();
|
}
|
};
|
</script>
|
<style lang="less">
|
@import "@/styles/table-common.less";
|
</style>
|