<template>
|
<div class="mod-config">
|
<basic-container>
|
<ttable :table="table" @handleSelectionChange="handleSelectionChange" :uploadInfo="uploadInfo" :prelang="prelang"
|
:options="options" :ajaxFun="ajaxFun" ref="masterProductionScheduleTable">
|
<template #toolbar>
|
<el-dropdown v-if="permissions.masterproductionschedule_create_order" @command="orderTypeHandleCommand">
|
<el-button>
|
车间订单<i class="el-icon-arrow-down el-icon--right"></i>
|
</el-button>
|
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-item :key="item" :command="item.command" v-for="item in orderTypeArr" :disabled="item.disabled">{{
|
item.label }}</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
|
<el-dropdown v-if="permissions.masterproductionschedule_state_change" @command="handleCommand"
|
style="margin-left: 10px">
|
<el-button>
|
状态改变<i class="el-icon-arrow-down el-icon--right"></i>
|
</el-button>
|
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-item :key="item" :command="item.command" v-for="item in stateTagArr" :disabled="item.disabled">{{
|
item.label }}</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
|
<el-dropdown v-if="permissions.masterproductionschedule_doc_relate" @command="documentHandle"
|
style="margin-left: 10px">
|
<el-button>
|
工艺文件<i class="el-icon-arrow-down el-icon--right"></i>
|
</el-button>
|
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-item :key="item" :command="item.command" v-for="item in documentTagArr" :disabled="item.disabled">
|
{{ item.label }}
|
</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
<!--审核状态改变-->
|
<el-dropdown v-if="permissions.masterproductionschedule_audit_change" @command="handleCommitCommand"
|
style="margin-left: 10px">
|
<el-button>
|
审核状态改变<i class="el-icon-arrow-down el-icon--right"></i>
|
</el-button>
|
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-item :key="item" :command="item.command" v-for="item in commitStateTagArr" :disabled="item.disabled">{{item.label }}</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
<!-- <el-button v-if="permissions.masterproductionschedule_submit_oa" @click="commitOa()" type="primary"
|
style="margin-left:10px;" :loading="loadingOa">提交OA
|
</el-button> -->
|
<!-- <el-button
|
v-if="permissions.masterproductionschedule_sync_scm"
|
@click="syncScm()"
|
type="primary"
|
style="margin-left:10px;"
|
>同步SCM
|
</el-button>
|
<el-button
|
v-if="permissions.masterproductionschedule_statechange_scm"
|
@click="stateChangeScm()"
|
type="primary"
|
style="margin-left:10px;"
|
>SCM状态变更
|
</el-button> -->
|
<el-button
|
type="primary"
|
style="margin-left:10px;"
|
@click="addPlanProcure"
|
>新增采购计划
|
</el-button>
|
</template>
|
</ttable>
|
|
<!-- 弹窗, 修改 -->
|
<table-form v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getData" />
|
<source-table v-if="masterPlanSourceDialogVisible" ref="source" @refreshDataList="getData" />
|
<order-table v-if="orderVisible" ref="order" />
|
<manufacturing-order v-if="manufacturingOrderVisible" ref="manufacturingOrder" @refreshDataList="getData" />
|
<outsourcing-order v-if="outsourcingOrderVisible" ref="outsourcingOrder" @refreshDataList="getData" />
|
<!--库存-->
|
<stockDialog :currshowlist.sync="stockVisible" :partName="partName" />
|
<!--工艺文件-->
|
<DocumentTable :currshowlist.sync="showDocument" :multiSelect="false" :relationOrderList="masterPlanSelection"
|
@listenToDocumentEvent="selectDocument">
|
</DocumentTable>
|
<!--手动创建车间订单-->
|
<ManualManufacturingOrder :currshowlist.sync="showManualManufacturingOrder"
|
:manualMasterProduction="manualMasterProduction" @refreshOrderFromManual="refreshOrderFromManual">
|
</ManualManufacturingOrder>
|
<!--自动创建车间订单-->
|
<AutoManufacturingorder :currshowlist.sync="showAutoManufacturingOrder" :masterProduction="manualMasterProduction"
|
:isReportOperation="isReportOperation" :outPutBatchList="selectedOutPutBatchList" :qtyPlaned="qtyPlaned"
|
@refreshDataList="AutoManuFinished">
|
</AutoManufacturingorder>
|
|
<!--弹窗,新增-->
|
<MasterproductionForm :currshowlist.sync="showMasterproductionForm" @refreshDataList="getData">
|
</MasterproductionForm>
|
<!--产出批次-->
|
<!--<OutPutBatch
|
:currshowlist.sync="showOutPutBatch"
|
:createOrderType="createOrderType"
|
:outPutBatchList="outPutBatchList"
|
@returnBatchData="returnBatchData"
|
></OutPutBatch>-->
|
</basic-container>
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import TableForm from './masterproductionschedule-form'
|
import MasterproductionForm from './masterproduction-form'
|
import SourceTable from './source-table'
|
import OrderTable from './order-table'
|
import ManufacturingOrder from './manufacturing-order'
|
import ManualManufacturingOrder from './manual-manufacturingorder'
|
import AutoManufacturingorder from './auto-manufacturingorder'
|
import OutsourcingOrder from '../outsourcingorder/outsourcingorder-form'
|
import {
|
delObj,
|
fetchList,
|
loadOrderHandle,
|
addPlanPurchasing
|
} from '@/api/plan/masterproductionschedule'
|
import ttable from '@/views/common/ztt-table.vue'
|
import stockDialog from '@/views/common/stock'
|
import {
|
changeMpsState,
|
handleDocument,
|
rejectHandleDocument,
|
auditMasterProductionSchedule,
|
changeAudit
|
} from '../../../api/plan/masterproductionschedule'
|
import { highPrecisionReduce } from '@/util/highPrecision'
|
import DocumentTable from '@/views/common/document.vue'
|
import { remote } from '@/api/admin/dict'
|
import { getObj as getSysParam } from '@/api/admin/sys-public-param'
|
import { sysParam } from '../../../config/sysParam' // 系统参数
|
import { getByMpsIds } from '@/api/plan/operationtaskproduce'
|
import { masterProductionScheduleSave, changeState } from '@/api/scm/common'
|
|
export default {
|
data() {
|
return {
|
ajaxFun: fetchList,
|
statesList: [
|
{ value: '01pending', label: '待处理' },
|
{ value: '02processed', label: '已处理' },
|
{ value: '03canceled', label: '已作废' }
|
],
|
isAuditList: [
|
{
|
value: '01draft',
|
label: '草稿'
|
},
|
{
|
value: '02pending',
|
label: '审核中'
|
},
|
{
|
value: '03accepted',
|
label: '通过'
|
},
|
{
|
value: '04reject',
|
label: '退回'
|
}
|
],
|
orderTypeArr: [],
|
stateTagArr: [
|
{
|
label: '标记待处理',
|
command: 'PENDING',
|
disabled: false,
|
permitArr: ['02processed']
|
},
|
{
|
label: '标记已处理',
|
command: 'PROCESSED',
|
disabled: false,
|
permitArr: ['01pending']
|
},
|
{
|
label: '标记已作废',
|
command: 'CANCELED',
|
disabled: false,
|
permitArr: ['01pending']
|
}
|
],
|
documentTagArr: [
|
{
|
label: '关联工艺文件',
|
command: 'RELEVANCE',
|
disabled: false
|
},
|
{
|
label: '移除工艺文件',
|
command: 'NORELEVANCE',
|
disabled: false
|
}
|
],
|
commitStateTagArr: [
|
{
|
label: '标记通过',
|
command: 'PROCESSED',
|
disabled: false,
|
permitArr: ['01draft']
|
},
|
{
|
label: '标记取消',
|
command: 'CANCELLED',
|
disabled: false,
|
permitArr: ['03accepted']
|
}
|
],
|
events: '',
|
showDocument: false,
|
masterPlanSourceDialogVisible: false,
|
orderVisible: false,
|
manufacturingOrderVisible: false,
|
outsourcingOrderVisible: false,
|
masterPlanSelection: [],
|
mpsRequirementsVisible: false,
|
coStates: [],
|
currentRow: null,
|
multipleSelection: [],
|
isShowQuery: false,
|
uploadInfo: {
|
// 是否展示上传EXCEL以及对应的url
|
isShow: false,
|
url: ''
|
},
|
dateTimeFilters: {},
|
prelang: 'operation',
|
options: {
|
height: 300, // 默认高度-为了表头固定
|
stripe: true, // 是否为斑马纹 table
|
highlightCurrentRow: false, // 是否要高亮当前行
|
border: true, // 是否有纵向边框
|
lazy: false, // 是否需要懒加载
|
fit: true, // 列的宽度是否自撑开
|
multiSelect: true, //
|
seqNo: true,
|
isRefresh: true, // 是否显示刷新按钮
|
isShowHide: true, // 是否显示显影按钮H
|
isSearch: true, // 高级查询按钮
|
defaultOrderBy: { column: 'createTime', direction: 'desc' }
|
},
|
table: {
|
total: 0,
|
currentPage: 1,
|
pageSize: 20,
|
data: [],
|
// 标题
|
column: [
|
{
|
minWidth: '100',
|
prop: 'source',
|
label: '来源',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '120',
|
prop: 'state',
|
label: '状态',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'select',
|
formatter: this.getScheduleState,
|
optList: () => {
|
return this.getScheduleStateList()
|
}
|
},
|
{
|
minWidth: '120',
|
prop: 'isAudit',
|
label: '审核状态',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'select',
|
formatter: this.getIsAudit,
|
optList: () => {
|
return this.isAuditList
|
}
|
},
|
{
|
minWidth: '140',
|
prop: 'customerOrderNo',
|
label: '订单号',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '100',
|
prop: 'mpsNo',
|
label: '生产计划号',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text',
|
render: { fun: this.addOrUpdateHandle }
|
},
|
{
|
minWidth: '120',
|
prop: 'partNo',
|
label: '零件号',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '120',
|
prop: 'partName',
|
label: '零件',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '80',
|
prop: 'docNumber',
|
label: '工艺文件号',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '140',
|
prop: 'qtyRequired',
|
// label: '主计划需求数量',
|
label: '销售数量',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '140',
|
prop: 'inventoryReservedQuantity',
|
label: '库存预留数量',
|
sort: true,
|
isTrue: true,
|
isSearch: false,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '140',
|
prop: 'outsourcingNumber',
|
label: '委外数量',
|
sort: true,
|
isTrue: true,
|
isSearch: false,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '140',
|
prop: 'manufacturingQuantity',
|
label: '制造数量',
|
sort: true,
|
isTrue: true,
|
isSearch: false,
|
searchInfoType: 'text'
|
},
|
|
{
|
minWidth: '80',
|
prop: 'unit',
|
label: '零件单位',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '120',
|
width: '120',
|
prop: 'requiredDate',
|
label: '主计划需求日期',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text',
|
formatter: this.formatDutyDate
|
},
|
{
|
minWidth: '120',
|
width: '120',
|
prop: 'promisedDeliveryDate',
|
label: '承诺日期',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text',
|
formatter: (row, column, cellValue) => {
|
var formatVal
|
if (cellValue) {
|
if (this.getDays(cellValue, row)) {
|
formatVal =
|
'<div style="background-color:red;color: #fff;">' +
|
cellValue.substring(0, 10) +
|
'</div>'
|
} else {
|
formatVal =
|
'<span>' +
|
(cellValue != null ? cellValue.substring(0, 10) : '') +
|
'</span>'
|
}
|
} else {
|
formatVal =
|
'<span>' +
|
(cellValue != null ? cellValue.substring(0, 10) : '') +
|
'</span>'
|
}
|
return formatVal
|
}
|
},
|
{
|
minWidth: '120',
|
prop: 'manufactureAttr',
|
label: '制造属性',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'select',
|
formatter: this.getManufactureAttr,
|
optList: () => {
|
return this.manufactureAttrs
|
}
|
},
|
{
|
minWidth: '120',
|
prop: 'remark',
|
label: '备注',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '120',
|
width: '120',
|
prop: 'updateTime',
|
label: '更新时间',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'datetimerange',
|
formatter: this.formatDutyDate
|
},
|
{
|
minWidth: '120',
|
prop: 'updateUser',
|
label: '更新人',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '140',
|
width: '120',
|
prop: 'createTime',
|
label: '创建时间',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'datetimerange',
|
formatter: this.formatDutyDate
|
},
|
{
|
minWidth: '140',
|
prop: 'createUser',
|
label: '创建人',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
// {
|
// minWidth: '140',
|
// prop: 'outerColor',
|
// label: '外护颜色',
|
// sort: true,
|
// isTrue: true,
|
// isSearch: true,
|
// searchInfoType: 'text'
|
// },
|
// {
|
// minWidth: '140',
|
// prop: 'lengthRequirement',
|
// label: '盘长要求',
|
// sort: true,
|
// isTrue: true,
|
// isSearch: true,
|
// searchInfoType: 'text'
|
// },
|
// {
|
// minWidth: '140',
|
// prop: 'printRequirement',
|
// label: '印字要求',
|
// sort: true,
|
// isTrue: true,
|
// isSearch: true,
|
// searchInfoType: 'text'
|
// },
|
{
|
minWidth: '140',
|
prop: 'remark',
|
label: '销售订单备注',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
}
|
],
|
toolbar: [],
|
operator: [
|
{
|
text: '作废',
|
type: 'text',
|
size: 'small',
|
fun: this.deleteMainPlan
|
}
|
// {
|
// text: '订单预留',
|
// type: 'text',
|
// size: 'small',
|
// fun: this.customReserved
|
// },
|
// {
|
// text: '查看库存',
|
// type: 'text',
|
// size: 'small',
|
// fun: this.stockHandle
|
// },
|
// {
|
// text: '来源',
|
// type: 'text',
|
// size: 'small',
|
// fun: this.searchMasterPlanSourceHandle
|
// },
|
// {
|
// text: '订单',
|
// type: 'text',
|
// size: 'small',
|
// fun: this.searchOrderHandle
|
// }
|
],
|
operatorConfig: {
|
fixed: 'right',
|
label: '操作',
|
width: 100,
|
minWidth: 100
|
}
|
},
|
addOrUpdateVisible: false,
|
stockVisible: false,
|
partName: null,
|
loadingOa: false,
|
showManualManufacturingOrder: false,
|
showAutoManufacturingOrder: false,
|
showMasterproductionForm: false,
|
manualMasterProduction: null,
|
manufactureAttrs: [],
|
isReportOperation: false,
|
createOrderType: 'MANUAL',
|
outPutBatchList: [],
|
selectedOutPutBatchList: [],
|
qtyPlaned: 0,
|
hasMore: false
|
}
|
},
|
components: {
|
ttable,
|
TableForm,
|
SourceTable,
|
OrderTable,
|
ManufacturingOrder,
|
OutsourcingOrder,
|
stockDialog,
|
DocumentTable,
|
ManualManufacturingOrder,
|
AutoManufacturingorder,
|
MasterproductionForm
|
},
|
computed: {
|
...mapGetters(['permissions'])
|
},
|
activated() {
|
this.getData()
|
},
|
created() {
|
this.getManufactureAttrs()
|
/*
|
{
|
text: '新增',
|
type: 'primary',
|
fun: this.addMasterProductionSchedule,
|
disabled: false,
|
permitArr: []
|
},
|
{
|
text: '创建委外订单',
|
fun: this.createOutsourcingOrder
|
} */
|
if (this.permissions.plan_masterproductionschedule_add) {
|
this.table.toolbar.push({
|
text: '新增',
|
type: 'primary',
|
fun: this.addMasterProductionSchedule,
|
disabled: false,
|
permitArr: []
|
})
|
}
|
if (this.permissions.masterproductionschedule_create_outsourcing) {
|
this.table.toolbar.push({
|
text: '创建委外订单',
|
fun: this.createOutsourcingOrder
|
})
|
}
|
if (this.permissions.masterproductionschedule_create_order_manual) {
|
this.orderTypeArr.push({
|
label: '手动新增',
|
command: 'MANUAL',
|
disabled: false,
|
permitArr: ['02processed']
|
})
|
}
|
if (this.permissions.masterproductionschedule_create_order_auto) {
|
this.orderTypeArr.push({
|
label: '自动新增',
|
command: 'AUTO',
|
disabled: false,
|
permitArr: ['01pending']
|
})
|
}
|
this.getSysParam(sysParam.IS_REPORT_OPERATION)
|
},
|
methods: {
|
addPlanProcure(){
|
let val=this.masterPlanSelection.filter(item=>{
|
return item.technologyDocumentId==null||item.technologyDocumentId==''||item.docNumber==''||item.docNumber==null
|
})
|
if(val.length>0){
|
this.$message.warning("当前所选择的计划,含有未绑定工艺文件!")
|
return
|
}
|
addPlanPurchasing(this.masterPlanSelection).then(res=>{
|
console.log(res);
|
})
|
},
|
deleteMainPlan(row){
|
console.log(row);
|
},
|
getSysParam(paramKey) {
|
getSysParam(paramKey).then((response) => {
|
var paramVal = response.data.data
|
if (response.data.code === 0) {
|
if (paramVal != null && paramVal === 'true') {
|
this.isReportOperation = true
|
} else {
|
this.isReportOperation = false
|
}
|
} else {
|
this.isReportOperation = false
|
}
|
})
|
},
|
getManufactureAttr(row, column, cellValue) {
|
this.manufactureAttrs.forEach((obj) => {
|
if (obj.value === cellValue) {
|
cellValue = obj.label
|
}
|
})
|
return cellValue
|
},
|
getManufactureAttrs() {
|
remote('manufacture_attr_type').then((response) => {
|
if (response.data.code === 0) {
|
this.manufactureAttrs = response.data.data
|
} else {
|
this.manufactureAttrs = []
|
}
|
})
|
},
|
// 获取数据列表
|
getData() {
|
this.$refs.masterProductionScheduleTable.getDataList()
|
},
|
// 新增
|
addMasterProductionSchedule() {
|
this.showMasterproductionForm = true
|
},
|
// 修改
|
addOrUpdateHandle(row) {
|
this.addOrUpdateVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdate.init(row ? row.id : row, row ? row.state : row)
|
})
|
},
|
formatDutyDate(row, column, cellValue) {
|
if (cellValue) {
|
const dutyDateList = /\d{4}-\d{1,2}-\d{1,2}/g.exec(cellValue)
|
if (dutyDateList && dutyDateList.length > 0) {
|
return dutyDateList[0]
|
}
|
}
|
return ''
|
},
|
// 删除
|
deleteHandle(row) {
|
this.$confirm('是否确认删除ID为' + row.id, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
closeOnClickModal: false,
|
type: 'warning'
|
})
|
.then(function () {
|
return delObj(row.id)
|
})
|
.then((data) => {
|
this.$message.success('删除成功')
|
this.getData()
|
})
|
},
|
// 查看生产计划来源
|
searchMasterPlanSourceHandle(row) {
|
this.masterPlanSourceDialogVisible = true
|
this.$nextTick(() => {
|
this.$refs.source.init(row.id, row.state)
|
})
|
},
|
// 查看制造订单/委外订单
|
searchOrderHandle(row) {
|
this.orderVisible = true
|
this.$nextTick(() => {
|
this.$refs.order.init(row.id)
|
})
|
},
|
// 创建制造订单
|
createManufacturingOrder() {
|
if (this.masterPlanSelection && this.masterPlanSelection.length === 1) {
|
this.$router.push({
|
name: 'productorderForm',
|
query: {
|
id: null,
|
partId: this.masterPlanSelection[0].partId,
|
partName: this.masterPlanSelection[0].partName,
|
partNo: this.masterPlanSelection[0].partNo,
|
mpsId: this.masterPlanSelection[0].id,
|
// qtyRequired: Number(this.masterPlanSelection[0].qtyRequired - this.masterPlanSelection[0].inventoryReservedQuantity - this.masterPlanSelection[0].outsourcingNumber
|
// - this.masterPlanSelection[0].manufacturingQuantity ).toFixed(6)
|
// ,
|
qtyRequired: Number(
|
highPrecisionReduce(
|
highPrecisionReduce(
|
highPrecisionReduce(
|
this.masterPlanSelection[0].qtyRequired,
|
this.masterPlanSelection[0].inventoryReservedQuantity
|
),
|
this.masterPlanSelection[0].outsourcingNumber
|
),
|
this.masterPlanSelection[0].manufacturingQuantity
|
)
|
).toFixed(6),
|
|
requiredDate: this.masterPlanSelection[0].requiredDate,
|
outerColor: this.masterPlanSelection[0].outerColor
|
}
|
})
|
} else {
|
this.$message.error('请选择一条生产计划')
|
}
|
},
|
// 创建委外订单
|
createOutsourcingOrder() {
|
if (this.masterPlanSelection && this.masterPlanSelection.length === 1) {
|
this.outsourcingOrderVisible = true
|
this.$nextTick(() => {
|
this.$refs.outsourcingOrder.init(null, this.masterPlanSelection[0])
|
})
|
} else {
|
this.$message.error('请选择一条生产计划')
|
}
|
},
|
getScheduleStateList() {
|
return this.statesList
|
},
|
|
getScheduleState(row, column, cellValue) {
|
this.statesList.forEach((obj) => {
|
if (obj.value === cellValue) {
|
cellValue = obj.label
|
}
|
})
|
return cellValue
|
},
|
// 创建车间订单
|
orderTypeHandleCommand(event) {
|
if (event === 'MANUAL') {
|
// 手动新增,弹出手动新增的页面
|
if (this.masterPlanSelection.length == 0) {
|
this.$message.error('请选择生产计划')
|
} else {
|
if (this.masterPlanSelection.length == 1) {
|
const masterPlan = this.masterPlanSelection[0]
|
if (
|
masterPlan.isAudit != null &&
|
masterPlan.isAudit == '03accepted'
|
) {
|
this.manualMasterProduction = masterPlan
|
this.showManualManufacturingOrder = true
|
} else {
|
this.$message.error(
|
'只有【审核状态】为‘通过’的生产计划,才能进行车间订单的创建'
|
)
|
}
|
} else {
|
this.$message.error('只能选择一条生产计划')
|
}
|
}
|
} else {
|
// 自动新增,弹出自动新增的页面
|
if (this.masterPlanSelection.length == 0) {
|
this.$message.error('请选择生产计划')
|
} else {
|
if (this.masterPlanSelection.length == 1) {
|
const masterPlan = this.masterPlanSelection[0]
|
if (
|
masterPlan.isAudit != null &&
|
masterPlan.isAudit == '03accepted'
|
) {
|
this.manualMasterProduction = masterPlan
|
// 根据主计划id,查询对应的产出批次
|
getByMpsIds([masterPlan.id]).then((repsonse) => {
|
const resData = repsonse.data.data
|
const resCode = repsonse.data.code
|
if (resCode === 0) {
|
const _that = this
|
for (const key in resData) {
|
resData[key].forEach((item) => {
|
if (item.moId != null) {
|
_that.$set(item, 'commonChecked', false)
|
} else {
|
_that.$set(item, 'commonChecked', true)
|
}
|
})
|
}
|
this.hasMore = false
|
this.showAutoManufacturingOrder = true
|
}
|
})
|
} else {
|
this.$message.error(
|
'只有【审核状态】为‘通过’的生产计划,才能进行车间订单的创建'
|
)
|
}
|
} else {
|
this.$message.error('只能选择一条生产计划')
|
}
|
}
|
}
|
},
|
// 选中产出批次时的,回调
|
returnBatchData(selectedObj) {
|
//
|
this.selectedOutPutBatchList = selectedObj.outPutBatchList
|
this.qtyPlaned = selectedObj.qtyPlaned
|
this.hasMore = selectedObj.hasMore
|
if (selectedObj.createOrderType === 'MANUAL') {
|
this.showManualManufacturingOrder = true
|
} else if (selectedObj.createOrderType === 'AUTO') {
|
this.showAutoManufacturingOrder = true
|
}
|
},
|
// 自动创建车间订单-完成后的回调
|
AutoManuFinished() {
|
if (this.hasMore) {
|
this.orderTypeHandleCommand('AUTO')
|
} else {
|
this.getData()
|
}
|
},
|
// 状态改变
|
handleCommand(event) {
|
var eventName
|
if (event == 'PENDING') {
|
eventName = '待处理'
|
} else if (event == 'PROCESSED') {
|
eventName = '已处理'
|
} else {
|
eventName = '已作废'
|
}
|
if (this.masterPlanSelection.length > 0) {
|
changeMpsState(
|
this.masterPlanSelection.map((item) => {
|
return item.id
|
}),
|
event
|
).then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
this.$message.success(eventName + '修改成功')
|
this.getData()
|
} else {
|
this.$message.error(eventName + '修改失败')
|
}
|
})
|
} else {
|
this.$message.error('请选择' + eventName + '的对象')
|
}
|
},
|
getIsAudit(row, column, cellValue) {
|
this.isAuditList.forEach((obj) => {
|
if (obj.value === cellValue) {
|
cellValue = obj.label
|
}
|
})
|
return cellValue
|
},
|
// 审核状态改变
|
handleCommitCommand(event) {
|
if (this.masterPlanSelection.length > 0) {
|
if (this.masterPlanSelection.length > 1) {
|
this.$message.error('只能选择一条生产计划')
|
} else {
|
const masterPlan = this.masterPlanSelection[0]
|
if (event == 'CANCELLED') {
|
if (
|
masterPlan.isAudit != null &&
|
masterPlan.isAudit == '03accepted'
|
) {
|
loadOrderHandle(masterPlan.id).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
if (resData.data.length > 0) {
|
this.$confirm(
|
'主生产计划已创建车间订单, 是否继续?',
|
'提示',
|
{
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}
|
)
|
.then(() => {
|
if (masterPlan.technologyDocumentId != null) {
|
changeAudit(masterPlan.id, '01draft').then(
|
(response) => {
|
const data = response.data
|
if (data.code == 0) {
|
this.$message.success('审核状态变更成功')
|
this.getData()
|
} else {
|
this.$message.error('审核状态变更失败')
|
}
|
}
|
)
|
} else {
|
this.$message.error('该条生产计划,未关联工艺文件!')
|
}
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消'
|
})
|
})
|
} else {
|
if (masterPlan.technologyDocumentId != null) {
|
changeAudit(masterPlan.id, '01draft').then((response) => {
|
const data = response.data
|
if (data.code == 0) {
|
this.$message.success('审核状态变更成功')
|
this.getData()
|
} else {
|
this.$message.error('审核状态变更失败')
|
}
|
})
|
} else {
|
this.$message.error('该条生产计划,未关联工艺文件!')
|
}
|
}
|
} else {
|
this.$message.error('查询车间订单失败')
|
}
|
})
|
} else {
|
this.$message.error(
|
'只有【审核状态】为‘通过’的生产计划,才能标记取消!'
|
)
|
}
|
} else {
|
if (masterPlan.isAudit != null && masterPlan.isAudit == '01draft') {
|
if (masterPlan.technologyDocumentId != null) {
|
changeAudit(masterPlan.id, '03accepted').then((response) => {
|
const data = response.data
|
if (data.code == 0) {
|
this.$message.success('审核状态变更成功')
|
this.getData()
|
} else {
|
this.$message.error('审核状态变更失败')
|
}
|
})
|
} else {
|
this.$message.error('该条生产计划,未关联工艺文件!')
|
}
|
} else {
|
this.$message.error(
|
'只有【审核状态】为‘草稿’的生产计划,才能标记通过!'
|
)
|
}
|
}
|
}
|
} else {
|
this.$message.error('请选择一条生产计划')
|
}
|
},
|
// table自带事件
|
handleSelectionChange(val) {
|
// 根据状态,禁用表头按钮
|
// 筛选出选中记录的状态
|
var stateArr = val.map(function (value, index) {
|
return value.state
|
})
|
// 选中状态数组元素去重
|
var uniqueStateArr = []
|
for (var i = 0; i < stateArr.length; i++) {
|
if (uniqueStateArr.indexOf(stateArr[i]) == -1) {
|
uniqueStateArr.push(stateArr[i])
|
}
|
}
|
// 循环自定义按钮,判断每个按钮的permitArr是否完全包含选中状态,若完全包含,则按钮亮,否则按钮灰
|
for (var i = 0; i < this.stateTagArr.length; i++) {
|
if (
|
uniqueStateArr.every((val) =>
|
this.stateTagArr[i].permitArr.length <= 0
|
? true
|
: this.stateTagArr[i].permitArr.includes(val)
|
)
|
) {
|
this.stateTagArr[i].disabled = false
|
} else {
|
this.stateTagArr[i].disabled = true
|
}
|
}
|
this.masterPlanSelection = val
|
},
|
// 查看库存
|
stockHandle(row) {
|
this.stockVisible = true
|
this.partName = row.partName
|
},
|
selectDocument(document) {
|
if (document) {
|
this.changeDocument(document.id)
|
}
|
},
|
documentHandle(event) {
|
var status = false
|
this.events = event
|
if (this.masterPlanSelection.length == 0) {
|
this.$message.error('请至少选择一条生产计划')
|
} else {
|
if (event == 'RELEVANCE') {
|
this.masterPlanSelection.forEach((item) => {
|
if (item.isDocument) {
|
status = true
|
this.$message.error(
|
'存在生产计划已关联工艺文件,如需更改,请先解除关联'
|
)
|
}
|
})
|
if (!status) {
|
this.showDocument = true
|
}
|
} else {
|
this.changeDocument(null)
|
}
|
}
|
},
|
changeDocument(id) {
|
var eventName
|
if (this.events == 'RELEVANCE') {
|
eventName = '关联工艺文件'
|
const masterProductionIds = []
|
this.masterPlanSelection.forEach((item) => {
|
masterProductionIds.push(item.id)
|
})
|
handleDocument(masterProductionIds, id).then((res) => {
|
if (res.data.code == 0) {
|
this.$message.success(eventName + '成功')
|
this.getData()
|
} else {
|
this.$message.error(res.data.msg)
|
}
|
})
|
} else if (this.events == 'NORELEVANCE') {
|
eventName = '移除工艺文件'
|
const masterProductionIds = []
|
this.masterPlanSelection.forEach((item) => {
|
masterProductionIds.push(item.id)
|
})
|
rejectHandleDocument(masterProductionIds).then((res) => {
|
if (res.data.code == 0) {
|
this.$message.success(eventName + '成功')
|
this.getData()
|
} else {
|
this.$message.error(res.data.msg)
|
}
|
})
|
}
|
},
|
// 跳转至客户订单预留页面
|
customReserved(row) {
|
if (row.customerOrderNo != null) {
|
localStorage.setItem('masterschedule_customno', row.customerOrderNo)
|
localStorage.setItem('masterschedule_partno', row.partNo)
|
localStorage.setItem('masterschedule_qtyrequired', row.qtyRequired)
|
|
this.$router.push('/warehouse/orderreserved/index').catch(() => { })
|
} else {
|
this.$message.warning('该生产计划,不可进行客户订单预留!')
|
}
|
},
|
// 同步SCM
|
syncScm() {
|
masterProductionScheduleSave().then((response) => {
|
this.$message.success('同步SCM成功!')
|
})
|
},
|
// SCM状态变更
|
stateChangeScm() {
|
if (this.masterPlanSelection.length == 0) {
|
this.$message.error('请选择一条生产计划')
|
} else {
|
changeState(this.masterPlanSelection[0].id).then((response) => {
|
this.$message.success('SCM状态变更成功!')
|
})
|
}
|
},
|
// 提交OA
|
commitOa() {
|
if (this.masterPlanSelection.length == 0) {
|
this.$message.error('请选择一条生产计划')
|
} else {
|
if (this.masterPlanSelection.length > 1) {
|
this.$message.error('只能选择一条生产计划')
|
} else {
|
const masterPlan = this.masterPlanSelection[0]
|
if (masterPlan.isAudit != null && masterPlan.isAudit == '01draft') {
|
this.loadingOa = true
|
auditMasterProductionSchedule(masterPlan.id)
|
.then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
this.$message.success('提交OA成功!')
|
this.getData()
|
} else {
|
this.$message.error('提交OA失败!')
|
}
|
this.loadingOa = false
|
})
|
.catch(() => {
|
this.loadingOa = false
|
})
|
} else {
|
this.$message.error(
|
'只有【审核状态】为‘草稿’的生产计划,才可进行OA提交!'
|
)
|
}
|
}
|
}
|
},
|
// 手动创建车间订单时,刷新主计划
|
refreshOrderFromManual() {
|
this.getData()
|
},
|
// 与当前时间比较
|
getDays(strDateStart, row) {
|
// var time = (new Date(strDateStart).getTime() / 1000) - (new Date(strDateStart).format('YYYY-MM-DD').getTime() / 1000)
|
// var days = parseFloat(time / 60 / 60 / 24).toFixed(2);
|
// if (days <= 7 && days>=0) {
|
// return true
|
// } else {
|
// return false
|
// }
|
|
const d1 = new Date(strDateStart).format('yyyy-MM-dd')
|
const d2 = new Date(row.requiredDate).format('yyyy-MM-dd') // 当前日期
|
var a1 = Date.parse(new Date(d1))
|
var a2 = Date.parse(new Date(d2))
|
var days = parseInt((a1 - a2) / (1000 * 60 * 60 * 24))
|
if (days <= 7 && days >= 0) {
|
return true
|
} else {
|
return false
|
}
|
}
|
}
|
}
|
</script>
|