Browse Source

feat(srm): 重构供应商地址管理功能并更新状态选项国际化

- 将供应商地址组件从 srmBaseInformation 模块迁移至 srmSupplier 模块
- 重构供应商地址页面,添加完整的增删改查功能和表单验证
- 实现供应商地址的搜索、分页、导出功能
- 添加供应商地址API接口,包括查询、创建、更新、删除操作
- 将所有状态选择项从中文"启用/禁用"改为英文"Yes/No"选项
- 更新供应商列表页面的状态字段和API调用
- 完善权限控制和错误处理机制
master
qiankanghui 6 days ago
parent
commit
b3864cd675
  1. 601
      src/views/modules/srmSupplier/com_srmSupplier_Address.vue
  2. 16
      src/views/modules/srmSupplier/srmSupplierAddress.vue
  3. 75
      src/views/modules/srmSupplier/supplierList.vue

601
src/views/modules/srmSupplier/com_srmSupplier_Address.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>

16
src/views/modules/srmSupplier/srmSupplierAddress.vue

@ -79,7 +79,7 @@
</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-input v-model="modalData.site" :disabled="modalDisableFlag || modalData.flag === '1'" style="width: 100%"></el-input>
</el-form-item>
</el-col>
</el-row>
@ -377,21 +377,15 @@ export default {
supplierId: [
{
required: true,
validator: this.validateField,
trigger: 'blur'
}
],
site: [
{
required: true,
validator: this.validateField,
message: '供应商ID不能为空',
trigger: 'blur'
}
],
addressId: [
{
required: true,
validator: this.validateField,
message: '地址ID不能为空',
trigger: 'blur'
}
],
@ -573,7 +567,7 @@ export default {
updateBy: this.$store.state.user.name,
flag: '2'
}
this.modalDisableFlag = true
this.modalDisableFlag = true // 使site
this.modalFlag = true
this.$nextTick(() => {
//

75
src/views/modules/srmSupplier/supplierList.vue

@ -27,14 +27,14 @@
</el-form>
<el-table
:height="height"
:data="mainDataList"
border
ref="mainTable"
highlight-current-row
@row-click="changeData"
v-loading="dataListLoading"
style="margin-top: 0px; width: 100%;">
:height="height"
:data="mainDataList"
border
ref="mainTable"
highlight-current-row
@row-click="changeData"
v-loading="dataListLoading"
style="margin-top: 0px; width: 100%;">
<el-table-column
v-for="(item,index) in columnArray1" :key="index"
:sortable="item.columnSortable"
@ -64,16 +64,16 @@
</template>
</el-table-column>
</el-table>
<!-- 分页插件 -->
<el-pagination style="margin-top: 0px"
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 分页插件 -->
<el-pagination style="margin-top: 0px"
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<el-tabs v-model="activeName" style="margin-top: 0px; width: 99%;" @tab-click="tabClick" class="customer-tab" type="border-card">
<el-tab-pane label="Share" name="share" style="">
@ -121,6 +121,9 @@
<el-tab-pane label="Qualifications Documents" name="documents" style="">
<documents ref="documents"></documents>
</el-tab-pane>
<el-tab-pane label="Address" name="AddressTab" style="">
<AddressTab ref="AddressTab"></AddressTab>
</el-tab-pane>
</el-tabs>
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
@ -364,6 +367,7 @@ import Chooselist from '@/views/modules/common/Chooselist_eam'
import contract from './com_srmSupplier_Contract'
import share from './com_srmSupplier_share'
import documents from './com_srmSupplier_DocumentDefinition'
import AddressTab from './com_srmSupplier_Address'
export default {
data () {
return {
@ -1079,7 +1083,8 @@ export default {
Chooselist,
contract,
documents,
share
share,
AddressTab
},
mounted () {
@ -1172,6 +1177,9 @@ export default {
if (this.activeName === 'documents') {
this.refreshDocumentsTable()
}
if (this.activeName === 'AddressTab') {
this.refreshAddressTable()
}
},
async exportExcel () {
this.searchData.limit = -1
@ -1206,9 +1214,24 @@ export default {
objectType: 'supplier',
height: Number(this.height) - 20
}
this.$refs.documents.init(inData)
},
refreshShareTable () {
refreshAddressTable () {
let inData = {
supplierId: this.currentRow.supplierNo, // 使supplierId
site: this.currentRow.site,
supplierNo: this.currentRow.supplierNo,
height: Number(this.height) - 20
}
this.$nextTick(() => {
const addressComp = this.$refs.AddressTab
if (addressComp && typeof addressComp.init === 'function') {
addressComp.init(inData)
}
})
},
refreshShareTable() {
let inData = {
site: this.currentRow.site,
supplierNo: this.currentRow.supplierNo,
@ -1218,7 +1241,7 @@ export default {
this.$refs.share.init(inData)
},
//
addSupplier () {
addSupplier() {
this.isAdd = true
this.currentSupplier = {
site: this.$store.state.user.site,
@ -1227,17 +1250,17 @@ export default {
this.supplierDialogVisible = true
},
//
editSupplier () {
editSupplier() {
if (!this.currentRow) {
this.$message.warning('Please select a supplier to edit')
return
}
this.isAdd = false
this.currentSupplier = { ...this.currentRow }
this.currentSupplier = {...this.currentRow}
this.supplierDialogVisible = true
},
//
saveSupplier () {
saveSupplier() {
this.$refs.supplierForm.validate((valid) => {
if (valid) {
const apiCall = this.isAdd ? createSrmSupplier(this.currentSupplier) : updateSrmSupplier(this.currentSupplier)
@ -1260,7 +1283,7 @@ export default {
},
//
deleteSupplier (row) {
deleteSupplier(row) {
this.$confirm('Are you sure you want to delete this supplier?', 'Confirm Delete', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
@ -1279,7 +1302,7 @@ export default {
})
}
},
created () {
created() {
//
this.getMainData()
}

Loading…
Cancel
Save