充值管理
This commit is contained in:
348
src/views/modules/recharge/rechargeList.vue
Normal file
348
src/views/modules/recharge/rechargeList.vue
Normal file
@@ -0,0 +1,348 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<div style="display: flex;align-items: center;">
|
||||
<p
|
||||
class="info_bg"
|
||||
style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis;margin-right: 20px;"
|
||||
>
|
||||
提示:以下充值商品只针对于<span style="color: #17b3a3; font-weight: 600"
|
||||
>【安卓】</span
|
||||
>平台
|
||||
</p>
|
||||
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-refresh "
|
||||
@click="
|
||||
pageIndex = 1;
|
||||
getDataList();
|
||||
"
|
||||
>刷新</el-button
|
||||
>
|
||||
<el-button
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="addOrUpdateHandle()"
|
||||
>新增</el-button
|
||||
>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
height="70vh"
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
@selection-change="selectionChangeHandle"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column label="ID" width="70" align="center" prop="priceTypeId">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="realMoney"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="充值金额"
|
||||
>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="money"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="天医币"
|
||||
>
|
||||
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="givejf"
|
||||
width="120"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="赠送积分"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="description"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="商品描述"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
width="200"
|
||||
prop="effective"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="有效时长"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.effective == '0'">
|
||||
长期有效
|
||||
</span>
|
||||
<span v-if="scope.row.effective == '1'">
|
||||
开始: {{ scope.row.startTime }}<br />
|
||||
结束: {{ scope.row.endTime }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="100"
|
||||
label="操作"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
size="small"
|
||||
@click.native="addOrUpdateHandle(scope.row.priceTypeId)"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
style="color:red"
|
||||
type="text"
|
||||
size="small"
|
||||
@click="deleteHandle(scope.row.priceTypeId)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
>
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update
|
||||
v-if="addOrUpdateVisible"
|
||||
ref="addOrUpdate"
|
||||
@refreshDataList="getDataList"
|
||||
@showchooseBookf="showchooseBookf"
|
||||
></add-or-update>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from "./views/add.vue";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dataForm: {
|
||||
key: "",
|
||||
qudao: "Android"
|
||||
},
|
||||
goodsTypeList: [
|
||||
{
|
||||
id: 0,
|
||||
title: "Android",
|
||||
value: "Android"
|
||||
}
|
||||
],
|
||||
dataList: [],
|
||||
publishStatus: false,
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false,
|
||||
chooseBookVisible: false,
|
||||
curriculumVisible: false,
|
||||
bookIds: [],
|
||||
LinkCouponVisible: false, // 显示优惠券弹窗
|
||||
curProductId: undefined // 当前的商品id
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate
|
||||
},
|
||||
activated() {
|
||||
this.getDataList();
|
||||
},
|
||||
methods: {
|
||||
showLinkCoupon(id) {
|
||||
this.curProductId = id;
|
||||
this.LinkCouponVisible = true;
|
||||
},
|
||||
proCouponClose() {
|
||||
this.LinkCouponVisible = false;
|
||||
},
|
||||
|
||||
handleEditTags(id) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.commonTags.open(id);
|
||||
});
|
||||
},
|
||||
handleEditCorrelation(id) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.correlation.open(id);
|
||||
});
|
||||
},
|
||||
closeBookf() {
|
||||
this.chooseBookVisible = false;
|
||||
},
|
||||
showchooseBookf(e) {
|
||||
// 显示图书列表
|
||||
this.chooseBookVisible = true;
|
||||
// console.log(this.bookIds,'this.bookIds')
|
||||
// this.$nextTick(() => {
|
||||
// this.$refs.chooseBook.getBookList()
|
||||
// this.bookIds = e.bookIds
|
||||
// })
|
||||
},
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true;
|
||||
|
||||
this.$http
|
||||
.request({
|
||||
url: this.$http.adornUrl(`/master/BuyConfig/getBookBuyConfigList`),
|
||||
|
||||
method: "POST",
|
||||
data: {
|
||||
page: this.pageIndex,
|
||||
limit: this.pageSize,
|
||||
type: "point",
|
||||
|
||||
qudao: this.dataForm.qudao
|
||||
},
|
||||
header: {
|
||||
//默认 无 说明:请求头
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
})
|
||||
.then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.result.records;
|
||||
this.totalPage = data.result.total;
|
||||
this.pageIndex = data.result.current;
|
||||
} else {
|
||||
this.dataList = [];
|
||||
this.totalPage = 0;
|
||||
this.pageIndex = 1;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.dataListLoading = false;
|
||||
}, 100);
|
||||
});
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle(val) {
|
||||
this.pageSize = val;
|
||||
this.pageIndex = 1;
|
||||
this.getDataList();
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle(val) {
|
||||
this.pageIndex = val;
|
||||
this.getDataList();
|
||||
},
|
||||
// 多选
|
||||
selectionChangeHandle(val) {
|
||||
this.dataListSelections = val;
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle(id) {
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
});
|
||||
},
|
||||
handleEditCurriculum(id) {
|
||||
this.curriculumVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.curriculum.init(id);
|
||||
});
|
||||
},
|
||||
// 删除
|
||||
deleteHandle(id) {
|
||||
var ids = id;
|
||||
|
||||
this.$confirm(
|
||||
`确定对[id=${ids}]进行[${id ? "删除" : "批量删除"}]操作?`,
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}
|
||||
).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/master/BuyConfig/delBookBuyConfig"),
|
||||
method: "post",
|
||||
data: this.$http.adornData({
|
||||
id: ids
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: "操作成功",
|
||||
type: "success",
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
SwitchChange(event) {
|
||||
/*点击时他会自动把你绑定的值变更,直接去请求数据就可以了*/
|
||||
var parms = {
|
||||
publishStatus: event.publishStatus,
|
||||
productId: event.productId
|
||||
};
|
||||
// console.log(parms)
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/book/shopproduct/update"),
|
||||
method: "post",
|
||||
data: parms
|
||||
})
|
||||
.then(res => {
|
||||
this.$message({
|
||||
message: "成功",
|
||||
type: "success"
|
||||
});
|
||||
this.loading = false;
|
||||
this.getDataList();
|
||||
})
|
||||
.catch(error => {
|
||||
this.loading = false;
|
||||
console.log(error);
|
||||
});
|
||||
console.log(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.info_bg {
|
||||
background: #e0dede;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
padding-left: 10px;
|
||||
// padding: 8px 5px;
|
||||
box-sizing: border-box;
|
||||
// margin-top: -10px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
width: calc(100% - 120px);
|
||||
float: left;
|
||||
}
|
||||
</style>
|
||||
486
src/views/modules/recharge/views/add.vue
Normal file
486
src/views/modules/recharge/views/add.vue
Normal file
@@ -0,0 +1,486 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.priceTypeId ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible"
|
||||
@close="handlereset"
|
||||
lock-scroll
|
||||
width="600px"
|
||||
>
|
||||
<el-form
|
||||
:model="dataForm"
|
||||
:rules="dataRule"
|
||||
ref="dataForm"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="充值金额" prop="realMoney">
|
||||
<el-input
|
||||
v-model="dataForm.realMoney"
|
||||
placeholder="充值金额"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="天医币" prop="money">
|
||||
<el-input v-model="dataForm.money" placeholder="天医币"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="商品描述" prop="description">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="dataForm.description"
|
||||
placeholder="商品描述"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="赠送积分" prop="givejf">
|
||||
<el-input style="width:100%" v-model="dataForm.givejf"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="有效时长" prop="effective">
|
||||
<el-radio v-model="dataForm.effective" :label="0">长期有效</el-radio>
|
||||
<el-radio v-model="dataForm.effective" :label="1">短期有效</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="开始时间"
|
||||
prop="startTime"
|
||||
v-if="dataForm.effective == 1"
|
||||
>
|
||||
<el-date-picker
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
v-model="dataForm.startTime"
|
||||
type="datetime"
|
||||
placeholder="选择开始时间"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="结束时间"
|
||||
prop="endTime"
|
||||
v-if="dataForm.effective == 1"
|
||||
>
|
||||
<el-date-picker
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
v-model="dataForm.endTime"
|
||||
type="datetime"
|
||||
placeholder="选择结束时间"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="handlereset">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
var validatePass = (rule, value, callback) => {
|
||||
console.log("rule at line 78:", rule);
|
||||
var title = rule.name;
|
||||
if (value == "" && rule.required) {
|
||||
callback(new Error(`请输入${title}`));
|
||||
} else {
|
||||
let regex = /^\d+(\.\d+)?$/;
|
||||
if (value <= 0 && rule.required) {
|
||||
callback(new Error(`${title}必须大于0`));
|
||||
}
|
||||
if (!regex.test(value)) {
|
||||
callback(new Error(`${title}只能包含数字`));
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
};
|
||||
return {
|
||||
pointMemery: [], // 花生币操作记录
|
||||
baseUrl: global.baseUrl,
|
||||
goodsTypeList: [],
|
||||
visible: false,
|
||||
categorys: [],
|
||||
fileList: [], // 封面图
|
||||
swiperfileList: [],
|
||||
dialogVisible: false,
|
||||
props: {
|
||||
value: "catId",
|
||||
label: "name",
|
||||
children: "children",
|
||||
checkStrictly: true
|
||||
},
|
||||
dataForm: {
|
||||
givejf: 0, // 赠送积分
|
||||
money: 0, // 充值金额
|
||||
realMoney: 0, // 优惠金额
|
||||
effective: 0, // 优惠金额
|
||||
type: "point", // 充值类型
|
||||
qudao: "Android", //
|
||||
|
||||
description: "", // 充值描述
|
||||
startTime: "", // 充值描述
|
||||
endTime: "" // 充值描述
|
||||
},
|
||||
bookidsd: [],
|
||||
dataRule: {
|
||||
description: [
|
||||
{
|
||||
required: true,
|
||||
message: "商品描述不能为空",
|
||||
trigger: "blur"
|
||||
}
|
||||
],
|
||||
money: [
|
||||
{
|
||||
required: true,
|
||||
message: "天医币不能为空",
|
||||
trigger: "blur"
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: validatePass,
|
||||
trigger: "blur",
|
||||
name: "天医币"
|
||||
}
|
||||
],
|
||||
realMoney: [
|
||||
{
|
||||
required: true,
|
||||
message: "充值金额不能为空",
|
||||
trigger: "blur"
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: validatePass,
|
||||
trigger: "blur",
|
||||
name: "充值金额"
|
||||
}
|
||||
],
|
||||
givejf: [
|
||||
{
|
||||
required: false,
|
||||
validator: validatePass,
|
||||
trigger: "blur",
|
||||
name: "赠送积分"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
changeRadio() {
|
||||
this.dataForm.startTime = "";
|
||||
this.dataForm.endTime = "";
|
||||
},
|
||||
contentUploadSuccess(res, file) {
|
||||
// console.log(res)
|
||||
let quill = this.$refs.myQuillEditor.quill;
|
||||
// 如果上传成功
|
||||
if (res) {
|
||||
// 获取光标所在位置
|
||||
let length = quill.getSelection().index;
|
||||
// 插入图片,res为服务器返回的图片链接地址
|
||||
quill.insertEmbed(length, "image", res.url);
|
||||
// 调整光标到最后
|
||||
quill.setSelection(length + 1);
|
||||
} else {
|
||||
// 提示信息,需引入Message
|
||||
this.$message.error("图片插入失败!");
|
||||
}
|
||||
},
|
||||
handleCheckedCitiesChange(value) {
|
||||
// console.log(value, 'value')
|
||||
},
|
||||
// 获取商品标签
|
||||
|
||||
showChooseBook() {
|
||||
// 显示图书列表
|
||||
this.$emit("showchooseBookf", { bookIds: this.dataForm.Books });
|
||||
|
||||
// console.log('发送指令')
|
||||
this.$bus.$emit("showchooseBook", { bookIds: this.dataForm.Books });
|
||||
},
|
||||
init(id) {
|
||||
this.dataForm = {
|
||||
givejf: 0, // 赠送积分
|
||||
money: 0, // 充值金额
|
||||
realMoney: 0, // 优惠金额
|
||||
effective: 0, // 优惠金额
|
||||
type: "point", // 充值类型
|
||||
qudao: "Android", //
|
||||
|
||||
description: "", // 充值描述
|
||||
startTime: "", //
|
||||
endTime: "" //
|
||||
};
|
||||
if (id) {
|
||||
this.dataForm.priceTypeId = id;
|
||||
}
|
||||
|
||||
this.visible = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$refs["dataForm"].resetFields();
|
||||
if (this.dataForm.priceTypeId) {
|
||||
this.$http
|
||||
.request({
|
||||
url: this.$http.adornUrl(
|
||||
`/master/BuyConfig/getBookBuyConfigById`
|
||||
),
|
||||
method: "POST",
|
||||
data: {
|
||||
id: this.dataForm.priceTypeId
|
||||
},
|
||||
header: {
|
||||
//默认 无 说明:请求头
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
})
|
||||
.then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm = {
|
||||
description: data.data.description,
|
||||
effective: data.data.effective,
|
||||
endTime: data.data.endTime,
|
||||
givejf: data.data.givejf,
|
||||
money: data.data.money,
|
||||
|
||||
priceTypeId: data.data.priceTypeId,
|
||||
qudao: data.data.qudao,
|
||||
realMoney: data.data.realMoney,
|
||||
startTime: data.data.startTime,
|
||||
|
||||
type: "point"
|
||||
};
|
||||
|
||||
data.data;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取商品类型
|
||||
getGoodsTypeList() {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/book/sysdictdata/selectByType/goodsType"),
|
||||
method: "get"
|
||||
}).then(({ data }) => {
|
||||
// console.log(data.dataList)
|
||||
this.goodsTypeList = data.dataList;
|
||||
});
|
||||
},
|
||||
// 删除图书
|
||||
deliteBook(index) {
|
||||
this.dataForm.Books.splice(index, 1);
|
||||
sessionStorage.setItem("Books", JSON.stringify(this.dataForm.Books));
|
||||
},
|
||||
dealImgChange(file, fileList) {
|
||||
this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg;
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs["dataForm"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.dataForm.realMoney == 0) {
|
||||
this.$message.error("充值金额不能为0");
|
||||
return false;
|
||||
}
|
||||
if (!this.dataForm.money) {
|
||||
this.$message.error("天医币不能为0");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.dataForm.effective == 1) {
|
||||
if (!this.dataForm.startTime || !this.dataForm.endTime) {
|
||||
this.$message.error("请选择时间");
|
||||
return false;
|
||||
}
|
||||
if (this.dataForm.startTime >= this.dataForm.endTime) {
|
||||
this.$message.error("开始时间不能大于结束时间");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(
|
||||
`/master/BuyConfig/saveOrUpdateBookBuyConfig`
|
||||
),
|
||||
method: "post",
|
||||
data: this.$http.adornData({ ...this.dataForm })
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: "操作成功",
|
||||
type: "success",
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false;
|
||||
this.$refs["dataForm"].resetFields();
|
||||
// this.$refs['dataForm'].reset()
|
||||
this.$emit("refreshDataList");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
changeTime(e) {
|
||||
console.log(e);
|
||||
},
|
||||
|
||||
getTreeList() {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/shopcategory/listTree`),
|
||||
method: "get",
|
||||
params: this.$http.adornParams()
|
||||
}).then(({ data }) => {
|
||||
this.categorys = data.data;
|
||||
});
|
||||
},
|
||||
handlePictureCardPreview(file) {
|
||||
this.dataForm.productImages = file.url;
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
bannerHandlePicSuccess(res, file) {
|
||||
// 轮播图上传成功
|
||||
if (res.msg == "success") {
|
||||
this.swiperfileList.push({
|
||||
name: file.name,
|
||||
url: res.url
|
||||
});
|
||||
// console.log(this.swiperfileList)
|
||||
this.$message.success("上传成功");
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
},
|
||||
// 字符串图片地址
|
||||
getStringImgUrl() {
|
||||
let arr = this.swiperfileList.map(item => item.url);
|
||||
if (arr.length <= 0) {
|
||||
return null;
|
||||
} else {
|
||||
return arr.toString();
|
||||
}
|
||||
},
|
||||
handlePicSuccess(res, file) {
|
||||
// console.log(res,'res')
|
||||
if (res.msg == "success") {
|
||||
this.dataForm.productImages = res.url;
|
||||
this.fileList.push({
|
||||
name: file.name,
|
||||
url: res.url
|
||||
});
|
||||
// console.log(this.dataForm.productImages,'productImages')
|
||||
this.$message.success("上传成功");
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
},
|
||||
bannerHandleRemove(file, fileList) {
|
||||
// 轮播图删除操作
|
||||
this.swiperfileList = fileList;
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
this.dataForm.productImages = "";
|
||||
this.fileList = [];
|
||||
this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg;
|
||||
},
|
||||
handlereset() {
|
||||
(this.fileList = []), (this.visible = false);
|
||||
this.dataForm.tagList = [];
|
||||
this.dataForm.Books = [];
|
||||
this.swiperfileList = [];
|
||||
this.$refs["dataForm"].resetFields();
|
||||
sessionStorage.setItem("Books", JSON.stringify([]));
|
||||
// this.$refs['dataForm'].reset()
|
||||
},
|
||||
// 失去焦点事件
|
||||
onEditorBlur(quill) {
|
||||
// console.log('editor blur!', quill)
|
||||
},
|
||||
// 获得焦点事件
|
||||
onEditorFocus(quill) {
|
||||
//console.log('editor focus!', quill)
|
||||
},
|
||||
// 准备富文本编辑器
|
||||
onEditorReady(quill) {
|
||||
// console.log('editor ready!', quill)
|
||||
}
|
||||
},
|
||||
components: {},
|
||||
mounted() {
|
||||
this.$bus.$on("haveBookIds", data => {
|
||||
sessionStorage.setItem("Books", JSON.stringify(data.bookIds));
|
||||
// console.log('haveBookIds',data)
|
||||
//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 = []);
|
||||
});
|
||||
},
|
||||
|
||||
watch: {
|
||||
"dataForm.effective": {
|
||||
handler(val, oldVal) {
|
||||
console.log("val at line 385:", val);
|
||||
if(val==0){
|
||||
this.dataForm.startTime = "";
|
||||
this.dataForm.endTime = "";
|
||||
}
|
||||
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
// .disUoloadSty {
|
||||
// .el-upload--picture-card {
|
||||
// display: none;
|
||||
// /* 上传按钮隐藏 */
|
||||
// }
|
||||
// }
|
||||
|
||||
// .el-form-item {
|
||||
// /deep/ .el-form-item__label {
|
||||
// font-size: 12px;
|
||||
// }
|
||||
// }
|
||||
|
||||
.el-uploadfeng {
|
||||
.el-upload-list__item {
|
||||
width: 95px;
|
||||
height: 95px;
|
||||
}
|
||||
|
||||
.el-upload--picture-card {
|
||||
width: 95px;
|
||||
height: 95px;
|
||||
line-height: 95px;
|
||||
}
|
||||
}
|
||||
|
||||
.shangpin_editor .ql-editor {
|
||||
height: 150px;
|
||||
}
|
||||
</style>
|
||||
348
src/views/modules/shop/recharge.vue
Normal file
348
src/views/modules/shop/recharge.vue
Normal file
@@ -0,0 +1,348 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
|
||||
<div style="display: flex;align-items: center;">
|
||||
<p
|
||||
class="info_bg"
|
||||
style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis;margin-right: 20px;"
|
||||
>
|
||||
提示:以下充值商品只针对于<span style="color: #17b3a3; font-weight: 600">【安卓】</span>平台
|
||||
</p>
|
||||
|
||||
<el-button
|
||||
size="mini"
|
||||
icon="el-icon-refresh "
|
||||
@click="
|
||||
pageIndex = 1;
|
||||
getDataList();
|
||||
"
|
||||
>刷新</el-button
|
||||
>
|
||||
<el-button
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="addOrUpdateHandle()"
|
||||
>新增</el-button
|
||||
>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<el-table
|
||||
height="70vh"
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
@selection-change="selectionChangeHandle"
|
||||
style="width: 100%"
|
||||
>
|
||||
|
||||
<el-table-column label="ID" width="70" align="center" prop="priceTypeId">
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="description"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="商品描述"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="money"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="天医币"
|
||||
>
|
||||
</el-table-column> <el-table-column
|
||||
prop="realMoney"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="充值金额"
|
||||
>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="givejf"
|
||||
width="160"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="赠送积分"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
width="120"
|
||||
|
||||
prop="effective"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="有效时长"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.effective == '0'">
|
||||
长期有效
|
||||
</span>
|
||||
<span v-if="scope.row.effective == '1'">
|
||||
{{ scope.row.startTime }}~
|
||||
{{ scope.row.endTime }}
|
||||
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="120"
|
||||
label="操作"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
size="small"
|
||||
@click.native="addOrUpdateHandle(scope.row.priceTypeId)"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
style="color:red"
|
||||
type="text"
|
||||
size="small"
|
||||
@click="deleteHandle(scope.row.priceTypeId)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
>
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dataForm: {
|
||||
key: "",
|
||||
qudao: "Android"
|
||||
},
|
||||
goodsTypeList: [
|
||||
{
|
||||
id: 0,
|
||||
title: "Android",
|
||||
value: "Android"
|
||||
}
|
||||
],
|
||||
dataList: [],
|
||||
publishStatus: false,
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false,
|
||||
chooseBookVisible: false,
|
||||
curriculumVisible: false,
|
||||
bookIds: [],
|
||||
LinkCouponVisible: false, // 显示优惠券弹窗
|
||||
curProductId: undefined // 当前的商品id
|
||||
};
|
||||
},
|
||||
components: {
|
||||
|
||||
},
|
||||
activated() {
|
||||
this.getDataList();
|
||||
},
|
||||
methods: {
|
||||
showLinkCoupon(id) {
|
||||
this.curProductId = id;
|
||||
this.LinkCouponVisible = true;
|
||||
},
|
||||
proCouponClose() {
|
||||
this.LinkCouponVisible = false;
|
||||
},
|
||||
|
||||
handleEditTags(id) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.commonTags.open(id);
|
||||
});
|
||||
},
|
||||
handleEditCorrelation(id) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.correlation.open(id);
|
||||
});
|
||||
},
|
||||
closeBookf() {
|
||||
this.chooseBookVisible = false;
|
||||
},
|
||||
showchooseBookf(e) {
|
||||
// 显示图书列表
|
||||
this.chooseBookVisible = true;
|
||||
// console.log(this.bookIds,'this.bookIds')
|
||||
// this.$nextTick(() => {
|
||||
// this.$refs.chooseBook.getBookList()
|
||||
// this.bookIds = e.bookIds
|
||||
// })
|
||||
},
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true;
|
||||
|
||||
this.$http
|
||||
.request({
|
||||
url: this.$http.adornUrl(`/master/BuyConfig/getBookBuyConfigList`),
|
||||
|
||||
method: "POST",
|
||||
data: {
|
||||
page: this.pageIndex,
|
||||
limit: this.pageSize,
|
||||
type: 'point',
|
||||
|
||||
qudao: this.dataForm.qudao
|
||||
},
|
||||
header: {
|
||||
//默认 无 说明:请求头
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
})
|
||||
.then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.result.records;
|
||||
this.totalPage = data.result.total;
|
||||
this.pageIndex = data.result.current;
|
||||
} else {
|
||||
this.dataList = [];
|
||||
this.totalPage = 0;
|
||||
this.pageIndex = 1;
|
||||
}
|
||||
setTimeout(()=>{
|
||||
this.dataListLoading = false;
|
||||
},100)
|
||||
|
||||
});
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle(val) {
|
||||
this.pageSize = val;
|
||||
this.pageIndex = 1;
|
||||
this.getDataList();
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle(val) {
|
||||
this.pageIndex = val;
|
||||
this.getDataList();
|
||||
},
|
||||
// 多选
|
||||
selectionChangeHandle(val) {
|
||||
this.dataListSelections = val;
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle(id) {
|
||||
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
});
|
||||
},
|
||||
handleEditCurriculum(id) {
|
||||
this.curriculumVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.curriculum.init(id);
|
||||
});
|
||||
},
|
||||
// 删除
|
||||
deleteHandle(id) {
|
||||
var ids = id
|
||||
|
||||
this.$confirm(
|
||||
`确定对[id=${ids}]进行[${id ? "删除" : "批量删除"}]操作?`,
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}
|
||||
).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/master/BuyConfig/delBookBuyConfig"),
|
||||
method: "post",
|
||||
data: this.$http.adornData({
|
||||
id:ids
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: "操作成功",
|
||||
type: "success",
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
SwitchChange(event) {
|
||||
/*点击时他会自动把你绑定的值变更,直接去请求数据就可以了*/
|
||||
var parms = {
|
||||
publishStatus: event.publishStatus,
|
||||
productId: event.productId
|
||||
};
|
||||
// console.log(parms)
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/book/shopproduct/update"),
|
||||
method: "post",
|
||||
data: parms
|
||||
})
|
||||
.then(res => {
|
||||
this.$message({
|
||||
message: "成功",
|
||||
type: "success"
|
||||
});
|
||||
this.loading = false;
|
||||
this.getDataList();
|
||||
})
|
||||
.catch(error => {
|
||||
this.loading = false;
|
||||
console.log(error);
|
||||
});
|
||||
console.log(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
.info_bg {
|
||||
background: #e0dede;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
padding-left: 10px;
|
||||
// padding: 8px 5px;
|
||||
box-sizing: border-box;
|
||||
// margin-top: -10px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
width: calc(100% - 120px);
|
||||
float: left;
|
||||
}
|
||||
</style>
|
||||
@@ -1,491 +0,0 @@
|
||||
<template>
|
||||
<el-dialog class="productsDialog" center :title="!dataForm.productId ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible"
|
||||
@close="handlereset" lock-scroll>
|
||||
<el-steps :active="steps" simple style="margin-bottom: 15px;">
|
||||
<el-step title="基本信息" icon="el-icon-edit"></el-step>
|
||||
<el-step title="商品详情" icon="el-icon-upload"></el-step>
|
||||
</el-steps>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm"
|
||||
label-width="100px">
|
||||
<div class="steps1" v-if="steps == 1">
|
||||
<el-form-item label="所属分类" prop="poids">
|
||||
<el-cascader v-model="dataForm.poids" :options="categorys" :props="props" clearable></el-cascader>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品类型" prop="goodsType">
|
||||
<el-select v-model="dataForm.goodsType" placeholder="请选择">
|
||||
<el-option v-for="item in goodsTypeList" :key="item.dictType" :label="item.dictValue" :value="item.dictType">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="商品名称" prop="productName">
|
||||
<el-input v-model="dataForm.productName" placeholder="商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品图" prop="productImages">
|
||||
<el-upload :limit="dataForm.limitCountImg" class="el-uploadfeng "
|
||||
:class="{ uoloadSty: dataForm.showBtnDealImg, disUoloadSty: dataForm.noneBtnImg }"
|
||||
:action= "baseUrl + '/oss/fileoss'" list-type="picture-card"
|
||||
:on-preview="handlePictureCardPreview" :file-list="fileList" :on-success="handlePicSuccess"
|
||||
accept=".jpeg,.jpg,.gif,.png" :on-remove="handleRemove">
|
||||
<i class="el-icon-plus"></i>
|
||||
</el-upload>
|
||||
<el-dialog :visible.sync="dialogVisible" :append-to-body="true">
|
||||
<img width="100%" :src="dataForm.productImages" alt="">
|
||||
</el-dialog>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品轮播图" prop="productImageList">
|
||||
<el-upload :limit="5" class="el-uploadfeng noneBtnImg"
|
||||
:class="{ uoloadSty: dataForm.showBtnDealImg, disUoloadSty: dataForm.noneBtnImg }"
|
||||
:action= "baseUrl + '/oss/fileoss'" list-type="picture-card"
|
||||
:on-preview="handlePictureCardPreview" :file-list="swiperfileList" :on-success="bannerHandlePicSuccess"
|
||||
accept=".jpeg,.jpg,.gif,.png" :on-remove="bannerHandleRemove">
|
||||
<i class="el-icon-plus"></i>
|
||||
</el-upload>
|
||||
<!-- <el-dialog :visible.sync="dialogVisible" :append-to-body="true">
|
||||
<img width="100%" :src="dataForm.productImageList" alt="">
|
||||
</el-dialog> -->
|
||||
<span>图片尺寸:600*600px,支持图片类型:.jpeg,.jpg,.gif,.png, 最多上传5张图片</span>
|
||||
</el-form-item>
|
||||
<div>
|
||||
<el-form-item label="活动价" prop="price" style="width: 50%; float: left;">
|
||||
<el-input v-model="dataForm.price" placeholder="活动价"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品价格" prop="hDprice" style="width: 50%; float: left;">
|
||||
<el-input v-model="dataForm.hDprice" placeholder="商品价格"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品重量" prop="weight" style="width: 50%; float: right;">
|
||||
<el-input style="width: 80%;" v-model="dataForm.weight" placeholder="商品重量"></el-input><span
|
||||
style="display: inline-block; float: right; width: 10%;">克</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品库存" prop="productStock" style="width: 50%; float: right;">
|
||||
<el-input v-model="dataForm.productStock" placeholder="商品库存"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<!-- <el-form-item label="上架状态" prop="publishStatus">
|
||||
<el-input v-model="dataForm.publishStatus" placeholder="上架状态"></el-input>
|
||||
</el-form-item> -->
|
||||
<div>
|
||||
<el-form-item label="出版社" prop="publisher" style="width: 50%; float: left;">
|
||||
<el-input placeholder="出版社" v-model="dataForm.publisher"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="作者" prop="author" style="width: 50%; float: right;">
|
||||
<el-input placeholder="作者" v-model="dataForm.author"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div>
|
||||
<el-form-item label="出版时间" prop="pubDate" style="width: 50%; float: left;">
|
||||
<el-date-picker @change="changed" format="yyyy 年 MM 月 dd 日" v-model="dataForm.pubDate" type="date" placeholder="选择日期时间">
|
||||
</el-date-picker>
|
||||
<!-- <el-input placeholder="出版时间" v-model=""></el-input> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="页数" prop="pageNum" style="width: 50%; float: right;">
|
||||
<el-input placeholder="页数" v-model="dataForm.pageNum"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div>
|
||||
<el-form-item label="内文用纸材质" prop="quality" style="width: 50%; float: left;">
|
||||
<el-input v-model="dataForm.quality" placeholder="内文用纸材质"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="开本" prop="format" style="width: 50%; float: right;">
|
||||
<el-input v-model="dataForm.format" placeholder="16开或其他规格"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div style="clear: both;">
|
||||
<el-form-item label="是否包邮" prop="isFreeMail">
|
||||
<el-radio-group v-model="dataForm.isFreeMail">
|
||||
<el-radio :label="'0'">是</el-radio>
|
||||
<el-radio :label="'1'">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<!-- <el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="dataForm.sort" placeholder="排序"></el-input>
|
||||
</el-form-item> -->
|
||||
</div>
|
||||
<div></div>
|
||||
<div class="steps2" v-if="steps == 2">
|
||||
<div style="margin-bottom: 15px;"><b>商品详情</b></div>
|
||||
<quill-editor v-model="dataForm.productDetails" ref="myQuillEditor" height:400px :options="editorOption"
|
||||
@blur="onEditorBlur($event)" @focus="onEditorFocus($event)" @change="onEditorChange($event)"
|
||||
@ready="onEditorReady($event)">
|
||||
</quill-editor>
|
||||
</div>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<!-- <el-button @click="handlereset">取消</el-button> -->
|
||||
<el-button type="warning" @click="steps = 1" plain size="mini">添加基本信息</el-button>
|
||||
<el-button type="success" @click="steps = 2" plain size="mini">添加商品详情</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()" plain size="mini">确 定</el-button>
|
||||
<el-button type="default" @click="handlereset" plain size="mini">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { quillEditor } from 'vue-quill-editor'
|
||||
import global from '../../common/common.vue' //引入共用组间
|
||||
|
||||
import 'quill/dist/quill.core.css'
|
||||
import 'quill/dist/quill.snow.css'
|
||||
import 'quill/dist/quill.bubble.css'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
baseUrl:global.baseUrl,
|
||||
goodsTypeList: [],
|
||||
steps: 1,
|
||||
visible: false,
|
||||
categorys: [],
|
||||
fileList: [], // 封面图
|
||||
swiperfileList: [],
|
||||
dialogVisible: false,
|
||||
props: {
|
||||
value: "catId",
|
||||
label: "name",
|
||||
children: "children",
|
||||
checkStrictly: true
|
||||
},
|
||||
dataForm: {
|
||||
hDprice:null, // 活动价
|
||||
productId: 0,
|
||||
limitCountImg: 1, // 图片数量
|
||||
productImageList: '', // 轮播图
|
||||
showBtnDealImg: true,
|
||||
noneBtnImg: false,
|
||||
productName: '',
|
||||
productStock:null, // 商品库存
|
||||
price: '',
|
||||
author: '',
|
||||
publisher: '',
|
||||
weight: '',
|
||||
pubDate: '',
|
||||
format: '', // 开本
|
||||
isFreeMail:'', // 是否包邮
|
||||
pageNum: '',
|
||||
quality: '', // 内文用纸
|
||||
sumSales: null, // 总销量
|
||||
publishStatus: '',
|
||||
productPid: '',
|
||||
productImages: '',
|
||||
createTime: '',
|
||||
updateTime: '',
|
||||
delFlag: '',
|
||||
sort: '',
|
||||
goodsType: '', // 商品类型
|
||||
poids: []
|
||||
},
|
||||
dataRule: {
|
||||
productName: [
|
||||
{ required: true, message: '商品名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
price: [
|
||||
{ required: true, message: '商品价格不能为空', trigger: 'blur' }
|
||||
],
|
||||
weight: [
|
||||
{ required: true, message: '商品重量不能为空', trigger: 'blur' }
|
||||
],
|
||||
goodsType: [
|
||||
{ required: true, message: '商品类型不能为空', trigger: 'blur' }
|
||||
],
|
||||
poids: [
|
||||
{ required: true, message: '商品父id不能为空', trigger: 'blur' }
|
||||
],
|
||||
productImages: [
|
||||
{ required: true, message: '商品图不能为空', trigger: 'blur' }
|
||||
],
|
||||
productDetails: [
|
||||
{ required: true, message: '商品详情不能为空', trigger: 'blur' }
|
||||
],
|
||||
productStock: [
|
||||
{ required: true, message: '商品库存不能为空', trigger: 'blur' }
|
||||
],
|
||||
// updateTime: [
|
||||
// { required: true, message: '更新时间不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
// delFlag: [
|
||||
// { required: true, message: '删除标记不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
// sort: [
|
||||
// { required: true, message: '排序不能为空', trigger: 'blur' }
|
||||
// ]
|
||||
},
|
||||
// 富文本编辑器配置
|
||||
editorOption: {
|
||||
modules: {
|
||||
toolbar: [
|
||||
['bold', 'italic', 'underline', 'strike'], // 加粗 斜体 下划线 删除线
|
||||
['blockquote', 'code-block'], // 引用 代码块
|
||||
[{ header: 1 }, { header: 2 }], // 1、2 级标题
|
||||
[{ list: 'ordered' }, { list: 'bullet' }], // 有序、无序列表
|
||||
[{ script: 'sub' }, { script: 'super' }], // 上标/下标
|
||||
[{ indent: '-1' }, { indent: '+1' }], // 缩进
|
||||
[{ direction: 'rtl' }], // 文本方向
|
||||
[{ size: ['12', '14', '16', '18', '20', '22', '24', '28', '32', '36'] }], // 字体大小
|
||||
[{ header: [1, 2, 3, 4, 5, 6] }], // 标题
|
||||
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
|
||||
// [{ font: ['songti'] }], // 字体种类
|
||||
[{ align: [] }], // 对齐方式
|
||||
['clean'], // 清除文本格式
|
||||
['image', 'video'] // 链接、图片、视频
|
||||
]
|
||||
},
|
||||
placeholder: '请输入正文'
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTreeList()
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.productId = id || 0
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.productId) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/shopproduct/info/${this.dataForm.productId}`),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams()
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm.productName = data.shopProduct.productName
|
||||
this.dataForm.price = data.shopProduct.price
|
||||
this.dataForm.goodsType = data.shopProduct.goodsType
|
||||
this.dataForm.weight = data.shopProduct.weight
|
||||
this.dataForm.publishStatus = data.shopProduct.publishStatus
|
||||
this.dataForm.productPid = data.shopProduct.productPid
|
||||
this.dataForm.productImages = data.shopProduct.productImages
|
||||
this.dataForm.createTime = data.shopProduct.createTime
|
||||
this.dataForm.updateTime = data.shopProduct.updateTime
|
||||
this.dataForm.delFlag = data.shopProduct.delFlag
|
||||
this.dataForm.sort = data.shopProduct.sort
|
||||
this.dataForm.publisher= data.shopProduct.publisher
|
||||
this.dataForm.author = data.shopProduct.author
|
||||
this.dataForm.pubDate = data.shopProduct.pubDate
|
||||
this.dataForm.pageNum = data.shopProduct.pageNum
|
||||
this.dataForm.quality = data.shopProduct.quality
|
||||
this.dataForm.format = data.shopProduct.format
|
||||
this.dataForm.isFreeMail = data.shopProduct.isFreeMail
|
||||
this.dataForm.productDetails = data.shopProduct.productDetails
|
||||
this.dataForm.poids = data.shopProduct.poids
|
||||
this.dataForm.productStock = data.shopProduct.productStock
|
||||
this.dataForm.hDprice = data.shopProduct.activityPrice
|
||||
if (data.shopProduct.productImages != "") {
|
||||
var img = { name: '', url: data.shopProduct.productImages }
|
||||
var attr = []
|
||||
attr.push(img)
|
||||
this.fileList = attr
|
||||
}
|
||||
if (data.shopProduct.productImageList == null || data.shopProduct.productImageList[0] == '' || data.shopProduct.productImageList == "") {
|
||||
return this.swiperfileList = []
|
||||
}else{
|
||||
// 有轮播图
|
||||
console.log(data.shopProduct.productImageList)
|
||||
let arr = []
|
||||
let arr1 = []
|
||||
|
||||
arr = data.shopProduct.productImageList.split(',');
|
||||
console.log(arr)
|
||||
arr.forEach((item, index) => {
|
||||
arr1.push({ name: index, url: item })
|
||||
});
|
||||
this.swiperfileList = arr1
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取商品类型
|
||||
getGoodsTypeList() {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/sysdictdata/selectByType/goodsType'),
|
||||
method: 'get',
|
||||
}).then(({ data }) => {
|
||||
console.log(data.dataList)
|
||||
this.goodsTypeList = data.dataList
|
||||
})
|
||||
},
|
||||
dealImgChange(file, fileList) {
|
||||
this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg;
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
this.dataForm.productImageList = this.getStringImgUrl()
|
||||
// console.log(this.dataForm.productImageList)
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/shopproduct/${!this.dataForm.productId ? 'save' : 'update'}`),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
'productId': this.dataForm.productId || undefined,
|
||||
'productName': this.dataForm.productName,
|
||||
'price': this.dataForm.price,
|
||||
'weight': this.dataForm.weight,
|
||||
'publishStatus': this.dataForm.publishStatus,
|
||||
'productPid': this.dataForm.poids[this.dataForm.poids.length - 1],
|
||||
'productImages': this.dataForm.productImages,
|
||||
'productImageList': this.dataForm.productImageList,
|
||||
'createTime': this.dataForm.createTime,
|
||||
'updateTime': this.dataForm.updateTime,
|
||||
'delFlag': this.dataForm.delFlag,
|
||||
'sort': this.dataForm.sort,
|
||||
'goodsType': this.dataForm.goodsType,
|
||||
'productDetails': this.dataForm.productDetails,
|
||||
'author': this.dataForm.author,
|
||||
'publisher': this.dataForm.publisher,
|
||||
'pubDate': this.dataForm.pubDate,
|
||||
'format': this.dataForm.format, // 开本
|
||||
'isFreeMail' : this.dataForm.isFreeMail,
|
||||
'pageNum': this.dataForm.pageNum,
|
||||
'quality': this.dataForm.quality, // 内文用纸
|
||||
'productStock' : this.dataForm.productStock , // 库存
|
||||
'activityPrice' : this.dataForm.hDprice
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.$refs['dataForm'].reset()
|
||||
this.$emit('refreshDataList')
|
||||
this.steps = 1
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
changed(e){
|
||||
console.log(e)
|
||||
},
|
||||
getTreeList() {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/shopcategory/listTree`),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams()
|
||||
}).then(({ data }) => {
|
||||
this.categorys = data.data;
|
||||
})
|
||||
},
|
||||
handlePictureCardPreview(file) {
|
||||
this.dataForm.productImages = file.url;
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
bannerHandlePicSuccess(res, file) {
|
||||
// 轮播图上传成功
|
||||
if (res.msg == "success") {
|
||||
this.swiperfileList.push({ name: file.name, url: res.url })
|
||||
console.log(this.swiperfileList)
|
||||
this.$message.success("上传成功");
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
},
|
||||
// 字符串图片地址
|
||||
getStringImgUrl() {
|
||||
let arr = this.swiperfileList.map(item => item.url)
|
||||
if(arr.length <= 0){
|
||||
return null
|
||||
}else{
|
||||
return arr.toString()
|
||||
}
|
||||
},
|
||||
handlePicSuccess(res, file) {
|
||||
// console.log(res,'res')
|
||||
if (res.msg == "success") {
|
||||
this.dataForm.productImages = res.url;
|
||||
this.fileList.push({ name: file.name, url: res.url })
|
||||
// console.log(this.dataForm.productImages,'productImages')
|
||||
this.$message.success("上传成功");
|
||||
} else {
|
||||
this.$message.error("上传失败");
|
||||
}
|
||||
},
|
||||
bannerHandleRemove(file, fileList) {
|
||||
// 轮播图删除操作
|
||||
this.swiperfileList = fileList
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
this.dataForm.productImages = '';
|
||||
this.dataForm.noneBtnImg = fileList.length >= this.dataForm.limitCountImg;
|
||||
},
|
||||
handlereset() {
|
||||
this.fileList = [],
|
||||
this.visible = false
|
||||
this.swiperfileList = []
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.$refs['dataForm'].reset()
|
||||
},
|
||||
// 失去焦点事件
|
||||
onEditorBlur(quill) {
|
||||
console.log('editor blur!', quill)
|
||||
},
|
||||
// 获得焦点事件
|
||||
onEditorFocus(quill) {
|
||||
console.log('editor focus!', quill)
|
||||
},
|
||||
// 准备富文本编辑器
|
||||
onEditorReady(quill) {
|
||||
console.log('editor ready!', quill)
|
||||
},
|
||||
// 内容改变事件
|
||||
onEditorChange({ quill, html, text }) {
|
||||
console.log('editor change!', quill, html, text)
|
||||
this.content = html
|
||||
}
|
||||
},
|
||||
components: {
|
||||
quillEditor
|
||||
},
|
||||
watch: {
|
||||
visible: {
|
||||
handler(val, oldVal) {
|
||||
this.getGoodsTypeList()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
.productsDialog{height: 800px; overflow-y: scroll;}
|
||||
.disUoloadSty {
|
||||
.el-upload--picture-card {
|
||||
display: none;
|
||||
/* 上传按钮隐藏 */
|
||||
}
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
/deep/ .el-form-item__label {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-uploadfeng {
|
||||
/deep/ .el-upload-list__item {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
/deep/ .el-upload--picture-card {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
line-height: 70px;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user