This commit is contained in:
@fawn-nine
2023-09-20 16:29:14 +08:00
parent 67d56c8f76
commit a2bbe84f45
4 changed files with 50 additions and 23 deletions

View File

@@ -7,7 +7,7 @@
<!-- <el-form-item label="图书id" prop="bookId"> <!-- <el-form-item label="图书id" prop="bookId">
<el-input v-model="dataForm.bookId" placeholder="图书id"></el-input> <el-input v-model="dataForm.bookId" placeholder="图书id"></el-input>
</el-form-item> --> </el-form-item> -->
<el-form-item label="章节序号" prop="number" v-show="opName== 'update'"> <el-form-item label="章节序号" prop="number" >
<el-input style="width: 150px;" type="number" v-model="dataForm.number" placeholder="章节序号12..."></el-input> <el-input style="width: 150px;" type="number" v-model="dataForm.number" placeholder="章节序号12..."></el-input>
</el-form-item> </el-form-item>
<el-form-item label="章节" prop="chapter"> <el-form-item label="章节" prop="chapter">

View File

@@ -27,7 +27,9 @@
<img width="100%" :src="dataForm.productImages" alt=""> <img width="100%" :src="dataForm.productImages" alt="">
</el-dialog> </el-dialog>
</el-form-item> </el-form-item>
<el-form-item label="简介/描述" prop="bookdesc">
<el-input type="textarea" rows="4" v-model="dataForm.bookdesc"></el-input>
</el-form-item>
<el-form-item label="书评详情" prop="productDetails"> <el-form-item label="书评详情" prop="productDetails">
<quill-editor v-model="dataForm.productDetails" ref="myQuillEditor" :options="editorOption" <quill-editor v-model="dataForm.productDetails" ref="myQuillEditor" :options="editorOption"
@blur="onEditorBlur($event)" @focus="onEditorFocus($event)" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)"
@@ -79,6 +81,7 @@
title: '', title: '',
productPid: '', productPid: '',
productImages: '', productImages: '',
bookdesc:'',
shupingid:null, shupingid:null,
}, },
@@ -172,7 +175,7 @@
// console.log(data,666) // console.log(data,666)
if (data && data.code === 0) { if (data && data.code === 0) {
this.dataForm.title = data.BookForumArticlesEntity.title this.dataForm.title = data.BookForumArticlesEntity.title
this.dataForm.bookdesc = data.BookForumArticlesEntity.bookdesc
this.dataForm.productImages = data.BookForumArticlesEntity.image this.dataForm.productImages = data.BookForumArticlesEntity.image
this.dataForm.productDetails = data.BookForumArticlesEntity.content this.dataForm.productDetails = data.BookForumArticlesEntity.content
@@ -224,7 +227,8 @@
'image': this.dataForm.productImages, 'image': this.dataForm.productImages,
'content': this.dataForm.productDetails, 'content': this.dataForm.productDetails,
'userid': this.$store.state.user.id, 'userid': this.$store.state.user.id,
'id': this.dataForm.shupingid 'id': this.dataForm.shupingid,
'bookdesc': this.dataForm.bookdesc
}) })
}).then(({ }).then(({
data data

View File

@@ -3,8 +3,7 @@
<!-- 选择关联图书 --> <!-- 选择关联图书 -->
<el-dialog v-if="tableData.length > 0" <el-dialog v-if="tableData.length > 0"
title="请选择" title="请选择图书"
v-loading="loading"
:visible.sync="chooseBookVisible" :visible.sync="chooseBookVisible"
width="30%" width="30%"
:before-close="handleClose"> :before-close="handleClose">
@@ -16,9 +15,10 @@
<el-button @click="getBookList()">查询</el-button> <el-button @click="getBookList()">查询</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table <el-table
:data="tableData" :data="tableData"
stripe stripe
v-loading="loading"
ref="multipleTablebb" ref="multipleTablebb"
style="width: 100%" style="width: 100%"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
@@ -49,7 +49,7 @@
layout="total, sizes, prev, pager, next, jumper"> layout="total, sizes, prev, pager, next, jumper">
</el-pagination> </el-pagination>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="chooseBookVisible = false"> </el-button> <el-button @click="handleClose()"> </el-button>
<el-button type="primary" @click="submitBookIds"> </el-button> <el-button type="primary" @click="submitBookIds"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
@@ -92,7 +92,8 @@ export default {
if (data.bookIds.length > 0) { if (data.bookIds.length > 0) {
this.$nextTick(()=> { this.$nextTick(()=> {
//this.toggleSelection() // 获取到已选中的数据 //this.toggleSelection() // 获取到已选中的数据
this.oldSelected = data.bookIds this.oldSelected = data.bookIds
console.log('以前选中的部分')
console.log(this.oldSelected,'oldSelected') console.log(this.oldSelected,'oldSelected')
}) })
@@ -142,18 +143,21 @@ export default {
}) })
}) })
// if (this.oldSelected.length > 0) {
// this.selectedBooks.forEach(item => {
// this.$refs.multipleTablebb.toggleRowSelection(item, true);
// })
// }
}, },
submitBookIds() { submitBookIds() {
// 提交bookids // 提交bookids
this.$bus.$emit("haveBookIds", { 'bookIds': this.selectedBooks }); // console.log('新选择的:', this.selectedBooks)
var arr = []
if (this.oldSelected.length > 0) {
// console.log('有之前选中的数据', this.oldSelected)
arr = this.oldSelected
arr = arr.concat(this.selectedBooks)
} else {
arr = this.selectedBooks
}
// console.log('需要提交的数组', arr, this.selectedBooks)
this.$bus.$emit("haveBookIds", { 'bookIds': arr });
this.handleClose() this.handleClose()
}, },
handleSelectionChange(e) { handleSelectionChange(e) {
@@ -161,6 +165,8 @@ export default {
this.selectedBooks = e this.selectedBooks = e
}, },
handleClose() { // 关闭组件 handleClose() { // 关闭组件
this.oldSelected = [],
this.selectedBooks = []
this.$emit('closeBookf', false) this.$emit('closeBookf', false)
}, },
// 每页数 // 每页数

View File

@@ -461,8 +461,8 @@
// 'quality': this.dataForm.quality, // 内文用纸 // 'quality': this.dataForm.quality, // 内文用纸
'productStock': this.dataForm.productStock, // 库存 'productStock': this.dataForm.productStock, // 库存
'activityPrice': this.dataForm.hDprice, 'activityPrice': this.dataForm.hDprice,
'bookids': this.bookidsd, // 关联的图书 'bookids': this.bookidsd, // 关联的图书[12,13,45]
'bookidsimages': this.dataForm.Books // 关联的图书对象 // 'bookidsimages': this.dataForm.Books // 关联的图书对象
}) })
}).then(({ }).then(({
data data
@@ -582,8 +582,25 @@
mounted() { mounted() {
this.$bus.$on("haveBookIds", (data) => { this.$bus.$on("haveBookIds", (data) => {
sessionStorage.setItem('Books', JSON.stringify(data.bookIds)) sessionStorage.setItem('Books', JSON.stringify(data.bookIds))
// console.log('haveBookIds',data) // console.log('haveBookIds',data)
data.bookIds.length > 0 ? this.dataForm.Books = data.bookIds : this.dataForm.Books = [] //console.log(data.bookIds, '收到的数据')
var newarr = []
var ids = [] //哨兵数组
if (data.bookIds && data.bookIds.length > 0) {
ids[0] = data.bookIds[0].id
newarr[0] = data.bookIds[0]
// console.log(ids,'ids')
// newarr.push(data.bookIds[0])
for (let index = 0; index < data.bookIds.length; index++) {
if (!ids.includes(data.bookIds[index].id)) {
// console.log(data.bookIds[index].id, 'data.bookIds[index].id')
newarr.push(data.bookIds[index])
ids.push(data.bookIds[index].id)
}
}
}
// console.log(newarr,'newarr',ids)
data.bookIds.length > 0 ? this.dataForm.Books = newarr : this.dataForm.Books = []
}); });
}, },