2023-05-12-01-bug

master
喻忠伟 2 years ago
parent d7d615dfe8
commit 282e5196c4
  1. 553
      ant-design-vue-jeecg/src/views/zygoods/modules/ZyGoodsForm.vue
  2. 83
      jeecg-boot/jeecg-boot-base/jeecg-boot-base-tools/src/main/java/org/jeecg/common/util/UniqueRanNumUtils.java
  3. 1697
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zygoods/controller/ZyGoodsController.java

@ -1,275 +1,280 @@
<template>
<a-spin :spinning="confirmLoading">
<j-form-container :disabled="formDisabled">
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
<a-row>
<a-col :span="24">
<a-form-model-item label="企业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="enterprisesId">
<j-select-depart1 v-model="model.enterprisesId" @change="getlx()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="服装类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="clothsTypeId">
<!--<j-dict-select-tag type="list" v-model="model.clothsTypeId" :dictCode="lx" placeholder="请选择类型" @change="getks()"/>-->
<j-dict-select-tag type="list" v-model="model.clothsTypeId" dictCode="zy_cloths_type,type_name,id" placeholder="请选择类型" @change="getks()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="服装款式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="styleId">
<j-dict-select-tag type="list" v-model="model.styleId" :dictCode="ks" placeholder="请选择款式" @change="getxh()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="服装型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="modelId">
<j-dict-select-tag type="list" v-model="model.modelId" :dictCode="xh" placeholder="请选择型号" @change="getspbh()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsCode">
<a-input v-model="model.goodsCode" placeholder="请输入商品编号" disabled></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsName">
<a-input v-model="model.goodsName" placeholder="请输入商品名称" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsIntr">
<a-textarea v-model="model.goodsIntr" placeholder="请输入商品描述" rows="4"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="是否定制" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customized">
<j-dict-select-tag type="radio" v-model="model.customized" dictCode="yn" placeholder="请选择是否定制" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsPicture">
<j-image-upload isMultiple v-model="model.goodsPicture" ></j-image-upload>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="默认图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="defaultPicture">
<j-image-upload isMultiple v-model="model.defaultPicture" ></j-image-upload>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品视频" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsVideo">
<j-upload v-model="model.goodsVideo" ></j-upload>
<video v-if="model.goodsVideo" :src="video" style="border:1px solid #d9d9d9;width:100%;" :autoplay="autoplay"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unit">
<a-input v-model="model.unit" placeholder="请输入单位" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="包装个数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="number">
<a-input-number v-model="model.number" placeholder="请输入包装个数" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="单价(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unitPrice">
<a-input-number v-model="model.unitPrice" placeholder="请输入单价" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="折扣(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="discount">
<a-input-number v-model="model.discount" placeholder="请输入折扣" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="促销价(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="promotionPrice">
<a-input-number v-model="model.promotionPrice" placeholder="请输入促销价" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="是否推荐" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recommend">
<j-dict-select-tag type="radio" v-model="model.recommend" dictCode="yn" placeholder="请选择是否推荐" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="产地" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="placeOrigin">
<a-input v-model="model.placeOrigin" placeholder="请输入产地" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
<j-dict-select-tag type="radio" v-model="model.status" dictCode="good_status" placeholder="请选择状态" />
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>
</a-spin>
</template>
<script>
import { httpAction, getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
export default {
name: 'ZyGoodsForm',
components: {
},
props: {
//
disabled: {
type: Boolean,
default: false,
required: false
}
},
data () {
return {
lx:'zy_cloths_type ,type_name,id',
ks:'zy_cloths_style,style_names,id',
xh:'zy_style_model,model_number,id',
autoplay:true,
model:{
customized:0,
recommend:0,
status:1,
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
validatorRules: {
enterprisesId:[{
required: true, message: '请选择企业!'
}],
modelId:[{
required: true, message: '请选择型号!'
}],
goodsCode: [
{ required: true, message: '请输入商品编号!'},
],
styleId: [
{ required: true, message: '请选择款式!'},
],
clothsTypeId:[{
required: true, message: '请选择类型!'
}],
number: [
{ required: false},
{ pattern: /^[+]{0,1}(\d+)$/, message: '包装个数必须大于等于0!'},
],
unitPrice: [
{ required: false},
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
],
discount: [
{ required: false},
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
],
promotionPrice: [
{ required: false},
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
],
goodsName: [
{ required: true, message: '请输入商品名称!'},
{ pattern: /^.{1,50}$/, message: '商品名称不能超过50个字符!'},
],
},
url: {
add: "/zygoods/zyGoods/add",
edit: "/zygoods/zyGoods/edit",
queryById: "/zygoods/zyGoods/queryById",
zy:"/zygoods/zyGoods/getspbh",
zystyle:"/zygoods/zyGoods/getzystyle",
}
}
},
computed: {
formDisabled(){
return this.disabled
},
video(){
return `${window._CONFIG['domianURL']}/sys/common/static/${this.model.goodsVideo}`
},
},
created () {
//model
this.modelDefault = JSON.parse(JSON.stringify(this.model));
},
methods: {
getlx(){
this.lx ="zy_cloths_type ,type_name,id,enterprise_id='" + this.model.enterprisesId + "'";
},
getks(){
this.ks ="zy_cloths_style,style_names,id,type_id='" + this.model.clothsTypeId + "'";
},
getxh(){
this.xh ="zy_style_model,model_number,id,style_id='" + this.model.styleId + "'";
getAction(this.url.zystyle, {ksid:this.model.styleId}).then((res) => {
if (res.success) {
// this.$forceUpdate();
this.$set(this.model,'goodsIntr',res.result.productOverview);
this.$set(this.model,'goodsPicture',res.result.designSketch);
this.$set(this.model,'defaultPicture',res.result.designSketch);
} else {
}
});
},
getspbh(){
getAction(this.url.zy, {lxid:this.model.clothsTypeId,xhid:this.model.modelId}).then((res) => {
if (res.success) {
// console.log(res.result.nums)
// this.$forceUpdate();
//
this.$set(this.model,'goodsCode',res.result);
} else {
}
});
},
add () {
this.edit(this.modelDefault);
},
edit (record) {
this.model = Object.assign({}, record);
this.visible = true;
},
submitForm () {
const that = this;
//
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if(!this.model.id){
httpurl+=this.url.add;
method = 'post';
}else{
httpurl+=this.url.edit;
method = 'put';
}
httpAction(httpurl,this.model,method).then((res)=>{
if(res.success){
that.$message.success(res.message);
that.$emit('ok');
}else{
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
})
}
})
},
}
}
<template>
<a-spin :spinning="confirmLoading">
<j-form-container :disabled="formDisabled">
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
<a-row>
<a-col :span="24">
<a-form-model-item label="企业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="enterprisesId">
<j-select-depart1 v-model="model.enterprisesId" @change="getlx()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="服装类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="clothsTypeId">
<!--<j-dict-select-tag type="list" v-model="model.clothsTypeId" :dictCode="lx" placeholder="请选择类型" @change="getks()"/>-->
<j-dict-select-tag type="list" v-model="model.clothsTypeId" dictCode="zy_cloths_type,type_name,id" placeholder="请选择类型" @change="getks()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="服装款式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="styleId">
<j-dict-select-tag type="list" v-model="model.styleId" :dictCode="ks" placeholder="请选择款式" @change="getxh()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="服装型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="modelId">
<j-dict-select-tag type="list" v-model="model.modelId" :dictCode="xh" placeholder="请选择型号" @change="getspbh()"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsCode">
<a-input v-model="model.goodsCode" placeholder="请输入商品编号" disabled></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsName">
<a-input v-model="model.goodsName" placeholder="请输入商品名称" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsIntr">
<a-textarea v-model="model.goodsIntr" placeholder="请输入商品描述" rows="4"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="是否定制" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customized">
<j-dict-select-tag type="radio" v-model="model.customized" dictCode="yn" placeholder="请选择是否定制" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsPicture">
<j-image-upload isMultiple v-model="model.goodsPicture" ></j-image-upload>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="默认图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="defaultPicture">
<j-image-upload isMultiple v-model="model.defaultPicture" ></j-image-upload>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="商品视频" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsVideo">
<j-upload v-model="model.goodsVideo" ></j-upload>
<video v-if="model.goodsVideo" :src="video" style="border:1px solid #d9d9d9;width:100%;" :autoplay="autoplay"/>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unit">
<a-input v-model="model.unit" placeholder="请输入单位" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="包装个数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="number">
<a-input-number v-model="model.number" placeholder="请输入包装个数" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="单价(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unitPrice">
<a-input-number v-model="model.unitPrice" placeholder="请输入单价" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="折扣(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="discount">
<a-input-number v-model="model.discount" placeholder="请输入折扣" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="促销价(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="promotionPrice">
<a-input-number v-model="model.promotionPrice" placeholder="请输入促销价" style="width: 100%" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="是否推荐" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recommend">
<j-dict-select-tag type="radio" v-model="model.recommend" dictCode="yn" placeholder="请选择是否推荐" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="产地" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="placeOrigin">
<a-input v-model="model.placeOrigin" placeholder="请输入产地" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
<j-dict-select-tag type="radio" v-model="model.status" dictCode="good_status" placeholder="请选择状态" />
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>
</a-spin>
</template>
<script>
import { httpAction, getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
export default {
name: 'ZyGoodsForm',
components: {
},
props: {
//
disabled: {
type: Boolean,
default: false,
required: false
}
},
data () {
return {
lx:'zy_cloths_type ,type_name,id',
ks:'zy_cloths_style,style_names,id',
xh:'zy_style_model,model_number,id',
autoplay:true,
model:{
customized:0,
recommend:0,
status:1,
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
validatorRules: {
enterprisesId:[{
required: true, message: '请选择企业!'
}],
modelId:[{
required: true, message: '请选择型号!'
}],
goodsCode: [
{ required: true, message: '请输入商品编号!'},
],
styleId: [
{ required: true, message: '请选择款式!'},
],
clothsTypeId:[{
required: true, message: '请选择类型!'
}],
number: [
{ required: false},
{ pattern: /^[+]{0,1}(\d+)$/, message: '包装个数必须大于等于0!'},
],
unitPrice: [
{ required: false},
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
],
discount: [
{ required: false},
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
],
promotionPrice: [
{ required: false},
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
],
goodsName: [
{ required: true, message: '请输入商品名称!'},
{ pattern: /^.{1,50}$/, message: '商品名称不能超过50个字符!'},
],
},
url: {
add: "/zygoods/zyGoods/add",
edit: "/zygoods/zyGoods/edit",
queryById: "/zygoods/zyGoods/queryById",
zy:"/zygoods/zyGoods/getspbh",
zystyle:"/zygoods/zyGoods/getzystyle",
}
}
},
computed: {
formDisabled(){
return this.disabled
},
video(){
return `${window._CONFIG['domianURL']}/sys/common/static/${this.model.goodsVideo}`
},
},
created () {
//model
this.modelDefault = JSON.parse(JSON.stringify(this.model));
},
methods: {
getlx(){
this.lx ="zy_cloths_type ,type_name,id,enterprise_id='" + this.model.enterprisesId + "'";
},
getks(){
this.ks ="zy_cloths_style,style_names,id,type_id='" + this.model.clothsTypeId + "'";
},
getxh(){
this.xh ="zy_style_model,model_number,id,style_id='" + this.model.styleId + "'";
getAction(this.url.zystyle, {ksid:this.model.styleId}).then((res) => {
if (res.success) {
// this.$forceUpdate();
this.$set(this.model,'goodsIntr',res.result.productOverview);
this.$set(this.model,'goodsPicture',res.result.designSketch);
this.$set(this.model,'defaultPicture',res.result.designSketch);
} else {
}
});
},
getspbh(){
// //-
if(!this.model.id)
{
getAction(this.url.zy, {lxid:this.model.clothsTypeId,xhid:this.model.modelId}).then((res) => {
if (res.success) {
// console.log(res.result.nums)
// this.$forceUpdate();
//
this.$set(this.model,'goodsCode',res.result);
} else {
}
});
}
},
add () {
this.edit(this.modelDefault);
},
edit (record) {
this.model = Object.assign({}, record);
this.visible = true;
},
submitForm () {
const that = this;
//
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if(!this.model.id){
httpurl+=this.url.add;
method = 'post';
}else{
httpurl+=this.url.edit;
method = 'put';
}
httpAction(httpurl,this.model,method).then((res)=>{
if(res.success){
that.$message.success(res.message);
that.$emit('ok');
}else{
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
})
}
})
},
}
}
</script>

@ -0,0 +1,83 @@
package org.jeecg.common.util;
import java.util.Random;
public class UniqueRanNumUtils {
/**
* 自定义进制(排除0,1,o,l)
*/
private static final char[] CUSTOM = new char[]{'Q', 'W', 'E', '8', 'A', 'S', '2', 'D', 'Z', 'X', '9', 'C', '7', 'P', '5', 'I', 'K', '3', 'M', 'J', 'U', 'F', 'R', '4', 'V', 'Y', 'L', 'T', 'N', '6', 'B', 'G'};
/**
* 不能与自定义进制有重复
*/
private static final char FLAG = 'H';
/**
* 进制长度
*/
private static final int LENGTH = CUSTOM.length;
/**
* 序列最小长度
*/
private static final int MINLENGTH = 6;
/**
* 根据ID生成六位随机码
* @return 随机码
*/
public static String generateCode(long id) {
char[] buf = new char[32];
int charPos = 32;
while ((id / LENGTH) > 0) {
int ind = (int) (id % LENGTH);
buf[--charPos] = CUSTOM[ind];
id /= LENGTH;
}
buf[--charPos] = CUSTOM[(int) (id % LENGTH)];
String str = new String(buf, charPos, (32 - charPos));
// 不够长度的自动随机补全
if (str.length() < MINLENGTH) {
StringBuilder sb = new StringBuilder();
sb.append(FLAG);
Random rnd = new Random();
for (int i = 1; i < MINLENGTH - str.length(); i++) {
sb.append(CUSTOM[rnd.nextInt(LENGTH)]);
}
str += sb.toString();
}
return str;
}
public static long codeToId(String code) {
char chs[] = code.toCharArray();
long res = 0L;
for (int i = 0; i < chs.length; i++) {
int ind = 0;
for (int j = 0; j < LENGTH; j++) {
if (chs[i] == CUSTOM[j]) {
ind = j;
break;
}
}
if (chs[i] == FLAG) {
break;
}
if (i > 0) {
res = res * LENGTH + ind;
} else {
res = ind;
}
}
return res;
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println(generateCode(i));
}
}
}
Loading…
Cancel
Save