master
mingsoft 3 years ago
parent c632a105a8
commit 7302b926f1
  1. 230
      src/main/webapp/WEB-INF/manager/cms/category/form.ftl

@ -41,9 +41,9 @@
<el-col span="12"> <el-col span="12">
<el-form-item label="所属栏目" prop="categoryId"> <el-form-item label="所属栏目" prop="categoryId">
<ms-tree-select ref="tree" <ms-tree-select ref="tree"
:props="{value: 'id',label: 'categoryTitle',children: 'children'}" :props="{value: 'id',label: 'categoryTitle',children: 'children'}"
:options="treeList" :style="{width:'100%'}" :options="treeList" :style="{width:'100%'}"
v-model="form.categoryId"></ms-tree-select> v-model="form.categoryId"></ms-tree-select>
<div class="ms-form-tip"> <div class="ms-form-tip">
不能将父级别栏目移动到自身子级栏目 不能将父级别栏目移动到自身子级栏目
</div> </div>
@ -67,6 +67,20 @@
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12">
<el-form-item label="自定义顺序" prop="categorySort">
<el-input-number
v-model="form.categorySort"
:disabled="false"
controls-position="">
</el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row
:gutter="0"
justify="start" align="top">
<el-col span="12"> <el-col span="12">
<el-form-item label="是否显示" prop="categoryDisplay"> <el-form-item label="是否显示" prop="categoryDisplay">
<el-radio-group v-model="form.categoryDisplay" <el-radio-group v-model="form.categoryDisplay"
@ -84,6 +98,23 @@
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12">
<el-form-item prop="mdiyModelId" label="文章自定义模型">
<el-select v-model="form.mdiyModelId"
:style="{width: '100%'}"
:filterable="false"
:disabled="false"
:multiple="false" :clearable="true"
placeholder="请选择文章自定义模型">
<el-option v-for='item in mdiyModelListOptions' :key="item.id" :value="item.id"
:label="item.modelName"></el-option>
</el-select>
<div class="ms-form-tip">
文章字段不满足,使用<b>代码生成器</b>生成<b>自定义模型</b>来扩展,<br/>
大概步骤:<i>代码生成器->复制自定义模型->打开系统后台的自定义管理->选择自定义模型->导入->文章 自定义模型 绑定</i>
</div>
</el-form-item>
</el-col>
</el-row> </el-row>
<el-row <el-row
gutter="0" gutter="0"
@ -109,22 +140,22 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12"> <el-col span="12">
<el-form-item prop="mdiyModelId" label="文章自定义模型">
<el-select v-model="form.mdiyModelId" <el-form-item label="是否可被搜索" prop="categoryIsSearch">
:style="{width: '100%'}" <el-radio-group v-model="form.categoryIsSearch"
:filterable="false" :style="{width: ''}"
:disabled="false" :disabled="false">
:multiple="false" :clearable="true" <el-radio :style="{issearch: true ? 'inline-block' : 'block'}"
placeholder="请选择文章自定义模型"> :label="item.value"
<el-option v-for='item in mdiyModelListOptions' :key="item.id" :value="item.id" v-for='(item, index) in categoryIsSearchOptions'
:label="item.modelName"></el-option> :key="item.value + index">
</el-select> {{true? item.label : item.value}}
</el-radio>
</el-radio-group>
<div class="ms-form-tip"> <div class="ms-form-tip">
文章字段不满足,使用<b>代码生成器</b>生成<b>自定义模型</b>来扩展,<br/> 选择否后不需重新生成,该栏目下的文章将不会被搜索页搜索;若该栏目选择不可被搜索,则所有子栏目也会不可被搜索;
大概步骤:<i>代码生成器->复制自定义模型->打开系统后台的自定义管理->选择自定义模型->导入->文章 自定义模型 绑定</i>
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row gutter="0" justify="start" align="top"> <el-row gutter="0" justify="start" align="top">
@ -146,6 +177,21 @@
</el-col> </el-col>
<el-col span="12"> <el-col span="12">
<el-form-item label="栏目属性" prop="categoryFlag">
<el-select v-model="form.categoryFlag"
:style="{width: '100%'}"
:filterable="false"
:disabled="false"
:multiple="true" :clearable="true"
placeholder="请选择栏目属性">
<el-option v-for='item in categoryFlagOptions' :key="item.dictValue"
:value="item.dictValue"
:label="item.dictLabel"></el-option>
</el-select>
<div class="ms-form-tip">
可以在自定义字典中管理
</div>
</el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row <el-row
@ -181,20 +227,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col span="12"> <el-col span="12">
<el-form-item label="自定义顺序" prop="categorySort">
<el-input-number
v-model="form.categorySort"
:disabled="false"
controls-position="">
</el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row
:gutter="0"
justify="start" align="top">
<el-col :span="12">
<el-form-item label="生成路径" prop="categoryPinyin"> <el-form-item label="生成路径" prop="categoryPinyin">
<el-input <el-input
v-model="form.categoryPinyin" v-model="form.categoryPinyin"
@ -209,26 +241,9 @@
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> </el-row>
<el-form-item label="栏目属性" prop="categoryFlag">
<el-select v-model="form.categoryFlag"
:style="{width: '100%'}"
:filterable="false"
:disabled="false"
:multiple="true" :clearable="true"
placeholder="请选择栏目属性">
<el-option v-for='item in categoryFlagOptions' :key="item.dictValue"
:value="item.dictValue"
:label="item.dictLabel"></el-option>
</el-select>
<div class="ms-form-tip">
可以在自定义字典中管理
</div>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="关键字" prop="categoryKeyword"> <el-form-item label="关键字" prop="categoryKeyword">
<el-input <el-input
type="textarea" :rows="5" type="textarea" :rows="5"
@ -268,6 +283,7 @@
:disabled="false" :disabled="false"
:data="{uploadPath:'/cms/category','isRename':true,'appId':true}" :data="{uploadPath:'/cms/category','isRename':true,'appId':true}"
:on-success="categoryImgSuccess" :on-success="categoryImgSuccess"
:on-error="categoryImgError"
accept="image/*" accept="image/*"
list-type="picture-card"> list-type="picture-card">
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
@ -289,6 +305,7 @@
:disabled="false" :disabled="false"
:data="{uploadPath:'/cms/category','isRename':true,'appId':true}" :data="{uploadPath:'/cms/category','isRename':true,'appId':true}"
:on-success="categoryIcoSuccess" :on-success="categoryIcoSuccess"
:on-error="categoryImgError"
accept="image/*" accept="image/*"
list-type="picture-card"> list-type="picture-card">
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
@ -315,7 +332,7 @@
var that = this var that = this
//验证拼音是否存在 //验证拼音是否存在
var validatorCategoryPinyin = function (rule, value, callback) { var validatorCategoryPinyin = function (rule, value, callback) {
// //
ms.http.get(ms.manager+'/cms/category/verifyPingYin.do',{ ms.http.get(ms.manager+'/cms/category/verifyPingYin.do',{
id:that.form.id, id:that.form.id,
categoryPinyin:that.form.categoryPinyin, categoryPinyin:that.form.categoryPinyin,
@ -351,6 +368,14 @@
"value": "disable", "value": "disable",
"label": "否" "label": "否"
}], }],
// 栏目是否被搜索
categoryIsSearchOptions: [{
"value": "enable",
"label": "是"
}, {
"value": "disable",
"label": "否"
}],
//表单数据 //表单数据
form: { form: {
// 栏目管理名称 // 栏目管理名称
@ -373,6 +398,8 @@
categoryKeyword: '', categoryKeyword: '',
// 栏目是否显示 // 栏目是否显示
categoryDisplay: 'enable', categoryDisplay: 'enable',
// 栏目是否被搜索
categoryIsSearch: 'enable',
// 栏目管理描述 // 栏目管理描述
categoryDescrip: '', categoryDescrip: '',
// banner图 // banner图
@ -401,7 +428,6 @@
categoryListUrlOptions: [], categoryListUrlOptions: [],
categoryUrlOptions: [], categoryUrlOptions: [],
mdiyModelListOptions: [], mdiyModelListOptions: [],
mdiyCategoryModelListOptions: [],
categoryFlagOptions: [], categoryFlagOptions: [],
rules: { rules: {
// 栏目管理名称 // 栏目管理名称
@ -409,10 +435,14 @@
"required": true, "required": true,
"message": "请选择栏目管理名称" "message": "请选择栏目管理名称"
}], }],
categoryListUrl: [{ categoryIsSearch: [{
"required": true, "required": true,
"message": "请选择列表模板" "message": "请选择栏目是否可被搜索"
}], }],
// categoryListUrl: [{
// "required": true,
// "message": "请选择列表模板"
// }],
categoryPinyin: [{ categoryPinyin: [{
validator: validatorCategoryPinyin, trigger: 'blur' validator: validatorCategoryPinyin, trigger: 'blur'
}, { }, {
@ -420,10 +450,10 @@
"message": "拼音格式不匹配" "message": "拼音格式不匹配"
}], }],
// 内容模板 // 内容模板
categoryUrl: [{ // categoryUrl: [{
"required": true, // "required": true,
"message": "请选择内容模板" // "message": "请选择内容模板"
}] // }]
} }
}; };
}, },
@ -495,9 +525,7 @@
}, },
getTree: function () { getTree: function () {
var that = this; var that = this;
ms.http.get(ms.manager + "/cms/category/list.do", { ms.http.get(ms.manager + "/cms/category/list.do").then(function (res) {
pageSize: 9999
}).then(function (res) {
if (res.result) { if (res.result) {
//res.data.rows.push({id:0,categoryId: null,categoryTitle:'顶级栏目管理'}); //res.data.rows.push({id:0,categoryId: null,categoryTitle:'顶级栏目管理'});
that.categoryList = res.data.rows; that.categoryList = res.data.rows;
@ -508,6 +536,14 @@
save: function () { save: function () {
var that = this; var that = this;
var model = undefined;
if (that.form.mdiyCategoryModelId && String(that.form.mdiyCategoryModelId)!="0"){
model = ms.mdiy.model.modelForm();
}
if (model && !model.validate()) {
this.activeName = 'custom-name';
return;
}
var url = ms.manager + "/cms/category/save.do"; var url = ms.manager + "/cms/category/save.do";
@ -558,6 +594,11 @@
data.categoryIco = JSON.stringify(data.categoryIco); data.categoryIco = JSON.stringify(data.categoryIco);
ms.http.post(url, data).then(function (data) { ms.http.post(url, data).then(function (data) {
if (data.result) { if (data.result) {
//保存时需要赋值关联ID
if (model) {
model.form.linkId = data.data.id;
model.save();
}
that.$notify({ that.$notify({
title: '成功', title: '成功',
@ -594,16 +635,18 @@
} }
}); });
}, },
//获取栏目内容模型
queryCategoryModelList: function () { //设置栏目模型
setCategoryModel: function (mdiyCategoryModelId) {
var that = this; var that = this;
ms.http.get(ms.manager + "/mdiy/model/list.do", { if (mdiyCategoryModelId) {
modelType: 'category' mdiyCategoryModelId += "";
}).then(function (res) { if (mdiyCategoryModelId == "0") {
if (res.result) { mdiyCategoryModelId = null;
that.mdiyCategoryModelListOptions = res.data.rows;
} }
}); that.form.mdiyCategoryModelId = mdiyCategoryModelId;
}
that.changeModel();
}, },
//获取当前分类 //获取当前分类
@ -637,11 +680,20 @@
if (!res.data.categoryId) { if (!res.data.categoryId) {
res.data.categoryId = '0'; res.data.categoryId = '0';
} }
var mdiyCategoryModelId = res.data.mdiyCategoryModelId;
if (mdiyCategoryModelId) {
mdiyCategoryModelId += "";
if (mdiyCategoryModelId == "0") {
mdiyCategoryModelId = null;
}
res.data.mdiyCategoryModelId = mdiyCategoryModelId;
}
that.form = res.data; //判断该分类是否存在文章,存在则不能修改栏目属性 that.form = res.data; //判断该分类是否存在文章,存在则不能修改栏目属性
that.contentList(that.form.id); that.contentList(that.form.id);
that.changeModel();
} }
}); });
}, },
@ -758,23 +810,46 @@
this.form.categoryIco.splice(index, 1); this.form.categoryIco.splice(index, 1);
} }
}, },
removeModel: function () { //categoryImg文件上传失败回调
categoryImgError: function (response, file, fileList) {
response = response.toString().replace("Error: ","")
response = JSON.parse(response);
this.$notify({
title: '失败',
message: response.msg,
type: 'warning'
});
},
categoryChange: function () {
this.changeModel();
},
changeModel: function () {
var that = this; var that = this;
var model = document.getElementById('model1'); that.editableTabs = [that.editableTabs[0]];
var custom = document.getElementById('c_model');
if (custom) { if (that.form) {
model.removeChild(custom); if (that.form.mdiyCategoryModelId) {
that.rederModel(that.form.mdiyCategoryModelId)
}
} }
that.model = undefined;
}, },
rederModel: function (modelId) {
var that = this;
that.editableTabs.push({
title: '加载中...',
name: 'custom-name'
});
this.$nextTick(function () {
ms.mdiy.model.extend("model1", {id:modelId},{ linkId: that.form.id },true).then(function(obj) {
that.model = obj;
that.editableTabs[1].title = obj.modelName
});
});
},
}, },
created: function () { created: function () {
this.queryColumnContentModelList(); this.queryColumnContentModelList();
this.queryCategoryModelList();
this.getTree(); this.getTree();
this.categoryListUrlOptionsGet(); this.categoryListUrlOptionsGet();
this.categoryUrlOptionsGet(); this.categoryUrlOptionsGet();
@ -801,3 +876,6 @@
width: 100%; width: 100%;
} }
</style> </style>

Loading…
Cancel
Save