From ccffb66258be18f8ebb9632559d1df79ef50740f Mon Sep 17 00:00:00 2001 From: yulixing Date: Fri, 5 Jul 2019 17:54:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A0=E6=9D=90=E5=BA=93=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShareLib/index.vue | 77 +- src/views/games/details/share/edit.1.vue | 1212 ++++++++++++++++++++++ src/views/games/details/share/edit.vue | 60 +- 3 files changed, 1307 insertions(+), 42 deletions(-) create mode 100644 src/views/games/details/share/edit.1.vue diff --git a/src/components/ShareLib/index.vue b/src/components/ShareLib/index.vue index 33a5200..d529688 100644 --- a/src/components/ShareLib/index.vue +++ b/src/components/ShareLib/index.vue @@ -12,7 +12,10 @@ :gutter="24" class="mgb-20" > - + - + - + { this.imgList = data.records this.imgsNum = data.total + this.imgsSelected = [] + this.selectedData.imgs = [] }) .catch(err => { console.log(err) @@ -344,10 +365,17 @@ export default { type: 'image', url: url }) - .then(() => { + .then(data => { this.$message.success('图片上传成功!') this.imgCurrentPage = 1 - this.getImgs() + if (this.useAsCom) { + this.imgList.unshift(data.result) + this.selectedData.imgs = [data.result] + this.imgsSelected = [0] + this.imgsNum += 1 + } else { + this.getImgs() + } }) .catch(err => { this.$message.error('图片保存失败!') @@ -370,8 +398,14 @@ export default { const idx = this.imgsSelected.indexOf(index) this.imgsSelected.splice(idx, 1) } else { + // 用作组件则只可单选 + if (this.useAsCom) { + this.imgsSelected = [] + this.selectedData.imgs = [] + } this.imgsSelected.push(index) } + const selectedImgs = [] this.imgsSelected.map(item => { selectedImgs.push(this.imgList[item]) @@ -459,8 +493,16 @@ export default { }) }, textTableSelectionChange(val) { - this.textsSelected = val - this.selectedData.texts = val + if (this.useAsCom && val.length > 1) { + const temp = val.pop() + this.$refs.textTable.clearSelection() + this.$refs.textTable.toggleRowSelection(temp) + this.textsSelected = [temp] + this.selectedData.texts = [temp] + } else { + this.textsSelected = val + this.selectedData.texts = val + } }, textRowClick(row, column, event) { this.$refs.textTable.toggleRowSelection(row) @@ -531,11 +573,18 @@ export default { type: 'text', text: this.tempText }) - .then(() => { + .then(data => { this.$message.success('分享语保存成功!') this.tempText = '' this.textCurrentPage = 1 - this.getTexts() + + if (this.useAsCom) { + this.textList.unshift(data.result) + this.$refs.textTable.toggleRowSelection(this.textList[0]) + this.textsNum += 1 + } else { + this.getImgs() + } }) .catch(err => { this.$message.error('分享语保存成功!') @@ -601,6 +650,10 @@ export default { line-height: 0; text-align: center; } + +.hide-checkbox >>> .el-table th > .cell .el-checkbox__inner { + display: none; +} diff --git a/src/views/games/details/share/edit.1.vue b/src/views/games/details/share/edit.1.vue new file mode 100644 index 0000000..8c45b43 --- /dev/null +++ b/src/views/games/details/share/edit.1.vue @@ -0,0 +1,1212 @@ + + + + + + + + diff --git a/src/views/games/details/share/edit.vue b/src/views/games/details/share/edit.vue index ae648f0..ed5cf49 100644 --- a/src/views/games/details/share/edit.vue +++ b/src/views/games/details/share/edit.vue @@ -448,14 +448,21 @@ class="el-icon-plus uploader-icon" /> - 从素材库中选择 + 从素材库中选择 - 从素材库中选择 + 从素材库中选择 @@ -471,7 +478,6 @@ title="素材库" :visible.sync="modalLibVisible" width="700px" - append-to-body top="3vh" :before-close="closeLib" > @@ -483,13 +489,14 @@ 取 消 确 定 @@ -789,9 +796,7 @@ export default { if (data.errcode === 0) { this.$message.success('分享图保存成功!') this.$router.push( - `/games/details/${this.uid}/share/edit?id=${ - data.result._id - }` + `/games/details/${this.uid}/share/edit?id=${data.result._id}` ) } }) @@ -896,9 +901,7 @@ export default { this.$message.success('分享图保存成功!') this.$refs['shareForm'].clearValidate() this.$router.push( - `/games/details/${ - this.uid - }/share/edit?id=${shareId}&data_type=dev` + `/games/details/${this.uid}/share/edit?id=${shareId}&data_type=dev` ) }) .catch(err => { @@ -948,9 +951,7 @@ export default { this.$router.go(0) } else { this.$router.push( - `/games/details/${this.uid}/share/edit?id=${ - this.$route.query.id - }&data_type=pro` + `/games/details/${this.uid}/share/edit?id=${this.$route.query.id}&data_type=pro` ) } }, @@ -1108,13 +1109,14 @@ export default { share_image: '' } this.isNewGroup = true - this.openModalShareGroup() + this.openLib('share_img') + // this.openModalShareGroup() }, editShareGroup(group, index) { this.shareGroupForm = JSON.parse(JSON.stringify(group)) this.isNewGroup = false this.groupIndex = index - this.openModalShareGroup() + this.openLib('share_img') }, delShareGroup(index) { this.$confirm('是否要删除该分享组?', '提示', { @@ -1137,19 +1139,18 @@ export default { this.shareGroupForm.share_image = res.url }, saveShareGroup() { - this.$refs['shareGroupForm'].validate(valid => { - if (valid) { - if (this.isNewGroup) { - this.shareGroups.push(this.shareGroupForm) - this.closeModalShareGroup() - } else { - this.shareGroups.splice(this.groupIndex, 1, this.shareGroupForm) - this.closeModalShareGroup() - } - } else { - this.$message.error('请完整填写表单!') - } - }) + this.saveTempShare() + if (!this.shareGroupForm.share_word || !this.shareGroupForm.share_image) { + this.$message.error('必须选择一个分享图和一句分享语!') + return + } + if (this.isNewGroup) { + this.shareGroups.push(this.shareGroupForm) + this.closeLib() + } else { + this.shareGroups.splice(this.groupIndex, 1, this.shareGroupForm) + this.closeLib() + } }, uploadErr() { this.$message.error('图片上传失败!') @@ -1166,7 +1167,7 @@ export default { this.modalLibVisible = true setTimeout(() => { this.$refs.shareLib.switchTab(name) - }, 0); + }, 0) }, closeLib() { this.modalLibVisible = false @@ -1184,7 +1185,6 @@ export default { if (data.imgs.length > 0) { this.shareGroupForm.share_image = data.imgs[0].url } - this.closeLib() } } }