Browse Source
feat(srm): 重构供应商地址管理功能并更新状态选项国际化
feat(srm): 重构供应商地址管理功能并更新状态选项国际化
- 将供应商地址组件从 srmBaseInformation 模块迁移至 srmSupplier 模块 - 重构供应商地址页面,添加完整的增删改查功能和表单验证 - 实现供应商地址的搜索、分页、导出功能 - 添加供应商地址API接口,包括查询、创建、更新、删除操作 - 将所有状态选择项从中文"启用/禁用"改为英文"Yes/No"选项 - 更新供应商列表页面的状态字段和API调用 - 完善权限控制和错误处理机制master
3 changed files with 655 additions and 37 deletions
-
601src/views/modules/srmSupplier/com_srmSupplier_Address.vue
-
16src/views/modules/srmSupplier/srmSupplierAddress.vue
-
75src/views/modules/srmSupplier/supplierList.vue
@ -0,0 +1,601 @@ |
|||
<template> |
|||
<div class="customer-css"> |
|||
<el-form :inline="true" label-position="top" :model="searchData"> |
|||
<el-form-item label="地址类型"> |
|||
<el-input v-model="searchData.addressType" clearable style="width: 120px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="是否激活"> |
|||
<el-select v-model="searchData.active" clearable style="width: 120px"> |
|||
<el-option label="是" value="Y"></el-option> |
|||
<el-option label="否" value="N"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label=" "> |
|||
<el-button type="primary" @click="getDataList()">查询</el-button> |
|||
<el-button type="primary" @click="addModal()">新增</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<el-table |
|||
:data="dataList" |
|||
:height="searchData.height" |
|||
border |
|||
v-loading="dataListLoading" |
|||
style="width: 100%; "> |
|||
<el-table-column |
|||
v-for="(item,index) in columnList" :key="index" |
|||
:sortable="item.columnSortable" |
|||
:prop="item.columnProp" |
|||
:header-align="item.headerAlign" |
|||
:show-overflow-tooltip="item.showOverflowTooltip" |
|||
:align="item.align" |
|||
:fixed="item.fixed==''?false:item.fixed" |
|||
:min-width="item.columnWidth" |
|||
:label="item.columnLabel"> |
|||
<template slot-scope="scope"> |
|||
<span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column |
|||
header-align="center" |
|||
align="center" |
|||
width="120" |
|||
fixed="right" |
|||
label="操作"> |
|||
<template slot-scope="scope"> |
|||
<el-link style="cursor: pointer" @click="updateModal(scope.row)">编辑 |</el-link> |
|||
<el-link style="cursor: pointer" @click="deleteSupplierAddress(scope.row)">删除</el-link> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<el-dialog title="供应商地址" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="500px"> |
|||
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;" ref="modalForm"> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-form-item label="供应商ID" prop="supplierId"> |
|||
<el-input v-model="modalData.supplierId" :disabled="modalDisableFlag" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item label="Site" prop="site"> |
|||
<el-input v-model="modalData.site" :disabled="modalDisableFlag" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-form-item label="地址ID" prop="addressId"> |
|||
<el-input v-model="modalData.addressId" :disabled="modalDisableFlag" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item label="公司名称" prop="companyName"> |
|||
<el-input v-model="modalData.companyName" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-form-item label="联系人" prop="contact"> |
|||
<el-input v-model="modalData.contact" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item label="联系电话" prop="phoneNo"> |
|||
<el-input v-model="modalData.phoneNo" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-form-item label="地址类型" prop="addressType"> |
|||
<el-input v-model="modalData.addressType" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item label="是否激活" prop="active"> |
|||
<el-select v-model="modalData.active" style="width: 100%"> |
|||
<el-option label="是" value="Y"></el-option> |
|||
<el-option label="否" value="N"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-form-item label="邮箱" prop="email"> |
|||
<el-input v-model="modalData.email" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item label="原产国" prop="originCountry"> |
|||
<el-input v-model="modalData.originCountry" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row :gutter="20"> |
|||
<el-col :span="12"> |
|||
<el-form-item label="装运港" prop="portOfLoading"> |
|||
<el-input v-model="modalData.portOfLoading" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
<el-col :span="12"> |
|||
<el-form-item label="地址" prop="address"> |
|||
<el-input v-model="modalData.address" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
</el-form> |
|||
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;" ref="modalForm"> |
|||
<el-form-item label="备注" prop="memo" style="width: 100%"> |
|||
<el-input v-model="modalData.memo" :rows="3" type="textarea" style="width: 100%"></el-input> |
|||
</el-form-item> |
|||
</el-form> |
|||
<el-footer style="height:40px;margin-top: 20px;text-align:center"> |
|||
<el-button type="primary" @click="saveData()">保存</el-button> |
|||
<el-button @click="modalFlag = false">关闭</el-button> |
|||
</el-footer> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { |
|||
searchSrmSupplierAddressList, |
|||
createSrmSupplierAddress, |
|||
updateSrmSupplierAddress, |
|||
deleteSrmSupplierAddress |
|||
} from "@/api/srm/srmSupplier.js" |
|||
|
|||
export default { |
|||
data() { |
|||
return { |
|||
dataList: [], |
|||
searchData: { |
|||
supplierId: '', |
|||
site: '', |
|||
addressType: '', |
|||
active: '', |
|||
height: 300, |
|||
page: 1, |
|||
limit: 1000, |
|||
isInitialized: false |
|||
}, |
|||
dataListLoading: false, |
|||
modalFlag: false, |
|||
modalDisableFlag: false, |
|||
modalData: { |
|||
supplierId: '', |
|||
site: '', |
|||
addressId: '', |
|||
companyName: '', |
|||
contact: '', |
|||
phoneNo: '', |
|||
address: '', |
|||
addressType: '', |
|||
active: '', |
|||
email: '', |
|||
originCountry: '', |
|||
portOfLoading: '', |
|||
memo: '', |
|||
createBy: this.$store.state.user.name, |
|||
updateBy: this.$store.state.user.name |
|||
}, |
|||
// 展示列集 |
|||
columnList: [ |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableSupplierId', |
|||
tableId: '9005Table', |
|||
tableName: "供应商地址表", |
|||
columnProp: 'supplierId', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: '供应商ID', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 120 |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableSite', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'site', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: 'Site', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 100, |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableAddressId', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'addressId', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: '地址ID', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 100, |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableCompanyName', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'companyName', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: '公司名称', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 150, |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableContact', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'contact', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: '联系人', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 100, |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TablePhoneNo', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'phoneNo', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: '联系电话', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 120, |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableAddress', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'address', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: '地址', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 200, |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableAddressType', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'addressType', |
|||
headerAlign: "center", |
|||
align: "left", |
|||
columnLabel: '地址类型', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 100, |
|||
}, |
|||
{ |
|||
userId: this.$store.state.user.name, |
|||
functionId: '9005', |
|||
serialNumber: '9005TableActive', |
|||
tableId: "9005Table", |
|||
tableName: "供应商地址表", |
|||
columnProp: 'active', |
|||
headerAlign: "center", |
|||
align: "center", |
|||
columnLabel: '是否激活', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
sortLv: 0, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 100, |
|||
} |
|||
], |
|||
rules: { |
|||
supplierId: [ |
|||
{ |
|||
required: true, |
|||
validator: this.validateField, |
|||
trigger: 'blur' |
|||
} |
|||
], |
|||
site: [ |
|||
{ |
|||
required: true, |
|||
validator: this.validateField, |
|||
trigger: 'blur' |
|||
} |
|||
], |
|||
addressId: [ |
|||
{ |
|||
required: true, |
|||
validator: this.validateField, |
|||
trigger: 'blur' |
|||
} |
|||
], |
|||
address: [ |
|||
{ |
|||
required: true, |
|||
validator: this.validateField, |
|||
trigger: 'blur' |
|||
} |
|||
], |
|||
companyName: [ |
|||
{ |
|||
required: true, |
|||
validator: this.validateField, |
|||
trigger: 'blur' |
|||
} |
|||
], |
|||
contact: [ |
|||
{ |
|||
required: true, |
|||
validator: this.validateField, |
|||
trigger: 'blur' |
|||
} |
|||
], |
|||
phoneNo: [ |
|||
{ |
|||
required: true, |
|||
validator: this.validateField, |
|||
trigger: 'blur' |
|||
} |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
validateField(rule, value, callback) { |
|||
if (!value || value.trim() === '') { |
|||
callback(new Error()); |
|||
} else { |
|||
callback(); |
|||
} |
|||
}, |
|||
|
|||
//初始化组件的参数 |
|||
init(inData) { |
|||
//初始化参数 |
|||
this.searchData = JSON.parse(JSON.stringify(inData)); |
|||
//刷新表格 |
|||
this.getDataList(); |
|||
|
|||
}, |
|||
|
|||
// 获取数据列表 |
|||
getDataList() { |
|||
this.dataListLoading = true; |
|||
// 准备请求参数 |
|||
const params = { |
|||
...this.searchData, |
|||
page: this.searchData.page, |
|||
limit: this.searchData.limit |
|||
}; |
|||
|
|||
searchSrmSupplierAddressList(params).then(({data}) => { |
|||
if (data && data.code === 0) { |
|||
const pageData = data.data || data.page; |
|||
this.dataList = pageData && pageData.list ? pageData.list : pageData || []; |
|||
} else { |
|||
this.$message.error(data.msg || '获取数据失败'); |
|||
this.dataList = []; |
|||
} |
|||
}).catch(error => { |
|||
console.error('获取供应商地址列表失败:', error); |
|||
this.$message.error('获取数据失败: ' + (error.message || '网络错误')); |
|||
this.dataList = []; |
|||
}).finally(() => { |
|||
this.dataListLoading = false; |
|||
}); |
|||
}, |
|||
|
|||
addModal() { |
|||
this.modalData = { |
|||
supplierId: this.searchData.supplierId, // 从传入的参数获取供应商ID |
|||
site: this.searchData.site, // 从传入的参数获取site |
|||
addressId: '', |
|||
companyName: '', |
|||
contact: '', |
|||
phoneNo: '', |
|||
address: '', |
|||
addressType: '', |
|||
active: 'Y', |
|||
email: '', |
|||
originCountry: '', |
|||
portOfLoading: '', |
|||
memo: '', |
|||
createBy: this.$store.state.user.name, |
|||
updateBy: this.$store.state.user.name, |
|||
flag: '1' |
|||
}; |
|||
this.modalDisableFlag = false; |
|||
this.modalFlag = true; |
|||
this.$nextTick(() => { |
|||
// 清除表单验证 |
|||
if (this.$refs.modalForm) { |
|||
this.$refs.modalForm.clearValidate(); |
|||
} |
|||
}); |
|||
}, |
|||
|
|||
updateModal(row) { |
|||
this.modalData = { |
|||
supplierId: row.supplierId, |
|||
site: row.site, |
|||
addressId: row.addressId, |
|||
companyName: row.companyName, |
|||
contact: row.contact, |
|||
phoneNo: row.phoneNo, |
|||
address: row.address, |
|||
addressType: row.addressType, |
|||
active: row.active, |
|||
email: row.email, |
|||
originCountry: row.originCountry, |
|||
portOfLoading: row.portOfLoading, |
|||
memo: row.memo, |
|||
createBy: row.createBy, |
|||
updateBy: this.$store.state.user.name, |
|||
flag: '2' |
|||
}; |
|||
this.modalDisableFlag = true; |
|||
this.modalFlag = true; |
|||
this.$nextTick(() => { |
|||
// 清除表单验证 |
|||
if (this.$refs.modalForm) { |
|||
this.$refs.modalForm.clearValidate(); |
|||
} |
|||
}); |
|||
}, |
|||
|
|||
// 删除 |
|||
deleteSupplierAddress(row) { |
|||
this.$confirm(`确定删除此供应商地址吗?地址ID:${row.addressId}`, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
// 根据后端接口,需要传递一个SrmSupplierAddress对象 |
|||
const deleteData = { |
|||
addressId: row.addressId, |
|||
site: row.site, |
|||
supplierId: row.supplierId // 同时传递supplierId,以防后端需要 |
|||
}; |
|||
|
|||
deleteSrmSupplierAddress(deleteData).then(({data}) => { |
|||
if (data && data.code === 0) { |
|||
this.$message({ |
|||
message: '操作成功', |
|||
type: 'success', |
|||
duration: 1500 |
|||
}); |
|||
this.getDataList(); // 直接刷新数据 |
|||
} else { |
|||
this.$alert(data.msg, '错误', { |
|||
confirmButtonText: '确定' |
|||
}); |
|||
} |
|||
}).catch(error => { |
|||
console.error('删除供应商地址失败:', error); |
|||
this.$message.error('删除失败: ' + (error.message || '网络错误')); |
|||
}); |
|||
}).catch(() => { |
|||
this.$message.info('已取消删除'); |
|||
}); |
|||
}, |
|||
|
|||
saveData() { |
|||
// 使用Element UI的表单验证方法 |
|||
this.$refs.modalForm.validate((valid) => { |
|||
if (valid) { |
|||
if (this.modalData.flag === '1') { |
|||
createSrmSupplierAddress(this.modalData).then(({data}) => { |
|||
if (data && data.code === 0) { |
|||
this.$message({ |
|||
message: '操作成功', |
|||
type: 'success', |
|||
duration: 1500 |
|||
}); |
|||
// 直接刷新数据并关闭弹窗 |
|||
this.getDataList(); // 刷新数据 |
|||
this.modalFlag = false; // 关闭弹窗 |
|||
} else { |
|||
this.$alert(data.msg, '错误', { |
|||
confirmButtonText: '确定' |
|||
}); |
|||
} |
|||
}).catch(error => { |
|||
console.error('保存供应商地址失败:', error); |
|||
this.$message.error('保存失败: ' + (error.message || '网络错误')); |
|||
}); |
|||
} else { |
|||
updateSrmSupplierAddress(this.modalData).then(({data}) => { |
|||
if (data && data.code === 0) { |
|||
this.$message({ |
|||
message: '操作成功', |
|||
type: 'success', |
|||
duration: 1500 |
|||
}); |
|||
// 直接刷新数据并关闭弹窗 |
|||
this.getDataList(); // 刷新数据 |
|||
this.modalFlag = false; // 关闭弹窗 |
|||
} else { |
|||
this.$alert(data.msg, '错误', { |
|||
confirmButtonText: '确定' |
|||
}); |
|||
} |
|||
}).catch(error => { |
|||
console.error('更新供应商地址失败:', error); |
|||
this.$message.error('更新失败: ' + (error.message || '网络错误')); |
|||
}); |
|||
} |
|||
} else { |
|||
console.log('表单验证失败'); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
|
|||
<style scoped lang="scss"> |
|||
.rq .auto /deep/ .el-form-item__content{ |
|||
height: auto; |
|||
line-height: 1.5; |
|||
} |
|||
</style> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue