|
|
@@ -48,8 +48,8 @@
|
|
|
<div class="titleInfo">售卖信息</div>
|
|
|
<div style="padding:0 20px;">
|
|
|
<el-form-item label="规格">
|
|
|
- <el-button type="primary" size="small" plain @click="dialogVisibleSpec = true"
|
|
|
- style="margin-bottom: 15px;">编辑</el-button>
|
|
|
+ <el-button type="primary" size="small" plain @click="specEditFun"
|
|
|
+ style="margin-bottom: 15px;" :disabled="title == '详情'?true:false" >编辑</el-button>
|
|
|
<tableCompontent :maxHeight="'400px'" :border="true" ref="tableRef1"
|
|
|
:tableData="this.formInline.specList" :columnData="columnData1">
|
|
|
</tableCompontent>
|
|
|
@@ -73,13 +73,15 @@
|
|
|
<el-form-item :prop="`skuList[${scope.$index}].pricePoint`"
|
|
|
:rules="{ required: true, message: '请输入', trigger: 'blur' }">
|
|
|
<div v-if="formInline.paymentType == 1 || formInline.paymentType == 2">
|
|
|
- <el-input-number v-model="scope.row.pricePoint" controls-position="right"
|
|
|
- :min="0"></el-input-number>
|
|
|
+ <el-input-number v-if="formInline.paymentType == 1" v-model="scope.row.pricePoint"
|
|
|
+ controls-position="right" :min="0"></el-input-number>
|
|
|
+ <el-input-number v-if="formInline.paymentType == 2" v-model="scope.row.priceMoney"
|
|
|
+ controls-position="right" :min="0"></el-input-number>
|
|
|
<span>{{ formInline.paymentType == 1 ? '积分' : '元' }}</span>
|
|
|
</div>
|
|
|
|
|
|
<div v-if="formInline.paymentType == 3" style="display: flex;width: 100%;">
|
|
|
- <el-input-number style="width:140px" v-model="scope.row.pricePoint" controls-position="right"
|
|
|
+ <el-input-number style="width:140px" v-model="scope.row.priceMoney" controls-position="right"
|
|
|
:min="0"></el-input-number>
|
|
|
<span>元 +</span>
|
|
|
<el-input-number style="width:140px" v-model="scope.row.pricePoint" controls-position="right"
|
|
|
@@ -117,7 +119,7 @@
|
|
|
<el-checkbox-group v-model="formInline.servicePromise" @change="handleCheckedChange">
|
|
|
<el-checkbox v-for="(item, index) in servicePromiseArr" :label="item.cdescribe" :key="index">{{
|
|
|
item.cdescribe
|
|
|
- }}
|
|
|
+ }}
|
|
|
</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
</el-form-item>
|
|
|
@@ -140,7 +142,7 @@
|
|
|
<!-- 操作按钮 -->
|
|
|
<div style="display: flex;justify-content: center;margin-top: 25px;">
|
|
|
<el-button @click="dialogVisibleSpec = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="specSetSave">保存</el-button>
|
|
|
+ <el-button type="primary" @click="specSetSave" >保存</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
@@ -148,7 +150,7 @@
|
|
|
|
|
|
<div style="display: flex;justify-content: center;margin-top: 25px;">
|
|
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="addOrEditOrDetailSave">保存</el-button>
|
|
|
+ <el-button type="primary" @click="addOrEditOrDetailSave" :disabled="title == '详情'?true:false" >保存</el-button>
|
|
|
<!-- <el-button type="primary" @click="previewFun">预览</el-button> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -163,7 +165,7 @@
|
|
|
import SavePreview from './savePreview.vue'
|
|
|
import tableCompontent from "@/components/tableCompontent/index.vue";
|
|
|
import Tinymce from "@/components/tinymce/index.vue";
|
|
|
-import { productSpecSetup, productGenerateProductNo, productSpecCombinations, productUpdate } from "@/api/points/pointsMall_api";
|
|
|
+import { productSpecSetup, productGenerateProductNo, productSpecCombinations, productUpdate, productCreate } from "@/api/points/pointsMall_api";
|
|
|
import { upload } from "@/api/public";
|
|
|
import { setTimeout } from "core-js";
|
|
|
export default {
|
|
|
@@ -305,6 +307,60 @@ export default {
|
|
|
})
|
|
|
|
|
|
},
|
|
|
+ //编辑规格按钮
|
|
|
+ specEditFun() {
|
|
|
+ //查询规格组合
|
|
|
+ if (this.formInline.productNo == null || this.formInline.productNo == '') {
|
|
|
+ this.$message.error("请先选择商品类型")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ productSpecCombinations({ productNo: this.formInline.productNo }).then(res => {
|
|
|
+ if (!res.data.length) {
|
|
|
+ this.dialogVisibleSpec = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.list2 = []
|
|
|
+ this.columnData2 = [{ label: '规格', prop: 'specName', type: 'editItem', tag: 'input', icon: 'el-icon-remove-outline', align: 'center' }]
|
|
|
+ let arr = res.data
|
|
|
+ const map = new Map();
|
|
|
+ arr.forEach(item => {
|
|
|
+ item.specNameValueList.forEach(spec => {
|
|
|
+ const key = spec.specName;
|
|
|
+ if (!map.has(key)) {
|
|
|
+ map.set(key, new Set());
|
|
|
+ }
|
|
|
+ map.get(key).add(spec.specValue);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ let maxSpecValueCount = 0;
|
|
|
+ // 2. 转成要的格式:specName + specValue1 + specValue2
|
|
|
+ map.forEach((valueSet, specName, index) => {
|
|
|
+ const values = Array.from(valueSet);
|
|
|
+ const obj = { specName: specName };
|
|
|
+ // 循环:自动加 specValue1、specValue2、specValue3...
|
|
|
+ values.forEach((val, index) => {
|
|
|
+ obj[`specValue${index + 1}`] = val;
|
|
|
+ });
|
|
|
+ maxSpecValueCount = Math.max(maxSpecValueCount, valueSet.size)
|
|
|
+
|
|
|
+ this.list2.push(obj); //生成展示页规格列表
|
|
|
+ });
|
|
|
+ for (let i = 1; i <= maxSpecValueCount; i++) {
|
|
|
+ this.columnData2.push({
|
|
|
+ prop: `specValue${i}`,
|
|
|
+ label: `规格值${i}`,
|
|
|
+ tag: 'input',
|
|
|
+ type: 'editItem',
|
|
|
+ headerIcon: 'el-icon-remove-outline',
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.dialogVisibleSpec = true
|
|
|
+ console.log(this.list2, 'this.list2')
|
|
|
+ console.log(this.columnData2, 'this.columnData2')
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
// 图片
|
|
|
handleImageSuccess(file) {
|
|
|
const formData = new FormData()
|
|
|
@@ -323,11 +379,39 @@ export default {
|
|
|
},
|
|
|
//预览后保存
|
|
|
savePreviewFun(params) {
|
|
|
- productUpdate(params).then(res => {
|
|
|
- this.$message.success(res.msg)
|
|
|
- this.dialogVisible = false
|
|
|
- this.$emit("getList");
|
|
|
- })
|
|
|
+ let obj = {}
|
|
|
+
|
|
|
+ obj.productNo = params.productNo
|
|
|
+ obj.categoryId = params.categoryId
|
|
|
+ obj.name = params.name
|
|
|
+ obj.productMainImage = params.productMainImage
|
|
|
+ obj.productImage = params.productImage
|
|
|
+ obj.summary = params.summary
|
|
|
+ obj.detail = params.detail
|
|
|
+ obj.specList = params.specList
|
|
|
+ obj.paymentType = params.paymentType
|
|
|
+ obj.skuList = params.skuList
|
|
|
+ obj.freight = params.freight
|
|
|
+ obj.deliveryTime = params.deliveryTime
|
|
|
+ obj.servicePromise = params.servicePromise
|
|
|
+ obj.saleStartTime = params.saleStartTime
|
|
|
+ obj.saleEndTime = params.saleEndTime
|
|
|
+ if (this.title == '详情' || this.title == '编辑') {
|
|
|
+ obj.id = params.id
|
|
|
+ productUpdate(obj).then(res => {
|
|
|
+
|
|
|
+ this.$message.success(res.msg)
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.$emit("getList");
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ productCreate(obj).then(res => {
|
|
|
+ this.$message.success(res.msg)
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.$emit("getList");
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
//新增、编辑、详情商品 ----保存
|
|
|
@@ -372,7 +456,7 @@ export default {
|
|
|
//获取商品编号
|
|
|
productGenerateProductNo({ categoryId: e }).then((res) => {
|
|
|
this.formInline.productNo = res.data
|
|
|
- //查询规格组合
|
|
|
+ // //查询规格组合
|
|
|
this.getSpecDetail(this.formInline.productNo)
|
|
|
});
|
|
|
|
|
|
@@ -425,9 +509,11 @@ export default {
|
|
|
//查询商品规格和规格明细
|
|
|
getSpecDetail() {
|
|
|
productSpecCombinations({ productNo: this.formInline.productNo }).then(res => {
|
|
|
+ if (!res.data.length) return
|
|
|
this.specDataReorganizeFun(res.data)
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
//拿到后端返回的规格组合数据--组装成页面需要的格式
|
|
|
specDataReorganizeFun(data) {
|
|
|
this.formInline.specList = []
|
|
|
@@ -438,9 +524,13 @@ export default {
|
|
|
arr.forEach(item => {
|
|
|
let obj = { specCombo: null, image: '', pricePoint: null, originPrice: null, stock: null }
|
|
|
obj.specCombo = item.specValueText
|
|
|
+ obj.originPrice = item.originPrice
|
|
|
+ obj.priceMoney = item.priceMoney
|
|
|
+ obj.pricePoint = item.pricePoint
|
|
|
+ obj.stock = item.stock
|
|
|
obj.image = item.image
|
|
|
- //生成规格明细table数据
|
|
|
- this.tableForm.skuList.push(obj)
|
|
|
+
|
|
|
+ this.tableForm.skuList.push(obj) //生成规格明细table数据
|
|
|
|
|
|
item.specNameValueList.forEach(spec => {
|
|
|
const key = spec.specName;
|
|
|
@@ -460,7 +550,8 @@ export default {
|
|
|
obj[`specValue${index + 1}`] = val;
|
|
|
});
|
|
|
maxSpecValueCount = Math.max(maxSpecValueCount, valueSet.size)
|
|
|
- this.formInline.specList.push(obj);
|
|
|
+
|
|
|
+ this.formInline.specList.push(obj); //生成展示页规格列表
|
|
|
});
|
|
|
for (let i = 1; i <= maxSpecValueCount; i++) {
|
|
|
this.columnData1.push({
|
|
|
@@ -468,7 +559,7 @@ export default {
|
|
|
label: `规格值${i}`,
|
|
|
});
|
|
|
}
|
|
|
- //console.log(this.formInline.skuList, 'this.formInline.skuList')
|
|
|
+ console.log(this.tableForm.skuList, 'this.tableForm.skuList')
|
|
|
},
|
|
|
//组装编辑规格table保存数据
|
|
|
specListReorganizeFun(data) {
|
|
|
@@ -524,6 +615,7 @@ export default {
|
|
|
newRow[col.prop] = "";
|
|
|
});
|
|
|
this.list2.push(newRow);
|
|
|
+ console.log(this.list2, this.columnData2, 'this.list2新增行')
|
|
|
},
|
|
|
|
|
|
// 2. 删除行
|
|
|
@@ -534,6 +626,7 @@ export default {
|
|
|
// 3. 新增列
|
|
|
addColumn() {
|
|
|
let colIndex = this.columnData2.length;
|
|
|
+ // 给每一行添加新列的空数据
|
|
|
let newCol = {
|
|
|
label: `规格值${colIndex}`,
|
|
|
prop: `specValue${colIndex}`,
|
|
|
@@ -542,13 +635,13 @@ export default {
|
|
|
headerIcon: 'el-icon-remove-outline',
|
|
|
align: 'center'
|
|
|
};
|
|
|
- this.columnData2.push(newCol);
|
|
|
|
|
|
- // 给每一行添加新列的空数据
|
|
|
+ this.columnData2.push(newCol);
|
|
|
this.list2.forEach(row => {
|
|
|
- row[newCol.prop] = "";
|
|
|
+ //row[newCol.prop] = "";
|
|
|
+ this.$set(row, row[newCol.prop], '')
|
|
|
+
|
|
|
});
|
|
|
- console.log(this.list2, this.columnData2, 'this.list2新增列')
|
|
|
},
|
|
|
|
|
|
// 4. 删除列
|