优化商品的多属性功能,编辑的页面也可以操作多属性
This commit is contained in:
@@ -10,7 +10,7 @@ Target Server Type : MYSQL
|
||||
Target Server Version : 50704
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2025-03-25 23:43:27
|
||||
Date: 2025-04-09 21:17:48
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
@@ -374,6 +374,7 @@ CREATE TABLE `jsh_material` (
|
||||
`enable_serial_number` varchar(1) DEFAULT '0' COMMENT '是否开启序列号,0否,1是',
|
||||
`enable_batch_number` varchar(1) DEFAULT '0' COMMENT '是否开启批号,0否,1是',
|
||||
`position` varchar(100) DEFAULT NULL COMMENT '仓位货架',
|
||||
`attribute` varchar(1000) DEFAULT NULL COMMENT '属性信息',
|
||||
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id',
|
||||
`delete_flag` varchar(1) DEFAULT '0' COMMENT '删除标记,0未删除,1删除',
|
||||
PRIMARY KEY (`id`),
|
||||
@@ -384,15 +385,15 @@ CREATE TABLE `jsh_material` (
|
||||
-- ----------------------------
|
||||
-- Records of jsh_material
|
||||
-- ----------------------------
|
||||
INSERT INTO `jsh_material` VALUES ('568', '17', '商品1', '制1', 'sp1', '', null, null, '', '个', '', null, null, null, null, '', '', '', '', '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('569', '17', '商品2', '', 'sp2', '', null, null, '', '只', '', null, null, null, null, '', '', '', '', '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('570', '17', '商品3', '', 'sp3', '', null, null, '', '个', '', null, null, null, null, '', '', '', '', '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('577', null, '商品8', '', 'sp8', '', null, null, '', '', '', null, '15', null, null, '', '', '', '', '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('579', '21', '商品17', '', 'sp17', '', null, null, '', '', '', null, '15', null, null, '', '', '', '', '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('586', '17', '序列号商品测试', '', 'xlh123', '', null, null, '', '个', '', null, null, null, null, '', '', '', '', '1', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('587', '17', '商品test1', '南通中远', '', 'test1', null, null, '', '个', '', null, null, null, null, '', '', '', '', '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('588', '21', '商品200', 'fafda', 'weqwe', '300ml', null, null, '红色', '个', 'aaaabbbbb', null, null, null, null, '', '', '', '', '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('619', null, '衣服', null, null, null, null, null, null, '件', null, '', null, null, null, '', null, null, null, '0', '0', null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('568', '17', '商品1', '制1', 'sp1', '', null, null, '', '个', '', null, null, null, null, '', '', '', '', '0', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('569', '17', '商品2', '', 'sp2', '', null, null, '', '只', '', null, null, null, null, '', '', '', '', '0', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('570', '17', '商品3', '', 'sp3', '', null, null, '', '个', '', null, null, null, null, '', '', '', '', '0', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('577', null, '商品8', '', 'sp8', '', null, null, '', '', '', null, '15', null, null, '', '', '', '', '0', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('579', '21', '商品17', '', 'sp17', '', null, null, '', '', '', null, '15', null, null, '', '', '', '', '0', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('586', '17', '序列号商品测试', '', 'xlh123', '', null, null, '', '个', '', null, null, null, null, '', '', '', '', '1', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('587', '17', '商品test1', '南通中远', '', 'test1', null, null, '', '个', '', null, null, null, null, '', '', '', '', '0', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('588', '21', '商品200', 'fafda', 'weqwe', '300ml', null, null, '红色', '个', 'aaaabbbbb', null, null, null, null, '', '', '', '', '0', '0', null, null, '63', '0');
|
||||
INSERT INTO `jsh_material` VALUES ('619', null, '衣服', null, null, null, null, null, null, '件', null, '', null, null, null, '', null, null, null, '0', '0', null, null, '63', '0');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for jsh_material_attribute
|
||||
|
||||
@@ -1650,4 +1650,11 @@ alter table jsh_material_property add tenant_id bigint(20) DEFAULT NULL COMMENT
|
||||
-- by jishenghua
|
||||
-- 给jsh_account_head表的文件字段增加长度
|
||||
-- --------------------------------------------------------
|
||||
alter table jsh_account_head change file_name file_name varchar(1000) DEFAULT NULL COMMENT '附件名称';
|
||||
alter table jsh_account_head change file_name file_name varchar(1000) DEFAULT NULL COMMENT '附件名称';
|
||||
|
||||
-- --------------------------------------------------------
|
||||
-- 时间 2025年4月9日
|
||||
-- by jishenghua
|
||||
-- 给商品表增加多属性字段,里面存多属性的数组
|
||||
-- --------------------------------------------------------
|
||||
alter table jsh_material add attribute varchar(1000) DEFAULT NULL COMMENT '属性信息' after position;
|
||||
@@ -47,6 +47,8 @@ public class Material {
|
||||
|
||||
private String position;
|
||||
|
||||
private String attribute;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private String deleteFlag;
|
||||
@@ -227,6 +229,14 @@ public class Material {
|
||||
this.position = position == null ? null : position.trim();
|
||||
}
|
||||
|
||||
public String getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public void setAttribute(String attribute) {
|
||||
this.attribute = attribute == null ? null : attribute.trim();
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
@@ -1585,6 +1585,76 @@ public class MaterialExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeIsNull() {
|
||||
addCriterion("attribute is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeIsNotNull() {
|
||||
addCriterion("attribute is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeEqualTo(String value) {
|
||||
addCriterion("attribute =", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeNotEqualTo(String value) {
|
||||
addCriterion("attribute <>", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeGreaterThan(String value) {
|
||||
addCriterion("attribute >", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("attribute >=", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeLessThan(String value) {
|
||||
addCriterion("attribute <", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeLessThanOrEqualTo(String value) {
|
||||
addCriterion("attribute <=", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeLike(String value) {
|
||||
addCriterion("attribute like", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeNotLike(String value) {
|
||||
addCriterion("attribute not like", value, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeIn(List<String> values) {
|
||||
addCriterion("attribute in", values, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeNotIn(List<String> values) {
|
||||
addCriterion("attribute not in", values, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeBetween(String value1, String value2) {
|
||||
addCriterion("attribute between", value1, value2, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAttributeNotBetween(String value1, String value2) {
|
||||
addCriterion("attribute not between", value1, value2, "attribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIsNull() {
|
||||
addCriterion("tenant_id is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -23,9 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -97,6 +95,21 @@ public class MaterialExtendService {
|
||||
updatedJson.add(tempJson);
|
||||
}
|
||||
}
|
||||
//针对多属性商品要考虑到有条码被删的情况,需要和原来的条码明细进行对比
|
||||
//1.先查询原来的条码列表
|
||||
List<MaterialExtendVo4List> meList = materialExtendMapperEx.getDetailList(materialId);
|
||||
//2.构造新的条码列表map
|
||||
Map<String, String> barCodeMap = new HashMap<>();
|
||||
for (int i = 0; i < meArr.size(); i++) {
|
||||
JSONObject tempJson = meArr.getJSONObject(i);
|
||||
barCodeMap.put(tempJson.getString("barCode"),tempJson.getString("barCode"));
|
||||
}
|
||||
//3.如果老的条码在新的里面不存在,则丢入删除队列
|
||||
for(MaterialExtendVo4List me: meList) {
|
||||
if(barCodeMap.get(me.getBarCode()) == null) {
|
||||
deletedJson.add(me.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != deletedJson) {
|
||||
|
||||
@@ -154,6 +154,8 @@ public class MaterialService {
|
||||
public int insertMaterial(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
Material m = JSONObject.parseObject(obj.toJSONString(), Material.class);
|
||||
m.setEnabled(true);
|
||||
//构造多属性数组字符串
|
||||
m.setAttribute(parseAttributeBySku(obj));
|
||||
try{
|
||||
materialMapperEx.insertSelectiveEx(m);
|
||||
Long mId = m.getId();
|
||||
@@ -196,6 +198,8 @@ public class MaterialService {
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
|
||||
Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
|
||||
//构造多属性数组字符串
|
||||
material.setAttribute(parseAttributeBySku(obj));
|
||||
try{
|
||||
materialMapper.updateByPrimaryKeySelective(material);
|
||||
if(material.getUnitId() == null) {
|
||||
@@ -1462,4 +1466,26 @@ public class MaterialService {
|
||||
public MaterialExtend getMaterialExtendBySerialNumber(String serialNumber) {
|
||||
return materialMapperEx.getMaterialExtendBySerialNumber(serialNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造多属性数组字符串
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public String parseAttributeBySku(JSONObject obj) {
|
||||
if(obj!=null) {
|
||||
JSONObject attributeObj = new JSONObject();
|
||||
JSONArray manySku = obj.getJSONArray("manySku");
|
||||
JSONArray skuOne = obj.getJSONArray("skuOne");
|
||||
JSONArray skuTwo = obj.getJSONArray("skuTwo");
|
||||
JSONArray skuThree = obj.getJSONArray("skuThree");
|
||||
attributeObj.put("manySku", manySku);
|
||||
attributeObj.put("skuOne", skuOne);
|
||||
attributeObj.put("skuTwo", skuTwo);
|
||||
attributeObj.put("skuThree", skuThree);
|
||||
return attributeObj.toJSONString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<result column="enable_serial_number" jdbcType="VARCHAR" property="enableSerialNumber" />
|
||||
<result column="enable_batch_number" jdbcType="VARCHAR" property="enableBatchNumber" />
|
||||
<result column="position" jdbcType="VARCHAR" property="position" />
|
||||
<result column="attribute" jdbcType="VARCHAR" property="attribute" />
|
||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
|
||||
<result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
|
||||
</resultMap>
|
||||
@@ -88,7 +89,7 @@
|
||||
<sql id="Base_Column_List">
|
||||
id, category_id, name, mfrs, model, standard, brand, mnemonic, color, unit, remark,
|
||||
img_name, unit_id, expiry_num, weight, enabled, other_field1, other_field2, other_field3,
|
||||
enable_serial_number, enable_batch_number, position, tenant_id, delete_flag
|
||||
enable_serial_number, enable_batch_number, position, attribute, tenant_id, delete_flag
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@@ -128,8 +129,8 @@
|
||||
unit_id, expiry_num, weight,
|
||||
enabled, other_field1, other_field2,
|
||||
other_field3, enable_serial_number, enable_batch_number,
|
||||
position, tenant_id, delete_flag
|
||||
)
|
||||
position, attribute, tenant_id,
|
||||
delete_flag)
|
||||
values (#{id,jdbcType=BIGINT}, #{categoryId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
|
||||
#{mfrs,jdbcType=VARCHAR}, #{model,jdbcType=VARCHAR}, #{standard,jdbcType=VARCHAR},
|
||||
#{brand,jdbcType=VARCHAR}, #{mnemonic,jdbcType=VARCHAR}, #{color,jdbcType=VARCHAR},
|
||||
@@ -137,8 +138,8 @@
|
||||
#{unitId,jdbcType=BIGINT}, #{expiryNum,jdbcType=INTEGER}, #{weight,jdbcType=DECIMAL},
|
||||
#{enabled,jdbcType=BIT}, #{otherField1,jdbcType=VARCHAR}, #{otherField2,jdbcType=VARCHAR},
|
||||
#{otherField3,jdbcType=VARCHAR}, #{enableSerialNumber,jdbcType=VARCHAR}, #{enableBatchNumber,jdbcType=VARCHAR},
|
||||
#{position,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
|
||||
)
|
||||
#{position,jdbcType=VARCHAR}, #{attribute,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT},
|
||||
#{deleteFlag,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Material">
|
||||
insert into jsh_material
|
||||
@@ -209,6 +210,9 @@
|
||||
<if test="position != null">
|
||||
position,
|
||||
</if>
|
||||
<if test="attribute != null">
|
||||
attribute,
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
tenant_id,
|
||||
</if>
|
||||
@@ -283,6 +287,9 @@
|
||||
<if test="position != null">
|
||||
#{position,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="attribute != null">
|
||||
#{attribute,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
#{tenantId,jdbcType=BIGINT},
|
||||
</if>
|
||||
@@ -366,6 +373,9 @@
|
||||
<if test="record.position != null">
|
||||
position = #{record.position,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.attribute != null">
|
||||
attribute = #{record.attribute,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.tenantId != null">
|
||||
tenant_id = #{record.tenantId,jdbcType=BIGINT},
|
||||
</if>
|
||||
@@ -401,6 +411,7 @@
|
||||
enable_serial_number = #{record.enableSerialNumber,jdbcType=VARCHAR},
|
||||
enable_batch_number = #{record.enableBatchNumber,jdbcType=VARCHAR},
|
||||
position = #{record.position,jdbcType=VARCHAR},
|
||||
attribute = #{record.attribute,jdbcType=VARCHAR},
|
||||
tenant_id = #{record.tenantId,jdbcType=BIGINT},
|
||||
delete_flag = #{record.deleteFlag,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
@@ -473,6 +484,9 @@
|
||||
<if test="position != null">
|
||||
position = #{position,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="attribute != null">
|
||||
attribute = #{attribute,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
tenant_id = #{tenantId,jdbcType=BIGINT},
|
||||
</if>
|
||||
@@ -505,6 +519,7 @@
|
||||
enable_serial_number = #{enableSerialNumber,jdbcType=VARCHAR},
|
||||
enable_batch_number = #{enableBatchNumber,jdbcType=VARCHAR},
|
||||
position = #{position,jdbcType=VARCHAR},
|
||||
attribute = #{attribute,jdbcType=VARCHAR},
|
||||
tenant_id = #{tenantId,jdbcType=BIGINT},
|
||||
delete_flag = #{deleteFlag,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
|
||||
@@ -190,6 +190,9 @@
|
||||
<if test="position != null">
|
||||
position,
|
||||
</if>
|
||||
<if test="attribute != null">
|
||||
attribute,
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
tenant_id,
|
||||
</if>
|
||||
@@ -264,6 +267,9 @@
|
||||
<if test="position != null">
|
||||
#{position,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="attribute != null">
|
||||
#{attribute,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
#{tenantId,jdbcType=BIGINT},
|
||||
</if>
|
||||
|
||||
@@ -157,13 +157,12 @@
|
||||
</a-tooltip>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="6" :sm="24" v-if="!model.id">
|
||||
<a-col :md="6" :sm="24">
|
||||
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="多属性" data-step="15" data-title="多属性"
|
||||
data-intro="多属性是针对的sku商品(比如服装、鞋帽行业),此处开关如果启用就可以在下方进行多sku的配置,配置具体的颜色、尺码之类的组合">
|
||||
<a-tooltip title="多属性针对服装、鞋帽等行业,需要先录入单位才能激活此处输入框">
|
||||
<a-tag class="tag-info" v-if="!manySkuStatus">需要先录入单位才能激活</a-tag>
|
||||
data-intro="多属性是针对的sku商品(比如服装、鞋帽、家纺行业),此处开关如果启用就可以在下方进行多sku的配置,配置具体的颜色、尺码之类的组合">
|
||||
<a-tooltip title="多属性针对服装、鞋帽、家纺等行业(注意不要勾选多单位,因为多属性商品不支持多单位,只支持单个的单位)">
|
||||
<a-select mode="multiple" v-decorator="[ 'manySku' ]" showSearch optionFilterProp="children"
|
||||
placeholder="请选择多属性(可多选)" @change="onManySkuChange" v-show="manySkuStatus">
|
||||
placeholder="请选择多属性(可多选)" @change="onManySkuChange" :disabled="attributeStatus">
|
||||
<a-select-option v-for="(item,index) in materialAttributeList" :key="index" :value="item.value" :disabled="item.disabled">
|
||||
{{ item.name }}
|
||||
</a-select-option>
|
||||
@@ -331,12 +330,12 @@
|
||||
unitStatus: false,
|
||||
manyUnitStatus: true,
|
||||
unitChecked: false,
|
||||
manySkuStatus: false,
|
||||
switchDisabled: false, //开关的启用状态
|
||||
barCodeSwitch: false, //生成条码开关
|
||||
maxBarCodeInfo: '', //最大条码
|
||||
meDeleteIdList: [], //删除条码信息的id数组
|
||||
prefixNo: 'material',
|
||||
attributeStatus: false,
|
||||
materialAttributeList: [],
|
||||
skuOneTitle: '属性1',
|
||||
skuTwoTitle: '属性2',
|
||||
@@ -344,6 +343,7 @@
|
||||
skuOneList: [],
|
||||
skuTwoList: [],
|
||||
skuThreeList: [],
|
||||
meOldDataSource: [],
|
||||
manySkuSelected: 0,
|
||||
model: {},
|
||||
showOkFlag: true,
|
||||
@@ -490,12 +490,21 @@
|
||||
})
|
||||
},
|
||||
edit (record) {
|
||||
let that = this
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, record);
|
||||
let attribute = record.attribute
|
||||
if(attribute) {
|
||||
//构造多属性
|
||||
let attrObj = JSON.parse(attribute)
|
||||
this.model.manySku = attrObj.manySku
|
||||
this.model.skuOne = attrObj.skuOne
|
||||
this.model.skuTwo = attrObj.skuTwo
|
||||
this.model.skuThree = attrObj.skuThree
|
||||
}
|
||||
this.activeKey = '1'
|
||||
this.manySkuSelected = 0
|
||||
this.barCodeSwitch = false
|
||||
this.manySkuStatus = false
|
||||
this.maxBarCodeInfo = ''
|
||||
this.visible = true
|
||||
this.meDeleteIdList = []
|
||||
@@ -511,7 +520,8 @@
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model, 'name', 'standard', 'unit', 'unitId', 'model', 'color', 'brand', 'mnemonic',
|
||||
'categoryId','enableSerialNumber','enableBatchNumber','position','expiryNum','weight','remark','mfrs','otherField1','otherField2','otherField3'))
|
||||
'categoryId','enableSerialNumber','enableBatchNumber','position','expiryNum','weight','remark','mfrs',
|
||||
'otherField1','otherField2','otherField3','manySku','skuOne','skuTwo','skuThree'))
|
||||
autoJumpNextInput('materialHeadModal')
|
||||
autoJumpNextInput('materialDetailModal')
|
||||
});
|
||||
@@ -532,12 +542,23 @@
|
||||
this.unitStatus = true
|
||||
this.manyUnitStatus = false
|
||||
}
|
||||
//编辑状态下有多属性,则不允许修改
|
||||
if(this.model.manySku) {
|
||||
this.attributeStatus = true
|
||||
//加载每个多属性的下拉框
|
||||
setTimeout(function() {
|
||||
that.loadSkuList(that.model.manySku)
|
||||
},1000)
|
||||
} else {
|
||||
this.attributeStatus = false
|
||||
}
|
||||
let params = { materialId: this.model.id }
|
||||
//编辑商品的时候多属性字段可以修改
|
||||
this.meTable.columns[2].readonly = false
|
||||
this.requestMeTableData(this.url.materialsExtendList, params, this.meTable)
|
||||
this.requestDepotTableData(this.url.depotWithStock, { mId: this.model.id }, this.depotTable)
|
||||
} else {
|
||||
this.attributeStatus = false
|
||||
this.switchDisabled = false
|
||||
this.meTable.columns[2].readonly = true
|
||||
this.requestDepotTableData(this.url.depotWithStock, { mId: 0 }, this.depotTable)
|
||||
@@ -555,6 +576,7 @@
|
||||
}
|
||||
}
|
||||
tab.dataSource = res.data.rows || []
|
||||
this.meOldDataSource = res.data.rows || []
|
||||
//复制新增商品-初始化条码信息
|
||||
if(this.action === 'copyAdd') {
|
||||
getMaxBarCode({}).then((res)=> {
|
||||
@@ -649,6 +671,10 @@
|
||||
this.$message.warning('抱歉,序列号和批号只能选择一项!');
|
||||
return;
|
||||
}
|
||||
if(formData.manySku && formData.unitId) {
|
||||
this.$message.warning('抱歉,多属性商品不能勾选多单位,请切换为单个单位!');
|
||||
return;
|
||||
}
|
||||
//校验商品是否存在,通过校验商品的名称、型号、规格、颜色、单位、制造商等
|
||||
let param = {
|
||||
id: this.model.id?this.model.id:0,
|
||||
@@ -885,6 +911,46 @@
|
||||
this.barCodeSwitch = false;
|
||||
this.meTable.dataSource = []
|
||||
},
|
||||
//编辑页面加载的时候加载存在的sku
|
||||
loadSkuList(value) {
|
||||
this.manySkuSelected = value.length
|
||||
//更新属性1和属性2和属性3的下拉框
|
||||
if(value.length <= 3) {
|
||||
let skuOneId = value[0]
|
||||
let skuTwoId = value[1]
|
||||
let skuThreeId = value[2]
|
||||
this.materialAttributeList.forEach(item => {
|
||||
if(item.value === skuOneId) {
|
||||
this.skuOneTitle = item.name
|
||||
}
|
||||
if(item.value === skuTwoId) {
|
||||
this.skuTwoTitle = item.name
|
||||
}
|
||||
if(item.value === skuThreeId) {
|
||||
this.skuThreeTitle = item.name
|
||||
}
|
||||
})
|
||||
if(skuOneId) {
|
||||
getMaterialAttributeValueListById({'id': skuOneId}).then((res)=>{
|
||||
this.skuOneList = res? res:[]
|
||||
this.form.setFieldsValue(pick(this.model, 'skuOne'))
|
||||
})
|
||||
}
|
||||
if(skuTwoId) {
|
||||
getMaterialAttributeValueListById({'id': skuTwoId}).then((res)=>{
|
||||
this.skuTwoList = res? res:[]
|
||||
this.form.setFieldsValue(pick(this.model, 'skuTwo'))
|
||||
})
|
||||
}
|
||||
if(skuThreeId) {
|
||||
getMaterialAttributeValueListById({'id': skuThreeId}).then((res)=>{
|
||||
this.skuThreeList = res? res:[]
|
||||
this.form.setFieldsValue(pick(this.model, 'skuThree'))
|
||||
})
|
||||
}
|
||||
}
|
||||
this.barCodeSwitch = false
|
||||
},
|
||||
onSkuChange() {
|
||||
let skuOneData = this.form.getFieldValue('skuOne')
|
||||
let skuTwoData = this.form.getFieldValue('skuTwo')
|
||||
@@ -961,16 +1027,41 @@
|
||||
let meTableData = []
|
||||
getMaxBarCode({}).then((res)=>{
|
||||
if(res && res.code===200) {
|
||||
let k = 0
|
||||
let maxBarCode = res.data.barCode-0
|
||||
for (let i = 0; i < barCodeSku.length; i++) {
|
||||
let currentBarCode = maxBarCode + i + 1
|
||||
meTableData.push({barCode: currentBarCode, commodityUnit: unit, sku: barCodeSku[i]})
|
||||
let currentBarCode = ''
|
||||
let currentId = ''
|
||||
let purchaseDecimal = ''
|
||||
let commodityDecimal = ''
|
||||
let wholesaleDecimal = ''
|
||||
let lowDecimal = ''
|
||||
for (let j = 0; j < this.meOldDataSource.length; j++) {
|
||||
if(barCodeSku[i] === this.meOldDataSource[j].sku) {
|
||||
currentBarCode = this.meOldDataSource[j].barCode
|
||||
currentId = this.meOldDataSource[j].id
|
||||
purchaseDecimal = this.meOldDataSource[j].purchaseDecimal
|
||||
commodityDecimal = this.meOldDataSource[j].commodityDecimal
|
||||
wholesaleDecimal = this.meOldDataSource[j].wholesaleDecimal
|
||||
lowDecimal = this.meOldDataSource[j].lowDecimal
|
||||
}
|
||||
}
|
||||
if(currentBarCode) {
|
||||
//此时说明该sku之前就存在
|
||||
meTableData.push({id: currentId, barCode: currentBarCode, commodityUnit: unit, sku: barCodeSku[i],
|
||||
purchaseDecimal: purchaseDecimal, commodityDecimal: commodityDecimal,
|
||||
wholesaleDecimal: wholesaleDecimal, lowDecimal: lowDecimal})
|
||||
} else {
|
||||
k = k+1
|
||||
currentBarCode = maxBarCode + k
|
||||
meTableData.push({barCode: currentBarCode, commodityUnit: unit, sku: barCodeSku[i]})
|
||||
}
|
||||
}
|
||||
this.meTable.dataSource = meTableData
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.warning('请填写单位(注意不要勾选多单位)');
|
||||
this.$message.warning('请填写单位(注意不要勾选多单位,因为多属性商品不支持多单位)');
|
||||
this.barCodeSwitch = false;
|
||||
}
|
||||
},
|
||||
@@ -1170,12 +1261,6 @@
|
||||
}
|
||||
},
|
||||
onlyUnitOnChange(e) {
|
||||
if(e.target.value) {
|
||||
//单位有填写了之后则显示多属性的文本框
|
||||
this.manySkuStatus = true
|
||||
} else {
|
||||
this.manySkuStatus = false
|
||||
}
|
||||
this.$refs.editableMeTable.getValues((error, values) => {
|
||||
let mArr = values
|
||||
for (let i = 0; i < mArr.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user