|
@@ -37,8 +37,11 @@ var articleEdit = new Vue({
|
|
|
// 状态
|
|
|
status: 0,
|
|
|
// 文章分类
|
|
|
- typeId: ''
|
|
|
+ typeId: '',
|
|
|
+ // 文章二级分类
|
|
|
+ childId: null,
|
|
|
},
|
|
|
+ hasSecondary: false, // 是否有二级分类
|
|
|
// 图片列表
|
|
|
articleImageList: [],
|
|
|
// 文章标签列表
|
|
@@ -47,6 +50,8 @@ var articleEdit = new Vue({
|
|
|
chooseLabels: [],
|
|
|
// 文章分类列表
|
|
|
articleTypeList: [],
|
|
|
+ // 文章二级分类列表
|
|
|
+ articleChildren: [],
|
|
|
// 待添加标签名
|
|
|
addLabelName: '',
|
|
|
/* 表单验证规则 */
|
|
@@ -84,7 +89,10 @@ var articleEdit = new Vue({
|
|
|
// 文章分类
|
|
|
typeId: [
|
|
|
{required: true, message: '请选择文章所属分类', trigger: 'change'}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ // childId: [
|
|
|
+ // {required: true, message: '请选择文章所属二级分类', trigger: 'change'}
|
|
|
+ // ]
|
|
|
},
|
|
|
formValidate: {},
|
|
|
variable: '',
|
|
@@ -170,7 +178,13 @@ var articleEdit = new Vue({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- handlerTypeId() {
|
|
|
+ handlerTypeId($event) {
|
|
|
+ this.onFocused()
|
|
|
+ this.onBlured()
|
|
|
+ this.articleChildren = this.articleTypeList.filter(i => i.typeId === $event)[0].articleTypes || []
|
|
|
+ this.formData.childId = null
|
|
|
+ },
|
|
|
+ handlerChildId() {
|
|
|
this.onFocused()
|
|
|
this.onBlured()
|
|
|
},
|
|
@@ -183,6 +197,7 @@ var articleEdit = new Vue({
|
|
|
},
|
|
|
// 设置表单初始数据
|
|
|
setFormData: function setFormData(shopArticle) {
|
|
|
+ const isParent = this.articleTypeList.filter(i => i.typeId === shopArticle.typeId).length > 0
|
|
|
for (var key in this.formData) {
|
|
|
if(key === 'labelIds' && shopArticle[key]){
|
|
|
this.formData[key] = shopArticle[key].split(',').map(v => parseInt(v));
|
|
@@ -190,6 +205,19 @@ var articleEdit = new Vue({
|
|
|
this.formData[key] = shopArticle[key];
|
|
|
}
|
|
|
}
|
|
|
+ if (!isParent) {
|
|
|
+ this.articleTypeList.forEach(i => {
|
|
|
+ if (i.articleTypes) {
|
|
|
+ i.articleTypes.forEach(e => {
|
|
|
+ if (e.typeId === shopArticle.typeId) {
|
|
|
+ this.articleChildren = i.articleTypes
|
|
|
+ this.formData.typeId = i.typeId
|
|
|
+ this.formData.childId = e.typeId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
// 初始化引导图
|
|
|
if (this.formData.guidanceImage) {
|
|
|
this.articleImageList = [{url: this.formData.guidanceImage}]
|
|
@@ -370,7 +398,9 @@ var articleEdit = new Vue({
|
|
|
onReallySave_new(params) {
|
|
|
let _this = this;
|
|
|
this.formData.shopId = this.shopId;
|
|
|
- SupplierApi.ArticleSubmitSave(this.formData, function (res) {
|
|
|
+ const form = JSON.parse(JSON.stringify(_this.formData))
|
|
|
+ form.typeId = form.childId || form.typeId;
|
|
|
+ SupplierApi.ArticleSubmitSave(form, function (res) {
|
|
|
if (res.code === 0) {
|
|
|
CAIMEI.dialog('自动保存成功');
|
|
|
_this.onFocused()
|
|
@@ -384,7 +414,9 @@ var articleEdit = new Vue({
|
|
|
onReallySave: function onReallySave() {
|
|
|
var _this = this;
|
|
|
this.formData.shopId = this.shopId;
|
|
|
- SupplierApi.ArticleSubmitSave(this.formData, function (res) {
|
|
|
+ const form = JSON.parse(JSON.stringify(_this.formData))
|
|
|
+ form.typeId = form.childId || form.typeId;
|
|
|
+ SupplierApi.ArticleSubmitSave(form, function (res) {
|
|
|
if (res.code === 0) {
|
|
|
CAIMEI.dialog('保存成功');
|
|
|
setTimeout(function () {
|