8 changed files with 1532 additions and 167 deletions
-
10src/api/baseInformation/srmInventoryPeriod.js
-
3src/api/order/srmSavingsReport.js
-
471src/views/modules/npcIqc/npcIqcList.vue
-
9src/views/modules/order/com_poOrder_CustomerPicker.vue
-
243src/views/modules/order/srmSavingsReportImport.vue
-
490src/views/modules/srmBaseInformation/srmInventoryPeriod.vue
-
121src/views/modules/srmPart/PartAdvancedCopyDialog.vue
-
352src/views/modules/srmPart/partInfoList.vue
@ -0,0 +1,10 @@ |
|||||
|
import { createAPI } from '@/utils/httpRequest.js' |
||||
|
|
||||
|
// 财年管理接口(CompanyID 使用系统 customer)
|
||||
|
export const getInventoryPeriodPage = (params) => createAPI('/srmInventoryPeriod/page', 'POST', params) |
||||
|
|
||||
|
export const saveInventoryPeriod = (params) => createAPI('/srmInventoryPeriod/save', 'POST', params) |
||||
|
|
||||
|
export const updateInventoryPeriod = (params) => createAPI('/srmInventoryPeriod/update', 'POST', params) |
||||
|
|
||||
|
export const deleteInventoryPeriod = (params) => createAPI('/srmInventoryPeriod/delete', 'POST', params) |
||||
@ -0,0 +1,490 @@ |
|||||
|
<template> |
||||
|
<div class="mod-config"> |
||||
|
<el-form :inline="true" label-position="top" :model="searchData"> |
||||
|
<!-- CompanyID 使用系统 customer:复用通用 Customer 权限选择器,允许不选,不选时查询所有客户财年数据 --> |
||||
|
<com-po-order-customer-picker |
||||
|
embedded |
||||
|
allow-empty |
||||
|
:site="$store.state.user.site" |
||||
|
v-model="searchData.companyId" |
||||
|
@change="onCustomerChange" /> |
||||
|
<el-form-item label="财年"> |
||||
|
<el-input v-model="searchData.years" clearable style="width: 120px"></el-input> |
||||
|
</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> |
||||
|
<download-excel |
||||
|
:fields="fields()" |
||||
|
:data="exportData" |
||||
|
type="xls" |
||||
|
:name="exportName" |
||||
|
:header="exportHeader" |
||||
|
:footer="exportFooter" |
||||
|
:fetch="createExportData" |
||||
|
:before-generate="startDownload" |
||||
|
:before-finish="finishDownload" |
||||
|
worksheet="财年" |
||||
|
class="el-button el-button--primary el-button--medium"> |
||||
|
{{ "导出" }} |
||||
|
</download-excel> |
||||
|
</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="deleteRow(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="560px" class="period-modal"> |
||||
|
<el-form label-position="top" :model="modalData" style="margin-left: 7px; margin-right: 7px;" ref="modalForm"> |
||||
|
<el-row :gutter="24"> |
||||
|
<!-- Customer 即 CompanyID,新增必选;编辑时作为主键锁定不可改。财年/月份/是否关账不展示,保存时自动计算 --> |
||||
|
<el-col :span="12"> |
||||
|
<com-po-order-customer-picker |
||||
|
embedded |
||||
|
:site="$store.state.user.site" |
||||
|
:disabled="modalDisableFlag" |
||||
|
v-model="modalData.companyId" /> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
<el-row :gutter="24"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="开始日期"> |
||||
|
<el-date-picker |
||||
|
v-model="modalData.beginDate" |
||||
|
type="date" |
||||
|
value-format="yyyy-MM-dd" |
||||
|
format="yyyy-MM-dd" |
||||
|
style="width: 100%" |
||||
|
placeholder="选择日期" |
||||
|
@change="onBeginDateChange"> |
||||
|
</el-date-picker> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="结束日期"> |
||||
|
<el-date-picker |
||||
|
v-model="modalData.endDate" |
||||
|
type="date" |
||||
|
value-format="yyyy-MM-dd" |
||||
|
format="yyyy-MM-dd" |
||||
|
style="width: 100%" |
||||
|
placeholder="选择日期"> |
||||
|
</el-date-picker> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
</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 { |
||||
|
getInventoryPeriodPage, |
||||
|
saveInventoryPeriod, |
||||
|
updateInventoryPeriod, |
||||
|
deleteInventoryPeriod |
||||
|
} from '@/api/baseInformation/srmInventoryPeriod.js' |
||||
|
import ComPoOrderCustomerPicker from '@/views/modules/order/com_poOrder_CustomerPicker.vue' |
||||
|
import dayjs from 'dayjs' |
||||
|
|
||||
|
export default { |
||||
|
data () { |
||||
|
return { |
||||
|
// 导出 start |
||||
|
exportData: [], |
||||
|
exportName: '财年' + dayjs().format('YYYYMMDDHHmmss'), |
||||
|
exportHeader: ['财年管理'], |
||||
|
exportFooter: [], |
||||
|
exportList: [], |
||||
|
// 导出 end |
||||
|
searchData: { |
||||
|
companyId: '', |
||||
|
years: '' |
||||
|
}, |
||||
|
height: 200, |
||||
|
pageIndex: 1, |
||||
|
pageSize: 20, |
||||
|
totalPage: 0, |
||||
|
dataList: [], |
||||
|
dataListLoading: false, |
||||
|
modalFlag: false, |
||||
|
modalDisableFlag: false, |
||||
|
modalData: { |
||||
|
companyId: '', |
||||
|
years: '', |
||||
|
months: '', |
||||
|
beginDate: '', |
||||
|
endDate: '', |
||||
|
closed: 'N', |
||||
|
flag: '1' |
||||
|
}, |
||||
|
columnList: [ |
||||
|
{ |
||||
|
userId: this.$store.state.user.name, |
||||
|
functionId: 'srmInventoryPeriod', |
||||
|
serialNumber: 'srmInventoryPeriodTableYears', |
||||
|
tableId: 'srmInventoryPeriodTable', |
||||
|
tableName: '财年表', |
||||
|
columnProp: 'years', |
||||
|
headerAlign: 'center', |
||||
|
align: 'center', |
||||
|
columnLabel: '财年', |
||||
|
columnHidden: false, |
||||
|
columnImage: false, |
||||
|
columnSortable: false, |
||||
|
sortLv: 0, |
||||
|
status: true, |
||||
|
fixed: '', |
||||
|
columnWidth: 100 |
||||
|
}, |
||||
|
{ |
||||
|
userId: this.$store.state.user.name, |
||||
|
functionId: 'srmInventoryPeriod', |
||||
|
serialNumber: 'srmInventoryPeriodTableCompanyId', |
||||
|
tableId: 'srmInventoryPeriodTable', |
||||
|
tableName: '财年表', |
||||
|
columnProp: 'companyId', |
||||
|
headerAlign: 'center', |
||||
|
align: 'center', |
||||
|
columnLabel: 'Customer', |
||||
|
columnHidden: false, |
||||
|
columnImage: false, |
||||
|
columnSortable: false, |
||||
|
sortLv: 0, |
||||
|
status: true, |
||||
|
fixed: '', |
||||
|
columnWidth: 120 |
||||
|
}, |
||||
|
{ |
||||
|
userId: this.$store.state.user.name, |
||||
|
functionId: 'srmInventoryPeriod', |
||||
|
serialNumber: 'srmInventoryPeriodTableBeginDate', |
||||
|
tableId: 'srmInventoryPeriodTable', |
||||
|
tableName: '财年表', |
||||
|
columnProp: 'beginDate', |
||||
|
headerAlign: 'center', |
||||
|
align: 'center', |
||||
|
columnLabel: '开始日期', |
||||
|
columnHidden: false, |
||||
|
columnImage: false, |
||||
|
columnSortable: false, |
||||
|
sortLv: 0, |
||||
|
status: true, |
||||
|
fixed: '', |
||||
|
columnWidth: 140 |
||||
|
}, |
||||
|
{ |
||||
|
userId: this.$store.state.user.name, |
||||
|
functionId: 'srmInventoryPeriod', |
||||
|
serialNumber: 'srmInventoryPeriodTableEndDate', |
||||
|
tableId: 'srmInventoryPeriodTable', |
||||
|
tableName: '财年表', |
||||
|
columnProp: 'endDate', |
||||
|
headerAlign: 'center', |
||||
|
align: 'center', |
||||
|
columnLabel: '结束日期', |
||||
|
columnHidden: false, |
||||
|
columnImage: false, |
||||
|
columnSortable: false, |
||||
|
sortLv: 0, |
||||
|
status: true, |
||||
|
fixed: '', |
||||
|
columnWidth: 140 |
||||
|
} |
||||
|
], |
||||
|
authSearch: false, |
||||
|
authSave: false, |
||||
|
authUpdate: false, |
||||
|
authDelete: false, |
||||
|
menuId: this.$route.meta.menuId || 'srmInventoryPeriod' |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
components: { |
||||
|
ComPoOrderCustomerPicker |
||||
|
}, |
||||
|
|
||||
|
mounted () { |
||||
|
this.$nextTick(() => { |
||||
|
this.height = window.innerHeight - 180 |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
created () { |
||||
|
this.getButtonAuthData() |
||||
|
// Customer 不再强制选择,默认不选即查询所有财年数据 |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
onBeginDateChange (val) { |
||||
|
// 输入开始日期后,结束日期自动填为开始日期 +1 年 -1 天,如 2025-11-01 -> 2026-10-31 |
||||
|
if (!val) { |
||||
|
return |
||||
|
} |
||||
|
this.modalData.endDate = dayjs(val).add(1, 'year').subtract(1, 'day').format('YYYY-MM-DD') |
||||
|
}, |
||||
|
|
||||
|
onCustomerChange (code) { |
||||
|
this.searchData.companyId = code |
||||
|
this.pageIndex = 1 |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
|
||||
|
sizeChangeHandle (val) { |
||||
|
this.pageSize = val |
||||
|
this.pageIndex = 1 |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
|
||||
|
currentChangeHandle (val) { |
||||
|
this.pageIndex = val |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
|
||||
|
buildQueryParams (extra) { |
||||
|
return Object.assign({ |
||||
|
site: this.$store.state.user.site, |
||||
|
companyId: this.searchData.companyId || '', |
||||
|
years: this.searchData.years || '', |
||||
|
page: this.pageIndex, |
||||
|
limit: this.pageSize |
||||
|
}, extra || {}) |
||||
|
}, |
||||
|
|
||||
|
async createExportData () { |
||||
|
this.exportList = [] |
||||
|
await getInventoryPeriodPage(this.buildQueryParams({ page: 1, limit: 999999 })).then(({ data }) => { |
||||
|
if (data && data.code === 0) { |
||||
|
const pageData = data.data || data.page |
||||
|
const rows = (pageData && pageData.list) ? pageData.list : (pageData || []) |
||||
|
this.exportList = Array.isArray(rows) ? rows : [] |
||||
|
} else { |
||||
|
this.$message.error((data && data.msg) || '导出失败') |
||||
|
} |
||||
|
}).catch(() => { |
||||
|
this.$message.error('导出失败') |
||||
|
}) |
||||
|
return this.exportList |
||||
|
}, |
||||
|
startDownload () { |
||||
|
this.dataListLoading = true |
||||
|
}, |
||||
|
finishDownload () { |
||||
|
this.dataListLoading = false |
||||
|
}, |
||||
|
fields () { |
||||
|
return this.columnList.reduce((acc, col) => { |
||||
|
acc[col.columnLabel] = col.columnProp |
||||
|
return acc |
||||
|
}, {}) |
||||
|
}, |
||||
|
|
||||
|
getDataList () { |
||||
|
this.dataListLoading = true |
||||
|
getInventoryPeriodPage(this.buildQueryParams()).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 = { |
||||
|
// 默认为空,弹窗内必须选择 Customer;带入列表已选客户方便录入 |
||||
|
companyId: this.searchData.companyId || '', |
||||
|
years: '', |
||||
|
months: '', |
||||
|
beginDate: '', |
||||
|
endDate: '', |
||||
|
closed: 'N', |
||||
|
flag: '1' |
||||
|
} |
||||
|
this.modalDisableFlag = false |
||||
|
this.modalFlag = true |
||||
|
this.$nextTick(() => { |
||||
|
if (this.$refs.modalForm) { |
||||
|
this.$refs.modalForm.clearValidate() |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
updateModal (row) { |
||||
|
this.modalData = { |
||||
|
companyId: row.companyId, |
||||
|
years: row.years, |
||||
|
months: row.months, |
||||
|
beginDate: row.beginDate || '', |
||||
|
endDate: row.endDate || '', |
||||
|
closed: row.closed || 'N', |
||||
|
flag: '2' |
||||
|
} |
||||
|
// 财年/月份/客户为主键,编辑时锁定不可改 |
||||
|
this.modalDisableFlag = true |
||||
|
this.modalFlag = true |
||||
|
this.$nextTick(() => { |
||||
|
if (this.$refs.modalForm) { |
||||
|
this.$refs.modalForm.clearValidate() |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
deleteRow (row) { |
||||
|
this.$confirm(`确定删除该财年记录吗?财年:${row.years},月份:${row.months}`, '提示', { |
||||
|
confirmButtonText: '确定', |
||||
|
cancelButtonText: '取消', |
||||
|
type: 'warning' |
||||
|
}).then(() => { |
||||
|
deleteInventoryPeriod({ |
||||
|
site: this.$store.state.user.site, |
||||
|
companyId: row.companyId, |
||||
|
years: row.years, |
||||
|
months: row.months |
||||
|
}).then(({ data }) => { |
||||
|
if (data && data.code === 0) { |
||||
|
this.getDataList() |
||||
|
this.$message({ message: data.msg || '删除成功', type: 'success', duration: 1500 }) |
||||
|
} else { |
||||
|
this.$alert(data.msg || '删除失败', '错误', { confirmButtonText: '确定' }) |
||||
|
} |
||||
|
}).catch(error => { |
||||
|
console.error('删除财年失败:', error) |
||||
|
this.$message.error('删除失败: ' + (error.message || '网络错误')) |
||||
|
}) |
||||
|
}).catch(() => { |
||||
|
this.$message.info('已取消删除') |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
saveData () { |
||||
|
if (!this.modalData.companyId) { |
||||
|
this.$message.warning('请选择 Customer') |
||||
|
return |
||||
|
} |
||||
|
const isAdd = this.modalData.flag === '1' |
||||
|
if (isAdd && (!this.modalData.beginDate || !this.modalData.endDate)) { |
||||
|
this.$message.warning('请选择开始日期和结束日期') |
||||
|
return |
||||
|
} |
||||
|
if (this.modalData.beginDate && this.modalData.endDate && |
||||
|
new Date(this.modalData.beginDate) > new Date(this.modalData.endDate)) { |
||||
|
this.$message.error('开始日期不能晚于结束日期') |
||||
|
return |
||||
|
} |
||||
|
// 新增时财年/月份不展示,自动取结束日期的年份/月份;编辑时沿用原主键 |
||||
|
let years = this.modalData.years |
||||
|
let months = this.modalData.months |
||||
|
if (isAdd) { |
||||
|
const end = dayjs(this.modalData.endDate) |
||||
|
years = end.year() |
||||
|
months = end.month() + 1 |
||||
|
} |
||||
|
const payload = { |
||||
|
site: this.$store.state.user.site, |
||||
|
companyId: this.modalData.companyId, |
||||
|
years: Number(years), |
||||
|
months: Number(months), |
||||
|
beginDate: this.modalData.beginDate || null, |
||||
|
endDate: this.modalData.endDate || null, |
||||
|
closed: this.modalData.closed || 'N' |
||||
|
} |
||||
|
const apiCall = isAdd ? saveInventoryPeriod(payload) : updateInventoryPeriod(payload) |
||||
|
apiCall.then(({ data }) => { |
||||
|
if (data && data.code === 0) { |
||||
|
this.$message({ message: data.msg || '操作成功', 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 || '网络错误')) |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
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; |
||||
|
} |
||||
|
/* 弹窗内 Customer 下拉撑满所在栅格,与下方日期列上下对齐 */ |
||||
|
.period-modal /deep/ .po-customer-picker .el-select { |
||||
|
width: 100%; |
||||
|
} |
||||
|
</style> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue