Commit bd50bef2 by cwq0219

商品管理

1 parent 9bc0e935
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</span> </span>
<slot v-if="item.addHtml" :name="item.addHtml" :scope="item"></slot> <slot v-if="item.addHtml" :name="item.addHtml" :scope="item"></slot>
<div v-else-if="item.type === 'input'"> <div v-else-if="item.type === 'input'">
<el-input :placeholder="item.placeholder || '请输入' + item.label" v-model.trim="formObj[item.name]" :disabled="item.isDisabled" :maxlength="item.maxlength" :clearable="item.isClear || false" :type="item.inputType || 'text'" :rows="item.rows || 2" :style="{ width: item.width || 'auto' }" :show-word-limit="item.showLimit || false" :show-password="item.showPass || false" @keydown.native="e => handleInputDown(e, item)" @blur.native.capture="item.inputBlur"> <el-input :placeholder="item.placeholder || '请输入' + item.label" v-model.trim="formObj[item.name]" :disabled="item.isDisabled" :maxlength="item.maxlength" :clearable="item.isClear || false" :type="item.inputType || 'text'" :rows="item.rows || 2" :style="{ width: item.width || 'auto' }" :show-word-limit="item.showLimit || false" :show-password="item.showPass || false" @keydown.native="e => handleInputDown(e, item)" @blur.native.capture="handleInputBlur(e, item)">
<span v-if="item.prepend" slot="prepend">{{ item.prepend }}</span> <span v-if="item.prepend" slot="prepend">{{ item.prepend }}</span>
<span v-if="item.append" slot="append">{{ item.append }}</span> <span v-if="item.append" slot="append">{{ item.append }}</span>
</el-input> </el-input>
...@@ -170,6 +170,9 @@ export default { ...@@ -170,6 +170,9 @@ export default {
item.keyFn() item.keyFn()
} }
}, },
handleInputBlur(e, item) {
item.inputBlur && item.inputBlur(e, item)
},
// 图片 // 图片
handleUploadChange(e, targetItem) { handleUploadChange(e, targetItem) {
var reader = new FileReader() var reader = new FileReader()
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<p class="edit-sub-title">{{ item.title }}</p> <p class="edit-sub-title">{{ item.title }}</p>
<glsx-combi-form class="edit-form-container" ref="editFormRef" :labelWidth="labelWidth" :isBlock="true" :formRef="item.editChildRef" :formObj="editForm" :formData="item.editFormData" :formRules="item.editRule"> <glsx-combi-form class="edit-form-container" ref="editFormRef" :labelWidth="labelWidth" :isBlock="true" :formRef="item.editChildRef" :formObj="editForm" :formData="item.editFormData" :formRules="item.editRule">
<template slot="describeBtn"> <template slot="describeBtn">
<el-button :disabled="routeInfo.addOrEdit == 3" type="primary" @click="handleDescribeImgAdd">添加图片</el-button> <el-button :disabled="isDisabled" type="primary" @click="handleDescribeImgAdd">添加图片</el-button>
</template> </template>
<div :style="{ 'margin-left': labelWidth }" slot="descImgs" slot-scope="scope"> <div :style="{ 'margin-left': labelWidth }" slot="descImgs" slot-scope="scope">
<div v-for="(subItem, subIndex) in editForm[scope.scope.name]" :key="subIndex" class="flex"> <div v-for="(subItem, subIndex) in editForm[scope.scope.name]" :key="subIndex" class="flex">
...@@ -97,15 +97,15 @@ ...@@ -97,15 +97,15 @@
</div> </div>
</div> </div>
<template slot="proSpecsBtn"> <template slot="proSpecsBtn">
<el-button :disabled="routeInfo.addOrEdit == 3" type="primary" @click="handleSpecsEdit(1)">添加规格</el-button> <el-button :disabled="isDisabled" type="primary" @click="handleSpecsEdit(1)">添加规格</el-button>
</template> </template>
<div slot="proSpecs" style="margin-left: 110px;"> <div slot="proSpecs" style="margin-left: 110px;">
<div v-for="(subItem, subIndex) in specificationDetailList" :key="subIndex"> <div v-for="(subItem, subIndex) in specificationDetailList" :key="subIndex">
<div> <div>
<span>规格名:</span> <span>规格名:</span>
<span>{{ subItem.specificationName }}</span> <span>{{ subItem.specificationName }}</span>
<el-button v-show="!disabled" type="text" @click="handleSpecsEdit(2, subItem, subIndex)">编辑</el-button> <el-button v-show="!isDisabled" type="text" @click="handleSpecsEdit(2, subItem, subIndex)">编辑</el-button>
<el-button v-show="!disabled" type="text" @click="handleSpecsDelete(subIndex)">删除</el-button> <el-button v-show="!isDisabled" type="text" @click="handleSpecsDelete(subIndex)">删除</el-button>
</div> </div>
<div class="flex"> <div class="flex">
<span style="width: 56px;">规格值:</span> <span style="width: 56px;">规格值:</span>
...@@ -135,16 +135,16 @@ ...@@ -135,16 +135,16 @@
<td :style="{ width: specsWidth }" v-for="(n, idx) in subItem.specsValueList" :key="idx">{{ n }}</td> <td :style="{ width: specsWidth }" v-for="(n, idx) in subItem.specsValueList" :key="idx">{{ n }}</td>
<td :style="{ width: specsWidth }"> <td :style="{ width: specsWidth }">
<div v-if="routeInfo.groupOrStore == 1"> <div v-if="routeInfo.groupOrStore == 1">
<el-input :class="{ 'border-red': (!(subItem.retailPrice + '') || (+editForm.supplyPrice > +subItem.retailPrice)) && submitted }" placeholder="零售价" v-model="subItem.retailPrice" ng-blur="handleBlur()"> <el-input :disabled="isDisabled" :class="{ 'border-red': (!(subItem.retailPrice + '') || +editForm.supplyPrice > +subItem.retailPrice) && submitted }" placeholder="零售价" v-model="subItem.retailPrice" ng-blur="handleBlur()">
<el-popover v-show="(!(subItem.retailPrice + '') || (+editForm.supplyPrice > +subItem.retailPrice)) && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" :content="!(subItem.retailPrice + '') ? '零售价是必填项' :'零售价要大于供货价'"> <el-popover v-show="(!(subItem.retailPrice + '') || +editForm.supplyPrice > +subItem.retailPrice) && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" :content="!(subItem.retailPrice + '') ? '零售价是必填项' : '零售价要大于供货价'">
<i class="el-icon-warning color-red" slot="reference"></i> <i class="el-icon-warning color-red" slot="reference"></i>
</el-popover> </el-popover>
</el-input> </el-input>
</div> </div>
<el-input v-else placeholder="零售价" v-model="subItem.retailPrice" ng-blur="handleBlur()"></el-input> <el-input :disabled="isDisabled" v-else placeholder="零售价" v-model="subItem.retailPrice" ng-blur="handleBlur()"></el-input>
</td> </td>
<td :style="{ width: specsWidth }"> <td :style="{ width: specsWidth }">
<el-input placeholder="库存" v-model="subItem.stock" :class="{ 'border-red': !(subItem.stock + '') && submitted }"> <el-input :disabled="isDisabled" placeholder="库存" v-model="subItem.stock" :class="{ 'border-red': !(subItem.stock + '') && submitted }">
<el-popover v-show="!(subItem.stock + '') && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" content="库存是必填项"> <el-popover v-show="!(subItem.stock + '') && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" content="库存是必填项">
<i class="el-icon-warning color-red" slot="reference"></i> <i class="el-icon-warning color-red" slot="reference"></i>
</el-popover> </el-popover>
...@@ -165,12 +165,12 @@ ...@@ -165,12 +165,12 @@
<p>作为货源供给门店的价格</p> <p>作为货源供给门店的价格</p>
</template> </template>
<div slot="selectMerchant" slot-scope="scope" class="select-merchant"> <div slot="selectMerchant" slot-scope="scope" class="select-merchant">
<el-button :disabled="routeInfo.addOrEdit == 3" type="primary" @click="handleRelateStoreClose(scope)">{{ editForm.supplyMerchantList.length ? '更换' : '请选择' }}</el-button> <el-button :disabled="isDisabled" type="primary" @click="handleRelateStoreClose(scope)">{{ editForm.supplyMerchantList.length ? '更换' : '请选择' }}</el-button>
</div> </div>
<div slot="merchantTable" class="select-merchant"> <div slot="merchantTable" class="select-merchant">
<GLTable v-show="editForm.supplyMerchantList.length" :hasPage="false" :tableParams="tableParams" :tableData="editForm.supplyMerchantList"> <GLTable v-show="editForm.supplyMerchantList.length" :hasPage="false" :tableParams="tableParams" :tableData="editForm.supplyMerchantList">
<span slot="auth-button" slot-scope="scope"> <span slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleMerchantDelete(scope)">删除</el-button> <el-button :disabled="isDisabled" type="text" @click="handleMerchantDelete(scope)">删除</el-button>
</span> </span>
</GLTable> </GLTable>
</div> </div>
...@@ -231,6 +231,7 @@ export default { ...@@ -231,6 +231,7 @@ export default {
footerWidth: '0', footerWidth: '0',
editChildRef: 'editChildRef', editChildRef: 'editChildRef',
submitted: false, submitted: false,
isDisabled: false,
routeInfo: { routeInfo: {
// 1-新增;2-编辑;3-查看 // 1-新增;2-编辑;3-查看
addOrEdit: 1, addOrEdit: 1,
...@@ -266,9 +267,11 @@ export default { ...@@ -266,9 +267,11 @@ export default {
spescRules: { spescRules: {
specificationName: [ specificationName: [
{ required: true, message: '请输入规格名', trigger: 'blur' }, { required: true, message: '请输入规格名', trigger: 'blur' },
{ validator: (rule, value, callback) => { {
return this.spescData.curSpeceNameList.some(item => item == value) ? callback(new Error('规格名重复')) : callback() validator: (rule, value, callback) => {
}, trigger: 'blur' return this.spescData.curSpeceNameList.some(item => item == value) ? callback(new Error('规格名重复')) : callback()
},
trigger: 'blur'
} }
], ],
specificationValueList: [{ required: true, message: '请输入规格值', trigger: 'change' }] specificationValueList: [{ required: true, message: '请输入规格值', trigger: 'change' }]
...@@ -316,7 +319,8 @@ export default { ...@@ -316,7 +319,8 @@ export default {
name: 'goodsName', name: 'goodsName',
type: 'input', type: 'input',
maxlength: 20, maxlength: 20,
width: '320px' width: '320px',
isDisabled: false
}, },
{ {
label: '商品缩略图', label: '商品缩略图',
...@@ -325,6 +329,7 @@ export default { ...@@ -325,6 +329,7 @@ export default {
width: '320px', width: '320px',
limitSize: 10, limitSize: 10,
maxPhotoNum: 1, maxPhotoNum: 1,
isDisabled: false,
handleUpload: (e, file, targetItem) => { handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1] const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
...@@ -341,6 +346,7 @@ export default { ...@@ -341,6 +346,7 @@ export default {
width: '100%', width: '100%',
limitSize: 20, limitSize: 20,
maxPhotoNum: 10, maxPhotoNum: 10,
isDisabled: false,
handleUpload: (e, file, targetItem) => { handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1] const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
...@@ -361,6 +367,7 @@ export default { ...@@ -361,6 +367,7 @@ export default {
uploadType: 'video', uploadType: 'video',
limitSize: 50, limitSize: 50,
maxPhotoNum: 1, maxPhotoNum: 1,
isDisabled: false,
handleUpload: (e, file, targetItem) => { handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1] const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
...@@ -378,7 +385,8 @@ export default { ...@@ -378,7 +385,8 @@ export default {
optionList: [], optionList: [],
optionId: 'id', optionId: 'id',
optionLabel: 'classifyName', optionLabel: 'classifyName',
optionsName: 'classifyList' optionsName: 'classifyList',
isDisabled: false
}, },
{ {
label: '关联专区', label: '关联专区',
...@@ -388,7 +396,8 @@ export default { ...@@ -388,7 +396,8 @@ export default {
optionList: [], optionList: [],
optionId: 'id', optionId: 'id',
optionLabel: 'zoneName', optionLabel: 'zoneName',
optionsName: 'zoneList' optionsName: 'zoneList',
isDisabled: false
}, },
{ {
label: '商品描述', label: '商品描述',
...@@ -447,7 +456,8 @@ export default { ...@@ -447,7 +456,8 @@ export default {
append: '元', append: '元',
width: '320px', width: '320px',
suffixSlot: 'retailPrice', suffixSlot: 'retailPrice',
isHide: false isHide: false,
isDisabled: false
}, },
{ {
label: '划线价', label: '划线价',
...@@ -455,7 +465,8 @@ export default { ...@@ -455,7 +465,8 @@ export default {
type: 'input', type: 'input',
append: '元', append: '元',
width: '320px', width: '320px',
suffixSlot: 'originalPrice' suffixSlot: 'originalPrice',
isDisabled: false
}, },
{ {
label: '供货价', label: '供货价',
...@@ -463,7 +474,8 @@ export default { ...@@ -463,7 +474,8 @@ export default {
type: 'input', type: 'input',
append: '元', append: '元',
width: '320px', width: '320px',
suffixSlot: 'supplyPrice' suffixSlot: 'supplyPrice',
isDisabled: false
}, },
{ {
label: '库存', label: '库存',
...@@ -472,7 +484,8 @@ export default { ...@@ -472,7 +484,8 @@ export default {
append: '件', append: '件',
width: '320px', width: '320px',
suffixSlot: 'goodsStock', suffixSlot: 'goodsStock',
isHide: false isHide: false,
isDisabled: false
} }
] ]
}, },
...@@ -490,6 +503,7 @@ export default { ...@@ -490,6 +503,7 @@ export default {
type: 'radio', type: 'radio',
optionId: 'confId', optionId: 'confId',
optionLabel: 'confName', optionLabel: 'confName',
isDisabled: false,
optionList: [ optionList: [
{ {
confId: 1, confId: 1,
...@@ -510,7 +524,8 @@ export default { ...@@ -510,7 +524,8 @@ export default {
type: 'input', type: 'input',
append: '元', append: '元',
width: '320px', width: '320px',
isHide: false isHide: false,
isDisabled: false
} }
] ]
}, },
...@@ -558,7 +573,10 @@ export default { ...@@ -558,7 +573,10 @@ export default {
this.getBaseDate().then(() => { this.getBaseDate().then(() => {
this.getOptionsList(0, 'editFormData', false) this.getOptionsList(0, 'editFormData', false)
}) })
this.isDisabled = this.routeInfo.addOrEdit == 3
this.routeInfo.groupOrStore == 2 && this.storeNoExitAttr()
this.routeInfo.addOrEdit != 1 ? this.getInfo() : '' this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
this.routeInfo.addOrEdit == 3 && this.setAllDisabled()
}, },
methods: { methods: {
...@@ -572,17 +590,45 @@ export default { ...@@ -572,17 +590,45 @@ export default {
}) })
}, },
handleTypeChange(val) { handleTypeChange(val) {
this.externalFormList[2].editRule.expressFee[0].required = val == 2 // this.externalFormList[2].editRule.expressFee[0].required = val == 2
var idx = this.externalFormList[2].editFormData.findIndex(item => item.name == 'expressFee') var idx = this.externalFormList[2].editFormData.findIndex(item => item.name == 'expressFee')
this.externalFormList[2].editFormData[idx].isHide = val != 2 this.externalFormList[2].editFormData[idx].isHide = val != 2
}, },
setAllDisabled() {
this.externalFormList.forEach(item => {
item.editFormData.forEach(subItem => {
subItem.isDisabled = true
})
})
},
hideOrShowAttr(obj, isHide=true) {
var idx = ''
obj.forEach(item => {
idx = this.externalFormList[item.pIdx].editFormData.findIndex(subItem => subItem.name == item.name)
this.externalFormList[item.pIdx].editFormData[idx].isHide = isHide
})
},
storeNoExitAttr() {
var attrObj = [
{
name: 'zoneId',
pIdx: 0
},
{
name: 'supplyPrice',
pIdx: 1
}
]
this.hideOrShowAttr(attrObj)
this.externalFormList.splice(3, 1)
},
retailStockRule() { retailStockRule() {
var list = ['retailPrice', 'goodsStock'] var list = ['retailPrice', 'goodsStock']
var idx = '' var idx = ''
list.forEach(item => { list.forEach(item => {
this.externalFormList[1].editRule[item][0].required = !this.editForm.specificationList.length // this.externalFormList[1].editRule[item][0].required = !this.specificationDetailList.length
idx = this.externalFormList[1].editFormData.findIndex(subItem => subItem.name == item) idx = this.externalFormList[1].editFormData.findIndex(subItem => subItem.name == item)
this.externalFormList[1].editFormData[idx].isHide = !!this.editForm.specificationList.length this.externalFormList[1].editFormData[idx].isHide = !!this.specificationDetailList.length
}) })
}, },
// 二次确认 // 二次确认
...@@ -628,7 +674,8 @@ export default { ...@@ -628,7 +674,8 @@ export default {
}, },
// 规格值解构 // 规格值解构
changeSpecs(isRecovery) { changeSpecs(isRecovery) {
this.specsWidth = (100 / ( this.specificationDetailList.length + 2 )) + '%' this.retailStockRule()
this.specsWidth = 100 / (this.specificationDetailList.length + 2) + '%'
this.nameToValSpecsList = [] this.nameToValSpecsList = []
var markIdx = 0 var markIdx = 0
for (var i = 0; i < this.specificationDetailList.length; i++) { for (var i = 0; i < this.specificationDetailList.length; i++) {
...@@ -700,14 +747,14 @@ export default { ...@@ -700,14 +747,14 @@ export default {
// 规格弹窗 // 规格弹窗
handleSpescDelete(tag) { handleSpescDelete(tag) {
this.spescEditForm.specificationValueList.splice(this.spescEditForm.specificationValueList.indexOf(tag), 1); this.spescEditForm.specificationValueList.splice(this.spescEditForm.specificationValueList.indexOf(tag), 1)
}, },
showInput() { showInput() {
this.specsInputVisible = true this.specsInputVisible = true
this.$nextTick(_ => { this.$nextTick(_ => {
this.$refs.saveSpescInput.$refs.input.focus() this.$refs.saveSpescInput.$refs.input.focus()
}); })
}, },
handleInputConfirm() { handleInputConfirm() {
...@@ -939,7 +986,7 @@ export default { ...@@ -939,7 +986,7 @@ export default {
isJump = true isJump = true
break break
} }
if ((this.routeInfo.groupOrStore == 1) && (+item.retailPrice < +this.editForm.supplyPrice)) { if (this.routeInfo.groupOrStore == 1 && +item.retailPrice < +this.editForm.supplyPrice) {
this.whereToGo('specificationDetailList') this.whereToGo('specificationDetailList')
isJump = true isJump = true
break break
...@@ -1077,10 +1124,10 @@ export default { ...@@ -1077,10 +1124,10 @@ export default {
vertical-align: bottom; vertical-align: bottom;
} }
.edit-pro .table-spesc .el-input--small.border-red .el-input__inner { .edit-pro .table-spesc .el-input--small.border-red .el-input__inner {
border: 1px solid #EB4E4E; border: 1px solid #eb4e4e;
} }
.color-red { .color-red {
color: #EB4E4E; color: #eb4e4e;
cursor: pointer; cursor: pointer;
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!