Browse Source
feat(srm): 重构供应商地址管理功能并更新状态选项国际化
feat(srm): 重构供应商地址管理功能并更新状态选项国际化
- 将供应商地址组件从 srmBaseInformation 模块迁移至 srmSupplier 模块 - 重构供应商地址页面,添加完整的增删改查功能和表单验证 - 实现供应商地址的搜索、分页、导出功能 - 添加供应商地址API接口,包括查询、创建、更新、删除操作 - 将所有状态选择项从中文"启用/禁用"改为英文"Yes/No"选项 - 更新供应商列表页面的状态字段和API调用 - 完善权限控制和错误处理机制master
9 changed files with 723 additions and 118 deletions
-
6src/api/srm/srmSupplier.js
-
8src/views/modules/srmBaseInformation/srmDeliveryTerm.vue
-
8src/views/modules/srmBaseInformation/srmPaymentTerm.vue
-
94src/views/modules/srmBaseInformation/srmSupplierAddress.vue
-
8src/views/modules/srmBaseInformation/srmSupplierCurrency.vue
-
8src/views/modules/srmBaseInformation/srmSupplierGroup.vue
-
4src/views/modules/srmBaseInformation/srmTax.vue
-
693src/views/modules/srmSupplier/srmSupplierAddress.vue
-
8src/views/modules/srmSupplier/supplierList.vue
@ -1,94 +0,0 @@ |
|||||
<template> |
|
||||
<div class="mod-config"> |
|
||||
<el-form :inline="true" label-position="top" label-width="100px" style="margin-top: -10px;"> |
|
||||
<el-button @click="getData()" type="primary" style="margin-left: 2px;margin-top: 33px">{{buttons.search}}</el-button> |
|
||||
</el-form> |
|
||||
|
|
||||
<el-table |
|
||||
:height="height" |
|
||||
:data="dataList" |
|
||||
border |
|
||||
v-loading="dataListLoading" |
|
||||
style="width: 100%;"> |
|
||||
<el-table-column |
|
||||
header-align="center" |
|
||||
align="center" |
|
||||
width="150" |
|
||||
label="操作"> |
|
||||
<template slot-scope="scope"> |
|
||||
<a type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</a> |
|
||||
<a type="text" size="small" @click="deleteHandle(scope.row.id)">删除</a> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
<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="20%" |
|
||||
:label="item.columnLabel"> |
|
||||
<template slot-scope="scope"> |
|
||||
<span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span> |
|
||||
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" |
|
||||
style="width: 100px; height: 80px"/></span> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
|
|
||||
</el-table> |
|
||||
</div> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
|
|
||||
import {} from "@/api/sysLanguage.js" |
|
||||
|
|
||||
export default { |
|
||||
name: "null", |
|
||||
data() { |
|
||||
return { |
|
||||
height: 200, |
|
||||
dataList:[], |
|
||||
dataListLoading: false, |
|
||||
buttons:{ |
|
||||
search:'查询', |
|
||||
}, |
|
||||
columnList: [ |
|
||||
{ |
|
||||
userId: this.$store.state.user.name, |
|
||||
functionId: 9002, |
|
||||
serialNumber: '9002tBlbasedataId', |
|
||||
tableId: "9002Blbasedata", |
|
||||
tableName: "工厂信息表", |
|
||||
columnProp: "id", |
|
||||
headerAlign: "center", |
|
||||
align: "left", |
|
||||
columnLabel: "工厂id", |
|
||||
columnHidden: false, |
|
||||
columnImage: false, |
|
||||
columnSortable: false, |
|
||||
sortLv: 0, |
|
||||
status: true, |
|
||||
fixed: '', |
|
||||
columnWidth: 50 |
|
||||
}, |
|
||||
], |
|
||||
} |
|
||||
}, |
|
||||
mounted() { |
|
||||
this.$nextTick(() => { |
|
||||
this.height = window.innerHeight - 240; |
|
||||
}) |
|
||||
}, |
|
||||
methods: {}, |
|
||||
created() { |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<style scoped> |
|
||||
|
|
||||
</style> |
|
||||
@ -0,0 +1,693 @@ |
|||||
|
<template> |
||||
|
<div class="mod-config"> |
||||
|
<el-form :inline="true" label-position="top" :model="searchData"> |
||||
|
<el-form-item label="供应商ID"> |
||||
|
<el-input v-model="searchData.supplierId" clearable style="width: 120px"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="Site"> |
||||
|
<el-input v-model="searchData.site" clearable style="width: 120px"></el-input> |
||||
|
</el-form-item> |
||||
|
<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 v-if="authSearch" type="primary" @click="getDataList()">查询</el-button> |
||||
|
<el-button v-if="authSave" type="primary" @click="addModal()">新增</el-button> |
||||
|
<el-button @click="exportExcel()" type="primary" style="margin-left: 2px">导出</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
|
||||
|
<el-table |
||||
|
:height="height" |
||||
|
:data="dataList" |
||||
|
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 |
||||
|
fixed="right" |
||||
|
header-align="center" |
||||
|
align="center" |
||||
|
width="120" |
||||
|
label="操作"> |
||||
|
<template slot-scope="scope"> |
||||
|
<el-link style="cursor: pointer" v-if="authUpdate" @click="updateModal(scope.row)">编辑 |</el-link> |
||||
|
<el-link style="cursor: pointer" v-if="authDelete" @click="deleteSupplierAddress(scope.row)">删除</el-link> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
|
||||
|
<!-- 分页栏 --> |
||||
|
<el-pagination |
||||
|
@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-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" 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 type="primary" @click="modalFlag = false">关闭</el-button> |
||||
|
</el-footer> |
||||
|
</el-dialog> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { |
||||
|
searchSrmSupplierAddressList, |
||||
|
createSrmSupplierAddress, |
||||
|
updateSrmSupplierAddress, |
||||
|
deleteSrmSupplierAddress |
||||
|
} from "@/api/srm/srmSupplier.js" |
||||
|
import excel from "@/utils/excel-util.js"; |
||||
|
import dayjs from "dayjs"; |
||||
|
|
||||
|
export default { |
||||
|
data () { |
||||
|
return { |
||||
|
// 导出 |
||||
|
exportName: "供应商地址" + dayjs().format('YYYYMMDDHHmmss'), |
||||
|
searchData: { |
||||
|
supplierId: '', |
||||
|
site: '', |
||||
|
addressType: '', |
||||
|
active: '', |
||||
|
page: 1, |
||||
|
limit: 10, |
||||
|
}, |
||||
|
height: 200, |
||||
|
pageIndex: 1, |
||||
|
pageSize: 20, |
||||
|
totalPage: 0, |
||||
|
dataList: [], |
||||
|
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' |
||||
|
} |
||||
|
] |
||||
|
}, |
||||
|
authSearch: false, |
||||
|
authSave: false, |
||||
|
authUpdate: false, |
||||
|
authDelete: false, |
||||
|
menuId: this.$route.meta.menuId || 'srmSupplierAddress', |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
mounted () { |
||||
|
this.$nextTick(() => { |
||||
|
this.height = window.innerHeight - 180 |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
created () { |
||||
|
// 按钮控制 |
||||
|
this.getButtonAuthData() |
||||
|
// 无论是否有查询权限,都获取数据列表 |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
validateField(rule, value, callback) { |
||||
|
if (!value || value.trim() === '') { |
||||
|
callback(new Error()); |
||||
|
} else { |
||||
|
callback(); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
// 每页数 |
||||
|
sizeChangeHandle (val) { |
||||
|
this.pageSize = val |
||||
|
this.pageIndex = 1 |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
|
||||
|
// 当前页 |
||||
|
currentChangeHandle (val) { |
||||
|
this.pageIndex = val |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
|
||||
|
async exportExcel() { |
||||
|
const params = { |
||||
|
...this.searchData, |
||||
|
limit: -1, |
||||
|
page: 1 |
||||
|
}; |
||||
|
|
||||
|
excel.exportTable({ |
||||
|
url: "/srmSupplierAddress/getSupplierAddressList", |
||||
|
columnMapping: this.columnList, |
||||
|
mergeSetting: [], |
||||
|
params: params, |
||||
|
fileName: this.exportName + ".xlsx", |
||||
|
// 返回包含rows字段的对象,让excel工具能够正确提取数据 |
||||
|
rowFetcher: res => { |
||||
|
if (res && res.data && res.data.code === 0) { |
||||
|
return { rows: res.data.data || [] }; |
||||
|
} |
||||
|
return { rows: [] }; |
||||
|
}, |
||||
|
columnFormatter: [], |
||||
|
dropColumns: [], |
||||
|
}); |
||||
|
}, |
||||
|
|
||||
|
// 获取数据列表 |
||||
|
getDataList () { |
||||
|
this.dataListLoading = true; |
||||
|
// 准备请求参数 |
||||
|
const params = { |
||||
|
...this.searchData, |
||||
|
page: this.pageIndex, |
||||
|
limit: this.pageSize |
||||
|
}; |
||||
|
|
||||
|
searchSrmSupplierAddressList(params).then(({data}) => { |
||||
|
if (data && data.code === 0) { |
||||
|
const pageData = data.data || data.page; |
||||
|
this.dataList = pageData && pageData.list ? pageData.list : pageData; |
||||
|
if(pageData && pageData.currPage) { |
||||
|
this.pageIndex = pageData.currPage; |
||||
|
this.pageSize = pageData.pageSize; |
||||
|
this.totalPage = pageData.totalCount; |
||||
|
} else { |
||||
|
// 如果返回的数据格式不包含分页信息,根据实际返回数据处理 |
||||
|
this.totalPage = this.dataList ? this.dataList.length : 0; |
||||
|
} |
||||
|
} else { |
||||
|
this.$message.error(data.msg || '获取数据失败') |
||||
|
} |
||||
|
}).catch(error => { |
||||
|
console.error('获取供应商地址列表失败:', error) |
||||
|
this.$message.error('获取数据失败: ' + (error.message || '网络错误')) |
||||
|
}).finally(() => { |
||||
|
this.dataListLoading = false; |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
addModal () { |
||||
|
this.modalData = { |
||||
|
supplierId: '', |
||||
|
site: this.$store.state.user.currentSite || '', |
||||
|
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('表单验证失败'); |
||||
|
} |
||||
|
}); |
||||
|
}, |
||||
|
|
||||
|
//获取按钮的权限数据 |
||||
|
getButtonAuthData () { |
||||
|
let searchFlag = this.isAuth(this.menuId+":search") |
||||
|
let saveFlag = this.isAuth(this.menuId+":save") |
||||
|
let updateFlag = this.isAuth(this.menuId+":update") |
||||
|
let deleteFlag = this.isAuth(this.menuId+":delete") |
||||
|
//处理页面的权限数据 |
||||
|
this.authSearch = !searchFlag |
||||
|
this.authSave = !saveFlag |
||||
|
this.authUpdate = !updateFlag |
||||
|
this.authDelete = !deleteFlag |
||||
|
}, |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
<style scoped lang="scss"> |
||||
|
.el-table /deep/ .cell{ |
||||
|
height: auto; |
||||
|
line-height: 1.5; |
||||
|
} |
||||
|
</style> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue