|
@@ -119,79 +119,62 @@ const edit = new Vue({
|
|
},
|
|
},
|
|
data: {
|
|
data: {
|
|
isPC: window.innerWidth > 768,
|
|
isPC: window.innerWidth > 768,
|
|
- referenceType: 1,
|
|
|
|
- dateType: 1,
|
|
|
|
- referenceDialog: false,
|
|
|
|
- referenceEditType: 'add',
|
|
|
|
- sm: null,
|
|
|
|
|
|
+ referenceType: 1, // 添加 | 引用参考资料类型
|
|
|
|
+ referenceDialog: false, // 参考资料表单弹窗
|
|
|
|
+ referenceEditType: 'add', // 参考资料编辑类型 add 添加 edit 编辑
|
|
|
|
+ contentEdit: null, // 编辑器
|
|
|
|
+ // 提交表单数据
|
|
formData: {
|
|
formData: {
|
|
|
|
+ authUserId:'',
|
|
id: '', // 词条id
|
|
id: '', // 词条id
|
|
name: '', // 词条名称
|
|
name: '', // 词条名称
|
|
alias: '', // 义项名
|
|
alias: '', // 义项名
|
|
- description: '', // 词条概述
|
|
|
|
- img: '', // 头图地址
|
|
|
|
|
|
+ discription: '', // 词条概述
|
|
|
|
+ image: '', // 头图地址
|
|
typeId: '', // 分类id
|
|
typeId: '', // 分类id
|
|
seoKeyword: '', // seo关键字
|
|
seoKeyword: '', // seo关键字
|
|
status: 0, // 状态0保存草稿箱 1已发布
|
|
status: 0, // 状态0保存草稿箱 1已发布
|
|
- imageList: [], // 概述图册集合
|
|
|
|
infoList: [], // 信息栏集合
|
|
infoList: [], // 信息栏集合
|
|
referenceList: [], // 参考资料集合
|
|
referenceList: [], // 参考资料集合
|
|
|
|
+ textInfoList: [],
|
|
|
|
+ imageList: [], // 概述图册集合
|
|
videoList: [], // 视频集合
|
|
videoList: [], // 视频集合
|
|
},
|
|
},
|
|
|
|
+ // 提交表单校验
|
|
rules: {
|
|
rules: {
|
|
name: [{required: true, message: '词条名称不能为空', trigger: ['blur']}],
|
|
name: [{required: true, message: '词条名称不能为空', trigger: ['blur']}],
|
|
alias: [{required: true, message: '词条名称不能为空', trigger: ['change']}],
|
|
alias: [{required: true, message: '词条名称不能为空', trigger: ['change']}],
|
|
- description: [{required: true, message: '词条名称不能为空', trigger: ['change']}],
|
|
|
|
|
|
+ discription: [{required: true, message: '词条名称不能为空', trigger: ['change']}],
|
|
img: [{required: true, message: '请上传词条头图', trigger: ['change']}],
|
|
img: [{required: true, message: '请上传词条头图', trigger: ['change']}],
|
|
|
|
+ typeId: [{required: true, message: '请选择词条分类', trigger: ['change']}],
|
|
|
|
+ status: [{required: true, message: '请选择词条发布状态', trigger: ['change']}],
|
|
},
|
|
},
|
|
- referenceList: [{
|
|
|
|
- id: 1,
|
|
|
|
- ctrlId: 'SDAJKLJ4642', // 关联id
|
|
|
|
- /* (网络资料) */
|
|
|
|
- referenceType: 1, // '参考类型资料(1.网络;2.著作;3.其他)'
|
|
|
|
- website: '网址',
|
|
|
|
- articleName: '文章名称',
|
|
|
|
- websiteName: '网址名称',
|
|
|
|
- publishTimeStr: '发表时间',
|
|
|
|
- acitationTimeStr: '引文时间',
|
|
|
|
- /* 著作资料)*/
|
|
|
|
- author: '作者',
|
|
|
|
- workName: '著作名',
|
|
|
|
- publicationPlace: '出版地',
|
|
|
|
- press: '出版社',
|
|
|
|
- publicationYearStr: '出版年',
|
|
|
|
- acitationWeb: '引文编码',
|
|
|
|
- /* (其他资料) */
|
|
|
|
- referenceDescription: '参考资料说明',
|
|
|
|
- imageDescription: '图片描述',
|
|
|
|
- imageUrl: '图片地址',
|
|
|
|
- entryId: '词条id',
|
|
|
|
- entryType: '词条类型(先不传)'
|
|
|
|
- }],
|
|
|
|
|
|
+ // 参考资料信息表单
|
|
referenceData: {
|
|
referenceData: {
|
|
id: 1,
|
|
id: 1,
|
|
ctrlId: '', // 关联id
|
|
ctrlId: '', // 关联id
|
|
/* (网络资料) */
|
|
/* (网络资料) */
|
|
referenceType: 1, // '参考类型资料(1.网络;2.著作;3.其他)'
|
|
referenceType: 1, // '参考类型资料(1.网络;2.著作;3.其他)'
|
|
- website: '网址',
|
|
|
|
- articleName: '文章名称',
|
|
|
|
- websiteName: '网址名称',
|
|
|
|
- publishTimeStr: '发表时间',
|
|
|
|
- acitationTimeStr: '引文时间',
|
|
|
|
|
|
+ website: '',
|
|
|
|
+ articleName: '',
|
|
|
|
+ websiteName: '',
|
|
|
|
+ publishTimeStr: '',
|
|
|
|
+ acitationTimeStr: '',
|
|
/* 著作资料)*/
|
|
/* 著作资料)*/
|
|
- author: '作者',
|
|
|
|
- workName: '著作名',
|
|
|
|
- publicationPlace: '出版地',
|
|
|
|
- press: '出版社',
|
|
|
|
- publicationYearStr: '出版年',
|
|
|
|
- acitationWeb: '引文编码',
|
|
|
|
|
|
+ author: '',
|
|
|
|
+ workName: '',
|
|
|
|
+ publicationPlace: '',
|
|
|
|
+ press: '',
|
|
|
|
+ publicationYearStr: '',
|
|
|
|
+ acitationWeb: '',
|
|
/* (其他资料) */
|
|
/* (其他资料) */
|
|
- referenceDescription: '参考资料说明',
|
|
|
|
- imageDescription: '图片描述',
|
|
|
|
- imageUrl: '图片地址',
|
|
|
|
- entryId: '词条id',
|
|
|
|
- entryType: '词条类型(先不传)'
|
|
|
|
|
|
+ referenceDescription: '',
|
|
|
|
+ imageDescription: '',
|
|
|
|
+ imageUrl: '',
|
|
|
|
+ entryId: '',
|
|
|
|
+ entryType: ''
|
|
},
|
|
},
|
|
|
|
+ // 参考资料表单规则校验
|
|
referenceRule: {
|
|
referenceRule: {
|
|
referenceType: [{required: true, message: '请选择参考类型资料', trigger: ['change']}],
|
|
referenceType: [{required: true, message: '请选择参考类型资料', trigger: ['change']}],
|
|
website: [{required: true, message: '请输入网址', trigger: ['blur']}],
|
|
website: [{required: true, message: '请输入网址', trigger: ['blur']}],
|
|
@@ -203,46 +186,216 @@ const edit = new Vue({
|
|
publicationYearStr: [{required: true, message: '请输入出版年', trigger: ['blur']}],
|
|
publicationYearStr: [{required: true, message: '请输入出版年', trigger: ['blur']}],
|
|
referenceDescription: [{required: true, message: '请输入参考资料说明', trigger: ['blur']}],
|
|
referenceDescription: [{required: true, message: '请输入参考资料说明', trigger: ['blur']}],
|
|
},
|
|
},
|
|
|
|
+ // 上传文件列表
|
|
fileList: [],
|
|
fileList: [],
|
|
- coverList: []
|
|
|
|
|
|
+ // 上传封面列表
|
|
|
|
+ coverList: [],
|
|
|
|
+ //词条类型列表
|
|
|
|
+ typeList: [],
|
|
|
|
+ // 敏感词校验数据
|
|
|
|
+ formValidate: {}
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.formData.id = CAIMEI.getUrlParam('id')
|
|
|
|
+ this.fetchTypeList()
|
|
|
|
+ // 如果是编辑就获取表单数据
|
|
|
|
+ if(this.formData.id){
|
|
|
|
+ this.fetchEntryData()
|
|
|
|
+ }else{
|
|
|
|
+ this.initFormDataList()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted(){
|
|
|
|
+ $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
|
|
|
|
+ $('.navLayout').find('.navList').eq(3).addClass("on").find('.con').show().find('a').eq(0).addClass("on");
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ // 获取表单数据
|
|
|
|
+ fetchEntryData(){
|
|
|
|
+ const self = this
|
|
|
|
+ shopBikeApi.FetchEntryDetail({id: this.formData.id}, function(res){
|
|
|
|
+ self.initFormData(res.data)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 初始化表单数据
|
|
|
|
+ initFormData(data){
|
|
|
|
+ for (const key in this.formData) {
|
|
|
|
+ if(data.hasOwnProperty(key)){
|
|
|
|
+ this.formData[key] = data[key]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const imageList = this.formData.imageList.map(item =>{
|
|
|
|
+ return {url: item.image, type: 'image'}
|
|
|
|
+ })
|
|
|
|
+ const videoList = this.formData.videoList.map(item =>{
|
|
|
|
+ return {fileName: item.fileName, uuid: item.ossName, url: item.url, type: 'video'}
|
|
|
|
+ })
|
|
|
|
+ this.fileList = [...imageList, ...videoList]
|
|
|
|
+ if(this.formData.image){
|
|
|
|
+ this.coverList = [{ url: this.formData.image, type: 'image' }]
|
|
|
|
+ }
|
|
|
|
+ const infoSize = 4 - this.formData.infoList.length
|
|
|
|
+ const textInfoSize = 4 - this.formData.textInfoList.length
|
|
|
|
+ this.initFormDataList( infoSize, textInfoSize)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 获取图片列表
|
|
|
|
+ filterImageList(fileList) {
|
|
|
|
+ const imageList = fileList.filter(file => file.type.indexOf('image') > -1)
|
|
|
|
+ return imageList.map(file => ({entryId: '', image: file.url}))
|
|
|
|
+ },
|
|
|
|
+ // 获取视频列表
|
|
|
|
+ filterVideoList(fileList) {
|
|
|
|
+ const imageList = fileList.filter(file => file.type.indexOf('video') > -1)
|
|
|
|
+ return imageList.map(file => ({
|
|
|
|
+ entryId: '',
|
|
|
|
+ fileTitle: file.fileName,
|
|
|
|
+ fileName: file.fileName,
|
|
|
|
+ ossName: file.uuid,
|
|
|
|
+ ossUrl: file.url
|
|
|
|
+ }))
|
|
|
|
+ },
|
|
|
|
+ // 提交表单
|
|
|
|
+ async handleConfirm() {
|
|
|
|
+ try {
|
|
|
|
+ this.formData.authUserId = GLOBAL_SHOP_ID
|
|
|
|
+ this.formData.imageList = this.filterImageList(this.fileList)
|
|
|
|
+ this.formData.videoList = this.filterVideoList(this.fileList)
|
|
|
|
+ await this.$refs.ruleForm.validate()
|
|
|
|
+ const params = {
|
|
|
|
+ id: this.formData.id, // 词条id
|
|
|
|
+ name: this.formData.name, // 词条名称
|
|
|
|
+ alias: this.formData.alias, // 义项名
|
|
|
|
+ discription: this.formData.discription, // 词条概述
|
|
|
|
+ image: this.formData.image, // 头图地址
|
|
|
|
+ typeId: this.formData.typeId, // 分类id
|
|
|
|
+ seoKeyword: this.formData.seoKeyword, // seo关键字
|
|
|
|
+ status: this.formData.status, // 状态0保存草稿箱 1已发布
|
|
|
|
+ infoListStr: JSON.stringify(this.formData.infoList), // 信息栏集合
|
|
|
|
+ referenceListStr:JSON.stringify(this.formData.referenceList), // 参考资料集合
|
|
|
|
+ textInfoListStr: JSON.stringify(this.formData.textInfoList),
|
|
|
|
+ imageListStr: JSON.stringify(this.formData.imageList), // 概述图册集合
|
|
|
|
+ videoListStr:JSON.stringify(this.formData.videoList), // 视频集合
|
|
|
|
+ };
|
|
|
|
+ this.sensitiveWordsValidate(params)
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log(e)
|
|
|
|
+ this.socrllToErrorWord()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ /// 确定提交
|
|
|
|
+ onReallySave(params) {
|
|
|
|
+ const self = this
|
|
|
|
+ shopBikeApi.SaveEntrySumbit(params, function (res) {
|
|
|
|
+ CAIMEI.dialog('词条保存成功', false);
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ self.handleBack()
|
|
|
|
+ }, 500)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 获取词条分类
|
|
|
|
+ fetchTypeList() {
|
|
|
|
+ const slef = this
|
|
|
|
+ shopBikeApi.FetchTypeList(function (res) {
|
|
|
|
+ slef.typeList = res.data
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 初始化表单列表项数据
|
|
|
|
+ initFormDataList(infoSize = 4, textInfoSize = 4) {
|
|
|
|
+ for (let i = 0; i < infoSize; i++) {
|
|
|
|
+ this.formData.infoList.push(this.genereateInfo())
|
|
|
|
+ }
|
|
|
|
+ for (let i = 1; i < textInfoSize; i++) {
|
|
|
|
+ this.formData.textInfoList.push(this.genereateTextInfo(i))
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
// ref dialog 隐藏
|
|
// ref dialog 隐藏
|
|
handleRefDialogClose() {
|
|
handleRefDialogClose() {
|
|
this.referenceDialog = false
|
|
this.referenceDialog = false
|
|
this.referenceType = 1
|
|
this.referenceType = 1
|
|
},
|
|
},
|
|
// 提交确定ref
|
|
// 提交确定ref
|
|
- handleConfirmReference() {
|
|
|
|
- if (this.referenceEditType === 'add') {
|
|
|
|
- this.referenceData.ctrlId = this.sm.parcel()
|
|
|
|
- this.referenceList.push(deepClone(this.referenceData))
|
|
|
|
- } else {
|
|
|
|
- const index = this.referenceList.findIndex(ref => ref.ctrlId === this.referenceData.ctrlId);
|
|
|
|
- this.referenceList.splice(index, 1, deepClone(this.referenceData))
|
|
|
|
|
|
+ async handleConfirmReference() {
|
|
|
|
+ try {
|
|
|
|
+ await this.$refs.referenceForm.validate()
|
|
|
|
+ if (this.referenceEditType === 'add') {
|
|
|
|
+ this.referenceData.ctrlId = this.contentEdit.parcel()
|
|
|
|
+ this.formData.referenceList.push(deepClone(this.referenceData))
|
|
|
|
+ } else {
|
|
|
|
+ const index = this.formData.referenceList.findIndex(ref => ref.ctrlId === this.referenceData.ctrlId);
|
|
|
|
+ this.formData.referenceList.splice(index, 1, deepClone(this.referenceData))
|
|
|
|
+ }
|
|
|
|
+ this.referenceDialog = false
|
|
|
|
+ this.referenceEditType = 'add'
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log(e)
|
|
}
|
|
}
|
|
- this.referenceDialog = false
|
|
|
|
- this.referenceEditType = 'add'
|
|
|
|
},
|
|
},
|
|
- handleSelectReference(item) {
|
|
|
|
|
|
+ handleSelectReference(item, index) {
|
|
this.referenceDialog = false
|
|
this.referenceDialog = false
|
|
- this.sm.parcel(item.ctrlId)
|
|
|
|
|
|
+ this.contentEdit.parcel(item.ctrlId, index+1)
|
|
|
|
+ },
|
|
|
|
+ handleReferenceTypeChange(){
|
|
|
|
+ this.$refs.referenceForm.resetFields()
|
|
},
|
|
},
|
|
// ref tab 切换
|
|
// ref tab 切换
|
|
handleTabChange(index) {
|
|
handleTabChange(index) {
|
|
this.referenceType = index;
|
|
this.referenceType = index;
|
|
},
|
|
},
|
|
|
|
+ // 新增参考资料,从已有参考资料选取
|
|
handleToolbarClick(e) {
|
|
handleToolbarClick(e) {
|
|
- this.sm = e
|
|
|
|
|
|
+ this.contentEdit = e
|
|
this.referenceDialog = true
|
|
this.referenceDialog = true
|
|
},
|
|
},
|
|
|
|
+ // 参考资料修改
|
|
handleReferenceEdit(item) {
|
|
handleReferenceEdit(item) {
|
|
this.referenceEditType = 'edit'
|
|
this.referenceEditType = 'edit'
|
|
- this.referenceData = item
|
|
|
|
|
|
+ this.referenceData = deepClone(item)
|
|
this.referenceDialog = true
|
|
this.referenceDialog = true
|
|
},
|
|
},
|
|
|
|
+ // 参考资料删除
|
|
handleReferenceDelete(item) {
|
|
handleReferenceDelete(item) {
|
|
- this.referenceList = this.referenceList.filter(ref => ref.ctrlId !== item.ctrlId)
|
|
|
|
|
|
+ this.formData.referenceList = this.formData.referenceList.filter(ref => ref.ctrlId !== item.ctrlId)
|
|
|
|
+ },
|
|
|
|
+ // 信息栏数据
|
|
|
|
+ genereateInfo() {
|
|
|
|
+ return {
|
|
|
|
+ entryId: '',
|
|
|
|
+ infoName: '',
|
|
|
|
+ infoContent: '',
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 新增信息栏
|
|
|
|
+ handleInfoAdd() {
|
|
|
|
+ this.formData.infoList.push(this.genereateInfo())
|
|
|
|
+ },
|
|
|
|
+ // 删除信息栏
|
|
|
|
+ handleInfoRemove(index) {
|
|
|
|
+ this.formData.infoList.splice(index, 1)
|
|
|
|
+ },
|
|
|
|
+ // 正文目录数据
|
|
|
|
+ genereateTextInfo(type) {
|
|
|
|
+ let placeholderList = ['定义(一级目录)', '定义(二级目录)', '内容']
|
|
|
|
+ return {
|
|
|
|
+ id: '',
|
|
|
|
+ entryId: '',
|
|
|
|
+ dictionaryContent: '',
|
|
|
|
+ dictionaryType: type,
|
|
|
|
+ referenceId: '',
|
|
|
|
+ textType: '',
|
|
|
|
+ parentId: '',
|
|
|
|
+ placeholder: placeholderList[type - 1]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 添加正文目录
|
|
|
|
+ handleAddTextInfo(index, type) {
|
|
|
|
+ this.formData.textInfoList.splice(index + 1, 0, this.genereateTextInfo(type))
|
|
|
|
+ },
|
|
|
|
+ // 删除正文目录
|
|
|
|
+ handleRemoveTextInfo(index, type) {
|
|
|
|
+ this.formData.textInfoList.splice(index, 1)
|
|
},
|
|
},
|
|
// 文件上传成功
|
|
// 文件上传成功
|
|
handleUploadSuccess(fileList) {
|
|
handleUploadSuccess(fileList) {
|
|
@@ -255,15 +408,70 @@ const edit = new Vue({
|
|
// 封面上传成功
|
|
// 封面上传成功
|
|
handleCoverUploadSuccess(fileList) {
|
|
handleCoverUploadSuccess(fileList) {
|
|
this.coverList = fileList
|
|
this.coverList = fileList
|
|
- this.formData.img = fileList[0].url
|
|
|
|
|
|
+ this.formData.image = fileList[0].url
|
|
},
|
|
},
|
|
// 封面删除
|
|
// 封面删除
|
|
handleCoverRemove(file) {
|
|
handleCoverRemove(file) {
|
|
- this.formData.img = ''
|
|
|
|
|
|
+ this.formData.image = ''
|
|
this.coverList = this.coverList.filter(item => item.uuid !== file.uuid);
|
|
this.coverList = this.coverList.filter(item => item.uuid !== file.uuid);
|
|
},
|
|
},
|
|
- handleContentEditChange(html) {
|
|
|
|
- console.log(html)
|
|
|
|
- }
|
|
|
|
|
|
+ // 返回文章列表页面
|
|
|
|
+ handleBack() {
|
|
|
|
+ window.open('/supplier/encyclopedia/list.html', 'supplier-entry-list');
|
|
|
|
+ window.close();
|
|
|
|
+ },
|
|
|
|
+ // 敏感词校验
|
|
|
|
+ sensitiveWordsValidate(params) {
|
|
|
|
+ const whiteList = [];
|
|
|
|
+ const self = this;
|
|
|
|
+ SupplierApi.ShopBaikeProductWordsValidate({checkPoint: 2}, function (res) {
|
|
|
|
+ let flag = true
|
|
|
|
+ for (const key in params) {
|
|
|
|
+ if (!whiteList.includes(key)) {
|
|
|
|
+ const target = JSON.stringify(params[key])
|
|
|
|
+ const bool = new RegExp(res.data, 'g').test(target)
|
|
|
|
+ if (bool) {
|
|
|
|
+ const value = self.matchWords(target, res.data)
|
|
|
|
+ self.formValidate[key] = value
|
|
|
|
+ flag = false
|
|
|
|
+ } else {
|
|
|
|
+ self.formValidate[key] = ''
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (flag) return self.onReallySave(params)
|
|
|
|
+ const tip = '当前发布内容存在敏感词,已为您标记在输入框下方,请修改后,再进行保存发布,强行保存发布将会导致审核不通过!'
|
|
|
|
+ self.$confirm(tip, '提示', {confirmButtonText: '保存', cancelButtonText: '取消'}).then(function () {
|
|
|
|
+ self.onReallySave(params)
|
|
|
|
+ }).catch(function () {
|
|
|
|
+ console.log('修改敏感词')
|
|
|
|
+ self.socrllToErrorWord() // 滚动到提示处
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 匹配敏感词
|
|
|
|
+ matchWords(word, validate) {
|
|
|
|
+ const list = []
|
|
|
|
+ const matcher = word.matchAll(new RegExp(validate, 'g'))
|
|
|
|
+ let done = false
|
|
|
|
+ while (!done) {
|
|
|
|
+ const item = matcher.next()
|
|
|
|
+ done = item.done
|
|
|
|
+ if (item.value) {
|
|
|
|
+ list.push(item.value[0])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list.join(',')
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ socrllToErrorWord() {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ const scrollTop = $('.el-form-item__error').eq(0).parents('.el-form-item').offset().top
|
|
|
|
+ $('body,html').animate({
|
|
|
|
+ scrollTop: scrollTop - $('#globalHead').height() - 60
|
|
|
|
+ }, 800)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
}
|
|
}
|
|
})
|
|
})
|