Commit 2d0a211e by cwq0219

商品编辑-规格值

1 parent 4d4414f5
......@@ -97,14 +97,14 @@
</div>
</div>
<template slot="proSpecsBtn">
<el-button :disabled="routeInfo.addOrEdit == 3" type="primary" @click="handleSpecsEdit(scope)">添加规格</el-button>
<el-button :disabled="routeInfo.addOrEdit == 3" type="primary" @click="handleSpecsEdit(1)">添加规格</el-button>
</template>
<div slot="proSpecs" style="margin-left: 110px;">
<div v-for="(subItem, subIndex) in specificationDetailList" :key="subIndex">
<div>
<span>规格名:</span>
<span>{{ subItem.specificationName }}</span>
<el-button v-show="!disabled" type="text" @click="handleSpecsEdit(2, subItem, index)">编辑</el-button>
<el-button v-show="!disabled" type="text" @click="handleSpecsEdit(2, subItem, subIndex)">编辑</el-button>
<el-button v-show="!disabled" type="text" @click="handleSpecsDelete(subIndex)">删除</el-button>
</div>
<div class="flex">
......@@ -176,6 +176,18 @@
<el-dialog :visible.sync="isImgVisible">
<img class="dialog-img" width="100%" :src="dialogImageUrl" alt="" />
</el-dialog>
<glsx-dialog title="规格" :isVisible.sync="isSpescVisible" width="70%" @confirmDialog="handleSpescConfirm" @closeDialog="handleSpescClose">
<el-form label-width="120px" :model="spescEditForm" :rules="spescRules" ref="spescRef">
<el-form-item label="规格名:" prop="specificationName">
<el-input class="w-320" :size="size" v-model="spescEditForm.specificationName" placeholder="请输入规格名"></el-input>
</el-form-item>
<el-form-item label="规格值:" prop="specificationValueList">
<el-tag style="margin-right: 10px;" v-for="(tag, i) in spescEditForm.specificationValueList" :key="i" closable :type="tag.type" @close="handleSpescDelete(tag)">{{ tag.specificationValue }}</el-tag>
<el-input class="input-new-tag" v-if="specsInputVisible" v-model="spescInputVal" ref="saveSpescInput" :size="size" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm"></el-input>
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 规格值</el-button>
</el-form-item>
</el-form>
</glsx-dialog>
<relate-store-dialog v-if="relateStoreVisible" ref="relateStore" :relateStoreVisible="relateStoreVisible" :storeApi="storeApi" :storeSearchForm="storeSearchForm" :storeSelected="selectedList" @handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose">
<el-row slot>
<el-form :model="storeSearchForm" ref="relate" :inline="true" label-width="90px">
......@@ -238,14 +250,25 @@ export default {
specificationDetailList: [],
nameToValSpecsList: [],
minRetailPrice: '',
// specsTableParams: {
// tableColumns: [
// {
// label: '码数',
// prop: ''
// }
// ]
// },
// 添加规格弹窗
isSpescVisible: false,
spescRules: {
specificationName: [
{ required: true, message: '请输入规格名', trigger: 'blur' },
{ validator: (rule, value, callback) => {
return this.spescData.curSpeceNameList.some(item => item == value) ? callback(new Error('规格名重复')) : callback()
}, trigger: 'blur'
}
],
specificationValueList: [{ required: true, message: '请输入规格值', trigger: 'change' }]
},
spescData: {
status: '',
curSpeceNameList: []
},
spescEditForm: {},
specsInputVisible: false,
spescInputVal: '',
// 表单
editForm: {
goodsName: '',
......@@ -549,6 +572,19 @@ export default {
this.externalFormList[1].editFormData[idx].isHide = !!this.editForm.specificationList.length
})
},
// 二次确认
secondSimpleConfirm(title, txt, fn) {
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
fn && fn()
}
}
})
},
// 选择门店
handleRelateStoreClose() {
this.selectedList = this.$common.utils.deepClone(this.editForm.supplyMerchantList)
......@@ -563,16 +599,9 @@ export default {
this.$refs.relateStore.handleCurrentChange(1)
},
handleMerchantDelete(obj) {
this.$messageBox.confirm('是否删除该门店?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
var idx = this.editForm.supplyMerchantList.findIndex(item => item.merchantNo == obj.scope.merchantNo)
this.editForm.supplyMerchantList.splice(idx, 1)
}
}
this.secondSimpleConfirm('删除', '是否删除该门店?', () => {
var idx = this.editForm.supplyMerchantList.findIndex(item => item.merchantNo == obj.scope.merchantNo)
this.editForm.supplyMerchantList.splice(idx, 1)
})
},
// 找最小规格值
......@@ -586,6 +615,7 @@ export default {
},
// 规格值解构
changeSpecs(isRecovery) {
this.specsWidth = (100 / ( this.specificationDetailList.length + 2 )) + '%'
this.nameToValSpecsList = []
var markIdx = 0
for (var i = 0; i < this.specificationDetailList.length; i++) {
......@@ -620,8 +650,8 @@ export default {
}
}
}
console.log(this.nameToValSpecsList)
console.log(this.specificationDetailList)
// console.log(this.nameToValSpecsList)
// console.log(this.specificationDetailList)
if (isRecovery) {
this.nameToValSpecsList.forEach((item, index) => {
var specificationObj = {}
......@@ -639,7 +669,7 @@ export default {
}
})
}
console.log(this.nameToValSpecsList)
// console.log(this.nameToValSpecsList)
},
setLocaleCompare(params) {
......@@ -655,6 +685,63 @@ export default {
return obj.join('&').replace(/,/g, '-')
},
// 规格弹窗
handleSpescDelete(tag) {
this.spescEditForm.specificationValueList.splice(this.spescEditForm.specificationValueList.indexOf(tag), 1);
},
showInput() {
this.specsInputVisible = true
this.$nextTick(_ => {
this.$refs.saveSpescInput.$refs.input.focus()
});
},
handleInputConfirm() {
let spescInputVal = this.spescInputVal
if (this.spescEditForm.specificationValueList.length == 8) {
this.$message({
message: '规格值最多不能超过8个',
type: 'error',
customClass: 'zZindex'
})
return true
}
if (this.spescEditForm.specificationValueList.findIndex(i => i.specificationValue == spescInputVal) != -1) {
this.$message({
message: spescInputVal + '规格值已经存在',
type: 'error',
customClass: 'zZindex'
})
return true
}
if (spescInputVal) {
this.spescEditForm.specificationValueList.push({ specificationValue: spescInputVal })
}
this.specsInputVisible = false
this.spescInputVal = ''
},
handleSpescConfirm() {
this.$refs.spescRef.validate(valid => {
if (valid) {
if (this.spescData.status == 1) {
this.specificationDetailList.push(this.spescEditForm)
} else {
this.specificationDetailList[this.spescData.targetIdx] = this.spescEditForm
}
this.editForm.retailPrice = ''
this.editForm.goodsStock = ''
this.handleSpescClose()
this.changeSpecs(false)
}
})
},
handleSpescClose() {
this.isSpescVisible = !this.isSpescVisible
},
// 添加规格status(1 - 新增;2 - 编辑)
handleSpecsEdit(status, targetItem, targetIdx) {
if (status == 1 && this.specificationDetailList.length >= 5) {
......@@ -670,39 +757,27 @@ export default {
curSpeceNameList.push(item.specificationName)
}
})
var params = {
this.spescData = {
// 1 - 新增;2 - 编辑
status: status,
targetIdx: targetIdx,
curSpeceNameList: curSpeceNameList
}
if (status == 2) {
params.formData = JSON.parse(JSON.stringify(targetItem))
}
// $uibModal.open({
// templateUrl: 'biz/mallManage/view/model/editSpecsModel.html',
// controller: 'editSpecsModel',
// size: 'lg',
// resolve: {
// specsConfig: function () {
// return params
// }
// }
// }).result.then(function (specsForm) {
// //关闭弹框后执行方法
// if (status == 1) {
// $scope.specificationDetailList.push(specsForm)
// $scope.specsWidth = (100 / ($scope.specificationDetailList.length + 2)) + '%'
// } else {
// $scope.specificationDetailList[targetIdx] = specsForm
// }
// $scope.formData.retailPrice = ''
// $scope.formData.goodsStock = ''
// changeSpecs(false)
// }, function () {});
this.spescEditForm = status == 2 ? this.$common.utils.deepClone(targetItem) : { specificationName: '', specificationValueList: [] }
console.log(this.spescEditForm)
this.handleSpescClose()
},
// 删除规格值
handleSpecsDelete(index) {
this.secondSimpleConfirm('删除', '是否删除该规格?', () => {
this.specificationDetailList.splice(index, 1)
this.changeSpecs(false)
})
},
// 恢复规格值
recoverySpec() {
this.specsWidth = (100 / ( this.specificationDetailList.length + 2 )) + '%'
this.changeSpecs(true)
},
// 恢复商品描述
......@@ -826,15 +901,8 @@ export default {
this.editForm.descImgList.splice(idx, 1)
},
handleImgDelete(attrName, subIndex) {
this.$messageBox.confirm('是否删除该图片?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
this.editForm[attrName].splice(subIndex, 1)
}
}
this.secondSimpleConfirm('删除', '是否删除该图片?', () => {
this.editForm[attrName].splice(subIndex, 1)
})
},
handleImgLook(src) {
......@@ -906,4 +974,23 @@ export default {
.edit-pro .table-spesc .el-input--small .el-input__inner {
text-align: center !important;
}
.edit-pro .w-320 {
width: 320px;
}
/* .el-tag + .el-tag {
margin-left: 10px;
} */
.button-new-tag {
height: 32px;
line-height: 30px;
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
vertical-align: bottom;
}
.zZindex {
z-index: 3000 !important;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!