Commit bd50bef2 by cwq0219

商品管理

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