优化多属性模块

This commit is contained in:
季圣华
2021-07-23 00:18:59 +08:00
parent c7d1ea4e87
commit 8fb8aecfb7
5 changed files with 199 additions and 6 deletions

View File

@@ -122,6 +122,7 @@ const editMaterialProperty = (params)=>putAction("/materialProperty/update",para
//商品类型
const queryMaterialCategoryTreeList = (params)=>getAction("/materialCategory/getMaterialCategoryTree",params);
const queryMaterialCategoryById = (params)=>getAction("/materialCategory/findById",params);
const checkMaterialCategory = (params)=>getAction("/materialCategory/checkIsNameExist",params);
//商品管理
const addMaterial = (params)=>postAction("/material/add",params);
const editMaterial = (params)=>putAction("/material/update",params);
@@ -135,6 +136,10 @@ const addSerialNumber = (params)=>postAction("/serialNumber/add",params);
const editSerialNumber = (params)=>putAction("/serialNumber/update",params);
const checkSerialNumber = (params)=>getAction("/serialNumber/checkIsNameExist",params);
const batAddSerialNumber = (params)=>postAction("/serialNumber/batAddSerialNumber",params);
//多属性
const addMaterialAttribute = (params)=>postAction("/materialAttribute/add",params);
const editMaterialAttribute = (params)=>putAction("/materialAttribute/update",params);
const checkMaterialAttribute = (params)=>getAction("/materialAttribute/checkIsNameExist",params);
//功能管理
const addFunction = (params)=>postAction("/function/add",params);
const editFunction = (params)=>putAction("/function/update",params);
@@ -243,6 +248,7 @@ export {
editMaterialProperty,
queryMaterialCategoryTreeList,
queryMaterialCategoryById,
checkMaterialCategory,
addMaterial,
editMaterial,
checkMaterial,
@@ -254,6 +260,9 @@ export {
editSerialNumber,
checkSerialNumber,
batAddSerialNumber,
addMaterialAttribute,
editMaterialAttribute,
checkMaterialAttribute,
addFunction,
editFunction,
checkFunction,

View File

@@ -20,17 +20,21 @@
</a-table>
</div>
<!-- table区域-end -->
<!-- 表单区域 -->
<material-attribute-modal ref="modalForm" @ok="modalFormOk"></material-attribute-modal>
</a-card>
</a-col>
</a-row>
</template>
<script>
import MaterialAttributeModal from './modules/MaterialAttributeModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JDate from '@/components/jeecg/JDate'
export default {
name: "MaterialAttributeList",
mixins:[JeecgListMixin],
components: {
MaterialAttributeModal,
JDate
},
data () {
@@ -57,7 +61,7 @@
}
},
{title: '属性名', dataIndex: 'attributeName', width: 100},
{title: '属性值', dataIndex: 'attributeValue', width: 400},
{title: '属性值用竖线隔开', dataIndex: 'attributeValue', width: 400},
{
title: '操作',
dataIndex: 'action',

View File

@@ -97,7 +97,7 @@
<script>
import MaterialCategoryModal from '../material/modules/MaterialCategoryModal'
import pick from 'lodash.pick'
import {queryMaterialCategoryTreeList,queryMaterialCategoryById} from '@/api/api'
import {queryMaterialCategoryTreeList,queryMaterialCategoryById,checkMaterialCategory} from '@/api/api'
import {httpAction, deleteAction} from '@/api/manage'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
export default {
@@ -143,7 +143,12 @@ export default {
edges: []
},
validatorRules:{
name: {rules: [{required: true, message: '请输入名称!'}]},
name: {
rules: [
{required: true, message: '请输入名称!'},
{ validator: this.validateName}
]
},
serialNo: {rules: [{required: true, message: '请输入编号!'}]}
},
url: {
@@ -259,7 +264,6 @@ export default {
nodeModalClose() {
},
hide() {
console.log(111)
this.visible = false
},
onCheck(checkedKeys, info) {
@@ -357,6 +361,23 @@ export default {
openSelect() {
this.$refs.sysDirectiveModal.show()
},
validateName(rule, value, callback){
let params = {
name: value,
id: this.model.id?this.model.id:0
};
checkMaterialCategory(params).then((res)=>{
if(res && res.code===200) {
if(!res.data.status){
callback();
} else {
callback("名称已经存在");
}
} else {
callback(res.data);
}
});
},
handleAdd() {
this.$refs.materialCategoryModal.add()
this.$refs.materialCategoryModal.title = '新增'

View File

@@ -0,0 +1,137 @@
<template>
<a-modal
:title="title"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭"
wrapClassName="ant-modal-cust-warp"
style="top:20%;height: 50%;overflow-y: hidden">
<template slot="footer">
<a-button key="back" v-if="isReadOnly" @click="handleCancel">
关闭
</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="属性名">
<a-input placeholder="请输入属性名" v-decorator.trim="[ 'attributeName', validatorRules.attributeName]" />
</a-form-item>
</a-form>
<a-form :form="form">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="属性值">
<a-textarea :rows="2" placeholder="请输入属性值(用竖线隔开)" v-decorator.trim="[ 'attributeValue', validatorRules.attributeValue]" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import pick from 'lodash.pick'
import {addMaterialAttribute,editMaterialAttribute,checkMaterialAttribute } from '@/api/api'
export default {
name: "MaterialAttributeModal",
data () {
return {
title:"操作",
visible: false,
model: {},
isReadOnly: false,
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules:{
attributeName:{
rules: [
{ required: true, message: '请输入属性名!' },
{ min: 1, max: 10, message: '长度在 1 10 个字符', trigger: 'blur' },
{ validator: this.validateAttributeName}
]
},
attributeValue:{
rules: [
{ required: true, message: '请输入属性值用竖线隔开!' }
]
}
}
}
},
created () {
},
methods: {
add () {
this.edit({});
},
edit (record) {
this.form.resetFields();
this.model = Object.assign({}, record);
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'attributeName', 'attributeValue'))
});
},
close () {
this.$emit('close');
this.visible = false;
},
handleOk () {
const that = this;
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true;
let formData = Object.assign(this.model, values);
let obj;
if(!this.model.id){
obj=addMaterialAttribute(formData);
}else{
obj=editMaterialAttribute(formData);
}
obj.then((res)=>{
if(res.code === 200){
that.$emit('ok');
}else{
that.$message.warning(res.data.message);
}
}).finally(() => {
that.confirmLoading = false;
that.close();
})
}
})
},
handleCancel () {
this.close()
},
validateAttributeName(rule, value, callback){
let params = {
name: value,
id: this.model.id?this.model.id:0
};
checkMaterialAttribute(params).then((res)=>{
if(res && res.code===200) {
if(!res.data.status){
callback();
} else {
callback("名称已经存在");
}
} else {
callback(res.data);
}
});
}
}
}
</script>
<style scoped>
</style>

View File

@@ -37,7 +37,7 @@
<script>
import { httpAction } from '@/api/manage'
import { queryMaterialCategoryTreeList } from '@/api/api'
import { queryMaterialCategoryTreeList, checkMaterialCategory } from '@/api/api'
import pick from 'lodash.pick'
import ATextarea from 'ant-design-vue/es/input/TextArea'
export default {
@@ -67,7 +67,12 @@
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules:{
name: {rules: [{required: true, message: '请输入名称!'}]},
name: {
rules: [
{required: true, message: '请输入名称!'},
{ validator: this.validateName}
]
},
serialNo: {rules: [{required: true, message: '请输入编号!'}]}
},
url: {
@@ -135,6 +140,23 @@
},
handleCancel () {
this.close()
},
validateName(rule, value, callback){
let params = {
name: value,
id: this.model.id?this.model.id:0
};
checkMaterialCategory(params).then((res)=>{
if(res && res.code===200) {
if(!res.data.status){
callback();
} else {
callback("名称已经存在");
}
} else {
callback(res.data);
}
});
}
}
}