Commit b408b960 by 张立顺

fix sku编辑bug修复

1 parent cfe0edab
...@@ -76,12 +76,12 @@ ...@@ -76,12 +76,12 @@
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示编码,延保不必填 --> <!-- 轻改/延保展示编码,延保不必填 -->
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>商品编码</span> <span>商品编码</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span>第三方名称</span> <span>第三方名称</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
...@@ -90,32 +90,32 @@ ...@@ -90,32 +90,32 @@
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示,延保不必填 --> <!-- 轻改/延保展示,延保不必填 -->
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>计价单位</span> <span>计价单位</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>采购成本/元</span> <span>采购成本/元</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>质保时间/年</span> <span>质保时间/年</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span> <span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span>
<span>运营系数</span> <span>运营系数</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span> <span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span>
<span>运营成本</span> <span>运营成本</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span> <span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span>
<span>适用区域</span> <span>适用区域</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
...@@ -174,8 +174,7 @@ ...@@ -174,8 +174,7 @@
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示配件性质,延保不必填 --> <!-- 轻改/延保展示配件性质,延保不必填 -->
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" <td class="col-accessory-type"
class="col-accessory-type"
style="position: relative;"> style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>配件性质</span> <span>配件性质</span>
...@@ -212,7 +211,7 @@ ...@@ -212,7 +211,7 @@
:title="n"> :title="n">
{{ n }} {{ n }}
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model.trim="row.item.type" <el-input v-model.trim="row.item.type"
class="w-150-per w-150-per" class="w-150-per w-150-per"
:class="{ 'border-red': !isEquityOrExtendType && filterEmpty(row.item.type) && row.item.typeEmpty }" :class="{ 'border-red': !isEquityOrExtendType && filterEmpty(row.item.type) && row.item.typeEmpty }"
...@@ -222,7 +221,7 @@ ...@@ -222,7 +221,7 @@
@blur="handleTypeBlur($event, row.originalIndex)"> @blur="handleTypeBlur($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model.trim="row.item.thirdPartyName" <el-input v-model.trim="row.item.thirdPartyName"
class="w-150-per" class="w-150-per"
maxlength="50" maxlength="50"
...@@ -238,7 +237,7 @@ ...@@ -238,7 +237,7 @@
size="small"> size="small">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-select v-model="row.item.priceUnitType" <el-select v-model="row.item.priceUnitType"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': filterEmpty(row.item.priceUnitType) && row.item.priceUnitTypeEmpty }" :class="{ 'border-red': filterEmpty(row.item.priceUnitType) && row.item.priceUnitTypeEmpty }"
...@@ -251,7 +250,7 @@ ...@@ -251,7 +250,7 @@
:value="opt.value" /> :value="opt.value" />
</el-select> </el-select>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.purchaseCost" <el-input v-model="row.item.purchaseCost"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (filterEmpty(row.item.purchaseCost) && row.item.purchaseCostEmpty) || row.item.purchaseCostRangeError }" :class="{ 'border-red': (filterEmpty(row.item.purchaseCost) && row.item.purchaseCostEmpty) || row.item.purchaseCostRangeError }"
...@@ -261,7 +260,7 @@ ...@@ -261,7 +260,7 @@
@input="handlePurchaseCostInput($event, row.originalIndex)"> @input="handlePurchaseCostInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.warrantyPeriod" <el-input v-model="row.item.warrantyPeriod"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (filterEmpty(row.item.warrantyPeriod) && row.item.warrantyPeriodEmpty) || row.item.warrantyPeriodRangeError }" :class="{ 'border-red': (filterEmpty(row.item.warrantyPeriod) && row.item.warrantyPeriodEmpty) || row.item.warrantyPeriodRangeError }"
...@@ -271,7 +270,7 @@ ...@@ -271,7 +270,7 @@
@input="handleWarrantyPeriodInput($event, row.originalIndex)"> @input="handleWarrantyPeriodInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.operationCoefficient" <el-input v-model="row.item.operationCoefficient"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCoefficient) && row.item.operationCoefficientEmpty) || row.item.operationCoefficientRangeError }" :class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCoefficient) && row.item.operationCoefficientEmpty) || row.item.operationCoefficientRangeError }"
...@@ -281,7 +280,7 @@ ...@@ -281,7 +280,7 @@
@input="handleOperationCoefficientInput($event, row.originalIndex)"> @input="handleOperationCoefficientInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.operationCost" <el-input v-model="row.item.operationCost"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCost) && row.item.operationCostEmpty) || row.item.operationCostRangeError }" :class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCost) && row.item.operationCostEmpty) || row.item.operationCostRangeError }"
...@@ -291,7 +290,7 @@ ...@@ -291,7 +290,7 @@
@input="handleOperationCostInput($event, row.originalIndex)"> @input="handleOperationCostInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model.trim="row.item.applicableArea" <el-input v-model.trim="row.item.applicableArea"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': !isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.applicableArea) && row.item.applicableAreaEmpty }" :class="{ 'border-red': !isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.applicableArea) && row.item.applicableAreaEmpty }"
...@@ -460,8 +459,7 @@ ...@@ -460,8 +459,7 @@
<el-switch v-model="row.item.entityCardFlag"> <el-switch v-model="row.item.entityCardFlag">
</el-switch> </el-switch>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" <td class="col-accessory-type">
class="col-accessory-type">
<span class="sku-accessory-type">{{ formatAccessoryType(row.item.accessoryType) }}</span> <span class="sku-accessory-type">{{ formatAccessoryType(row.item.accessoryType) }}</span>
</td> </td>
<td style="width: 60px;"> <td style="width: 60px;">
......
<!-- 表单 --> <!-- 表单 -->
<template> <template>
<div :class="'product-form'"> <div class="product-form">
<el-form :model="formData" :rules="rules" :ref="formRef + 'd2FormRuleForm'"> <el-form :ref="`${formRef}d2FormRuleForm`"
:model="formData"
:rules="rules">
<slot name="title" /> <slot name="title" />
<div <div v-for="(i, idx) in formList"
v-for="(i, idx) in formList"
:key="idx" :key="idx"
:style="'border-bottom: none;'"
class="product-form-block" class="product-form-block"
> style="border-bottom: none;">
<p v-show="i.title" class="edit-sub-title"> <p v-show="i.title" class="edit-sub-title">
{{ i.title }} {{ i.title }}
</p> </p>
<div> <div>
<div v-for="(item, index) in i.formBlock" :key="index"> <div v-for="(item, index) in i.formBlock" :key="index">
<el-form-item <el-form-item v-if="
:prop="item.name" item.type === 'input'
:label="item.label ? item.label + ':' : ''" || item.type === 'select'
|| item.type === 'special-select'
|| item.type === 'cascader'
"
:id="item.name" :id="item.name"
:label-width="item.label ? '120px' : '0px'"
class="dis-in-block" class="dis-in-block"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }" :label="item.label ? `${item.label}:` : ''"
v-if=" :label-width="item.label ? '120px' : '0px'"
item.type === 'input' || :prop="item.name"
item.type === 'select' || :style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
item.type === 'special-select' || <el-input v-if="item.type === 'input'"
item.type === 'cascader'
"
>
<el-input
v-if="item.type === 'input'"
v-model.trim="formData[item.name]" v-model.trim="formData[item.name]"
:placeholder="item.label" clearable
:disabled="item.isDisabled || pageData.pageDisabled"
:maxlength="item.maxlength" :maxlength="item.maxlength"
:placeholder="item.label"
:style="{ width: item.width || formItemWidth }" :style="{ width: item.width || formItemWidth }"
:disabled="item.isDisabled || pageData.pageDisabled"
clearable
@input="input($event, item)"
@blur="blur(item)" @blur="blur(item)"
> @input="input($event, item)">
<i slot="suffix" class="suffix">{{ item.unit }}</i> <template #suffix>
<i class="suffix">{{ item.unit }}</i>
</template>
</el-input> </el-input>
<!-- 选择框 --> <!-- 选择框 -->
<el-select <el-select v-else-if="item.type === 'select'"
v-else-if="item.type === 'select'"
v-model="formData[item.name]" v-model="formData[item.name]"
:clearable="item.isClear" :clearable="item.isClear"
:placeholder="'请选择' + item.label"
@change="selectAddAttr($event, item)"
:style="{ width: item.width || formItemWidth }"
filterable
:disabled="item.isDisabled || pageData.pageDisabled" :disabled="item.isDisabled || pageData.pageDisabled"
> filterable
<el-option :placeholder="`请选择${item.label}`"
v-for="subItem in item.optionList" :style="{ width: item.width || formItemWidth }"
@change="selectAddAttr($event, item)">
<el-option v-for="subItem in item.optionList"
:key="subItem[item.optionId]" :key="subItem[item.optionId]"
:label="subItem[item.optionLabel]"
:value="subItem[item.optionId]"
:disabled="subItem.isDisabled" :disabled="subItem.isDisabled"
/> :label="subItem[item.optionLabel]"
:value="subItem[item.optionId]" />
</el-select> </el-select>
<!-- 可添加选项选择框 --> <!-- 可添加选项选择框 -->
<el-select <el-select v-else-if="item.type === 'special-select'"
v-else-if="item.type === 'special-select'"
v-model="formData[item.name]" v-model="formData[item.name]"
:clearable="item.isClear" :clearable="item.isClear"
:placeholder="'请选择' + item.label" :disabled="item.isDisabled || pageData.pageDisabled"
filterable
:placeholder="`请选择${item.label}`"
:style="{ width: item.width || formItemWidth }" :style="{ width: item.width || formItemWidth }"
@change="selectAddAttr($event, item)"
@blur="selectBlur" @blur="selectBlur"
@focus="selectFocus" @change="selectAddAttr($event, item)"
filterable @focus="selectFocus">
:disabled="item.isDisabled || pageData.pageDisabled" <el-option v-for="(subItem, subIndex) in item.optionList"
>
<el-option
v-for="(subItem, subIndex) in item.optionList"
:key="subItem[item.optionId]" :key="subItem[item.optionId]"
:label="subItem[item.optionLabel]" :label="subItem[item.optionLabel]"
:value="subItem[item.optionId]" :value="subItem[item.optionId]">
>
<!-- 品牌方 --> <!-- 品牌方 -->
<div class="flex-option" v-if="item.partitionFlag == 1"> <div v-if="item.partitionFlag == 1" class="flex-option">
<el-input <el-input v-show="editOptionIndex == subIndex"
v-show="editOptionIndex == subIndex"
:maxlength="10"
class="add-option-input"
:autofocus="true"
@click.stop.native="editOptionFocus"
v-model.trim="editOptionValue" v-model.trim="editOptionValue"
size="small" :autofocus="true"
class="add-option-input"
:maxlength="10"
placeholder="请输入" placeholder="请输入"
/> size="small"
<span @click.stop.native="editOptionFocus" />
v-show=" <span v-show="
editOptionIndex == -1 || editOptionIndex != subIndex editOptionIndex == -1 || editOptionIndex != subIndex
" "
class="add-option-input" class="add-option-input">
>{{ subItem[item.optionLabel] }}</span {{ subItem[item.optionLabel] }}
> </span>
<div> <div>
<i <i v-show="
v-show=" item.optionList.length > 1
item.optionList.length > 1 && && editOptionIndex != subIndex
editOptionIndex != subIndex
" "
class="el-icon-edit edit_icon" class="el-icon-edit edit_icon"
@click.stop=" @click.stop="
editOption( editOption(
subIndex, subIndex,
subItem[item.optionLabel], subItem[item.optionLabel],
item.partitionFlag item.partitionFlag,
) )
" " />
/> <i v-show="
<i item.optionList.length > 1
v-show=" && editOptionIndex == subIndex
item.optionList.length > 1 &&
editOptionIndex == subIndex
" "
class="el-icon-check option_icon add_icon" class="el-icon-check option_icon add_icon"
@click.stop=" @click.stop="
editOptionConfirm( editOptionConfirm(
subItem[item.optionId], subItem[item.optionId],
index, index,
item.partitionFlag item.partitionFlag,
) )
" " />
/> <i v-if="item.optionList.length > 1"
<i
v-if="item.optionList.length > 1"
class="el-icon-close del_icon" class="el-icon-close del_icon"
@click.stop=" @click.stop="
delOption( delOption(
subItem[item.optionId], subItem[item.optionId],
index, index,
item.partitionFlag, item.partitionFlag,
item item,
) )
" " />
/>
</div> </div>
</div> </div>
</el-option> </el-option>
<div class="add-option"> <div class="add-option">
<div v-if="showOptionInput" class="flex-option"> <div v-if="showOptionInput" class="flex-option">
<el-input <el-input v-model.trim="addOptionValue"
class="add-option-input" class="add-option-input"
:maxlength="10" :maxlength="10"
v-model.trim="addOptionValue"
size="small"
placeholder="请输入" placeholder="请输入"
/> size="small" />
<div> <div>
<i <i v-if="addOptionValue"
v-if="addOptionValue"
class="el-icon-check option_icon add_icon" class="el-icon-check option_icon add_icon"
@click.stop="addOptionConfirm(item.partitionFlag)" @click.stop="addOptionConfirm(item.partitionFlag)" />
/> <i class="el-icon-close option_icon del_icon"
<i @click.stop="delOption(undefined)" />
class="el-icon-close option_icon del_icon"
@click.stop="delOption(undefined)"
/>
</div> </div>
</div> </div>
<div style="display: flex; align-items: center"> <div style="display: flex; align-items: center">
<i <i class="el-icon-circle-plus-outline"
class="el-icon-circle-plus-outline" style="color: #2a58ad; font-size: 20px; margin-right: 3px" />
style="color: #2a58ad; font-size: 20px; margin-right: 3px" <el-button type="text"
/> @click.stop="addOption">
<el-button type="text" @click.stop="addOption" 新增一项
>新增一项</el-button </el-button>
>
</div> </div>
</div> </div>
</el-select> </el-select>
<!-- 级联选择器 --> <!-- 级联选择器 -->
<el-cascader <el-cascader v-else-if="item.type === 'cascader'"
v-else-if="item.type === 'cascader'"
:style="{ width: item.width || formItemWidth }"
:options="item.optionList"
v-model="formData[item.name]" v-model="formData[item.name]"
:placeholder="'请选择' + item.label"
filterable
@change="selectAddAttr($event, item)"
aria-hidden="false" aria-hidden="false"
:disabled="pageData.pageDisabled" :disabled="pageData.pageDisabled"
filterable
:options="item.optionList"
:placeholder="`请选择${item.label}`"
:props="{ :props="{
checkStrictly: true, checkStrictly: true,
label: item.optionLabel, label: item.optionLabel,
value: item.optionId value: item.optionId,
}" }"
> :style="{ width: item.width || formItemWidth }"
@change="selectAddAttr($event, item)">
</el-cascader> </el-cascader>
</el-form-item> </el-form-item>
</div> </div>
<!-- 膜类配置字段 1太阳膜 14改色膜 6改色膜(众筹)12车衣 4车衣(众筹)--> <!-- 膜类配置字段 1太阳膜 14改色膜 6改色膜(众筹)12车衣 4车衣(众筹) -->
<div v-if="membraneTypeList.includes(formData.goodsType)"> <div v-if="membraneTypeList.includes(formData.goodsType)">
<div v-for="(item, index) in membranesFormBlock" :key="index"> <div v-for="(item, index) in membranesFormBlock" :key="index">
<el-form-item <el-form-item :id="item.name"
:prop="item.name"
:label="item.label ? item.label + ':' : ''"
:id="item.name"
:label-width="item.label ? '120px' : '0px'"
class="dis-in-block" class="dis-in-block"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }" :label="item.label ? `${item.label}:` : ''"
> :label-width="item.label ? '120px' : '0px'"
:prop="item.name"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<div v-if="item.type === 'input'"> <div v-if="item.type === 'input'">
<span>1卷 = </span> <span>1卷 = </span>
<el-input <el-input v-model.trim="formData[item.name]"
v-model.trim="formData[item.name]" :disabled="item.isDisabled"
:placeholder="item.label" :placeholder="item.label"
:style="{ width: item.width || formItemWidth }" :style="{ width: item.width || formItemWidth }"
:disabled="item.isDisabled"
@input="handleInput($event, item)"
@blur="blur(item)" @blur="blur(item)"
> @input="handleInput($event, item)">
<i slot="suffix" class="suffix">{{ item.unit }}</i> <template #suffix>
<i class="suffix">{{ item.unit }}</i>
</template>
</el-input> </el-input>
<span> 米 </span> <span> 米 </span>
</div> </div>
<!-- 多选选择框 --> <!-- 多选选择框 -->
<el-select <el-select v-else-if="item.type === 'multiple-select'"
v-else-if="item.type === 'multiple-select'"
v-model="formData[item.name]" v-model="formData[item.name]"
multiple
collapse-tags collapse-tags
:placeholder="'请选择' + item.label"
@change="selectAddAttr($event, item)"
:style="{ width: item.width || formItemWidth }"
filterable filterable
> multiple
<el-option :placeholder="`请选择${item.label}`"
:style="{ width: item.width || formItemWidth }"
@change="selectAddAttr($event, item)">
<el-option v-if="$$(item.optionList, 'length')"
label="全选" label="全选"
value="全选" value="全选"
@click.native="selectAll($event, item)" @click.native="selectAll($event, item)">
v-if="$$(item.optionList, 'length')" </el-option>
></el-option> <el-option v-for="subItem in item.optionList"
<el-option
v-for="subItem in item.optionList"
:key="subItem[item.optionId]" :key="subItem[item.optionId]"
:label="subItem[item.optionLabel]" :label="subItem[item.optionLabel]"
:value="subItem[item.optionId]" :value="subItem[item.optionId]" />
/>
</el-select> </el-select>
<div <div v-else-if="item.type === 'table'"
v-else-if="item.type === 'table'" :style="{ width: item.width }">
:style="{ width: item.width }"
>
<table class="table-spesc"> <table class="table-spesc">
<tbody> <tbody>
<tr <tr style="
style="
background: #f2f4f7; background: #f2f4f7;
height: 42px; height: 42px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
" ">
>
<td style="width: 50%"> <td style="width: 50%">
<span>部位</span> <span>部位</span>
</td> </td>
...@@ -267,12 +228,11 @@ ...@@ -267,12 +228,11 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table <table id="goodsPositionList-table"
class="table-spesc content-table" class="table-spesc content-table">
id="goodsPositionList-table"
>
<tbody> <tbody>
<tr <tr v-for="(subItem, subIndex) in selectedPositionIds"
:key="subIndex"
style=" style="
border-bottom: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5;
height: 40px; height: 40px;
...@@ -280,41 +240,35 @@ ...@@ -280,41 +240,35 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
" ">
v-for="(subItem, subIndex) in selectedPositionIds"
:key="subIndex"
>
<td style="width: 50%"> <td style="width: 50%">
<span>{{ subItem.confName }}</span> <span>{{ subItem.confName }}</span>
</td> </td>
<td style="width: 50%"> <td style="width: 50%">
<el-input <el-input v-model="subItem.deductionStandard"
style="width: 80px" class="w-100-per"
placeholder="扣减标准"
size="small"
v-model="subItem.deductionStandard"
:class="{ :class="{
'w-100-per': true,
'border-red': filterEmpty( 'border-red': filterEmpty(
subItem.deductionStandard subItem.deductionStandard,
) ),
}" }"
@input="deductionHandleInput($event, subIndex)" placeholder="扣减标准"
> size="small"
<el-popover style="width: 80px"
v-show="filterEmpty(subItem.deductionStandard)" @input="deductionHandleInput($event, subIndex)">
slot="suffix" <template #suffix>
<el-popover v-show="filterEmpty(subItem.deductionStandard)"
content="扣减标准必填"
placement="top" placement="top"
title title
width="90"
trigger="hover" trigger="hover"
content="扣减标准必填" width="90">
> <template #reference>
<i <i class="el-icon-warning color-red" />
class="el-icon-warning color-red" </template>
slot="reference"
/>
</el-popover> </el-popover>
</template>
</el-input> </el-input>
<span style="margin-left: 5px">米</span> <span style="margin-left: 5px">米</span>
</td> </td>
...@@ -345,33 +299,28 @@ ...@@ -345,33 +299,28 @@
</div> --> </div> -->
</div> </div>
<div> <div>
<div <div v-for="(item, index) in i.formBlock"
v-for="(item, index) in i.formBlock"
:key="index" :key="index"
style="position: relative" style="position: relative">
> <el-form-item v-if="
<el-form-item item.type === 'photo'
:prop="item.name" || item.type === 'video'
:label="item.label ? item.label + ':' : ''" || item.type === 'descList'
|| item.type === 'radio'
"
:id="item.name" :id="item.name"
:label-width="item.label ? '120px' : '0px'"
:required="item.name === 'accessoryType'"
class="dis-in-block" class="dis-in-block"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }" :label="item.label ? `${item.label}:` : ''"
v-if=" :label-width="item.label ? '120px' : '0px'"
item.type === 'photo' || :prop="item.name"
item.type === 'video' || :style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
item.type === 'descList' ||
item.type === 'radio'
"
>
<template v-if="item.type === 'radio'"> <template v-if="item.type === 'radio'">
<el-radio-group v-model="formData[item.name]" :disabled="item.isDisabled || pageData.pageDisabled" @change="item.name === 'accessoryType' && handleAccessoryTypeChange()"> <el-radio-group v-model="formData[item.name]"
<el-radio :disabled="item.isDisabled || pageData.pageDisabled"
v-for="(opt, optIdx) in (item.radioOptions || [])" @change="item.name === 'accessoryType' && handleAccessoryTypeChange()">
<el-radio v-for="(opt, optIdx) in (item.radioOptions || [])"
:key="optIdx" :key="optIdx"
:label="opt.value" :label="opt.value">
>
{{ opt.label }} {{ opt.label }}
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
...@@ -382,22 +331,22 @@ ...@@ -382,22 +331,22 @@
</p> </p>
<div v-if="item.name == 'thumbUrl'"> <div v-if="item.name == 'thumbUrl'">
<div v-if="!formData[item.name]" class="activity-img img-w-h"> <div v-if="!formData[item.name]" class="activity-img img-w-h">
<div class="add">+</div> <div class="add">
<span class="number" +
>{{ formData[item.name] ? 1 : 0 }}/{{ </div>
<span class="number">
{{ formData[item.name] ? 1 : 0 }}/{{
item.maxPhotoNum item.maxPhotoNum
}}</span }}
> </span>
<input <input :id="`${item.name}file`"
type="file"
name="thumbUrl"
:id="item.name + 'file'"
ref="file" ref="file"
class="activity-img img-w-h"
accept="image/png, image/jpeg, image/gif, image/jpg" accept="image/png, image/jpeg, image/gif, image/jpg"
@change="(e) => handleImgChange(e, item)" class="activity-img img-w-h"
name="thumbUrl"
style="opacity: 0" style="opacity: 0"
/> type="file"
@change="(e) => handleImgChange(e, item)" />
</div> </div>
<template> <template>
<div v-if="formData[item.name]"> <div v-if="formData[item.name]">
...@@ -405,14 +354,10 @@ ...@@ -405,14 +354,10 @@
<img class="img-w-h" :src="formData[item.name]" /> <img class="img-w-h" :src="formData[item.name]" />
<span class="img-btns"> <span class="img-btns">
<span class="btn-item"> <span class="btn-item">
<i <i class="el-icon-delete"
@click="handleImgDelete(item)" @click="handleImgDelete(item)" />
class="el-icon-delete" <i class="el-icon-zoom-in"
/> @click="handleImgLook(formData[item.name], item)" />
<i
@click="handleImgLook(formData[item.name], item)"
class="el-icon-zoom-in"
/>
</span> </span>
</span> </span>
</span> </span>
...@@ -420,50 +365,40 @@ ...@@ -420,50 +365,40 @@
</template> </template>
</div> </div>
<div v-else> <div v-else>
<div <div v-if="
v-if=" (formData[item.name] && formData[item.name].length)
(formData[item.name] && formData[item.name].length) < < item.maxPhotoNum
item.maxPhotoNum
" "
class="activity-img img-w-h" class="activity-img img-w-h">
> <div class="add">
<div class="add">+</div> +
<span class="number" </div>
>{{ formData[item.name].length }}/{{ <span class="number">
{{ formData[item.name].length }}/{{
item.maxPhotoNum item.maxPhotoNum
}}</span }}
> </span>
<input <input :id="`${item.name}file`"
type="file"
name="thumbUrl"
:id="item.name + 'file'"
ref="file" ref="file"
class="activity-img img-w-h"
accept="image/png, image/jpeg, image/gif, image/jpg" accept="image/png, image/jpeg, image/gif, image/jpg"
@change="(e) => handleImgChange(e, item)" class="activity-img img-w-h"
name="thumbUrl"
style="opacity: 0" style="opacity: 0"
/> type="file"
@change="(e) => handleImgChange(e, item)" />
</div> </div>
<template> <template>
<div <div v-if="formData[item.name] && formData[item.name].length">
v-if="formData[item.name] && formData[item.name].length" <span v-for="(subItem, subIndex) in formData[item.name]"
>
<span
v-for="(subItem, subIndex) in formData[item.name]"
:key="subIndex" :key="subIndex"
class="muti-imgs img-w-h" class="muti-imgs img-w-h">
>
<img class="img-w-h" :src="subItem.content" /> <img class="img-w-h" :src="subItem.content" />
<span class="img-btns"> <span class="img-btns">
<span class="btn-item"> <span class="btn-item">
<i <i class="el-icon-delete"
@click="handleImgDelete(item, subIndex)" @click="handleImgDelete(item, subIndex)" />
class="el-icon-delete" <i class="el-icon-zoom-in"
/> @click="handleImgLook(subItem.content, item)" />
<i
@click="handleImgLook(subItem.content, item)"
class="el-icon-zoom-in"
/>
</span> </span>
</span> </span>
</span> </span>
...@@ -476,51 +411,45 @@ ...@@ -476,51 +411,45 @@
{{ item.topTips }} {{ item.topTips }}
</p> </p>
<div v-if="!formData[item.name]" class="activity-img img-w-h"> <div v-if="!formData[item.name]" class="activity-img img-w-h">
<div class="add">+</div> <div class="add">
<span class="number" +
>{{ formData[item.name] ? 1 : 0 }}/{{ </div>
<span class="number">
{{ formData[item.name] ? 1 : 0 }}/{{
item.maxPhotoNum item.maxPhotoNum
}}</span }}
> </span>
<input <input :id="`${item.name}file`"
type="file"
style="opacity: 0"
:id="item.name + 'file'"
ref="file" ref="file"
accept="video/mp4"
class="activity-img img-w-h" class="activity-img img-w-h"
style="opacity: 0"
:style=" :style="
item.uploadStyle && item.uploadStyle
item.uploadStyle.hasOwnProperty('imgWH') && item.uploadStyle.hasOwnProperty('imgWH')
? item.uploadStyle.imgWH ? item.uploadStyle.imgWH
: '' : ''
" "
accept="video/mp4" type="file"
@change="(e) => handleVideoChange(e, item)" @change="(e) => handleVideoChange(e, item)" />
/>
</div> </div>
<template> <template>
<div v-if="formData[item.name]"> <div v-if="formData[item.name]">
<span class="muti-imgs img-w-h"> <span class="muti-imgs img-w-h">
<video <video class="img-w-h activity-img"
class="img-w-h activity-img" :src="formData[item.name]"
:style=" :style="
item.uploadStyle && item.uploadStyle
item.uploadStyle.hasOwnProperty('imgWH') && item.uploadStyle.hasOwnProperty('imgWH')
? item.uploadStyle.imgWH ? item.uploadStyle.imgWH
: '' : ''
" " />
:src="formData[item.name]"
/>
<span class="img-btns"> <span class="img-btns">
<span class="btn-item"> <span class="btn-item">
<i <i class="el-icon-delete"
@click="handleImgDelete(item, 0)" @click="handleImgDelete(item, 0)" />
class="el-icon-delete" <i class="el-icon-zoom-in"
/> @click="handleImgLook(formData[item.name], item)" />
<i
@click="handleImgLook(formData[item.name], item)"
class="el-icon-zoom-in"
/>
</span> </span>
</span> </span>
</span> </span>
...@@ -536,55 +465,41 @@ ...@@ -536,55 +465,41 @@
添加图片 添加图片
</el-button> </el-button>
</el-row> </el-row>
<el-row <el-row v-for="(subItem, subIndex) in formData[item.name]"
v-for="(subItem, subIndex) in formData[item.name]" :key="subIndex">
:key="subIndex" <div v-if="subItem.resType === 2" style="position: relative">
> <el-input v-model.trim="subItem.content"
<div style="position: relative" v-if="subItem.resType === 2">
<el-input
class="desc-input" class="desc-input"
type="textarea"
v-model.trim="subItem.content"
:rows="4"
maxlength="256" maxlength="256"
placeholder="请输入详情内容" placeholder="请输入详情内容"
/> :rows="4"
<i type="textarea" />
class="el-icon-delete desc-txt-delete" <i class="el-icon-delete desc-txt-delete"
@click="handleImgDelete(item, subIndex)" @click="handleImgDelete(item, subIndex)" />
/>
</div> </div>
<div <div v-else-if="subItem.resType === 1"
class="activity-img muti-imgs img-w-h" class="activity-img muti-imgs img-w-h">
v-else-if="subItem.resType === 1" <div v-show="!subItem.content" class="add">
> +
<div v-show="!subItem.content" class="add">+</div> </div>
<img <img v-show="subItem.content"
v-show="subItem.content"
class="img-w-h" class="img-w-h"
:src="subItem.content" :src="subItem.content" />
/> <span v-show="subItem.content" class="img-btns">
<span class="img-btns" v-show="subItem.content">
<span class="btn-item"> <span class="btn-item">
<i <i class="el-icon-delete"
@click="handleImgDelete(item, subIndex)" @click="handleImgDelete(item, subIndex)" />
class="el-icon-delete" <i class="el-icon-zoom-in"
/> @click="handleImgLook(subItem.content)" />
<i
@click="handleImgLook(subItem.content)"
class="el-icon-zoom-in"
/>
</span> </span>
</span> </span>
<input <input :id="`${item.name}file`"
:id="item.name + 'file'"
ref="file" ref="file"
type="file"
class="activity-Input img-w-h"
accept="image/png, image/jpeg, image/gif, image/jpg" accept="image/png, image/jpeg, image/gif, image/jpg"
@change="(e) => handleImgChange(e, item, subIndex)" class="activity-Input img-w-h"
style="opacity: 0" style="opacity: 0"
/> type="file"
@change="(e) => handleImgChange(e, item, subIndex)" />
</div> </div>
</el-row> </el-row>
</template> </template>
...@@ -614,32 +529,76 @@ ...@@ -614,32 +529,76 @@
</el-form-item> --> </el-form-item> -->
</el-form> </el-form>
<el-dialog :visible.sync="lookImgVisible"> <el-dialog :visible.sync="lookImgVisible">
<video <video v-if="dialogObj.uploadType == 'video'"
v-if="dialogObj.uploadType == 'video'"
class="dialog-video" class="dialog-video"
style="width: 100%; height: 100%"
controls controls
> style="width: 100%; height: 100%">
<source :src="dialogObj.url" type="video/mp4" /> <source :src="dialogObj.url" type="video/mp4" />
</video> </video>
<img v-else width="100%" :src="dialogObj.url" alt="图片" /> <img v-else
alt="图片"
:src="dialogObj.url"
width="100%" />
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { deepClone } from "@/common/util" import GlOssApi from "glsk-oss-jssdk";
import { uploadImg, uploadVideo } from "@/api/sys.base" import { mapActions, mapMutations } from "vuex";
import { limitPrice } from "@/common/format" import { uploadImg, uploadVideo } from "@/api/sys.base";
import { applicableModelTypeList, BaseData } from "@/common/constants.js" import { applicableModelTypeList, BaseData } from "@/common/constants.js";
import { mapActions, mapMutations } from "vuex" import { limitPrice } from "@/common/format";
import { baseConfig } from "@/main" import { deepClone } from "@/common/util";
import GlOssApi from "glsk-oss-jssdk" import { baseConfig } from "@/main";
// import GlOssApi from "@/common/oss.js" // import GlOssApi from "@/common/oss.js"
const SESSION_NAME = `${process.env.VUE_APP_STORAGE_PREFIX}-${process.env.VUE_APP_VERSION}-info` const SESSION_NAME = `${process.env.VUE_APP_STORAGE_PREFIX}-${process.env.VUE_APP_VERSION}-info`;
export default { export default {
name: "ProductForm", name: "ProductForm",
inject: ["pageData"], inject: ["pageData"],
props: {
// add - 新增;edit - 编辑
addOrEdit: {
type: String,
default: "add",
},
headImg: {
type: Object,
default: () => {
return {
isHas: false,
attr: "",
};
},
},
formItemWidth: {
type: String,
default: "100%",
},
formRef: {
type: String,
default: "",
},
originData: {
type: Object,
default: () => {
return {};
},
},
formList: {
type: Array,
default: () => {},
},
storeApi: {
type: Function,
default: () => {},
},
formName: {
type: String,
default: () => {},
},
},
data() { data() {
return { return {
equitySceneType: baseConfig.equitySceneType || [], equitySceneType: baseConfig.equitySceneType || [],
...@@ -657,7 +616,7 @@ export default { ...@@ -657,7 +616,7 @@ export default {
selectedValue: "", selectedValue: "",
dialogObj: { dialogObj: {
url: "", url: "",
uploadType: "" uploadType: "",
}, },
rules: { rules: {
goodsName: [ goodsName: [
...@@ -665,62 +624,52 @@ export default { ...@@ -665,62 +624,52 @@ export default {
{ {
validator: (rule, value, cb) => { validator: (rule, value, cb) => {
if ( if (
value && value
!value.includes("太阳膜") && && !value.includes("太阳膜")
this.solarFilmArr?.includes(this.formData?.goodsType) && this.solarFilmArr?.includes(this.formData?.goodsType)
) { ) {
return cb( return cb(
new Error( new Error(
"产品名称必须包含“太阳膜”字样才可将产品挂在太阳膜类目下" "产品名称必须包含“太阳膜”字样才可将产品挂在太阳膜类目下",
) ),
) );
} else { } else {
cb() cb();
} }
}, },
trigger: "blur" trigger: "blur",
} },
], ],
tempGoodsType: [ tempGoodsType: [
{ required: true, message: "请选择类目", trigger: "change" } { required: true, message: "请选择类目", trigger: "change" },
], ],
supplierCode: [ supplierCode: [
{ required: true, message: "请选择供应方", trigger: "change" } { required: true, message: "请选择供应方", trigger: "change" },
], ],
sapCode: [ sapCode: [
{ {
validator: (rule, value, cb) => { validator: (rule, value, cb) => {
if (value && !/^[0-9A-Za-z]+$/.test(value)) { if (value && !/^[0-9A-Z]+$/i.test(value)) {
return cb(new Error("只能输入数字或字母")) return cb(new Error("只能输入数字或字母"));
} else { } else {
cb() cb();
} }
}, },
trigger: "change" trigger: "change",
} },
], ],
thumbUrl: [ thumbUrl: [
{ required: true, message: "请选择缩略图", trigger: "blur" } { required: true, message: "请选择缩略图", trigger: "blur" },
], ],
positionIds: [ positionIds: [
{ required: true, message: "请选择部位", trigger: "change" } { required: true, message: "请选择部位", trigger: "change" },
], ],
convertedValue: [ convertedValue: [
{ required: true, message: "请输入比例换算", trigger: "change" } { required: true, message: "请输入比例换算", trigger: "change" },
], ],
accessoryType: [ accessoryType: [
{ { required: true, message: "请勾选配件性质", trigger: "change" },
validator: (rule, value, cb) => { ],
// 权益/延保类目配件性质不必填
if (this.equitySceneType?.includes(this.formData?.goodsType) || this.extendedPosiType?.includes(this.formData?.goodsType))
return cb();
if (!value && value !== 0)
return cb(new Error("请选择配件性质"));
cb();
},
trigger: "change"
}
]
}, },
copyMembranesFormBlock: [ copyMembranesFormBlock: [
{ {
...@@ -730,13 +679,13 @@ export default { ...@@ -730,13 +679,13 @@ export default {
optionList: [], optionList: [],
optionId: "position", optionId: "position",
optionLabel: "confName", optionLabel: "confName",
width: "432px" width: "432px",
}, },
{ {
name: "convertedValue", name: "convertedValue",
label: "比例换算", label: "比例换算",
type: "input", type: "input",
width: "110px" width: "110px",
}, },
{ {
name: "carTypeList", name: "carTypeList",
...@@ -745,567 +694,533 @@ export default { ...@@ -745,567 +694,533 @@ export default {
optionList: deepClone(applicableModelTypeList), optionList: deepClone(applicableModelTypeList),
optionId: "confId", optionId: "confId",
optionLabel: "confName", optionLabel: "confName",
width: "432px" width: "432px",
}, },
{ {
name: "goodsPositionList", name: "goodsPositionList",
label: "扣减标准", label: "扣减标准",
type: "table", type: "table",
width: "268px" width: "268px",
} },
], ],
membranesFormBlock: [], membranesFormBlock: [],
reg: { reg: {
numReg: /^[1-9]\d*$/, numReg: /^[1-9]\d*$/,
priceReg: /^\d[\d\.]*$/ priceReg: /^\d[\d.]*$/,
}, },
selectedPositionIds: [], selectedPositionIds: [],
membraneTypeList: baseConfig.membraneTypeList membraneTypeList: baseConfig.membraneTypeList,
// productServiceItemList: [] // productServiceItemList: []
} };
},
props: {
// add - 新增;edit - 编辑
addOrEdit: {
type: String,
default: "add"
},
headImg: {
type: Object,
default: () => {
return {
isHas: false,
attr: ""
}
}
},
formItemWidth: {
type: String,
default: "100%"
},
formRef: {
type: String,
default: ""
},
originData: {
type: Object,
default: () => {
return {}
}
},
formList: {
type: Array,
default: () => {}
},
storeApi: {
type: Function,
default: () => {}
},
formName: {
type: String,
default: () => {}
}
}, },
watch: { watch: {
originData: { "originData": {
handler(newVal) { handler(newVal) {
if (newVal) { if (newVal) {
this.formData = deepClone(this.originData) this.formData = deepClone(this.originData);
if (newVal.accessoryType != null) { if (newVal.accessoryType != null) {
this.$nextTick(() => this.handleAccessoryTypeChange()) this.$nextTick(() => this.handleAccessoryTypeChange());
} }
} }
}, },
deep: true deep: true,
}, },
"formData.positionIds": { "formData.positionIds": {
async handler(newVal) { async handler(newVal) {
const copyPositionTypeList = await this.get(BaseData.positionTypeList) const copyPositionTypeList = await this.get(BaseData.positionTypeList);
const arr = deepClone(copyPositionTypeList)?.filter( const arr = deepClone(copyPositionTypeList)?.filter(
(val) => newVal.indexOf(val.position) > -1 val => newVal.includes(val.position),
) );
this.formData.goodsPositionList?.forEach((val) => { this.formData.goodsPositionList?.forEach((val) => {
arr.forEach((item) => { arr.forEach((item) => {
if (val.position === item.position) { if (val.position === item.position) {
item.deductionStandard = val.deductionStandard item.deductionStandard = val.deductionStandard;
item.olddeductionStandard = `${val.deductionStandard}` item.olddeductionStandard = `${val.deductionStandard}`;
}
})
})
this.selectedPositionIds = arr
this.setUpdateGoodsInfo({ goodsPositionList: newVal })
} }
});
});
this.selectedPositionIds = arr;
this.setUpdateGoodsInfo({ goodsPositionList: newVal });
},
}, },
"formData.goodsType": { "formData.goodsType": {
handler() { handler() {
if ( if (
this.addOrEdit === "edit" && this.addOrEdit === "edit"
(this.formData?.status != 3 || this.formData?.scrmFlag == "Y") && (this.formData?.status != 3 || this.formData?.scrmFlag == "Y")
) ) {
return return;
this.setFormItemStatus() }
this.setFormItemStatus();
}, },
deep: true deep: true,
}, },
"formData.supplierCode": { "formData.supplierCode": {
handler() { handler() {
if ( if (
this.addOrEdit === "edit" && this.addOrEdit === "edit"
(this.formData?.status != 3 || this.formData?.scrmFlag == "Y") && (this.formData?.status != 3 || this.formData?.scrmFlag == "Y")
) ) {
return return;
this.setFormItemStatus()
},
deep: true
} }
this.setFormItemStatus();
},
deep: true,
},
}, },
async mounted() { async mounted() {
this.GlOssApi = new GlOssApi({ this.GlOssApi = new GlOssApi({
baseConfig baseConfig,
}) });
this.positionTypeList = await this.get(BaseData.positionTypeList) this.positionTypeList = await this.get(BaseData.positionTypeList);
this.formData = deepClone(this.originData) this.formData = deepClone(this.originData);
this.formData.merchantId = this.userInfo.detail.merchantId this.formData.merchantId = this.userInfo.detail.merchantId;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs[this.formRef + "d2FormRuleForm"].clearValidate() this.$refs[this.formRef + "d2FormRuleForm"].clearValidate();
}) });
const copyMembranesFormBlock = deepClone(this.copyMembranesFormBlock) const copyMembranesFormBlock = deepClone(this.copyMembranesFormBlock);
// 太阳膜类 部位下拉框数据 // 太阳膜类 部位下拉框数据
copyMembranesFormBlock[ copyMembranesFormBlock[
copyMembranesFormBlock.findIndex((val) => val.name == "positionIds") copyMembranesFormBlock.findIndex(val => val.name == "positionIds")
].optionList = this.positionTypeList ].optionList = this.positionTypeList;
if (this.formData.goodsType == 1) { if (this.formData.goodsType == 1) {
this.membranesFormBlock = copyMembranesFormBlock this.membranesFormBlock = copyMembranesFormBlock;
} else if ( } else if (
this.formData.goodsType == 12 || this.formData.goodsType == 12
this.formData.goodsType == 14 || || this.formData.goodsType == 14
this.formData.goodsType == 4 || || this.formData.goodsType == 4
this.formData.goodsType == 6 || this.formData.goodsType == 6
) { ) {
this.membranesFormBlock = [copyMembranesFormBlock[1]] this.membranesFormBlock = [copyMembranesFormBlock[1]];
} }
}, },
methods: { methods: {
...mapActions({ ...mapActions({
get: "d2admin/base/get" get: "d2admin/base/get",
}), }),
...mapMutations("goodsInfoData", ["setUpdateGoodsInfo"]), ...mapMutations("goodsInfoData", ["setUpdateGoodsInfo"]),
setFormItemStatus() { setFormItemStatus() {
// 获取供应方和延保类目的选项列表 // 获取供应方和延保类目的选项列表
const supplierIndex = this.formList[0]?.formBlock.findIndex( const supplierIndex = this.formList[0]?.formBlock.findIndex(
(val) => val.name === "supplierCode" val => val.name === "supplierCode",
) );
const goodsTypeIndex = this.formList[0]?.formBlock.findIndex( const goodsTypeIndex = this.formList[0]?.formBlock.findIndex(
(val) => val.name === "tempGoodsType" val => val.name === "tempGoodsType",
) );
const suppOptionList = const suppOptionList
this.formList[0]?.formBlock[supplierIndex]?.optionList = this.formList[0]?.formBlock[supplierIndex]?.optionList;
const goodsTypeOptionList = const goodsTypeOptionList
this.formList[0]?.formBlock[goodsTypeIndex]?.optionList = this.formList[0]?.formBlock[goodsTypeIndex]?.optionList;
// 更新供应方选项的 disabled 状态 // 更新供应方选项的 disabled 状态
const updateSupplierOptions = (isDisabled) => { const updateSupplierOptions = (isDisabled) => {
suppOptionList?.forEach((item) => { suppOptionList?.forEach((item) => {
item.isDisabled = item.isDisabled
isDisabled && !this.supplierCode?.includes(`${item.id}`) = isDisabled && !this.supplierCode?.includes(`${item.id}`);
}) });
this.$set( this.$set(
this.formList[0].formBlock[supplierIndex], this.formList[0].formBlock[supplierIndex],
"optionList", "optionList",
suppOptionList suppOptionList,
) );
} };
// 更新延保类目选项的 disabled 状态 // 更新延保类目选项的 disabled 状态
const updateGoodsTypeOptions = (isDisabled) => { const updateGoodsTypeOptions = (isDisabled) => {
const updatedGoodsTypeOptionList = goodsTypeOptionList.map((item) => { const updatedGoodsTypeOptionList = goodsTypeOptionList.map((item) => {
const newItem = { const newItem = {
...item, ...item,
disabled: disabled:
isDisabled && this.extendedPosiType?.includes(item.categoryType) isDisabled && this.extendedPosiType?.includes(item.categoryType),
} };
if (newItem.children) { if (newItem.children) {
newItem.children = newItem.children.map((i) => ({ newItem.children = newItem.children.map(i => ({
...i, ...i,
disabled: newItem.disabled, disabled: newItem.disabled,
children: i.children children: i.children
? i.children.map((j) => ({ ...j, disabled: newItem.disabled })) ? i.children.map(j => ({ ...j, disabled: newItem.disabled }))
: undefined : undefined,
})) }));
} }
return newItem return newItem;
}) });
this.$set( this.$set(
this.formList[0].formBlock[goodsTypeIndex], this.formList[0].formBlock[goodsTypeIndex],
"optionList", "optionList",
updatedGoodsTypeOptionList updatedGoodsTypeOptionList,
) );
} };
// 根据 goodsType 更新供应方选项 // 根据 goodsType 更新供应方选项
if (this.extendedPosiType?.includes(this.formData?.goodsType)) { if (this.extendedPosiType?.includes(this.formData?.goodsType)) {
updateSupplierOptions(true) updateSupplierOptions(true);
} else { } else {
updateSupplierOptions(false) updateSupplierOptions(false);
} }
// 根据 supplierCode 更新延保类目选项 // 根据 supplierCode 更新延保类目选项
if ( if (
this.formData?.supplierCode && this.formData?.supplierCode
!this.supplierCode?.includes(`${this.formData?.supplierCode}`) && !this.supplierCode?.includes(`${this.formData?.supplierCode}`)
) { ) {
updateGoodsTypeOptions(true) updateGoodsTypeOptions(true);
} else { } else {
updateGoodsTypeOptions(false) updateGoodsTypeOptions(false);
} }
}, },
selectBlur() { selectBlur() {
this.editOptionIndex = -1 this.editOptionIndex = -1;
this.showOptionInput = false this.showOptionInput = false;
}, },
selectFocus() { selectFocus() {
this.editOptionIndex = -1 this.editOptionIndex = -1;
this.showOptionInput = false this.showOptionInput = false;
}, },
addOption() { addOption() {
this.showOptionInput = true this.showOptionInput = true;
this.addOptionValue = "" this.addOptionValue = "";
}, },
addOptionConfirm(partitionFlag) { addOptionConfirm(partitionFlag) {
const data = { const data = {
relatedPartyName: this.addOptionValue, relatedPartyName: this.addOptionValue,
partitionFlag: partitionFlag, partitionFlag,
createdBy: JSON.parse(unescape(sessionStorage.getItem(SESSION_NAME))) createdBy: JSON.parse(unescape(sessionStorage.getItem(SESSION_NAME)))
.loginAccount.userName, .loginAccount
.userName,
updatedBy: JSON.parse(unescape(sessionStorage.getItem(SESSION_NAME))) updatedBy: JSON.parse(unescape(sessionStorage.getItem(SESSION_NAME)))
.loginAccount.userName .loginAccount
} .userName,
this.$emit("handleAddBrandSupplyConfirm", data) };
this.addOptionValue = "" this.$emit("handleAddBrandSupplyConfirm", data);
this.showOptionInput = false this.addOptionValue = "";
this.showOptionInput = false;
}, },
editOption(e, value) { editOption(e, value) {
this.editOptionValue = value this.editOptionValue = value;
this.editOptionIndex = e this.editOptionIndex = e;
}, },
editOptionFocus(event) { editOptionFocus(event) {
event.stopPropagation() event.stopPropagation();
}, },
editOptionConfirm(e, index, partitionFlag) { editOptionConfirm(e, index, partitionFlag) {
const data = { const data = {
relatedPartyName: this.editOptionValue, relatedPartyName: this.editOptionValue,
id: e, id: e,
partitionFlag: partitionFlag partitionFlag,
} };
this.$emit("handleEditBrandSupplyConfirm", data) this.$emit("handleEditBrandSupplyConfirm", data);
this.editOptionIndex = -1 this.editOptionIndex = -1;
this.editOptionValue = "" this.editOptionValue = "";
}, },
delOption(e, index, partitionFlag, item) { delOption(e, index, partitionFlag, item) {
if (e) { if (e) {
const data = { const data = {
relatedPartyName: this.editOptionValue, relatedPartyName: this.editOptionValue,
id: e, id: e,
partitionFlag: partitionFlag, partitionFlag,
deletedFlag: "Y" deletedFlag: "Y",
} };
this.formData[item.name] = "" this.formData[item.name] = "";
this.$emit("handleEditBrandSupplyConfirm", data) this.$emit("handleEditBrandSupplyConfirm", data);
} else { } else {
this.showOptionInput = false this.showOptionInput = false;
this.addOptionValue = "" this.addOptionValue = "";
} }
}, },
// 修复直接调用可以会因为没有对应方法报错的问题 // 修复直接调用可以会因为没有对应方法报错的问题
input(event, item) { input(event, item) {
item.handleInput && item.handleInput(event) item.handleInput && item.handleInput(event);
}, },
// 比例换算输入框 // 比例换算输入框
handleInput(newValue, item) { handleInput(newValue, item) {
newValue = newValue.replace(/[^\d.]/g, "") newValue = newValue.replace(/[^\d.]/g, "");
let oldValue = `${this.formData["oldconvertedValue"]}` let oldValue = `${this.formData.oldconvertedValue}`;
this.$set( this.$set(
this.formData, this.formData,
"convertedValue", "convertedValue",
limitPrice(newValue, oldValue, 6, 0, 1) limitPrice(newValue, oldValue, 6, 0, 1),
) );
this.$set( this.$set(
this.formData, this.formData,
"oldconvertedValue", "oldconvertedValue",
this.formData["convertedValue"] this.formData.convertedValue,
) );
}, },
blur(item) { blur(item) {
item.handleBlur && item.handleBlur() item.handleBlur && item.handleBlur();
}, },
// 扣减标准输入框 // 扣减标准输入框
deductionHandleInput(event, index) { deductionHandleInput(event, index) {
event = event.replace(/[^\d.]/g, "") event = event.replace(/[^\d.]/g, "");
let oldValue = `${this.selectedPositionIds[index]["olddeductionStandard"]}` let oldValue = `${this.selectedPositionIds[index].olddeductionStandard}`;
this.$set( this.$set(
this.selectedPositionIds[index], this.selectedPositionIds[index],
"deductionStandard", "deductionStandard",
limitPrice(event, oldValue, 6, 2, 0) limitPrice(event, oldValue, 6, 2, 0),
) );
this.$set( this.$set(
this.selectedPositionIds[index], this.selectedPositionIds[index],
"olddeductionStandard", "olddeductionStandard",
this.selectedPositionIds[index]["deductionStandard"] this.selectedPositionIds[index].deductionStandard,
) );
}, },
clearGoodsType(item) { clearGoodsType(item) {
this.formData[item.name] = "" this.formData[item.name] = "";
}, },
// 选择框-添加其他属性 // 选择框-添加其他属性
selectAddAttr(value, targetItem) { selectAddAttr(value, targetItem) {
this.selectedValue = value this.selectedValue = value;
this.editOptionIndex = -1 this.editOptionIndex = -1;
if (targetItem.name == "tempGoodsType") { if (targetItem.name == "tempGoodsType") {
var tempVal = targetItem.optionList.find( let tempVal = targetItem.optionList.find(
(item) => item.categoryType === value?.[0] item => item.categoryType === value?.[0],
) );
let secondGoodsObj let secondGoodsObj;
let thirdGoodsObj let thirdGoodsObj;
targetItem.optionList?.forEach((val) => { targetItem.optionList?.forEach((val) => {
val.children?.find((item) => { val.children?.find((item) => {
if (item.categoryType === value?.[1]) { if (item.categoryType === value?.[1]) {
secondGoodsObj = item secondGoodsObj = item;
} }
item.children?.find((val) => { item.children?.find((val) => {
if (val.categoryType === value?.[2]) { if (val.categoryType === value?.[2]) {
thirdGoodsObj = val thirdGoodsObj = val;
} }
}) });
}) });
}) });
this.formData.goodsType = value?.[0] // 一级类目 this.formData.goodsType = value?.[0]; // 一级类目
this.formData.secondaryGoodsType = value?.[1] || "" // 二级类目 this.formData.secondaryGoodsType = value?.[1] || ""; // 二级类目
this.formData.thirdLevelGoodsType = value?.[2] || "" // 三级类目 this.formData.thirdLevelGoodsType = value?.[2] || ""; // 三级类目
this.formData.goodsTypeName = tempVal.categoryName // 一级类目名 this.formData.goodsTypeName = tempVal.categoryName; // 一级类目名
this.formData.secondaryGoodsTypeName = this.formData.secondaryGoodsTypeName
secondGoodsObj?.categoryName || "" // 二级类目名 = secondGoodsObj?.categoryName || ""; // 二级类目名
this.formData.thirdLevelGoodsTypeName = this.formData.thirdLevelGoodsTypeName
thirdGoodsObj?.categoryName || "" // 三级类目名 = thirdGoodsObj?.categoryName || ""; // 三级类目名
const copyMembranesFormBlock = deepClone(this.copyMembranesFormBlock) const copyMembranesFormBlock = deepClone(this.copyMembranesFormBlock);
// 太阳膜类 部位下拉框数据 // 太阳膜类 部位下拉框数据
copyMembranesFormBlock[ copyMembranesFormBlock[
copyMembranesFormBlock.findIndex((val) => val.name == "positionIds") copyMembranesFormBlock.findIndex(val => val.name == "positionIds")
].optionList = this.positionTypeList ].optionList = this.positionTypeList;
this.formData.convertedValue = 30 this.formData.convertedValue = 30;
this.membranesFormBlock = [] this.membranesFormBlock = [];
if (this.formData.goodsType == 1) { if (this.formData.goodsType == 1) {
this.membranesFormBlock = copyMembranesFormBlock this.membranesFormBlock = copyMembranesFormBlock;
} else if (this.membraneTypeList?.includes(this.formData.goodsType)) { } else if (this.membraneTypeList?.includes(this.formData.goodsType)) {
// 膜类配置比例换算 // 膜类配置比例换算
this.membranesFormBlock = [copyMembranesFormBlock[1]] this.membranesFormBlock = [copyMembranesFormBlock[1]];
} }
this.setUpdateGoodsInfo({ goodsType: value?.[0] }) this.setUpdateGoodsInfo({ goodsType: value?.[0] });
} }
// 修改供应方 // 修改供应方
if (targetItem.name == "supplierCode") { if (targetItem.name == "supplierCode") {
this.setUpdateGoodsInfo({ supplierCode: value }) this.setUpdateGoodsInfo({ supplierCode: value });
} }
}, },
// 全选 // 全选
selectAll(value, targetItem) { selectAll(value, targetItem) {
const _formData = this.formData const _formData = this.formData;
if (targetItem.name == "positionIds") { if (targetItem.name == "positionIds") {
if ( if (
_formData.positionIds.length < _formData.positionIds.length
deepClone(this.positionTypeList).length + 1 < deepClone(this.positionTypeList).length + 1
) { ) {
_formData.positionIds = deepClone(this.positionTypeList).map( _formData.positionIds = deepClone(this.positionTypeList).map(
(item) => { (item) => {
return item.position return item.position;
} },
) );
} else { } else {
_formData.positionIds = [] _formData.positionIds = [];
} }
this.$emit("update:updateMultipleSelect", this.selectedArr) this.$emit("update:updateMultipleSelect", this.selectedArr);
} }
if (targetItem.name == "carTypeList") { if (targetItem.name == "carTypeList") {
if ( if (
_formData.carTypeList.length < _formData.carTypeList.length
deepClone(applicableModelTypeList).length + 1 < deepClone(applicableModelTypeList).length + 1
) { ) {
_formData.carTypeList = deepClone(applicableModelTypeList).map( _formData.carTypeList = deepClone(applicableModelTypeList).map(
(item) => { (item) => {
return item.confId return item.confId;
} },
) );
} else { } else {
_formData.carTypeList = [] _formData.carTypeList = [];
} }
} }
}, },
// 图片 // 图片
handleImgChange(e, targetItem, subIndex = 0) { handleImgChange(e, targetItem, subIndex = 0) {
const fileInfo = e.srcElement.files[0] const fileInfo = e.srcElement.files[0];
const fileName = e.target.files[0].name const fileName = e.target.files[0].name;
if (!fileInfo) return if (!fileInfo)
return;
if (fileInfo?.size / 1024 / 1024 > 10) { if (fileInfo?.size / 1024 / 1024 > 10) {
document.getElementById(`${targetItem.name}file`).value = "" document.getElementById(`${targetItem.name}file`).value = "";
return this.$message.warning("请上传10M以内图片") return this.$message.warning("请上传10M以内图片");
} }
if (!/jpg|jpeg|png|webp/i.test(fileInfo.type)) { if (!/jpg|jpeg|png|webp/i.test(fileInfo.type)) {
this.$message.error(`上传图片格式不正确!`) this.$message.error(`上传图片格式不正确!`);
document.getElementById(`${targetItem.name}file`).value = "" document.getElementById(`${targetItem.name}file`).value = "";
return return;
} }
const success = (res) => { const success = (res) => {
this.$refs[this.formRef + "d2FormRuleForm"].clearValidate( this.$refs[this.formRef + "d2FormRuleForm"].clearValidate(
targetItem.name targetItem.name,
) );
if (targetItem.name === "goodsImgList") { if (targetItem.name === "goodsImgList") {
this.formData[targetItem.name].push({ content: res.aliyunAddress }) this.formData[targetItem.name].push({ content: res.aliyunAddress });
} else if (targetItem.name === "thumbUrl") { } else if (targetItem.name === "thumbUrl") {
this.formData[targetItem.name] = res.aliyunAddress this.formData[targetItem.name] = res.aliyunAddress;
} else { } else {
this.formData[targetItem.name][subIndex].content = res.aliyunAddress this.formData[targetItem.name][subIndex].content = res.aliyunAddress;
}
document.getElementById(`${targetItem.name}file`).value = ""
} }
document.getElementById(`${targetItem.name}file`).value = "";
};
const fail = (err) => { const fail = (err) => {
document.getElementById(`${targetItem.name}file`).value = "" document.getElementById(`${targetItem.name}file`).value = "";
} };
this.handleOssUpload(fileInfo, fileName, success, fail) this.handleOssUpload(fileInfo, fileName, success, fail);
}, },
handleOssUpload(file, fileName, success, fail) { handleOssUpload(file, fileName, success, fail) {
const bucketName = "jinrong-huidan-test" // 桶名 const bucketName = "jinrong-huidan-test"; // 桶名
const fileType = fileName.substr(fileName.lastIndexOf(".") + 1) const fileType = fileName.substr(fileName.lastIndexOf(".") + 1);
this.GlOssApi.multipartUpload(file, success, fail, bucketName, fileType) this.GlOssApi.multipartUpload(file, success, fail, bucketName, fileType);
}, },
handleAccessoryTypeChange() { handleAccessoryTypeChange() {
this.$emit("accessoryTypeChange", this.formData.accessoryType) this.$emit("accessoryTypeChange", this.formData.accessoryType);
}, },
// 图片删除 // 图片删除
handleImgDelete(targetItem, subIndex = -1) { handleImgDelete(targetItem, subIndex = -1) {
Array.isArray(this.formData[targetItem.name]) Array.isArray(this.formData[targetItem.name])
? this.formData[targetItem.name].splice(subIndex, 1) ? this.formData[targetItem.name].splice(subIndex, 1)
: (this.formData[targetItem.name] = "") : (this.formData[targetItem.name] = "");
}, },
// 图片查看 // 图片查看
handleImgLook(src, targetItem) { handleImgLook(src, targetItem) {
this.lookImgVisible = true this.lookImgVisible = true;
this.dialogObj = { this.dialogObj = {
url: src, url: src,
uploadType: targetItem.type || "photo" uploadType: targetItem.type || "photo",
} };
}, },
// 视频 // 视频
handleVideoChange(e, targetItem) { handleVideoChange(e, targetItem) {
const fileInfo = e.srcElement.files[0] const fileInfo = e.srcElement.files[0];
const fileName = e.target.files[0].name const fileName = e.target.files[0].name;
if (!fileInfo) return if (!fileInfo)
return;
if (fileInfo?.size / 1024 / 1024 > 20) { if (fileInfo?.size / 1024 / 1024 > 20) {
return this.$message({ return this.$message({
message: "视频内容大于20M", message: "视频内容大于20M",
type: "warning" type: "warning",
}) });
} }
if (!/mp4|m4v|avi/i.test(fileInfo.type)) { if (!/mp4|m4v|avi/i.test(fileInfo.type)) {
this.$message.error(`上传视频格式不正确!`) this.$message.error(`上传视频格式不正确!`);
document.getElementById(`${targetItem.name}file`).value = "" document.getElementById(`${targetItem.name}file`).value = "";
return return;
} }
const success = (res) => { const success = (res) => {
this.formData[targetItem.name] = res.aliyunAddress this.formData[targetItem.name] = res.aliyunAddress;
document.getElementById(`${targetItem.name}file`).value = "" document.getElementById(`${targetItem.name}file`).value = "";
} };
const fail = (err) => { const fail = (err) => {
document.getElementById(`${targetItem.name}file`).value = "" document.getElementById(`${targetItem.name}file`).value = "";
} };
this.handleOssUpload(fileInfo, fileName, success, fail) this.handleOssUpload(fileInfo, fileName, success, fail);
}, },
// 描述 1-图片;2-文字 // 描述 1-图片;2-文字
handleAddDesc(resType, targetItem) { handleAddDesc(resType, targetItem) {
const orderNo = this.formData[targetItem.name].length const orderNo = this.formData[targetItem.name].length;
this.formData[targetItem.name].push({ this.formData[targetItem.name].push({
resType: resType, resType,
orderNo: orderNo, orderNo,
content: "" content: "",
}) });
}, },
handleClose() { handleClose() {
this.$emit("handleClose") this.$emit("handleClose");
}, },
jumpScroll(idName) { jumpScroll(idName) {
document.getElementById(idName).scrollIntoView() document.getElementById(idName).scrollIntoView();
}, },
filterEmpty(data) { filterEmpty(data) {
return (data ?? "") === "" return (data ?? "") === "";
}, },
filterPosiotion() { filterPosiotion() {
const arr = [] const arr = [];
for (var i = 0; i < this.selectedPositionIds.length; i++) { for (let i = 0; i < this.selectedPositionIds.length; i++) {
const item = this.selectedPositionIds[i] const item = this.selectedPositionIds[i];
if (this.filterEmpty(item.deductionStandard)) { if (this.filterEmpty(item.deductionStandard)) {
this.jumpScroll("goodsPositionList-table") this.jumpScroll("goodsPositionList-table");
return true return true;
} }
arr.push({ arr.push({
goodsCode: this.formData.goodsCode, goodsCode: this.formData.goodsCode,
position: item.position, position: item.position,
deductionStandard: item.deductionStandard deductionStandard: item.deductionStandard,
}) });
} }
return arr return arr;
}, },
handleUp(callback) { handleUp(callback) {
this.$refs[this.formRef + "d2FormRuleForm"].validate((valid, options) => { this.$refs[this.formRef + "d2FormRuleForm"].validate((valid, options) => {
if (valid) { if (valid) {
// 会员权益 类目 // 会员权益 类目
// if (this.equitySceneType.includes(this.formData.goodsType)) this.formData.productServiceItemList = this.productServiceItemList // if (this.equitySceneType.includes(this.formData.goodsType)) this.formData.productServiceItemList = this.productServiceItemList
const goodsPositionList = this.filterPosiotion() const goodsPositionList = this.filterPosiotion();
if (goodsPositionList === true) { if (goodsPositionList === true) {
this.$message.warning("请填写扣减标准") this.$message.warning("请填写扣减标准");
return return;
} }
this.formData.goodsPositionList = goodsPositionList this.formData.goodsPositionList = goodsPositionList;
const brandOptionList = const brandOptionList
this.formList[0].formBlock[ = this.formList[0].formBlock[
this.formList[0].formBlock.findIndex( this.formList[0].formBlock.findIndex(
(val) => val.name == "brandMerchantCode" val => val.name == "brandMerchantCode",
) )
].optionList || [] ].optionList || [];
const supplierOptionList = const supplierOptionList
this.formList[0].formBlock[ = this.formList[0].formBlock[
this.formList[0].formBlock.findIndex( this.formList[0].formBlock.findIndex(
(val) => val.name == "supplierCode" val => val.name == "supplierCode",
) )
].optionList || [] ].optionList || [];
this.formData.brandMerchantCode && this.formData.brandMerchantCode
(this.formData.brandMerchantName = brandOptionList.find( && (this.formData.brandMerchantName = brandOptionList.find(
(item) => item.id === this.formData.brandMerchantCode item => item.id === this.formData.brandMerchantCode,
)?.relatedPartyName) )?.relatedPartyName);
this.formData.supplierCode && this.formData.supplierCode
(this.formData.supplierName = supplierOptionList.find( && (this.formData.supplierName = supplierOptionList.find(
(item) => item.id === this.formData.supplierCode item => item.id === this.formData.supplierCode,
)?.relatedPartyName) )?.relatedPartyName);
this.$emit("handleAddConfirm", this.formData) this.$emit("handleAddConfirm", this.formData);
if (callback)
callback(this.formData);
} else { } else {
const needRuleList = options ? Object.keys(options) : [] const needRuleList = options ? Object.keys(options) : [];
if ( if (
this.formData?.goodsName && this.formData?.goodsName
!this.formData?.goodsName?.includes("太阳膜") && && !this.formData?.goodsName?.includes("太阳膜")
this.solarFilmArr?.includes(this.formData?.goodsType) && this.solarFilmArr?.includes(this.formData?.goodsType)
) { ) {
// 太阳膜类目 产品名称关键字与类目不匹配 // 太阳膜类目 产品名称关键字与类目不匹配
this.$message.warning( this.$message.warning(
"产品名称必须包含“太阳膜”字样才可将产品挂在太阳膜类目下" "产品名称必须包含“太阳膜”字样才可将产品挂在太阳膜类目下",
) );
}
if (needRuleList?.length) this.jumpScroll(needRuleList[0])
return
}
if (callback) callback(this.formData)
})
} }
if (needRuleList?.length)
this.jumpScroll(needRuleList[0]);
return;
} }
} });
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.product-form { .product-form {
.product-form-block { .product-form-block {
...@@ -1518,9 +1433,7 @@ export default { ...@@ -1518,9 +1433,7 @@ export default {
display: none !important; display: none !important;
} }
::v-deep ::v-deep .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
.el-radio:focus:not(.is-focus):not(:active):not(.is-disabled)
.el-radio__inner {
box-shadow: none !important; box-shadow: none !important;
} }
</style> </style>
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示商品编码,延保不必填 --> <!-- 轻改/延保展示商品编码,延保不必填 -->
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>商品编码</span> <span>商品编码</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示第三方名称 --> <!-- 轻改/延保展示第三方名称 -->
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span>第三方名称</span> <span>第三方名称</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
...@@ -38,32 +38,32 @@ ...@@ -38,32 +38,32 @@
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示,延保不必填 --> <!-- 轻改/延保展示,延保不必填 -->
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>计价单位</span> <span>计价单位</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>采购成本/元</span> <span>采购成本/元</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>质保时间/年</span> <span>质保时间/年</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span> <span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span>
<span>运营系数</span> <span>运营系数</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span> <span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span>
<span>运营成本</span> <span>运营成本</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" style="position: relative;"> <td style="position: relative;">
<span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span> <span v-if="!isEquityOrExtendType && goodsInfoData.accessoryType !== 1" class="color-red">*</span>
<span>适用区域</span> <span>适用区域</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
...@@ -125,8 +125,7 @@ ...@@ -125,8 +125,7 @@
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示配件性质,延保不必填 --> <!-- 轻改/延保展示配件性质,延保不必填 -->
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" <td class="col-accessory-type"
class="col-accessory-type"
style="position: relative;"> style="position: relative;">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>配件性质</span> <span>配件性质</span>
...@@ -192,7 +191,7 @@ ...@@ -192,7 +191,7 @@
</template> </template>
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model.trim="row.item.type" <el-input v-model.trim="row.item.type"
class="w-150-per w-150-per" class="w-150-per w-150-per"
:class="{ 'border-red': !isEquityOrExtendType && filterEmpty(row.item.type) && row.item.typeEmpty }" :class="{ 'border-red': !isEquityOrExtendType && filterEmpty(row.item.type) && row.item.typeEmpty }"
...@@ -203,7 +202,7 @@ ...@@ -203,7 +202,7 @@
@input="handleTypeInput($event, row.originalIndex)"> @input="handleTypeInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model.trim="row.item.thirdPartyName" <el-input v-model.trim="row.item.thirdPartyName"
class="w-150-per" class="w-150-per"
maxlength="50" maxlength="50"
...@@ -219,7 +218,7 @@ ...@@ -219,7 +218,7 @@
size="small"> size="small">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-select v-model="row.item.priceUnitType" <el-select v-model="row.item.priceUnitType"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': filterEmpty(row.item.priceUnitType) && row.item.priceUnitTypeEmpty }" :class="{ 'border-red': filterEmpty(row.item.priceUnitType) && row.item.priceUnitTypeEmpty }"
...@@ -232,7 +231,7 @@ ...@@ -232,7 +231,7 @@
:value="opt.value" /> :value="opt.value" />
</el-select> </el-select>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.purchaseCost" <el-input v-model="row.item.purchaseCost"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (filterEmpty(row.item.purchaseCost) && row.item.purchaseCostEmpty) || row.item.purchaseCostRangeError }" :class="{ 'border-red': (filterEmpty(row.item.purchaseCost) && row.item.purchaseCostEmpty) || row.item.purchaseCostRangeError }"
...@@ -242,7 +241,7 @@ ...@@ -242,7 +241,7 @@
@input="handlePurchaseCostInput($event, row.originalIndex)"> @input="handlePurchaseCostInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.warrantyPeriod" <el-input v-model="row.item.warrantyPeriod"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (filterEmpty(row.item.warrantyPeriod) && row.item.warrantyPeriodEmpty) || row.item.warrantyPeriodRangeError }" :class="{ 'border-red': (filterEmpty(row.item.warrantyPeriod) && row.item.warrantyPeriodEmpty) || row.item.warrantyPeriodRangeError }"
...@@ -252,7 +251,7 @@ ...@@ -252,7 +251,7 @@
@input="handleWarrantyPeriodInput($event, row.originalIndex)"> @input="handleWarrantyPeriodInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.operationCoefficient" <el-input v-model="row.item.operationCoefficient"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCoefficient) && row.item.operationCoefficientEmpty) || row.item.operationCoefficientRangeError }" :class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCoefficient) && row.item.operationCoefficientEmpty) || row.item.operationCoefficientRangeError }"
...@@ -262,7 +261,7 @@ ...@@ -262,7 +261,7 @@
@input="handleOperationCoefficientInput($event, row.originalIndex)"> @input="handleOperationCoefficientInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model="row.item.operationCost" <el-input v-model="row.item.operationCost"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCost) && row.item.operationCostEmpty) || row.item.operationCostRangeError }" :class="{ 'border-red': (!isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.operationCost) && row.item.operationCostEmpty) || row.item.operationCostRangeError }"
...@@ -272,7 +271,7 @@ ...@@ -272,7 +271,7 @@
@input="handleOperationCostInput($event, row.originalIndex)"> @input="handleOperationCostInput($event, row.originalIndex)">
</el-input> </el-input>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)"> <td>
<el-input v-model.trim="row.item.applicableArea" <el-input v-model.trim="row.item.applicableArea"
class="w-150-per" class="w-150-per"
:class="{ 'border-red': !isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.applicableArea) && row.item.applicableAreaEmpty }" :class="{ 'border-red': !isAccessoryTypeOriginal(row.item) && filterEmpty(row.item.applicableArea) && row.item.applicableAreaEmpty }"
...@@ -433,8 +432,7 @@ ...@@ -433,8 +432,7 @@
<el-switch v-model="row.item.entityCardFlag"> <el-switch v-model="row.item.entityCardFlag">
</el-switch> </el-switch>
</td> </td>
<td v-if="!equitySceneType.includes(goodsInfoData.goodsType)" <td class="col-accessory-type">
class="col-accessory-type">
<span class="sku-accessory-type">{{ formatAccessoryType(row.item.accessoryType) }}</span> <span class="sku-accessory-type">{{ formatAccessoryType(row.item.accessoryType) }}</span>
</td> </td>
<td style="width: 60px;"> <td style="width: 60px;">
......
<template> <template>
<div class="sourceMaterial-form" id="sourceMaterial-form"> <div id="sourceMaterial-form" class="sourceMaterial-form">
<div class="title">产品系列-SPU</div> <div class="title">
<productForm v-if="show" 产品系列-SPU
</div>
<ProductForm v-if="show"
ref="d2GoodsProductForm" ref="d2GoodsProductForm"
:add-or-edit="addOrEdit" :add-or-edit="addOrEdit"
form-name="product"
:origin-data="editData"
:form-list="editForm" :form-list="editForm"
form-name="product"
:form-ref="proFormRef" :form-ref="proFormRef"
:is-product="false" :is-product="false"
:origin-data="editData"
@accessoryTypeChange="handleAccessoryTypeChange" @accessoryTypeChange="handleAccessoryTypeChange"
@handleAddBrandSupplyConfirm="handleAddBrandSupplyConfirm" @handleAddBrandSupplyConfirm="handleAddBrandSupplyConfirm"
@handleEditBrandSupplyConfirm="handleEditBrandSupplyConfirm"> @handleEditBrandSupplyConfirm="handleEditBrandSupplyConfirm">
</productForm> </ProductForm>
</div> </div>
</template> </template>
<script> <script>
import { deepClone } from '@/common/util' import { mapActions } from "vuex";
import { mapActions } from 'vuex' import { addBrandSupplyMerchant, editBrandSupplyMerchant, getAllCategory, getBrandSupplyMerchant, getProductTypeBySceneId } from "@/api/product";
import { getBrandSupplyMerchant, addBrandSupplyMerchant, editBrandSupplyMerchant, getProductTypeBySceneId, getAllCategory } from '@/api/product' import { deepClone } from "@/common/util";
import productForm from './productForm.vue' import { baseConfig } from "@/main";
import { baseConfig } from '@/main' import productForm from "./productForm.vue";
export default { export default {
name: 'SourceMaterial', name: "SourceMaterial",
components: {
ProductForm: productForm,
},
props: {
addOrEdit: String,
formData: Object,
},
data() { data() {
return { return {
userInfo: this.$store.state.d2admin.user.info, userInfo: this.$store.state.d2admin.user.info,
show: false, show: false,
editData: { editData: {
goodsName: '', goodsName: "",
goodsType: '', goodsType: "",
tempGoodsType: [], tempGoodsType: [],
goodsTypeName: '', goodsTypeName: "",
sapCode: '', sapCode: "",
brandMerchantCode: '', brandMerchantCode: "",
brandMerchantName: '', brandMerchantName: "",
supplierCode: '', supplierCode: "",
supplierName: '', supplierName: "",
thumbUrl: '', thumbUrl: "",
goodsImgList: [], goodsImgList: [],
goodsDescList: [], goodsDescList: [],
videoUrl: '', videoUrl: "",
convertedValue: '', convertedValue: "",
positionIds: [], positionIds: [],
carTypeList: [1, 2, 3, 4], carTypeList: [1, 2, 3, 4],
goodsPositionList: [], goodsPositionList: [],
goodsSource: 0, goodsSource: 0,
accessoryType: '' accessoryType: "",
}, },
proFormRef: 'pro', proFormRef: "pro",
editForm: [{ editForm: [{
formBlock: [ formBlock: [
{ {
name: 'goodsName', name: "goodsName",
label: '产品名称', label: "产品名称",
type: 'input', type: "input",
maxlength: 20, maxlength: 20,
width: '432px', width: "432px",
isDisabled: false isDisabled: false,
}, },
{ {
name: 'tempGoodsType', name: "tempGoodsType",
label: '类目', label: "类目",
isRequired: true, isRequired: true,
type: 'cascader', type: "cascader",
isClear: false, isClear: false,
isDisabled: false, isDisabled: false,
optionList: [], optionList: [],
optionId: 'categoryType', optionId: "categoryType",
optionLabel: 'categoryName', optionLabel: "categoryName",
width: '432px' width: "432px",
}, { },
name: 'sapCode', {
label: '编号', name: "sapCode",
type: 'input', label: "编号",
type: "input",
maxlength: 32, maxlength: 32,
width: '432px' width: "432px",
}, { },
name: 'brandMerchantCode', {
label: '品牌方', name: "brandMerchantCode",
label: "品牌方",
isRequired: true, isRequired: true,
type: 'special-select', type: "special-select",
isClear: true, isClear: true,
optionList: [], optionList: [],
optionId: 'id', optionId: "id",
optionLabel: 'relatedPartyName', optionLabel: "relatedPartyName",
partitionFlag: 1, partitionFlag: 1,
width: '432px' width: "432px",
}, { },
name: 'supplierCode', {
label: '供应方', name: "supplierCode",
label: "供应方",
isRequired: true, isRequired: true,
type: 'select', type: "select",
isClear: true, isClear: true,
optionList: [], optionList: [],
optionId: 'id', optionId: "id",
optionLabel: 'relatedPartyName', optionLabel: "relatedPartyName",
partitionFlag: 2, partitionFlag: 2,
width: '432px', width: "432px",
isDisabled: false isDisabled: false,
}, { },
name: 'thumbUrl', {
label: '缩略图', name: "thumbUrl",
type: 'photo', label: "缩略图",
tips: ['注:用于小程序主页商品列表配图展示', '请上传10M以内的jpg、jpeg、png图片,建议图片尺寸256*216'], type: "photo",
maxPhotoNum: 1 tips: ["注:用于小程序主页商品列表配图展示", "请上传10M以内的jpg、jpeg、png图片,建议图片尺寸256*216"],
}, { maxPhotoNum: 1,
name: 'goodsImgList', },
label: '产品主图', {
type: 'photo', name: "goodsImgList",
tips: ['注:用于在小程序商品详情页的顶部展示', '请上传10M以内的jpg、jpeg、png图片,建议图片尺寸256*216'], label: "产品主图",
maxPhotoNum: 10 type: "photo",
}, { tips: ["注:用于在小程序商品详情页的顶部展示", "请上传10M以内的jpg、jpeg、png图片,建议图片尺寸256*216"],
name: 'videoUrl', maxPhotoNum: 10,
label: '产品视频', },
type: 'video', {
tips: ['注:作为商品详情页顶部展示,格式建议mp4,大小不超过20M'], name: "videoUrl",
maxPhotoNum: 1 label: "产品视频",
}, { type: "video",
name: 'goodsDescList', tips: ["注:作为商品详情页顶部展示,格式建议mp4,大小不超过20M"],
label: '详情描述', maxPhotoNum: 1,
type: 'descList', },
maxlength: 256 {
}, { name: "goodsDescList",
name: 'accessoryType', label: "详情描述",
label: '配件性质', type: "descList",
type: 'radio', maxlength: 256,
},
{
name: "accessoryType",
label: "配件性质",
type: "radio",
isRequired: true, isRequired: true,
radioOptions: [ radioOptions: [
{ value: 1, label: '原厂件' }, { value: 1, label: "原厂件" },
{ value: 2, label: '品牌件' } { value: 2, label: "品牌件" },
] ],
}] },
],
}], }],
baseData: { baseData: {
productType: [] productType: [],
},
selfBuildGoodsType: baseConfig.selfBuildGoodsType || '' // 服务商自建类目值
}
},
components: {
productForm: productForm
}, },
selfBuildGoodsType: baseConfig.selfBuildGoodsType || "", // 服务商自建类目值
props: { };
addOrEdit: String,
formData: Object
}, },
mounted() { mounted() {
if (this.addOrEdit === 'edit') { if (this.addOrEdit === "edit") {
this.show = false this.show = false;
this.editData = deepClone(this.formData) this.editData = deepClone(this.formData);
this.editData.brandMerchantCode = Number(deepClone(this.formData).brandMerchantCode) || '' this.editData.brandMerchantCode = Number(deepClone(this.formData).brandMerchantCode) || "";
this.editData.supplierCode = Number(deepClone(this.formData).supplierCode) || '' this.editData.supplierCode = Number(deepClone(this.formData).supplierCode) || "";
if (!this.editData.goodsDescList) this.editData.goodsDescList = [] if (!this.editData.goodsDescList)
this.editData.goodsDescList = [];
// 太阳膜默认适用全部车型 部位回显 // 太阳膜默认适用全部车型 部位回显
if (this.editData.goodsType == 1) { if (this.editData.goodsType == 1) {
this.editData.carTypeList = deepClone(this.formData).carTypeList ? deepClone(this.formData).carTypeList : [1, 2, 3, 4] this.editData.carTypeList = deepClone(this.formData).carTypeList ? deepClone(this.formData).carTypeList : [1, 2, 3, 4];
this.editData.positionIds = deepClone(this.formData)?.goodsPositionList?.map(item => { return item.position }) this.editData.positionIds = deepClone(this.formData)?.goodsPositionList?.map((item) => {
return item.position;
});
} }
this.editData.goodsImgList = this.editData.goodsImgList || [] this.editData.goodsImgList = this.editData.goodsImgList || [];
this.editData.goodsImgList.forEach(i => { this.editData.goodsImgList.forEach((i) => {
delete i.createdDate delete i.createdDate;
delete i.updatedDate delete i.updatedDate;
}) });
this.editData.goodsDescList.forEach(i => { this.editData.goodsDescList.forEach((i) => {
delete i.createdDate delete i.createdDate;
delete i.updatedDate delete i.updatedDate;
}) });
this.$nextTick(() => { this.$nextTick(() => {
this.show = true this.show = true;
}) });
} else { } else {
this.show = true this.show = true;
} }
// 获取品牌方/供应方数据 1品牌商 2供应方 // 获取品牌方/供应方数据 1品牌商 2供应方
this.getBrandSupplyList(1) this.getBrandSupplyList(1);
this.getBrandSupplyList(2) this.getBrandSupplyList(2);
// 获取类目 // 获取类目
this.getGoodTypeList() this.getGoodTypeList();
}, },
methods: { methods: {
...mapActions({ ...mapActions({
get: 'd2admin/base/get', get: "d2admin/base/get",
close: 'd2admin/page/close' close: "d2admin/page/close",
}), }),
// 获取全部类目 屏蔽服务商自建类目 // 获取全部类目 屏蔽服务商自建类目
getGoodTypeList() { getGoodTypeList() {
getAllCategory({ categoryTypeList: this.selfBuildGoodsType, pageSize: 9999, currentPage: 1 }).then(res => { getAllCategory({ categoryTypeList: this.selfBuildGoodsType, pageSize: 9999, currentPage: 1 }).then((res) => {
const obj = this.editForm[0].formBlock[this.editForm[0].formBlock.findIndex(val => val.name == 'tempGoodsType')] const obj = this.editForm[0].formBlock[this.editForm[0].formBlock.findIndex(val => val.name == "tempGoodsType")];
obj.optionList = res?.list || [] obj.optionList = res?.list || [];
// SCRM同步过来商品 或者非草稿支持在当前类目下变更1.2.3级类目,不允许更换一级类目 // SCRM同步过来商品 或者非草稿支持在当前类目下变更1.2.3级类目,不允许更换一级类目
if (this.addOrEdit === 'edit' && (this.formData?.status != 3 || this.formData?.scrmFlag == 'Y')) { if (this.addOrEdit === "edit" && (this.formData?.status != 3 || this.formData?.scrmFlag == "Y")) {
obj.optionList.forEach(item => { obj.optionList.forEach((item) => {
if (item.categoryType != this.editData.goodsType) { if (item.categoryType != this.editData.goodsType) {
item.disabled = true item.disabled = true;
item?.children?.forEach(i => { item?.children?.forEach((i) => {
i.disabled = true i.disabled = true;
i?.children?.forEach(j => { i?.children?.forEach((j) => {
j.disabled = true j.disabled = true;
}) });
}) });
} }
}) });
} else { } else {
const goodsTypeIndex = this.editForm[0]?.formBlock.findIndex(val => val.name === 'tempGoodsType') const goodsTypeIndex = this.editForm[0]?.formBlock.findIndex(val => val.name === "tempGoodsType");
const goodsTypeOptionList = this.editForm[0]?.formBlock[goodsTypeIndex]?.optionList const goodsTypeOptionList = this.editForm[0]?.formBlock[goodsTypeIndex]?.optionList;
// 更新延保类目选项的 disabled 状态 // 更新延保类目选项的 disabled 状态
const updateGoodsTypeOptions = (isDisabled) => { const updateGoodsTypeOptions = (isDisabled) => {
const updatedGoodsTypeOptionList = goodsTypeOptionList.map(item => { const updatedGoodsTypeOptionList = goodsTypeOptionList.map((item) => {
const newItem = { ...item, disabled: isDisabled && this.baseConfig?.extendedPosiType?.includes(item.categoryType) }; const newItem = { ...item, disabled: isDisabled && this.baseConfig?.extendedPosiType?.includes(item.categoryType) };
if (newItem.children) { if (newItem.children) {
newItem.children = newItem.children.map(i => ({ newItem.children = newItem.children.map(i => ({
...i, ...i,
disabled: newItem.disabled, disabled: newItem.disabled,
children: i.children ? i.children.map(j => ({ ...j, disabled: newItem.disabled })) : undefined children: i.children ? i.children.map(j => ({ ...j, disabled: newItem.disabled })) : undefined,
})) }));
}
return newItem
})
this.$set(this.editForm[0].formBlock[goodsTypeIndex], 'optionList', updatedGoodsTypeOptionList)
} }
return newItem;
});
this.$set(this.editForm[0].formBlock[goodsTypeIndex], "optionList", updatedGoodsTypeOptionList);
};
// 根据 supplierCode 更新延保类目选项 // 根据 supplierCode 更新延保类目选项
if (this.formData?.supplierCode && !this.baseConfig?.supplierCode?.includes(`${this.formData?.supplierCode}`)) { if (this.formData?.supplierCode && !this.baseConfig?.supplierCode?.includes(`${this.formData?.supplierCode}`)) {
updateGoodsTypeOptions(true) updateGoodsTypeOptions(true);
} else { } else {
updateGoodsTypeOptions(false) updateGoodsTypeOptions(false);
} }
} }
// SCRM同步过来商品字段不可编辑 // SCRM同步过来商品字段不可编辑
if (this.formData?.scrmFlag == 'Y') { if (this.formData?.scrmFlag == "Y") {
let disabledLabel = ['goodsName', 'supplierCode'] let disabledLabel = ["goodsName", "supplierCode"];
for (var i = 0; i < disabledLabel.length; i++) { for (var i = 0; i < disabledLabel.length; i++) {
this.editForm[0].formBlock[this.editForm[0].formBlock.findIndex(val => val.name == disabledLabel[i])].isDisabled = true this.editForm[0].formBlock[this.editForm[0].formBlock.findIndex(val => val.name == disabledLabel[i])].isDisabled = true;
} }
} }
}) });
}, },
// 获取品牌/供应方 // 获取品牌/供应方
getBrandSupplyList(num) { getBrandSupplyList(num) {
getBrandSupplyMerchant({ getBrandSupplyMerchant({
partitionFlag: num partitionFlag: num,
}).then(res => { }).then((res) => {
if (num == 1) { if (num == 1) {
this.editForm[0].formBlock[this.editForm[0].formBlock.findIndex(val => val.name == 'brandMerchantCode')].optionList = res this.editForm[0].formBlock[this.editForm[0].formBlock.findIndex(val => val.name == "brandMerchantCode")].optionList = res;
} else { } else {
const supplierIndex = this.editForm[0]?.formBlock.findIndex(val => val.name === "supplierCode") const supplierIndex = this.editForm[0]?.formBlock.findIndex(val => val.name === "supplierCode");
this.editForm[0].formBlock[supplierIndex].optionList = res this.editForm[0].formBlock[supplierIndex].optionList = res;
const suppOptionList = this.editForm[0]?.formBlock[supplierIndex]?.optionList const suppOptionList = this.editForm[0]?.formBlock[supplierIndex]?.optionList;
// 更新供应方选项的 disabled 状态 // 更新供应方选项的 disabled 状态
const updateSupplierOptions = (isDisabled) => { const updateSupplierOptions = (isDisabled) => {
suppOptionList?.forEach(item => { suppOptionList?.forEach((item) => {
item.isDisabled = isDisabled && !this.baseConfig?.supplierCode?.includes(`${item.id}`) item.isDisabled = isDisabled && !this.baseConfig?.supplierCode?.includes(`${item.id}`);
}) });
this.$set(this.editForm[0].formBlock[supplierIndex], 'optionList', suppOptionList) this.$set(this.editForm[0].formBlock[supplierIndex], "optionList", suppOptionList);
} };
// 根据 goodsType 更新供应方选项 // 根据 goodsType 更新供应方选项
if (this.baseConfig?.extendedPosiType?.includes(this.formData?.goodsType)) { if (this.baseConfig?.extendedPosiType?.includes(this.formData?.goodsType)) {
updateSupplierOptions(true) updateSupplierOptions(true);
} else { } else {
updateSupplierOptions(false) updateSupplierOptions(false);
} }
} }
}) });
}, },
// 新增品牌商/供应商 // 新增品牌商/供应商
handleAddBrandSupplyConfirm(data) { handleAddBrandSupplyConfirm(data) {
addBrandSupplyMerchant(data).then(res => { addBrandSupplyMerchant(data).then((res) => {
this.getBrandSupplyList(data.partitionFlag) this.getBrandSupplyList(data.partitionFlag);
}) });
}, },
// 编辑删除 品牌商/供应商 // 编辑删除 品牌商/供应商
handleEditBrandSupplyConfirm(data) { handleEditBrandSupplyConfirm(data) {
editBrandSupplyMerchant(data).then(res => { editBrandSupplyMerchant(data).then((res) => {
this.getBrandSupplyList(data.partitionFlag) this.getBrandSupplyList(data.partitionFlag);
}) });
}, },
handleAccessoryTypeChange(val) { handleAccessoryTypeChange(val) {
this.$emit('accessoryTypeChange', val) this.$emit("accessoryTypeChange", val);
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.sourceMaterial-form { .sourceMaterial-form {
background: #ffffff; background: #ffffff;
...@@ -292,7 +309,7 @@ export default { ...@@ -292,7 +309,7 @@ export default {
height: 50px; height: 50px;
line-height: 50px; line-height: 50px;
padding: 0 20px; padding: 0 20px;
border-bottom: 1px solid #E5E5E5; border-bottom: 1px solid #e5e5e5;
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: #333333; color: #333333;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!