去除无效的代码
This commit is contained in:
parent
0995a3b75f
commit
bf023ccad5
@ -101,7 +101,7 @@ public class CodeGenerator {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
// 模板路径
|
// 模板路径
|
||||||
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/templates/java/");
|
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/templates/");
|
||||||
Configuration cfg = Configuration.defaultConfiguration();
|
Configuration cfg = Configuration.defaultConfiguration();
|
||||||
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
|
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
|
||||||
// 生成代码
|
// 生成代码
|
||||||
|
@ -1,735 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="search">
|
|
||||||
<Row>
|
|
||||||
<Col>
|
|
||||||
<Card>
|
|
||||||
<%
|
|
||||||
if(searchSize>0&&!hideSearch){
|
|
||||||
%>
|
|
||||||
<Row <% if(searchSize>0){ %>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"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<Input type="text" v-model="searchForm.${item.field}" placeholder="请输入${item.name}" clearable style="width: 200px"/>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="select"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<Select v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px">
|
|
||||||
<Option value="0">请自行编辑下拉菜单</Option>
|
|
||||||
</Select>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="date"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<DatePicker type="date" v-model="searchForm.${item.field}" placeholder="请选择" readonly clearable style="width: 200px"></DatePicker>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="daterange"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<DatePicker v-model="selectDate" type="daterange" format="yyyy-MM-dd" clearable @on-change="selectDateRange" placeholder="选择起始时间" readonly style="width: 200px"></DatePicker>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="area"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<al-cascader v-model="searchForm.${item.field}" data-type="code" level="${item.searchLevel}" style="width:200px"/>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<Form-item style="margin-left:-35px;" class="br">
|
|
||||||
<Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
|
|
||||||
<Button @click="handleReset">重置</Button>
|
|
||||||
</Form-item>
|
|
||||||
</Form>
|
|
||||||
</Row>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(searchSize>0&&hideSearch){
|
|
||||||
%>
|
|
||||||
<Row @keydown.enter.native="handleSearch">
|
|
||||||
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
|
|
||||||
<%
|
|
||||||
for(item in firstTwo){
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="text"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<Input type="text" v-model="searchForm.${item.field}" placeholder="请输入${item.name}" clearable style="width: 200px"/>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="select"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<Select v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px">
|
|
||||||
<Option value="0">请自行编辑下拉菜单</Option>
|
|
||||||
</Select>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="date"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<DatePicker type="date" v-model="searchForm.${item.field}" placeholder="请选择" readonly clearable style="width: 200px"></DatePicker>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="daterange"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<DatePicker v-model="selectDate" type="daterange" format="yyyy-MM-dd" clearable @on-change="selectDateRange" readonly placeholder="选择起始时间" style="width: 200px"></DatePicker>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="area"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<al-cascader v-model="searchForm.${item.field}" data-type="code" level="${item.searchLevel}" style="width:200px"/>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<span v-if="drop">
|
|
||||||
<%
|
|
||||||
for(item in rest){
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="text"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<Input type="text" v-model="searchForm.${item.field}" placeholder="请输入${item.name}" clearable style="width: 200px"/>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="select"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<Select v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px">
|
|
||||||
<Option value="0">请自行编辑下拉菜单</Option>
|
|
||||||
</Select>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="date"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<DatePicker type="date" v-model="searchForm.${item.field}" placeholder="请选择" clearable style="width: 200px" readonly format="yyyy-MM-dd HH:mm:ss"></DatePicker>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="daterange"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<DatePicker v-model="selectDate" type="daterange" format="yyyy-MM-dd" clearable @on-change="selectDateRange" placeholder="选择起始时间" readonly style="width: 200px"></DatePicker>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.searchType=="area"){
|
|
||||||
%>
|
|
||||||
<Form-item label="${item.name}" prop="${item.field}">
|
|
||||||
<al-cascader v-model="searchForm.${item.field}" data-type="code" level="${item.searchLevel}" style="width:200px"/>
|
|
||||||
</Form-item>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
</span>
|
|
||||||
<Form-item 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>
|
|
||||||
</Form-item>
|
|
||||||
</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>
|
|
||||||
<Row v-show="openTip">
|
|
||||||
<Alert show-icon>
|
|
||||||
已选择 <span class="select-count">{{selectCount}}</span> 项
|
|
||||||
<a class="select-clear" @click="clearSelectAll">清空</a>
|
|
||||||
</Alert>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect"></Table>
|
|
||||||
</Row>
|
|
||||||
<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>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable='false' :width="${modalWidth}">
|
|
||||||
<Form ref="form" :model="form" :label-width="100" :rules="formValidate" <% if(rowNum>1){ %>inline<% } %>>
|
|
||||||
<%
|
|
||||||
for(item in fields){
|
|
||||||
if(item.editable){
|
|
||||||
%>
|
|
||||||
<FormItem label="${item.name}" prop="${item.field}" <% if(rowNum>1&&(item.type=="switch"||item.type=="radio")){ %>style="width:${itemWidth}"<% } %>>
|
|
||||||
<%
|
|
||||||
if(item.type=="text"){
|
|
||||||
%>
|
|
||||||
<Input v-model="form.${item.field}" clearable style="width:${width}"/>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="select"){
|
|
||||||
%>
|
|
||||||
<Select v-model="form.${item.field}" clearable style="width:${width}">
|
|
||||||
<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:${width}"></InputNumber>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="date"){
|
|
||||||
%>
|
|
||||||
<DatePicker type="date" v-model="form.${item.field}" readonly clearable style="width:${width}"></DatePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="daterange"){
|
|
||||||
%>
|
|
||||||
<DatePicker type="daterange" v-model="form.${item.field}" readonly clearable style="width:${width}"></DatePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="time"){
|
|
||||||
%>
|
|
||||||
<TimePicker type="time" v-model="form.${item.field}" clearable style="width:${width}"></TimePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="area"){
|
|
||||||
%>
|
|
||||||
<al-cascader v-model="form.${item.field}" data-type="code" level="${item.level}" style="width:${width}"/>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="slider"){
|
|
||||||
%>
|
|
||||||
<Slider v-model="form.${item.field}" style="width:${width}"></Slider>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="upload"){
|
|
||||||
%>
|
|
||||||
<upload-pic-input v-model="form.${item.field}" style="width:${width}"></upload-pic-input>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
</FormItem>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
</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(upload){
|
|
||||||
%>
|
|
||||||
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
export default {
|
|
||||||
name: "${vueName}",
|
|
||||||
components: {
|
|
||||||
<%
|
|
||||||
if(upload){
|
|
||||||
%>
|
|
||||||
uploadPicInput
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
},
|
|
||||||
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: "" // 终止时间
|
|
||||||
<% } %>
|
|
||||||
},
|
|
||||||
<% if(daterangeSearch){ %>
|
|
||||||
selectDate: null,
|
|
||||||
<% } %>
|
|
||||||
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=="area"){ %>
|
|
||||||
${item.field}: [],
|
|
||||||
<% }else{ %>
|
|
||||||
${item.field}: "",
|
|
||||||
<% } %>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
},
|
|
||||||
// 表单验证规则
|
|
||||||
formValidate: {
|
|
||||||
<%
|
|
||||||
for(item in fields){
|
|
||||||
if(item.editable&&item.validate){
|
|
||||||
%>
|
|
||||||
<% if(item.type=="daterange"||item.type=="area"){ %>
|
|
||||||
${item.field}: [{ type: "array", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else if(item.type=="date"){ %>
|
|
||||||
${item.field}: [{ type: "date", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else if(item.type=="number"||item.type=="slider"){ %>
|
|
||||||
${item.field}: [{ type: "number", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else if(item.type=="switch"){ %>
|
|
||||||
${item.field}: [{ type: "boolean", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else{ %>
|
|
||||||
${item.field}: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% } %>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
},
|
|
||||||
submitLoading: false, // 添加或编辑提交状态
|
|
||||||
selectList: [], // 多选数据
|
|
||||||
selectCount: 0, // 多选计数
|
|
||||||
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: 200,
|
|
||||||
render: (h, params) => {
|
|
||||||
return h("div", [
|
|
||||||
h(
|
|
||||||
"Button",
|
|
||||||
{
|
|
||||||
props: {
|
|
||||||
type: "primary",
|
|
||||||
size: "small",
|
|
||||||
icon: "ios-create-outline"
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
marginRight: "5px"
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
click: () => {
|
|
||||||
this.edit(params.row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"编辑"
|
|
||||||
),
|
|
||||||
h(
|
|
||||||
"Button",
|
|
||||||
{
|
|
||||||
props: {
|
|
||||||
type: "error",
|
|
||||||
size: "small",
|
|
||||||
icon: "md-trash"
|
|
||||||
},
|
|
||||||
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();
|
|
||||||
},
|
|
||||||
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;
|
|
||||||
this.selectCount = e.length;
|
|
||||||
},
|
|
||||||
<% 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;
|
|
||||||
// 带多条件搜索参数获取表单数据 请自行修改接口
|
|
||||||
this.getRequest("/${vueName}/getByPage", this.searchForm).then(res => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.success) {
|
|
||||||
this.data = res.result.records;
|
|
||||||
this.total = res.result.total;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 以下为模拟数据
|
|
||||||
//this.data = [
|
|
||||||
//];
|
|
||||||
this.total = this.data.length;
|
|
||||||
this.loading = false;
|
|
||||||
},
|
|
||||||
handleSubmit() {
|
|
||||||
this.$refs.form.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
this.submitLoading = true;
|
|
||||||
if (this.modalType === 0) {
|
|
||||||
// 添加 避免编辑后传入id等数据 记得删除
|
|
||||||
delete this.form.id;
|
|
||||||
this.postRequest("/${vueName}/insertOrUpdate", 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 {
|
|
||||||
// 编辑
|
|
||||||
this.postRequest("/${vueName}/insertOrUpdate", 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: () => {
|
|
||||||
// 删除
|
|
||||||
this.deleteRequest("/${vueName}/delByIds/" + v.id).then(res => {
|
|
||||||
this.$Modal.remove();
|
|
||||||
if (res.success) {
|
|
||||||
this.$Message.success("操作成功");
|
|
||||||
this.getDataList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 模拟请求成功
|
|
||||||
//this.$Message.success("操作成功");
|
|
||||||
//this.$Modal.remove();
|
|
||||||
//this.getDataList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
delAll() {
|
|
||||||
if (this.selectCount <= 0) {
|
|
||||||
this.$Message.warning("您还未选择要删除的数据");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$Modal.confirm({
|
|
||||||
title: "确认删除",
|
|
||||||
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
|
|
||||||
loading: true,
|
|
||||||
onOk: () => {
|
|
||||||
let ids = "";
|
|
||||||
this.selectList.forEach(function(e) {
|
|
||||||
ids += e.id + ",";
|
|
||||||
});
|
|
||||||
ids = ids.substring(0, ids.length - 1);
|
|
||||||
// 批量删除
|
|
||||||
this.deleteRequest("/${vueName}/delByIds/" + 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";
|
|
||||||
.search {
|
|
||||||
.operation {
|
|
||||||
margin-bottom: 2vh;
|
|
||||||
}
|
|
||||||
.select-count {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #40a9ff;
|
|
||||||
}
|
|
||||||
.select-clear {
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
.page {
|
|
||||||
margin-top: 2vh;
|
|
||||||
}
|
|
||||||
.drop-down {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,687 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="search">
|
|
||||||
<Card>
|
|
||||||
<Row class="operation">
|
|
||||||
<Button @click="add" type="primary" icon="md-add">添加子节点</Button>
|
|
||||||
<Button @click="addRoot" icon="md-add">添加一级节点</Button>
|
|
||||||
<Button @click="delAll" icon="md-trash">批量删除</Button>
|
|
||||||
<Button @click="getParentList" icon="md-refresh">刷新</Button>
|
|
||||||
<i-switch v-model="strict" size="large" style="margin-left:5px">
|
|
||||||
<span slot="open">级联</span>
|
|
||||||
<span slot="close">单选</span>
|
|
||||||
</i-switch>
|
|
||||||
</Row>
|
|
||||||
<Row type="flex" justify="start">
|
|
||||||
<Col span="6">
|
|
||||||
<Alert show-icon>
|
|
||||||
当前选择编辑:
|
|
||||||
<span class="select-title">{{editTitle}}</span>
|
|
||||||
<a class="select-clear" v-if="form.id" @click="cancelEdit">取消选择</a>
|
|
||||||
</Alert>
|
|
||||||
<Input
|
|
||||||
v-model="searchKey"
|
|
||||||
suffix="ios-search"
|
|
||||||
@on-change="search"
|
|
||||||
placeholder="输入节点名搜索"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
<div class="tree-bar" :style="{maxHeight: maxHeight}">
|
|
||||||
<Tree
|
|
||||||
ref="tree"
|
|
||||||
:data="data"
|
|
||||||
:load-data="loadData"
|
|
||||||
show-checkbox
|
|
||||||
@on-check-change="changeSelect"
|
|
||||||
@on-select-change="selectTree"
|
|
||||||
:check-strictly="!strict"
|
|
||||||
></Tree>
|
|
||||||
<Spin size="large" fix v-if="loading"></Spin>
|
|
||||||
</div>
|
|
||||||
</Col>
|
|
||||||
<Col span="${span}" style="margin-left:10px">
|
|
||||||
<Form ref="form" :model="form" :label-width="100" :rules="formValidate" <% if(rowNum>1){ %>inline<% } %>>
|
|
||||||
<FormItem label="上级节点" prop="parentTitle">
|
|
||||||
<div style="display:flex;">
|
|
||||||
<Input v-model="form.parentTitle" readonly style="margin-right:10px;"/>
|
|
||||||
<Poptip transfer trigger="click" placement="right-start" title="选择上级部门" width="250">
|
|
||||||
<Button icon="md-list">选择部门</Button>
|
|
||||||
<div slot="content" style="position:relative;min-height:5vh">
|
|
||||||
<Tree :data="dataEdit" :load-data="loadData" @on-select-change="selectTreeEdit"></Tree>
|
|
||||||
<Spin size="large" fix v-if="loadingEdit"></Spin>
|
|
||||||
</div>
|
|
||||||
</Poptip>
|
|
||||||
</div>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="名称" prop="title">
|
|
||||||
<Input v-model="form.title" />
|
|
||||||
</FormItem>
|
|
||||||
<%
|
|
||||||
for(item in fields){
|
|
||||||
if(item.editable){
|
|
||||||
%>
|
|
||||||
<FormItem label="${item.name}" prop="${item.field}" <% if(rowNum>1&&(item.type=="switch"||item.type=="radio")){ %>style="width:${itemWidth}"<% } %>>
|
|
||||||
<%
|
|
||||||
if(item.type=="text"){
|
|
||||||
%>
|
|
||||||
<Input v-model="form.${item.field}" style="width:${editWidth}"/>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="select"){
|
|
||||||
%>
|
|
||||||
<Select v-model="form.${item.field}" style="width:${editWidth}">
|
|
||||||
<Option value="0">请自行编辑下拉菜单</Option>
|
|
||||||
</Select>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="number"){
|
|
||||||
%>
|
|
||||||
<InputNumber v-model="form.${item.field}" style="width:${editWidth}"></InputNumber>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
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=="date"){
|
|
||||||
%>
|
|
||||||
<DatePicker type="date" v-model="form.${item.field}" style="width:${editWidth}"></DatePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="daterange"){
|
|
||||||
%>
|
|
||||||
<DatePicker type="daterange" v-model="form.${item.field}" style="width:${editWidth}"></DatePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="time"){
|
|
||||||
%>
|
|
||||||
<TimePicker type="time" v-model="form.${item.field}" style="width:${editWidth}"></TimePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="area"){
|
|
||||||
%>
|
|
||||||
<al-cascader v-model="form.${item.field}" data-type="code" level="${item.level}" style="width:${editWidth}"/>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="slider"){
|
|
||||||
%>
|
|
||||||
<Slider v-model="form.${item.field}" style="width:${editWidth}"></Slider>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="upload"){
|
|
||||||
%>
|
|
||||||
<upload-pic-input v-model="form.${item.field}" style="width:${editWidth}"></upload-pic-input>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
</FormItem>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<FormItem label="排序值" prop="sortOrder">
|
|
||||||
<Poptip trigger="hover" placement="right" content="值越小越靠前,支持小数">
|
|
||||||
<InputNumber :max="1000" :min="0" v-model="form.sortOrder"></InputNumber>
|
|
||||||
</Poptip>
|
|
||||||
</FormItem>
|
|
||||||
<br>
|
|
||||||
<Form-item>
|
|
||||||
<Button
|
|
||||||
@click="submitEdit"
|
|
||||||
:loading="submitLoading"
|
|
||||||
type="primary"
|
|
||||||
icon="ios-create-outline"
|
|
||||||
style="margin-right:5px"
|
|
||||||
>修改并保存</Button>
|
|
||||||
<Button @click="handleReset">重置</Button>
|
|
||||||
</Form-item>
|
|
||||||
</Form>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="${modalWidth}">
|
|
||||||
<Form ref="formAdd" :model="formAdd" :label-width="100" :rules="formValidate" <% if(rowNum>1){ %>inline<% } %>>
|
|
||||||
<div v-if="showParent">
|
|
||||||
<FormItem label="上级节点:">{{form.title}}</FormItem>
|
|
||||||
</div>
|
|
||||||
<FormItem label="名称" prop="title">
|
|
||||||
<Input v-model="form.title" />
|
|
||||||
</FormItem>
|
|
||||||
<%
|
|
||||||
for(item in fields){
|
|
||||||
if(item.editable){
|
|
||||||
%>
|
|
||||||
<FormItem label="${item.name}" prop="${item.field}" <% if(rowNum>1&&(item.type=="number"||item.type=="switch"||item.type=="radio")){ %>style="width:${itemWidth}"<% } %>>
|
|
||||||
<%
|
|
||||||
if(item.type=="text"){
|
|
||||||
%>
|
|
||||||
<Input v-model="formAdd.${item.field}" style="width:${width}"/>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="select"){
|
|
||||||
%>
|
|
||||||
<Select v-model="formAdd.${item.field}" style="width:${width}">
|
|
||||||
<Option value="0">请自行编辑下拉菜单</Option>
|
|
||||||
</Select>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="number"){
|
|
||||||
%>
|
|
||||||
<InputNumber v-model="formAdd.${item.field}"></InputNumber>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="switch"){
|
|
||||||
%>
|
|
||||||
<i-switch v-model="formAdd.${item.field}"></i-switch>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="radio"){
|
|
||||||
%>
|
|
||||||
<RadioGroup v-model="formAdd.${item.field}">
|
|
||||||
<Radio label="0">请自行编辑单选框</Radio>
|
|
||||||
<Radio label="1">请自行编辑单选框</Radio>
|
|
||||||
</RadioGroup>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="date"){
|
|
||||||
%>
|
|
||||||
<DatePicker type="date" v-model="formAdd.${item.field}" style="width:${width}"></DatePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="daterange"){
|
|
||||||
%>
|
|
||||||
<DatePicker type="daterange" v-model="formAdd.${item.field}" style="width:${width}"></DatePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="time"){
|
|
||||||
%>
|
|
||||||
<TimePicker type="time" v-model="formAdd.${item.field}" style="width:${width}"></TimePicker>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="area"){
|
|
||||||
%>
|
|
||||||
<al-cascader v-model="formAdd.${item.field}" data-type="code" level="${item.level}" style="width:${width}"/>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="slider"){
|
|
||||||
%>
|
|
||||||
<Slider v-model="formAdd.${item.field}" style="width:${width}"></Slider>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
if(item.type=="upload"){
|
|
||||||
%>
|
|
||||||
<upload-pic-input v-model="formAdd.${item.field}" style="width:${width}"></upload-pic-input>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
</FormItem>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<FormItem label="排序值" prop="sortOrder">
|
|
||||||
<Poptip trigger="hover" placement="right" content="值越小越靠前,支持小数">
|
|
||||||
<InputNumber :max="1000" :min="0" v-model="formAdd.sortOrder"></InputNumber>
|
|
||||||
</Poptip>
|
|
||||||
</FormItem>
|
|
||||||
</Form>
|
|
||||||
<div slot="footer">
|
|
||||||
<Button type="text" @click="modalVisible=false">取消</Button>
|
|
||||||
<Button type="primary" :loading="submitLoading" @click="submitAdd">提交</Button>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
<%
|
|
||||||
if(upload){
|
|
||||||
%>
|
|
||||||
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
export default {
|
|
||||||
name: "${vueName}",
|
|
||||||
components: {
|
|
||||||
<%
|
|
||||||
if(upload){
|
|
||||||
%>
|
|
||||||
uploadPicInput
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
maxHeight: "500px",
|
|
||||||
strict: true,
|
|
||||||
loading: false, // 树加载状态
|
|
||||||
loadingEdit: false, // 编辑上级树加载状态
|
|
||||||
modalVisible: false, // 添加显示
|
|
||||||
selectList: [], // 多选数据
|
|
||||||
selectCount: 0, // 多选计数
|
|
||||||
showParent: false, // 显示上级标识
|
|
||||||
modalTitle: "", // 添加标题
|
|
||||||
editTitle: "", // 编辑节点名称
|
|
||||||
searchKey: "", // 搜索树
|
|
||||||
form: {
|
|
||||||
// 编辑对象初始化数据
|
|
||||||
id: "",
|
|
||||||
title: "",
|
|
||||||
parentId: "",
|
|
||||||
parentTitle: "",
|
|
||||||
sortOrder: 0,
|
|
||||||
<%
|
|
||||||
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=="area"){ %>
|
|
||||||
${item.field}: [],
|
|
||||||
<% }else{ %>
|
|
||||||
${item.field}: "",
|
|
||||||
<% } %>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
},
|
|
||||||
formAdd: {
|
|
||||||
// 添加对象初始化数据
|
|
||||||
},
|
|
||||||
formValidate: {
|
|
||||||
// 表单验证规则
|
|
||||||
title: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
sortOrder: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
type: "number",
|
|
||||||
message: "排序值不能为空",
|
|
||||||
trigger: "blur"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
<%
|
|
||||||
for(item in fields){
|
|
||||||
if(item.editable&&item.validate){
|
|
||||||
%>
|
|
||||||
<% if(item.type=="daterange"||item.type=="area"){ %>
|
|
||||||
${item.field}: [{ type: "array", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else if(item.type=="date"){ %>
|
|
||||||
${item.field}: [{ type: "date", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else if(item.type=="number"||item.type=="slider"){ %>
|
|
||||||
${item.field}: [{ type: "number", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else if(item.type=="switch"){ %>
|
|
||||||
${item.field}: [{ type: "boolean", required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% }else{ %>
|
|
||||||
${item.field}: [{ required: true, message: "不能为空", trigger: "blur" }],
|
|
||||||
<% } %>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
},
|
|
||||||
submitLoading: false,
|
|
||||||
data: [],
|
|
||||||
dataEdit: []
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
init() {
|
|
||||||
// 初始化一级节点
|
|
||||||
this.getParentList();
|
|
||||||
// 初始化一级节点为编辑上级节点使用
|
|
||||||
this.getParentListEdit();
|
|
||||||
},
|
|
||||||
getParentList() {
|
|
||||||
// this.loading = true;
|
|
||||||
// this.getRequest("一级数据请求路径,如/tree/getByParentId/0").then(res => {
|
|
||||||
// this.loading = false;
|
|
||||||
// if (res.success) {
|
|
||||||
// res.result.forEach(function(e) {
|
|
||||||
// if (e.isParent) {
|
|
||||||
// e.loading = false;
|
|
||||||
// e.children = [];
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// this.data = res.result;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// 模拟请求成功
|
|
||||||
this.data = [
|
|
||||||
];
|
|
||||||
},
|
|
||||||
getParentListEdit() {
|
|
||||||
// this.loadingEdit = true;
|
|
||||||
// this.getRequest("/tree/getByParentId/0").then(res => {
|
|
||||||
// this.loadingEdit = false;
|
|
||||||
// if (res.success) {
|
|
||||||
// res.result.forEach(function(e) {
|
|
||||||
// if (e.isParent) {
|
|
||||||
// e.loading = false;
|
|
||||||
// e.children = [];
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// // 头部加入一级
|
|
||||||
// let first = {
|
|
||||||
// id: "0",
|
|
||||||
// title: "一级节点"
|
|
||||||
// };
|
|
||||||
// res.result.unshift(first);
|
|
||||||
// this.dataEdit = res.result;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// 模拟请求成功
|
|
||||||
this.dataEdit = [
|
|
||||||
];
|
|
||||||
},
|
|
||||||
loadData(item, callback) {
|
|
||||||
// 异步加载树子节点数据
|
|
||||||
// this.getRequest("请求路径,如/tree/getByParentId/" + item.id).then(res => {
|
|
||||||
// if (res.success) {
|
|
||||||
// res.result.forEach(function(e) {
|
|
||||||
// if (e.isParent) {
|
|
||||||
// e.loading = false;
|
|
||||||
// e.children = [];
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// callback(res.result);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
},
|
|
||||||
search() {
|
|
||||||
// 搜索树
|
|
||||||
if (this.searchKey) {
|
|
||||||
// 模拟请求
|
|
||||||
// this.loading = true;
|
|
||||||
// this.getRequest("搜索请求路径", { title: this.searchKey }).then(res => {
|
|
||||||
// this.loading = false;
|
|
||||||
// if (res.success) {
|
|
||||||
// this.data = res.result;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// 模拟请求成功
|
|
||||||
this.data = [
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
// 为空重新加载
|
|
||||||
this.getParentList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectTree(v) {
|
|
||||||
if (v.length > 0) {
|
|
||||||
// 转换null为""
|
|
||||||
for (let attr in v[0]) {
|
|
||||||
if (v[0][attr] === null) {
|
|
||||||
v[0][attr] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let str = JSON.stringify(v[0]);
|
|
||||||
let data = JSON.parse(str);
|
|
||||||
this.form = data;
|
|
||||||
this.editTitle = data.title;
|
|
||||||
} else {
|
|
||||||
this.cancelEdit();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cancelEdit() {
|
|
||||||
let data = this.$refs.tree.getSelectedNodes()[0];
|
|
||||||
if (data) {
|
|
||||||
data.selected = false;
|
|
||||||
}
|
|
||||||
this.$refs.form.resetFields();
|
|
||||||
this.form.id = "";
|
|
||||||
this.editTitle = "";
|
|
||||||
},
|
|
||||||
selectTreeEdit(v) {
|
|
||||||
if (v.length > 0) {
|
|
||||||
// 转换null为""
|
|
||||||
for (let attr in v[0]) {
|
|
||||||
if (v[0][attr] === null) {
|
|
||||||
v[0][attr] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let str = JSON.stringify(v[0]);
|
|
||||||
let data = JSON.parse(str);
|
|
||||||
this.form.parentId = data.id;
|
|
||||||
this.form.parentTitle = data.title;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleReset() {
|
|
||||||
this.$refs.form.resetFields();
|
|
||||||
this.form.status = 0;
|
|
||||||
},
|
|
||||||
submitEdit() {
|
|
||||||
this.$refs.form.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
if (!this.form.id) {
|
|
||||||
this.$Message.warning("请先点击选择要修改的节点");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.submitLoading = true;
|
|
||||||
// 避免传入null字符串
|
|
||||||
// this.postRequest("请求路径,如/tree/edit", this.form).then(res => {
|
|
||||||
// this.submitLoading = false;
|
|
||||||
// if (res.success) {
|
|
||||||
// this.$Message.success("编辑成功");
|
|
||||||
// this.init();
|
|
||||||
// this.modalVisible = false;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// 模拟成功
|
|
||||||
this.submitLoading = false;
|
|
||||||
this.$Message.success("编辑成功");
|
|
||||||
this.modalVisible = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
submitAdd() {
|
|
||||||
this.$refs.formAdd.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
this.submitLoading = true;
|
|
||||||
// this.postRequest("请求路径,如/tree/add", this.formAdd).then(res => {
|
|
||||||
// this.submitLoading = false;
|
|
||||||
// if (res.success) {
|
|
||||||
// this.$Message.success("添加成功");
|
|
||||||
// this.init();
|
|
||||||
// this.modalVisible = false;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// 模拟成功
|
|
||||||
this.submitLoading = false;
|
|
||||||
this.$Message.success("添加成功");
|
|
||||||
this.modalVisible = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
add() {
|
|
||||||
if (this.form.id == "" || this.form.id == null) {
|
|
||||||
this.$Message.warning("请先点击选择一个节点");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.modalTitle = "添加子节点";
|
|
||||||
this.showParent = true;
|
|
||||||
this.formAdd = {
|
|
||||||
parentId: this.form.id,
|
|
||||||
sortOrder: 0,
|
|
||||||
<%
|
|
||||||
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=="area"){ %>
|
|
||||||
${item.field}: [],
|
|
||||||
<% }else{ %>
|
|
||||||
${item.field}: "",
|
|
||||||
<% } %>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
};
|
|
||||||
this.modalVisible = true;
|
|
||||||
},
|
|
||||||
addRoot() {
|
|
||||||
this.modalTitle = "添加一级节点";
|
|
||||||
this.showParent = false;
|
|
||||||
this.formAdd = {
|
|
||||||
parentId: 0,
|
|
||||||
sortOrder: 0,
|
|
||||||
title: "",
|
|
||||||
<%
|
|
||||||
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=="area"){ %>
|
|
||||||
${item.field}: [],
|
|
||||||
<% }else{ %>
|
|
||||||
${item.field}: "",
|
|
||||||
<% } %>
|
|
||||||
<%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
};
|
|
||||||
this.modalVisible = true;
|
|
||||||
},
|
|
||||||
changeSelect(v) {
|
|
||||||
this.selectCount = v.length;
|
|
||||||
this.selectList = v;
|
|
||||||
},
|
|
||||||
delAll() {
|
|
||||||
if (this.selectCount <= 0) {
|
|
||||||
this.$Message.warning("您还未勾选要删除的数据");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$Modal.confirm({
|
|
||||||
title: "确认删除",
|
|
||||||
content: "您确认要删除所选的 " + this.selectCount + " 条数据及其下级所有数据?",
|
|
||||||
loading: true,
|
|
||||||
onOk: () => {
|
|
||||||
let ids = "";
|
|
||||||
this.selectList.forEach(function(e) {
|
|
||||||
ids += e.id + ",";
|
|
||||||
});
|
|
||||||
ids = ids.substring(0, ids.length - 1);
|
|
||||||
// this.deleteRequest("请求路径,如/tree/delByIds/" + ids).then(res => {
|
|
||||||
// this.$Modal.remove();
|
|
||||||
// if (res.success) {
|
|
||||||
// this.$Message.success("删除成功");
|
|
||||||
// this.selectList = [];
|
|
||||||
// this.selectCount = 0;
|
|
||||||
// this.cancelEdit();
|
|
||||||
// this.init();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// 模拟成功
|
|
||||||
this.$Modal.remove();
|
|
||||||
this.$Message.success("删除成功");
|
|
||||||
this.selectList = [];
|
|
||||||
this.selectCount = 0;
|
|
||||||
this.cancelEdit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
// 计算高度
|
|
||||||
let height = document.documentElement.clientHeight;
|
|
||||||
this.maxHeight = Number(height-287) + "px";
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<style lang="less">
|
|
||||||
// 建议引入通用样式 可删除下面样式代码
|
|
||||||
// @import "../../../styles/tree-common.less";
|
|
||||||
.search {
|
|
||||||
.operation {
|
|
||||||
margin-bottom: 2vh;
|
|
||||||
}
|
|
||||||
.select-title {
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #40a9ff;
|
|
||||||
}
|
|
||||||
.select-clear {
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-bar {
|
|
||||||
overflow: auto;
|
|
||||||
margin-top: 5px;
|
|
||||||
position: relative;
|
|
||||||
min-height: 80px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-bar::-webkit-scrollbar {
|
|
||||||
width: 6px;
|
|
||||||
height: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-bar::-webkit-scrollbar-thumb {
|
|
||||||
border-radius: 4px;
|
|
||||||
-webkit-box-shadow: inset 0 0 2px #d1d1d1;
|
|
||||||
background: #e4e4e4;
|
|
||||||
}
|
|
||||||
</style>
|
|
Loading…
x
Reference in New Issue
Block a user