fix:新增产品类型
parent
6b62162e8d
commit
0f656cfed6
|
|
@ -81,6 +81,7 @@
|
|||
<el-table-column label="产品名称" align="center" prop="productName" />
|
||||
<el-table-column label="产品型号" align="center" prop="model" />
|
||||
<el-table-column label="制造商" align="center" prop="vendorName" />
|
||||
<el-table-column label="产品类型" align="center" prop="level2TypeName" />
|
||||
<el-table-column label="目录单价" align="center" prop="cataloguePrice" />
|
||||
<el-table-column label="指导折扣" align="center" prop="guidanceDiscount">
|
||||
<template slot-scope="scope">
|
||||
|
|
@ -147,16 +148,81 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="产品类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择产品类型">
|
||||
<el-option
|
||||
v-for="dict in dict.type.product_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择产品类型" @change="handleTypeChange">
|
||||
<el-option
|
||||
v-for="dict in dict.type.product_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="二级类型" prop="level2Type">
|
||||
<el-select v-model="form.level2Type" placeholder="请选择二级产品类型" @change="handleLevel2TypeChange">
|
||||
<el-option
|
||||
v-for="dict in level2TypeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<div v-if="level2TypeRelation">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="终端类型" prop="terminalType">
|
||||
<el-radio-group v-model="form.terminalType">
|
||||
<el-radio label="胖终端"/>
|
||||
<el-radio label="瘦终端"/>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="国产化" prop="localization">
|
||||
<el-radio-group v-model="form.localization">
|
||||
<el-radio label="信创"/>
|
||||
<el-radio label="商用"/>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="CPU品牌" prop="cpuBrand">
|
||||
<el-select v-model="form.cpuBrand" placeholder="请选择CPU品牌">
|
||||
<el-option
|
||||
v-for="dict in dict.type.cpu_brand"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="CPU架构" prop="cpuArchitecture">
|
||||
<el-select v-model="form.cpuArchitecture" placeholder="请选择CPU架构">
|
||||
<el-option
|
||||
v-for="dict in dict.type.cpu_architecture"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="目录单价" prop="cataloguePrice">
|
||||
|
|
@ -187,9 +253,6 @@
|
|||
<el-form-item v-if="form.type == '11' || form.type == '22'" label="维保年限" prop="value">
|
||||
<el-input-number v-model="form.value" placeholder="请输入维保年限" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
|
|
@ -202,10 +265,11 @@
|
|||
<script>
|
||||
import { listProduct, getProduct, delProduct, addProduct, updateProduct, exportProduct } from "@/api/system/product";
|
||||
import {listAllVendor} from "@/api/base/vendor";
|
||||
import {getDicts} from "@/api/system/dict/data";
|
||||
|
||||
export default {
|
||||
name: "Product",
|
||||
dicts: ['product_type'],
|
||||
dicts: ['product_type', 'cpu_brand', 'cpu_architecture'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
|
|
@ -228,6 +292,10 @@ export default {
|
|||
open: false,
|
||||
// 制造商选项
|
||||
vendorOptions: [],
|
||||
// 制造商选项
|
||||
level2TypeOptions: [],
|
||||
// 二级类型关联信息
|
||||
level2TypeRelation: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
|
|
@ -258,6 +326,13 @@ export default {
|
|||
type: [
|
||||
{ required: true, message: "产品类型不能为空", trigger: "change" }
|
||||
],
|
||||
level2Type: [
|
||||
{ required: true, message: "二级产品类型不能为空", trigger: "change" }
|
||||
],
|
||||
terminalType: [],
|
||||
localization: [],
|
||||
cpuBrand: [],
|
||||
cpuArchitecture: [],
|
||||
cataloguePrice: [
|
||||
{ required: true, message: "目录单价不能为空", trigger: "blur" }
|
||||
],
|
||||
|
|
@ -291,17 +366,52 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
// 先加载字典数据,然后再获取产品列表
|
||||
this.getDicts().then(() => {
|
||||
this.getList();
|
||||
});
|
||||
this.getVendorList();
|
||||
},
|
||||
methods: {
|
||||
/** 加载字典数据 */
|
||||
getDicts() {
|
||||
return getDicts('product_type').then(response => {
|
||||
// 这里只是加载主产品类型字典,二级类型字典会在需要时动态加载
|
||||
return Promise.resolve();
|
||||
});
|
||||
},
|
||||
/** 查询产品管理列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProduct(this.queryParams).then(response => {
|
||||
this.productList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
// 先获取所有产品类型的字典数据
|
||||
const productTypes = this.dict.type.product_type || [];
|
||||
// 为每个产品添加level2TypeName字段
|
||||
Promise.all(
|
||||
response.rows.map(product => {
|
||||
return new Promise(resolve => {
|
||||
if (product.level2Type && product.type) {
|
||||
// 动态加载对应产品类型的二级类型字典
|
||||
getDicts('product_type_' + product.type).then(dictResponse => {
|
||||
const level2TypeOptions = dictResponse.data || [];
|
||||
const option = level2TypeOptions.find(opt => opt.dictValue === product.level2Type);
|
||||
product.level2TypeName = option ? option.dictLabel : '';
|
||||
resolve(product);
|
||||
}).catch(() => {
|
||||
product.level2TypeName = '';
|
||||
resolve(product);
|
||||
});
|
||||
} else {
|
||||
product.level2TypeName = '';
|
||||
resolve(product);
|
||||
}
|
||||
});
|
||||
})
|
||||
).then(processedProducts => {
|
||||
this.productList = processedProducts;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 查询制造商列表 */
|
||||
|
|
@ -324,6 +434,11 @@ export default {
|
|||
productName: null,
|
||||
model: null,
|
||||
type: null,
|
||||
level2Type: null,
|
||||
terminalType: null,
|
||||
localization: null,
|
||||
cpuBrand: null,
|
||||
cpuArchitecture: null,
|
||||
cataloguePrice: null,
|
||||
guidanceDiscount: null,
|
||||
vendorCode: null,
|
||||
|
|
@ -366,6 +481,14 @@ export default {
|
|||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改产品管理";
|
||||
// 加载二级类型选项
|
||||
if (this.form.type) {
|
||||
getDicts('product_type_' + this.form.type).then(response => {
|
||||
this.level2TypeOptions = response.data;
|
||||
// 调用二级类型变化处理
|
||||
this.handleLevel2TypeChange(this.form.level2Type);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
|
|
@ -411,6 +534,51 @@ export default {
|
|||
}).catch(() => {
|
||||
this.exportLoading = false;
|
||||
});
|
||||
},
|
||||
handleTypeChange(type) {
|
||||
this.form.level2Type = null;
|
||||
this.level2TypeOptions = [];
|
||||
// 当产品类型改变时,隐藏云终端配置部分
|
||||
this.level2TypeRelation = false;
|
||||
// 移除相关验证
|
||||
this.rules.terminalType = [];
|
||||
this.rules.localization = [];
|
||||
this.rules.cpuBrand = [];
|
||||
this.rules.cpuArchitecture = [];
|
||||
// 清空字段值
|
||||
this.form.terminalType = null;
|
||||
this.form.localization = null;
|
||||
this.form.cpuBrand = null;
|
||||
this.form.cpuArchitecture = null;
|
||||
getDicts('product_type_' + type).then(response => {
|
||||
this.level2TypeOptions = response.data;
|
||||
});
|
||||
},
|
||||
handleLevel2TypeChange(level2Type) {
|
||||
/*
|
||||
产品类型:硬件
|
||||
二级类型:汇智云终端、H3C云终端、转售云终端
|
||||
*/
|
||||
if (this.form.type == 2 && (level2Type == 3 || level2Type == 4 || level2Type == 5)) {
|
||||
this.level2TypeRelation = true;
|
||||
// 显示时添加必填验证
|
||||
this.rules.terminalType = [{ required: true, message: "终端类型不能为空", trigger: "change" }];
|
||||
this.rules.localization = [{ required: true, message: "国产化不能为空", trigger: "change" }];
|
||||
this.rules.cpuBrand = [{ required: true, message: "CPU品牌不能为空", trigger: "change" }];
|
||||
this.rules.cpuArchitecture = [{ required: true, message: "CPU架构不能为空", trigger: "change" }];
|
||||
} else {
|
||||
this.level2TypeRelation = false;
|
||||
// 隐藏时移除必填验证
|
||||
this.rules.terminalType = [];
|
||||
this.rules.localization = [];
|
||||
this.rules.cpuBrand = [];
|
||||
this.rules.cpuArchitecture = [];
|
||||
// 清空字段值
|
||||
this.form.terminalType = null;
|
||||
this.form.localization = null;
|
||||
this.form.cpuBrand = null;
|
||||
this.form.cpuArchitecture = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -73,6 +73,16 @@ public class ProductInfo extends BaseEntity
|
|||
private Long inventoryCount;
|
||||
private Long warehouseId;
|
||||
private String warehouseName;
|
||||
// 二级类型
|
||||
private String level2Type;
|
||||
// 终端类型
|
||||
private String terminalType;
|
||||
// 国产化
|
||||
private String localization;
|
||||
// CPU品牌
|
||||
private String cpuBrand;
|
||||
// CPU架构
|
||||
private String cpuArchitecture;
|
||||
@Getter
|
||||
public enum ProductTypeEnum {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,11 +17,17 @@
|
|||
<result property="updatedAt" column="updated_at" />
|
||||
<result property="deletedAt" column="deleted_at" />
|
||||
<result property="hzCode" column="hz_code" />
|
||||
<result property="level2Type" column="level2_type" />
|
||||
<result property="terminalType" column="terminal_type" />
|
||||
<result property="localization" column="localization" />
|
||||
<result property="cpuBrand" column="cpu_brand" />
|
||||
<result property="cpuArchitecture" column="cpu_architecture" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProductInfoVo">
|
||||
select t1.id, t1.product_code, t1.product_name, t1.model, t1.description, t1.remark, t1.created_at, t1.updated_at,
|
||||
t1.deleted_at,t1.value,t1.type,t1.hz_code,t1.catalogue_price,t1.guidance_discount,t1.vendor_code,t1.available_count,t1.cumulative_count
|
||||
t1.deleted_at,t1.value,t1.type,t1.hz_code,t1.catalogue_price,t1.guidance_discount,t1.vendor_code,t1.available_count,t1.cumulative_count,
|
||||
t1.level2_type, t1.terminal_type, t1.localization, t1.cpu_brand, t1.cpu_architecture
|
||||
,t2.vendor_name
|
||||
from product_info t1 left join oms_vendor_info t2 on t1.vendor_code = t2.vendor_code
|
||||
</sql>
|
||||
|
|
@ -162,6 +168,11 @@
|
|||
<if test="type != null">type,</if>
|
||||
<if test="value != null">value,</if>
|
||||
<if test="hzCode != null">hz_code,</if>
|
||||
<if test="level2Type != null and level2Type != ''">level2_type,</if>
|
||||
<if test="terminalType != null and terminalType != ''">terminal_type,</if>
|
||||
<if test="localization != null and localization != ''">localization,</if>
|
||||
<if test="cpuBrand != null and cpuBrand != ''">cpu_brand,</if>
|
||||
<if test="cpuArchitecture != null and cpuArchitecture != ''">cpu_architecture,</if>
|
||||
created_at,status,create_by
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
|
|
@ -176,6 +187,11 @@
|
|||
<if test="type != null">#{type},</if>
|
||||
<if test="value != null">#{value},</if>
|
||||
<if test="hzCode != null">#{hzCode},</if>
|
||||
<if test="level2Type != null and level2Type != ''">#{level2Type},</if>
|
||||
<if test="terminalType != null and terminalType != ''">#{terminalType},</if>
|
||||
<if test="localization != null and localization != ''">#{localization},</if>
|
||||
<if test="cpuBrand != null and cpuBrand != ''">#{cpuBrand},</if>
|
||||
<if test="cpuArchitecture != null and cpuArchitecture != ''">#{cpuArchitecture},</if>
|
||||
NOW(),0,#{createBy}
|
||||
</trim>
|
||||
</insert>
|
||||
|
|
@ -194,6 +210,11 @@
|
|||
<if test="type != null">type = #{type},</if>
|
||||
<if test="value != null">value = #{value},</if>
|
||||
<if test="hzCode != null">hz_code = #{hzCode},</if>
|
||||
<if test="level2Type != null and level2Type != ''">level2_type = #{level2Type},</if>
|
||||
<if test="terminalType != null and terminalType != ''">terminal_type = #{terminalType},</if>
|
||||
<if test="localization != null and localization != ''">localization = #{localization},</if>
|
||||
<if test="cpuBrand != null and cpuBrand != ''">cpu_brand = #{cpuBrand},</if>
|
||||
<if test="cpuArchitecture != null and cpuArchitecture != ''">cpu_architecture = #{cpuArchitecture},</if>
|
||||
<if test="createdAt != null">created_at = #{createdAt},</if>
|
||||
updated_at = NOW(),update_by=#{updateBy}
|
||||
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue