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