课程绑定

This commit is contained in:
2024-05-11 11:21:06 +08:00
parent d30e19e446
commit 515817103b
5 changed files with 494 additions and 176 deletions

View File

@@ -1,6 +1,8 @@
<template>
<div class="commonShopproduct" :style="`width: 100%; height: 100%; margin-top: -50px`">
<div
class="commonShopproduct"
:style="`width: 100%; height: 100%; margin-top: -50px`"
>
<!-- <el-form
:inline="true"
:model="dataForm"
@@ -29,9 +31,14 @@
<div class="search_form">
<div class="addFormBox shopFormBox">
<el-form ref="addForm" label-width="80px" :model="dataForm">
<slot name="searchFormItem" :dataForm="dataForm" v-if="!isNoSearch"></slot>
<slot
name="searchFormItem"
:dataForm="dataForm"
v-if="!isNoSearch"
></slot>
<el-form-item v-if="!isNoSearch"
<el-form-item
v-if="!isNoSearch"
label=""
class="form_item"
label-width="20px"
@@ -159,7 +166,7 @@ export default {
"isEdit",
"currentId",
"currentType",
"isNoSearch",
"isNoSearch"
],
data() {
return {
@@ -306,29 +313,50 @@ export default {
},
// 获取关联数据列表
async getAssociatedGoodsList() {
console.log("🚀 ~ getAssociatedGoodsList ~ form:", form);
console.log("🚀 ~ getAssociatedGoodsList ~ form:11111", form);
var form = { ...this.defaultForm, ...this.dataForm };
this.dataListLoading = true;
await this.$http({
url: this.$http.adornUrl(`${this.urlList.getAssociatedGoodsList}`),
method: "post",
data: this.$http.adornData({
current: 1,
limit: 99999999,
...form
})
}).then(async ({ data }) => {
if (data && data.code === 0) {
this.associatedGoodsList = [...data.result.records];
if (this.defaultForm.httpType == "raw") {
this.$http
.request({
url: this.$http.adornUrl(`${this.urlList.hasBindProductList}`),
method: "POST",
data: {
productId: this.defaultForm.productId
},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json"
}
})
.then(async ({ data }) => {
if (data && data.code === 0) {
this.associatedGoodsList = [...data[this.defaultForm.httpDataValueName]];
this.dataListLoading = false;
}
});
this.dataListLoading = false;
}
});
} else {
await this.$http({
url: this.$http.adornUrl(`${this.urlList.getAssociatedGoodsList}`),
method: "post",
data: this.$http.adornData({
current: 1,
limit: 99999999,
...form
})
}).then(async ({ data }) => {
if (data && data.code === 0) {
this.associatedGoodsList = [...data.result.records];
this.dataListLoading = false;
}
});
}
},
// 每页数
sizeChangeHandle(val) {

View File

@@ -39,6 +39,8 @@
</el-form-item>
</el-form>
</div>
<!-- @selection-change="handleSelectionChange" -->
<!-- @current-change="handleCurrentChange" -->
<el-table
ref="table"
height="calc(100% - 120px)"
@@ -48,26 +50,38 @@
size="mini"
highlight-current-row
v-loading="dataListLoading"
@selection-change="handleSelectionChange"
@current-change="handleCurrentChange"
style="width: 100%"
>
<el-table-column align="center" width="40px">
<!-- <el-table-column align="center" width="40px">
<template slot-scope="scope">
<el-radio v-model="currentRow" :label="scope.row"
>&nbsp;</el-radio
>
<!-- //或者是<el-radio v-model="currentRow" :label="scope.row"><i></i></el-radio> -->
</template>
</el-table-column>
</template>
</el-table-column> -->
<!-- <el-table-column :reserve-selection="true" type="selection" header-align="center" align="center" width="50">
</el-table-column> -->
<slot name="tableItem"></slot>
<el-table-column
header-align="center"
align="center"
label="操作"
width="80"
>
<template slot-scope="scope">
<el-button
type="text"
@click="handleCurrentChange(scope.row)"
size="mini"
>绑定</el-button
>
</template>
</el-table-column>
<!-- -->
</el-table>
<el-pagination
style="float: right;margin-top: 20px;"
style="float: right;margin-top: 20px;"
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
@@ -173,7 +187,7 @@ export default {
handleCurrentChange(val) {
console.log("🚀 ~ handleSelectionChange ~ val:", val);
this.$emit("submit", val.id);
this.$emit("submit", val.id,val);
// table组件选中事件,记得加上@selection-change="handleSelectionChange"
// this.multipleSelection = val;
@@ -216,7 +230,7 @@ export default {
var form = {
...this.defaultForm,
...this.dataForm,
current: this.pageIndex,
limit: this.pageSize
};
// form["marketId"] = this.currentId.toString();
@@ -231,24 +245,53 @@ export default {
// }
this.dataListLoading = true;
this.clear();
await this.$http({
url: this.$http.adornUrl(this.urlList.getNotToLabelList),
method: "post",
data: this.$http.adornData(form)
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataList = data.result.records;
this.totalPage = data.result.total;
} else {
this.dataList = [];
this.totalPage = 0;
}
// setTimeout(async () => {
// await this.setSelectRow();
// }, 200);
this.dataListLoading = false;
});
if (this.defaultForm.httpType == "raw") {
form.page = this.pageIndex;
this.$http
.request({
url: this.$http.adornUrl(`${this.urlList.CanBindProductList}`),
method: "POST",
data: {
...form
},
header: {
//默认 无 说明:请求头
"Content-Type": "application/json"
}
})
.then(({ data }) => {
if (data && data.code === 0) {
this.dataList = [...data.page[this.defaultForm.httpDataValueName]];
this.totalPage = data.page[this.defaultForm.httpDataTotalName];
} else {
this.dataList = [];
this.totalPage = 0;
}
// setTimeout(async () => {
// await this.setSelectRow();
// }, 200);
this.dataListLoading = false;
});
} else {
form.current = this.pageIndex;
await this.$http({
url: this.$http.adornUrl(this.urlList.getNotToLabelList),
method: "post",
data: this.$http.adornData(form)
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataList = data.result.records;
this.totalPage = data.result.total;
} else {
this.dataList = [];
this.totalPage = 0;
}
// setTimeout(async () => {
// await this.setSelectRow();
// }, 200);
this.dataListLoading = false;
});
}
},
clear() {
// this.$refs.table.clearSelection();