课程新增

This commit is contained in:
2024-05-14 14:46:12 +08:00
parent 338de0ac5d
commit 6638f02de6
3 changed files with 111 additions and 92 deletions

View File

@@ -328,7 +328,7 @@ export default {
methods: { methods: {
init(row) { init(row) {
console.log("11111", row); console.log("11111", row);
if (row.id) { if (row&&row.id) {
this.$http this.$http
.request({ .request({
url: this.$http.adornUrl(this.urlList.info), url: this.$http.adornUrl(this.urlList.info),

View File

@@ -1,8 +1,5 @@
<template> <template>
<div <div style="width: 100%; height: 100%;">
style="width: 100%; height: 100%;"
>
<!-- <el-form <!-- <el-form
:inline="true" :inline="true"
:model="dataForm" :model="dataForm"
@@ -85,7 +82,6 @@
border border
size="mini" size="mini"
v-loading="dataListLoading" v-loading="dataListLoading"
style="width: 100%" style="width: 100%"
> >
<!-- <el-table-column <!-- <el-table-column
@@ -97,12 +93,7 @@
> >
</el-table-column> --> </el-table-column> -->
<!-- --> <!-- -->
<el-table-column <el-table-column label="课程ID" width="70" align="center" prop="id">
label="课程ID"
width="70"
align="center"
prop="id"
>
<!-- <template slot-scope="scope"> <!-- <template slot-scope="scope">
{{ (pageIndex - 1) * pageSize + scope.$index + 1 }} {{ (pageIndex - 1) * pageSize + scope.$index + 1 }}
</template> --> </template> -->
@@ -114,6 +105,26 @@
label="课程名称" label="课程名称"
> >
</el-table-column> </el-table-column>
<el-table-column
prop="sort"
header-align="center"
align="center"
label="排序"
width="180"
>
<template slot-scope="scope">
<el-input
v-focus
v-if="scope.row[scope.column.property + 'Show']"
clearable
v-model="scope.row.sort"
@keyup.enter.native="onBlurFirst(scope.row, scope.column)"
@blur="onBlurFirst(scope.row, scope.column)"
>
</el-input>
<span v-else>{{ scope.row.sort }}</span>
</template>
</el-table-column>
<!-- <el-table-column <!-- <el-table-column
prop="product.price" prop="product.price"
width="120" width="120"
@@ -234,7 +245,7 @@
</div> </div>
</template> </template>
<script> <script>
// import chooseBook from './chooseBook.vue' // import chooseBook from './chooseBook.vue'
// import AddOrUpdate from './shopproduct-add-or-update' // import AddOrUpdate from './shopproduct-add-or-update'
export default { export default {
@@ -260,8 +271,8 @@ export default {
bookIds: [], bookIds: [],
selectShopArr: [], selectShopArr: [],
dataForm: { dataForm: {
keywords: "", keywords: ""
}, }
}; };
}, },
watch: { watch: {
@@ -273,28 +284,39 @@ export default {
console.log("🚀 ~ handler ~ val:", val); console.log("🚀 ~ handler ~ val:", val);
this.selectShopArr = []; this.selectShopArr = [];
this.$forceUpdate(); this.$forceUpdate();
}, }
}, }
}, },
components: { components: {
// AddOrUpdate, // AddOrUpdate,
// chooseBook // chooseBook
}, },
async activated() { async activated() {
this.multipleSelection = []; this.multipleSelection = [];
await this.getAssociatedGoodsList({ ...this.dataForm }); await this.getAssociatedGoodsList({ ...this.dataForm });
// await this.getGoodsTypeList(); // await this.getGoodsTypeList();
}, },
methods: { methods: {
shopDelete(row){ onBlurFirst(row, column) {
this.$emit('delete',row) //由于修改的数据只会让合并列的第一行数据改变,因此循环遍历列表修改相同类型的合并列的其余数据
this.associatedGoodsList.map(item => {
if (row.rootTargetCode == item.rootTargetCode) {
item.sort = Number(row.sort);
}
});
//修改原型数据
row[column.property + "Show"] = false;
this.updateTable();
},
shopDelete(row) {
this.$emit("delete", row);
}, },
// 获取商品类型 // 获取商品类型
getGoodsTypeList() { getGoodsTypeList() {
this.$http({ this.$http({
url: this.$http.adornUrl("/book/sysdictdata/selectByType/goodsType"), url: this.$http.adornUrl("/book/sysdictdata/selectByType/goodsType"),
method: "get", method: "get"
}).then(({ data }) => { }).then(({ data }) => {
// console.log(data.dataList) // console.log(data.dataList)
this.goodsTypeList = data.dataList; this.goodsTypeList = data.dataList;
@@ -306,14 +328,13 @@ this.$emit('delete',row)
// } else { // } else {
// this.selectShopArr = []; // this.selectShopArr = [];
// } // }
this.$emit('delete',this.associatedGoodsList,'all') this.$emit("delete", this.associatedGoodsList, "all");
this.$forceUpdate(); this.$forceUpdate();
}, },
selectShop(v) { selectShop(v) {
if (this.selectShopArr.includes(v.id)) { if (this.selectShopArr.includes(v.id)) {
this.selectShopArr = this.selectShopArr.filter(function (item) { this.selectShopArr = this.selectShopArr.filter(function(item) {
return item !== v.id; return item !== v.id;
}); });
} else { } else {
@@ -363,18 +384,18 @@ this.$emit('delete',row)
params: this.$http.adornParams({ params: this.$http.adornParams({
page: this.pageIndex, page: this.pageIndex,
limit: this.pageSize, limit: this.pageSize,
keywords: this.dataForm.keywords, keywords: this.dataForm.keywords
}), })
}).then(({ data }) => { }).then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.dataList = data.page.list; this.dataList = data.page.list;
console.log('this.dataList at line 372:', this.dataList) console.log("this.dataList at line 372:", this.dataList);
this.totalPage = data.page.totalPage; this.totalPage = data.page.totalPage;
} else { } else {
this.dataList = []; this.dataList = [];
this.totalPage = 0; this.totalPage = 0;
} }
this.$forceUpdate() this.$forceUpdate();
// setTimeout(async () => { // setTimeout(async () => {
// await this.setSelectRow(); // await this.setSelectRow();
// }, 200); // }, 200);
@@ -395,7 +416,7 @@ this.$emit('delete',row)
// if (this.currentType == "bookLabelId") { // if (this.currentType == "bookLabelId") {
// form.bookLabelId = this.currentId; // form.bookLabelId = this.currentId;
form.id = this.currentId; form.id = this.currentId;
console.log("🚀 ~ getAssociatedGoodsList ~ form:", form) console.log("🚀 ~ getAssociatedGoodsList ~ form:", form);
// } // }
// else if (this.currentType == "bookMarketId") { // else if (this.currentType == "bookMarketId") {
// form.bookMarketId = this.currentId; // form.bookMarketId = this.currentId;
@@ -411,10 +432,9 @@ this.$emit('delete',row)
page: 1, page: 1,
limit: 99999999, limit: 99999999,
...form
...form,
// bookLabelId: bookLabelId, // bookLabelId: bookLabelId,
}), })
}).then(async ({ data }) => { }).then(async ({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.associatedGoodsList = [...data.courseList]; this.associatedGoodsList = [...data.courseList];
@@ -452,7 +472,7 @@ this.$emit('delete',row)
deleteHandle(id) { deleteHandle(id) {
var ids = id var ids = id
? [id] ? [id]
: this.dataListSelections.map((item) => { : this.dataListSelections.map(item => {
return item.productId; return item.productId;
}); });
this.$confirm( this.$confirm(
@@ -461,13 +481,13 @@ this.$emit('delete',row)
{ {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning"
} }
).then(() => { ).then(() => {
this.$http({ this.$http({
url: this.$http.adornUrl("/book/shopproduct/delete"), url: this.$http.adornUrl("/book/shopproduct/delete"),
method: "post", method: "post",
data: this.$http.adornData(ids, false), data: this.$http.adornData(ids, false)
}).then(({ data }) => { }).then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message({ this.$message({
@@ -476,7 +496,7 @@ this.$emit('delete',row)
duration: 1500, duration: 1500,
onClose: () => { onClose: () => {
this.getDataList(); this.getDataList();
}, }
}); });
} else { } else {
this.$message.error(data.msg); this.$message.error(data.msg);
@@ -488,33 +508,32 @@ this.$emit('delete',row)
/*点击时他会自动把你绑定的值变更,直接去请求数据就可以了*/ /*点击时他会自动把你绑定的值变更,直接去请求数据就可以了*/
var parms = { var parms = {
publishStatus: event.publishStatus, publishStatus: event.publishStatus,
productId: event.productId, productId: event.productId
}; };
// console.log(parms) // console.log(parms)
this.$http({ this.$http({
url: this.$http.adornUrl("/book/shopproduct/update"), url: this.$http.adornUrl("/book/shopproduct/update"),
method: "post", method: "post",
data: parms, data: parms
}) })
.then((res) => { .then(res => {
this.$message({ this.$message({
message: "成功", message: "成功",
type: "success", type: "success"
}); });
this.loading = false; this.loading = false;
this.getDataList(); this.getDataList();
}) })
.catch((error) => { .catch(error => {
this.loading = false; this.loading = false;
console.log(error); console.log(error);
}); });
console.log(event); console.log(event);
}, }
}, }
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
li { li {
padding: 0; padding: 0;
@@ -609,4 +628,3 @@ li {
padding: 6px !important; padding: 6px !important;
} }
</style> </style>

View File

@@ -50,6 +50,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="title" header-align="center" align="center" label="课程名称"> <el-table-column prop="title" header-align="center" align="center" label="课程名称">
</el-table-column> </el-table-column>
<!-- <el-table-column prop="price" width="120" header-align="center" align="center" sortable label="价格"> <!-- <el-table-column prop="price" width="120" header-align="center" align="center" sortable label="价格">
</el-table-column> </el-table-column>
<el-table-column prop="activityPrice" width="120" header-align="center" align="center" sortable label="活动价"> <el-table-column prop="activityPrice" width="120" header-align="center" align="center" sortable label="活动价">