<template>
<div class="erp-config">
<title>{{ $route.name }}</title>
<h1>{{ $route.name }}</h1>
<aui-form id="editForm" label-width="100px">
<div class="first-field" :class="isShowMore ? 'showMore' : 'hideMore'">
<aui-form-item label="时间">
<aui-dropdown
v-model="searchForm.dateTime"
class="operationClas"
:op="dateMainOp"
place-holder="请输入"
></aui-dropdown>
</aui-form-item>
<aui-form-item label="工序">
<aui-dropdown size="small" v-model="searchForm.workSerctionListStr" :op="workSerctionMainOp"></aui-dropdown>
</aui-form-item>
<aui-form-item label="交付部门">
<aui-dropdown size="small" v-model="searchForm.deptCodeStr" :op="deptCodeMainOp"></aui-dropdown>
</aui-form-item>
<aui-form-item label="产品系列">
<aui-dropdown
size="small"
v-model="searchForm.prodSeriesCodeListStr"
:op="prodSeriesMainOp"
place-holder="请选择"
></aui-dropdown>
</aui-form-item>
<aui-form-item class="first-field-btn" label-width="0px">
<i
v-show="true"
class="hae-icon"
:class="isShowMore ? 'icon-down' : 'icon-left-o'"
@click="isShowMore = !isShowMore"
></i>
<aui-button hue="primary" round="true" size="small" @click="formValid">查询</aui-button>
<aui-button hue="primary" round="true" size="small" @click="reset">重置</aui-button>
</aui-form-item>
</div>
</aui-form>
<aui-grid ref="grid" :op="createGridOp"></aui-grid>
<aui-dialog-box
v-model="lineCommandVisible"
:dragable="true"
title="架线指令"
@close="handleLineCommandClose"
width="90%"
top="4%"
>
<cap-dept-line-command
v-if="lineCommandVisible"
:deptCode="deptCode"
:workStation="workStation"
:prodSeriesCode="prodSeriesCode"
:bucketStr="bucketStr"
:isCommandEdit="isCommandEdit"
></cap-dept-line-command>
</aui-dialog-box>
<!-- 架线 -->
<aui-dialog-box
id="gridTableDialog"
title="导入产能规划"
v-model="MaintainDeptProductionCapacityLinDialog.show"
width="90%"
top="4%"
:dragable="true"
@close="deptPlandClose"
>
<maintain-dept-production-capacity-lin
v-if="MaintainDeptProductionCapacityLinDialog.show"
:deptCodeStr="deptCode"
:workSerctionListStr="workStation"
:prodSeriesCodeListStr="prodSeriesCode"
:bucketStr="bucketStr"
></maintain-dept-production-capacity-lin>
</aui-dialog-box>
<aui-row class="gridTopImportBtns">
<i class="hae-icon icon-setup" @click.stop="toolBoxShow = !toolBoxShow">
<div v-show="toolBoxShow">
<aui-fileupload round="true" size="small" :mini-mode="true" class='hae-btn' :op="importop">导入</aui-fileupload>
<aui-button round="true" size="small" @click="dynamicExportClick">导出</aui-button>
<aui-button round="true" size="small" @click="downloadFile" resetTime='5000'>导入模板下载</aui-button>
</div>
</i>
</aui-row>
</div>
</template>
<script>
import { publicFun } from '../unit/js/public.js'
import { Grid, Form, FormItem, Dropdown, Button, Hae, DialogBox, $ } from '@aurora/ui3'
import moment from 'moment'
import CapDeptLineCommand from '../unit/prodforecast/CapDeptLineCommand'
import MaintainDeptProductionCapacityLin from '../prodforecast/MaintainDeptProductionCapacityLin'
export default {
components: {
MaintainDeptProductionCapacityLin,
AuiButton: Button,
AuiGrid: Grid,
AuiForm: Form,
AuiFormItem: FormItem,
AuiDropdown: Dropdown,
AuiDialogBox: DialogBox,
CapDeptLineCommand
},
data() {
let that = this
return {
isCommandEdit: this.$service.privilege.check('Service$linePlanInstructMaintainServiceImpl$save'),
deptCode: '',
workStation: '',
prodSeriesCode: '',
bucketStr: '',
updateMap: [],
// 新版是否显示更多条件
toolBoxShow: false,
isShowMore: false,
isTriangleIconShow: true, // 三角形图标显示
lineCommandVisible: false,
initBucketStr: '',
// 新版是否显示更多条件end
MaintainDeptProductionCapacityLinDialog: {
show: false
},
dataForUpdate: [],
searchForm: {
prodSeriesCodeListStr: '',
workSerctionListStr: '裸机',
deptCodeStr: '',
dateTime: ''
},
// 产品系列
prodSeriesMainOp: {
id: 'prodSeriesMainOp',
multi: false,
alwaysLoad: true,
showClearBtn: true,
editable: true,
autoSelect: true,
textField: 'prodSeriesEnName',
valueField: 'prodSeriesCode',
placeHolder: '-----请选择-----',
dataset: {
source: {
type: 'post',
url: 'services/linePlanFormulateService/getAllProdSeriesList'
}
},
emptyDataMsg: '-----没有数据-----'
},
// 工序
workSerctionMainOp: {
id: 'workSerctionMainOp',
multi: false,
showClearBtn: true,
editable: true,
validation: { required: true },
textField: 'key',
valueField: 'value',
placeHolder: '-----请选择-----',
dataset: {
source: {
type: 'POST',
url: 'services/linePlanFormulateService/getWorkStationList',
data: {
serviceType: '系统',
serviceName: '架线计划制定',
keyInfo: '工序'
}
}
},
emptyDataMsg: '-----没有数据-----'
},
// 交付部门
deptCodeMainOp: {
id: 'deptCodeMainOp',
multi: false,
alwaysLoad: true,
autoSelect: true,
showClearBtn: true,
editable: true,
textField: 'deptName',
valueField: 'deptCode',
placeHolder: '-----请选择-----',
dataset: {
source: {
type: 'post',
url: 'services/linePlanFormulateService/getDeptList'
}
},
emptyDataMsg: '-----没有数据-----'
},
// 时间
dateMainOp: {
multi: true,
id: 'dateMainOp',
autoSelect: true,
showClearBtn: true,
editable: true,
validation: { required: true },
emptyDataMsg: '-----没有数据-----',
textField: 'key',
valueField: 'value',
placeHolder: '-----请选择-----',
dataset: {
source: {
type: 'post',
url: 'services/linePlanFormulateService/getDateList'
}
}
},
// 表格的配置
createGridOp: {
name: 'baseGrid_V241015', // name值,配置个性化customSetting/customized
id: 'capDeptLinePlanGrid',
showTip: true,
tipOp: {
type: 'normal'
},
customized: false, // 是否打开隐藏列功能(动态列不能打开)
allowFreeze: true, // 冻结选项
allowResize: true,
allowSort: true,
percentWidth: false,
showStatus: false,
showPager: true, // 展示分页
autoLoad: true, // 自动加载
showSeq: false, // 展示序号
cssName: 'text-center',
rowRender: 'rowspan',
editMode: true,
columns: [],
pagerOp: {
mode: 'number',
pageSizes: [5, 10, 15],
pageVO: {
curPage: 1,
pageSize: 5
}
},
dataset: {
source: {
type: 'post'
}
},
onRenderRow(tr, rowData, rowIdx) {},
onBeforeEdit(cellValue, rowData, td, col) {
const regex = /f\d+/
if (regex.test(col.field)) {
let typeCodeList = ['nowQty', 'piecemealReqLineQty']
if (!typeCodeList.includes(rowData.typeCode) || rowData.deptCode === 'TBD') {
return false
}
}
if (col.field === 'nowQty') {
if (rowData.deptCode === 'TBD') {
return false
} else if (rowData.typeCode !== 'existingLineQty') {
return false
}
}
},
// 更新的操作,编辑完成后则执行的操作
onAfterEdit(value, rowData, td, col, oldValue) {
let reg = /^(0|[1-9][0-9]*)$/
if (!reg.test(value) && value !== '') {
Hae.topBox('请输入大于等于0的整数', 'warning', false, 2000)
return false
}
let param = {
prodSeriesCode: rowData.prodSeriesCode,
deptCode: rowData.deptCode,
workStation: rowData.workStation,
qty: Number(value)
}
if (col.field === 'nowQty') {
param.typeCode = 'nowQty'
param.bucketValueStr = null
} else {
param.typeCode = rowData.typeCode
param.bucketValueStr = col.header
}
const index = that.updateMap.findIndex(
(item) =>
item.bucketValueStr === param.bucketValueStr &&
item.deptCode === param.deptCode &&
item.typeCode === param.typeCode &&
item.prodSeriesCode === param.prodSeriesCode
)
if (index < 0) {
that.updateMap.push(param)
} else {
that.updateMap[index].qty = param.qty
}
},
operation: {
save: {
onBeforeSave(ajax, optOp, grid) {
Hae.ajax({
url: 'services/linePlanFormulateService/save',
type: 'post',
async: false,
data: that.updateMap,
dataType: 'text',
success: function (result) {
if (result === 'SUCCESS') {
Hae.topBox('保存成功', 'successful', false, 2000)
setTimeout(() => {
that.formValid()
}, 200)
} else {
Hae.topBox(result, 'error', false, 2000)
}
}
})
return false
}
},
deptPlan: {
id: 'deptPlan',
text: '导入产能规划',
onClick: this.searchToMaintain
},
editLineCommand: {
id: 'editLineCommand',
text: this.$service.privilege.check('Service$linePlanInstructMaintainServiceImpl$save')
? '创建架线指令'
: '查看架线指令',
onClick: this.editLineCommand
},
refresh: {
id: 'refresh',
text: '刷新预测需求线',
onClick: this.refresh
}
},
onCellStyle(field, rowData) {},
// 组件渲染完成时执行的事件。
onRender(grid) {}
}
}
},
created() {},
mounted() {
let that = this
// 注册全局单机事件隐藏导入按钮栏
document.addEventListener('click', (e) => {
setTimeout(() => {
if ($(e.target).hasClass('icon-setup') || $(e.target).hasClass('gridTopBtnDiv')) {
return false
} else {
if (that.toolBoxShow) {
that.toolBoxShow = false
}
}
}, 300)
})
// 判断是否有更多条件显示隐藏小三角
let editFormHeight = $('.first-field').outerHeight()
that.isTriangleIconShow = !(editFormHeight < 38)
that.isShowMore = false
that.selectStartTime()
that.MaintainDeptProductionCapacityLinDialog.show = false
setTimeout(() => {
that.formValid()
}, 800)
},
methods: {
searchToMaintain() {
this.MaintainDeptProductionCapacityLinDialog.show = true
this.prodSeriesCode = this.searchForm.prodSeriesCodeListStr
this.workStation = this.searchForm.workSerctionListStr
this.deptCode = this.searchForm.deptCodeStr
},
// 导出
dynamicExportClick() {
let that = this
let initExportData = {
tableName: that.tableName
}
that.arrayList.forEach(res => {
res[`${res.lineColumnName}`] = res.detail
initExportData[`${res.lineColumnName}`] = res.detail
})
Hae.ajax({
url:
'services/baseCommDetailService/export',
data: initExportData,
type: 'post',
success(data) {
Hae.confirm(
'导出任务已开始,你可以进入[我的导入导出>导出查询]中查看任务状态并下载导出文件!',
function(bool) {
if (bool) {
window.open('#/ListExport')
}
}
)
}
})
},
// 校验搜索
formValid() {
let that = this
Hae.validForm($('#editForm'), (result) => {
if (result === false) {
return false
} else {
that.getGirdMovingList()
}
})
},
selectStartTime() {
let that = this
Hae.ajax({
url: 'services/linePlanFormulateService/getDateList',
type: 'post',
async: false,
data: {},
success: function (result) {
if (result) {
const currentDate = moment() // 获取当前日期
const monday = currentDate.day(1).startOf('day') // 获取周一的日期
const futureThreeWeeks = moment(monday).add(4, 'weeks') // 未来三周的日期
let dateTimeStr = ''
let dateTimeArr = []
result.forEach((item) => {
if (
(moment(item.value).isAfter(monday) && moment(item.value).isBefore(futureThreeWeeks)) ||
moment(item.value).isSame(monday)
) {
dateTimeArr.push(item.value)
}
})
dateTimeStr = dateTimeArr.slice(0, 9).join(',')
that.searchForm.dateTime = dateTimeStr
}
}
})
},
// 编辑架线指令
editLineCommand() {
let that = this
if (!that.isCommandEdit) {
this.lineCommand()
return
}
let { widget } = that.$refs.grid
let data = widget.getSelectedRecords()
let selectData = data.filter((item) => {
return item.deptCode !== 'ALL'
})
// 架线指令初始化
if (selectData.length) {
selectData.forEach((obj) => {
obj.bucketStr = that.initBucketStr
})
Hae.ajax({
url: 'services/linePlanInstructMaintainService/initLineTask',
type: 'post',
data: selectData,
dataType: 'text',
success() {
that.lineCommand()
}
})
} else {
that.lineCommand()
}
},
lineCommand() {
this.deptCode = this.searchForm.deptCodeStr
this.workStation = this.searchForm.workSerctionListStr
this.prodSeriesCode = this.searchForm.prodSeriesCodeListStr
this.bucketStr = this.searchForm.dateTime
this.lineCommandVisible = true
},
searchToMaintainClose() {
this.MaintainDeptProductionCapacityLinDialog = true
},
handleLineCommandClose() {
this.lineCommandVisible = false
},
deptPlandClose() {
this.MaintainDeptProductionCapacityLinDialog.show = false
},
refresh() {
let that = this
let searchForm = that.searchForm
Hae.ajax({
url: 'services/linePlanFormulateService/refreshForecastRequireLine',
type: 'post',
data: searchForm,
dataType: 'text',
success(result) {
if (result === 'SUCCESS') {
Hae.topBox(result, 'successful', false, 2000)
let gridWidger = that.$refs['grid'].widget
publicFun.jumpFormerPage(gridWidger)
} else {
Hae.topBox(result, 'error', false, 2000)
let gridWidger = that.$refs['grid'].widget
publicFun.jumpFormerPage(gridWidger)
}
}
})
},
getGirdMovingList() {
let that = this
let gridColumns = []
let param = {}
param.deptCode = that.searchForm.deptCodeStr
param.prodSeriesCode = that.searchForm.prodSeriesCodeListStr
param.workStation = that.searchForm.workSerctionListStr
param.bucketStr = that.searchForm.dateTime
Hae.ajax({
url: 'services/linePlanFormulateService/getHeadBucketList',
type: 'post',
async: false,
data: param,
dataType: 'json',
success(result) {
that.isShowMore = false
gridColumns = [
{
multi: true,
columnType: 'select'
},
{
field: 'prodSeriesEnName',
headCss: 'text-center',
cssName: 'text-center',
width: '180px',
header: '产品系列',
showTip: 'true',
rowspan: true,
editable: false
},
{
field: 'deptName',
headCss: 'text-center',
cssName: 'text-center',
width: '180px',
header: '交付部门',
showTip: 'true',
rowspan: true,
editable: false
},
{
field: 'nowQty',
headCss: 'text-center',
cssName: 'text-center',
width: '130px',
header: '现有线体',
showTip: 'true',
rowspan: true,
editable: true
},
{
field: 'typeName',
headCss: 'text-center',
cssName: 'text-center',
width: '180px',
header: '维度',
showTip: 'true',
editable: false
}
]
if (result !== undefined) {
const currentDate = moment() // 获取当前日期
const monday = currentDate.day(1).startOf('day') // 获取周一的日期
const currentWeekMonday = moment(monday)
for (let i = 0; i < result.length; i++) {
let date = result[i].value
let field = result[i].key
let newDate = moment(date)
if (newDate.isAfter(currentWeekMonday) || newDate.isSame(currentWeekMonday)) {
gridColumns.push({
field,
header: date,
headCss: 'text-center',
cssName: 'text-center',
editable: true
})
} else {
gridColumns.push({
field,
header: date,
headCss: 'text-center',
cssName: 'text-center',
editable: false
})
}
}
that.initBucketStr = result.map((obj) => obj.value).join(',')
}
}
})
let newCol = {
columns: gridColumns,
dataset: {
source: {
url: 'services/linePlanFormulateService/getLinePlanList/page/{{pageSize}}/{{curPage}}',
data: param
}
}
}
that.updateMap = []
that.$refs.grid.widget.reInit(newCol)
},
reset() {
let that = this
that.searchForm = {
prodSeriesCodeListStr: '',
workSerctionListStr: '裸机',
deptCodeStr: '',
dateTime: ''
}
that.selectStartTime()
}
}
}
</script>
<style scoped src='./../unit/css/newModelPublic.css'/>
<style scoped>
.template-main {
position: relative;
}
.gridTopImportBtns {
width: 200px;
position: absolute;
top: 62px;
left: 410px;
z-index: 30;
}
.erp-config :deep(#capDeptLinePlanGrid .grid-body) {
height: calc(100% - 48px);
}
.grid-head-config {
height: 100%;
}
#capDeptLinePlanGrid {
height: calc(100% - 120px);
}
.erp-config :deep(#capDeptLinePlanGrid .hae-grid-body) {
height: 100%;
}
.erp-config {
height: 100%;
}
.hae-dialog-box .hae-dialog__body {
padding: 6px;
}
.erp-config :deep(.hae-dialog-box .hae-dialog__body) {
text-align: initial;
padding: 24px;
color: #5a5e66;
font-size: 14px;
overflow: hidden;
max-height: 95vh;
}
</style>
导出功能不起作用