<template>
|
<div style="height: 100%">
|
<div class="page-header">
|
<div class="header-left">
|
<a @click="$router.go(-1)"><i class="icon-btn-back"></i></a>
|
<h2>编辑-工序</h2>
|
</div>
|
<div class="btn-group header-right">
|
<el-button :disabled="isSubmit" v-thinclick="`dataFormSubmit`"
|
>保存</el-button
|
>
|
</div>
|
</div>
|
<div class="page-main">
|
<div class="operation-basic">
|
<el-form
|
:inline="true"
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="100px"
|
class="l-mes form-content"
|
>
|
<el-row class="first-row">
|
<el-col :span="24">
|
<el-form-item label="工序名称" prop="name">
|
<el-input
|
v-model="dataForm.name"
|
placeholder="工序名称"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="工序编号" prop="operationNo">
|
<el-input
|
v-model="dataForm.operationNo"
|
placeholder="工序编号"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="零件族" prop="partFamilyId">
|
<el-select
|
v-model="dataForm.partFamilyId"
|
filterable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in this.partFamilyOptions"
|
:key="index"
|
:label="item.partFamilyName"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工作中心" prop="workCenter">
|
<el-select
|
v-model="dataForm.workCenter"
|
placeholder="工作中心"
|
style="width: 100%"
|
filterable
|
>
|
<el-option
|
v-for="item in workCenterOptions"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="机器运转因素" prop="machRunFactor">
|
<el-input
|
v-model="dataForm.machRunFactor"
|
placeholder="机器运转因素"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="机器设置时间" prop="machSetupTime">
|
<el-input
|
v-model="dataForm.machSetupTime"
|
placeholder="机器设置时间"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="人工类别" prop="laborClassNo">
|
<el-select
|
v-model="dataForm.laborClassNo"
|
filterable
|
placeholder="请选择人工类别"
|
style="width:100%"
|
>
|
<el-option
|
v-for="(item, index) in laborClassNoOptions"
|
:label="item.label"
|
:value="item.value"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="劳力运转因素" prop="laborRunFactor">
|
<el-input
|
v-model="dataForm.laborRunFactor"
|
placeholder="劳力运转因素"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="劳力设置时间" prop="laborSetupTime">
|
<el-input
|
v-model="dataForm.laborSetupTime"
|
placeholder="劳力设置时间"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="因素单位" prop="runTimeCodeDb">
|
<el-select
|
v-model="dataForm.runTimeCodeDb"
|
placeholder="因素单位"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in runTimeCodeDbOptions"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="班组人员" prop="crewSize">
|
<el-input
|
v-model="dataForm.crewSize"
|
placeholder="班组人员"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="外部工序项目" prop="outsideOpItem">
|
<el-select
|
v-model="dataForm.outsideOpItem"
|
placeholder="外部工序项目"
|
style="width: 170px"
|
clearable
|
>
|
<el-option
|
v-for="item in outsideOpItemOptions"
|
:key="item.id"
|
:label='item.value + "-" + item.label '
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input
|
v-model="dataForm.remark"
|
placeholder="备注"
|
style="width: 280px"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row style="padding-top: 10px">
|
<el-col :span="24">
|
<el-form-item label="配置项">
|
<el-checkbox-group
|
v-model="checkboxGroup"
|
@change="checkboxGroupChange()"
|
>
|
<el-checkbox-button
|
label="productionCounting"
|
key="productionCounting"
|
>报工</el-checkbox-button
|
>
|
<el-checkbox-button label="daq" key="daq"
|
>采集</el-checkbox-button
|
>
|
<el-checkbox-button label="inspection" key="inspection"
|
>检验</el-checkbox-button
|
>
|
<el-checkbox-button
|
label="autoInspection"
|
key="autoInspection"
|
>自动报检</el-checkbox-button
|
>
|
<!-- <el-checkbox-button label="semiFinished" key="semiFinished"
|
>半成品</el-checkbox-button
|
> -->
|
<el-checkbox-button label="materialCost" key="materialCost"
|
>投料</el-checkbox-button
|
>
|
</el-checkbox-group>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
|
<div class="operation-detail">
|
<el-tabs type="card" style="width: 100%;height: 100%">
|
<!-- <el-tab-pane label="基础" style="height: 100%">
|
<el-card class="operation-capacity" header="工序能力">
|
<el-transfer
|
filterable
|
filter-placeholder="搜索"
|
:titles="['待选', '已选']"
|
v-model="dataForm.capabilityIds"
|
:data="capacities"
|
:button-texts="['到左边', '到右边']"
|
:props="{
|
key: 'id',
|
label: 'capabilityName'
|
}"
|
>
|
</el-transfer>
|
</el-card>
|
<el-card class="operation-param-list" header="附件">
|
<el-upload
|
drag
|
ref="upload"
|
action="/mes/operation/upload"
|
:headers="headers"
|
:auto-upload="true"
|
:before-upload="submitUpload"
|
:on-success="uploadSuccess"
|
:data="paramDatas"
|
:file-list="fileList"
|
list-type="text"
|
:on-remove="handleRemove"
|
:on-preview="handlePreview"
|
:with-credentials="true"
|
>
|
<i class="el-icon-upload"></i>
|
<div class="el-upload__text">
|
将文件拖到此处,或<em>点击上传</em>
|
</div>
|
</el-upload>
|
</el-card>
|
</el-tab-pane> -->
|
<el-tab-pane label="参数" style="height: 100%">
|
<el-card class="operation-capacity" header="工序参数集模板">
|
<div slot="header">
|
<span>参数集模板</span>
|
<el-button
|
style="float: right; padding: 3px 0"
|
type="text"
|
v-if="editable"
|
@click="addOperationTemplate()"
|
>添加</el-button
|
>
|
</div>
|
<el-table
|
:data="operationTemplateList"
|
highlight-current-row
|
@current-change="handleCurrentParamTemplateChange"
|
>
|
<el-table-column type="index" width="50" label="序号">
|
</el-table-column>
|
<el-table-column
|
label="模板名称"
|
prop="templateName"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
label="模板编号"
|
prop="templateNo"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
label="类型"
|
prop="templateType"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column label="备注" prop="remark" align="center">
|
</el-table-column>
|
<el-table-column label="操作" align="center" width="60px">
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="small"
|
v-if="editable"
|
@click.stop="delParam(scope.row.id, scope.$index)"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-card>
|
<el-card class="operation-param-list" header="参数">
|
<el-table
|
:data="operationParams"
|
height="500px"
|
class="l-mes-table"
|
border
|
stripe
|
>
|
<el-table-column label="参数编号" prop="code" align="center">
|
</el-table-column>
|
<el-table-column
|
label="参数项"
|
prop="parameterItem"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
label="参数类型"
|
prop="type"
|
align="center"
|
:formatter="getParam"
|
>
|
</el-table-column>
|
<el-table-column label="单位" prop="unit" align="center">
|
</el-table-column>
|
</el-table>
|
</el-card>
|
</el-tab-pane>
|
<!-- <el-tab-pane
|
v-if="isShowStepBusiness"
|
label="工步"
|
style="height: 100%"
|
>
|
<el-card class="operation-capacity" header="工步列表">
|
<div slot="header">
|
<span>工步列表</span>
|
<el-button
|
style="float: right; padding: 3px 0"
|
type="text"
|
v-if="editable"
|
@click="addStep()"
|
>添加</el-button
|
>
|
</div>
|
<el-table
|
id="stepTable"
|
ref="operationStepTable"
|
:default-sort="{ prop: 'index' }"
|
:data="stepList"
|
height="700"
|
style="width: 100%"
|
>
|
<el-table-column
|
prop="index"
|
label="序号"
|
width="50"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column prop="stepNo" label="工步编号" align="center">
|
</el-table-column>
|
<el-table-column prop="name" label="工步名称" align="center">
|
</el-table-column>
|
<el-table-column prop="remark" label="备注" align="center">
|
</el-table-column>
|
|
<el-table-column v-if="editable" label="操作" align="center">
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="mini"
|
@click.stop="insertStep(scope.row)"
|
>插入
|
</el-button>
|
<el-button
|
type="text"
|
size="mini"
|
@click.stop="handleDeleteStep(scope.row, scope.$index)"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-card>
|
</el-tab-pane> -->
|
</el-tabs>
|
<ParamTemplateDialog
|
:currshowlist.sync="showOperationTemplate"
|
@handleSelectionParamTemplateChange="selectOperationTemplate"
|
/>
|
<StepDialog
|
:currshowlist.sync="showStep"
|
@handleSelectionStepChange="selectStep"
|
/>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import {
|
getObj,
|
addObj,
|
putObj,
|
removeFile,
|
saveOperationTemplate,
|
delOperationTemplate,
|
saveOperationStep,
|
getLaborClassNo
|
} from '@/api/technology/operation'
|
import { getObj as getSysParam } from '@/api/admin/sys-public-param'
|
import { getOperationParam } from '@/api/basic/template'
|
import { fetchCapabilityForOperation } from '@/api/aps/capability'
|
import ElRow from 'element-ui/packages/row/src/row'
|
import { getStore } from '@/util/store.js'
|
import { validateSixDecimalPositives } from '@/util/validate'
|
import { loadPartFamily } from '@/api/basic/partFamily'
|
import ParamTemplateDialog from '@/views/common/operationParamTemplate.vue'
|
import StepDialog from '@/views/common/step.vue'
|
import { remote } from '../../../api/admin/dict'
|
import { sysParam } from '../../../config/sysParam' // 系统参数
|
const capabilityArray = [
|
'daq',
|
'productionCounting',
|
'inspection',
|
'autoInspection',
|
'semiFinished',
|
'materialCost'
|
]
|
|
export default {
|
components: { ElRow, ParamTemplateDialog, StepDialog },
|
data() {
|
return {
|
typeOptions: [],
|
ids: [],
|
showOperationTemplate: false,
|
showStep: false,
|
isInsertStep: false,
|
stepIndex: null,
|
isShowStepBusiness: false,
|
operationId: '',
|
newFileList: [],
|
capacities: [],
|
partFamilyOptions: [],
|
dialogImageUrl: '',
|
checkboxGroup: [],
|
operationParams: [],
|
dataForm: {
|
id: null,
|
operationNo: null,
|
name: null,
|
productionCounting: false,
|
daq: false,
|
semiFinished: false,
|
inspection: false,
|
autoInspection: false,
|
materialCost: false,
|
partFamilyId: null,
|
attachments: [],
|
capabilityIds: [],
|
remark: null,
|
workCenter: null,
|
machRunFactor: 0,
|
machSetupTime: 0,
|
laborClassNo: null,
|
laborRunFactor: 0,
|
laborSetupTime: 0,
|
runTimeCodeDb: '2',
|
crewSize: 1,
|
outsideOpItem:null
|
},
|
operationTemplateList: [],
|
stepList: [],
|
fileList: [],
|
headers: {
|
Authorization: 'Bearer ' + getStore({ name: 'access_token' })
|
},
|
paramDatas: {
|
operationId: null
|
},
|
dataRule: {
|
operationNo: [
|
{ required: true, message: '工序编号不能为空', trigger: 'blur' }
|
],
|
name: [
|
{ required: true, message: '工序名称不能为空', trigger: 'blur' }
|
],
|
productionCounting: [
|
{ required: true, message: '是否报工不能为空', trigger: 'blur' }
|
],
|
daq: [{ required: true, message: '是否数采不能为空', trigger: 'blur' }],
|
semiFinished: [
|
{ required: true, message: '是否生成半成品不能为空', trigger: 'blur' }
|
],
|
inspection: [
|
{ required: true, message: '是否质检不能为空', trigger: 'blur' }
|
],
|
materialCost: [
|
{ required: true, message: '是否投料不能为空', trigger: 'blur' }
|
]
|
},
|
isSubmit: false,
|
workCenterOptions: [],
|
runTimeCodeDbOptions: [],
|
laborClassNoOptions: [],
|
outsideOpItemOptions: []
|
}
|
},
|
computed: {
|
editable: function() {
|
if (this.dataForm.id) {
|
return true
|
} else {
|
return false
|
}
|
}
|
},
|
mounted() {
|
window.addEventListener(
|
'hashchange',
|
() => {
|
const currentPath = window.location.hash.slice(1)
|
if (this.$route.path !== currentPath) {
|
this.$router.push(currentPath)
|
}
|
},
|
false
|
)
|
},
|
methods: {
|
getOutsideOpItem() {
|
remote('out_side_type').then((response) => {
|
if (response.data.code === 0) {
|
this.outsideOpItemOptions = response.data.data
|
} else {
|
this.outsideOpItemOptions = []
|
}
|
})
|
},
|
rowDrop() {
|
const that = this
|
const tbody = document.querySelector(
|
'#stepTable .el-table__body-wrapper tbody'
|
)
|
// if (tbody != null) {
|
Sortable.create(tbody, {
|
// 结束拖拽
|
onEnd({ newIndex, oldIndex }) {
|
if (newIndex > oldIndex) {
|
// 下移
|
that.stepList
|
.filter((e) => e.index == oldIndex + 1)
|
.forEach((e) => (e.index = 'x'))
|
that.stepList
|
.filter((e) => e.index > oldIndex + 1 && e.index <= newIndex + 1)
|
.forEach((e) => (e.index = e.index - 1))
|
that.stepList
|
.filter((e) => e.index == 'x')
|
.forEach((e) => (e.index = newIndex + 1))
|
} else if (oldIndex > newIndex) {
|
// 上移
|
that.stepList
|
.filter((e) => e.index == oldIndex + 1)
|
.forEach((e) => (e.index = 'x'))
|
that.stepList
|
.filter((e) => e.index < oldIndex + 1 && e.index >= newIndex + 1)
|
.forEach((e) => (e.index = e.index + 1))
|
that.stepList
|
.filter((e) => e.index == 'x')
|
.forEach((e) => (e.index = newIndex + 1))
|
}
|
// 拖拽结束后,保存页面工步
|
const allSteps = []
|
let allStep
|
// 将原有工步放入allSteps
|
for (let i = 0; i < that.stepList.length; i++) {
|
allStep = {}
|
allStep.technologyOperationId = that.dataForm.id
|
allStep.technologyStepId = that.stepList[i].id
|
allStep.sort = that.stepList[i].index
|
allSteps.push(allStep)
|
}
|
// 保存
|
that.stepList = []
|
that.$nextTick(() => {
|
saveOperationStep(allSteps, that.dataForm.id).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const resSteps = resData.data
|
if (resSteps.length > 0) {
|
let operationStep
|
for (let i = 0; i < resSteps.length; i++) {
|
operationStep = {}
|
operationStep.id = resSteps[i].id
|
operationStep.name = resSteps[i].name
|
operationStep.stepNo = resSteps[i].stepNo
|
operationStep.remark = resSteps[i].remark
|
operationStep.index = resSteps[i].index
|
that.stepList.push(operationStep)
|
}
|
}
|
that.$message.success('移动工步成功')
|
} else {
|
that.$message.error('移动工步失败')
|
}
|
})
|
})
|
}
|
})
|
// }
|
},
|
init() {
|
this.operationId = this.dataForm.id
|
this.fetchCapabilityForOperation()
|
if (this.dataForm.id) {
|
getObj(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
|
capabilityArray.forEach((e) => {
|
if (this.dataForm[e]) {
|
this.checkboxGroup.push(e)
|
}
|
})
|
const attachments = this.dataForm.attachments
|
// 渲染附件
|
this.fileList = []
|
if (attachments != null && attachments.length > 0) {
|
let attachment
|
let fileEl
|
for (let i = 0; i < attachments.length; i++) {
|
attachment = attachments[i]
|
fileEl = {}
|
fileEl.name = attachment.original
|
fileEl.url = attachment.path
|
fileEl.id = attachment.id
|
fileEl.fileName = attachment.fileName
|
this.fileList.push(fileEl)
|
}
|
}
|
// 渲染工序参数集模板
|
const templates = this.dataForm.operationTemplateList
|
if (templates != null && templates.length > 0) {
|
let template
|
let operationTemplate
|
for (let i = 0; i < templates.length; i++) {
|
template = templates[i]
|
operationTemplate = {}
|
operationTemplate.id = template.id
|
operationTemplate.templateName = template.templateName
|
operationTemplate.templateNo = template.templateNo
|
operationTemplate.templateType = template.templateType
|
operationTemplate.remark = template.remark
|
this.operationTemplateList.push(operationTemplate)
|
}
|
} else {
|
this.operationTemplateList = []
|
}
|
// 渲染工步
|
const steps = this.dataForm.stepList
|
if (steps != null && steps.length > 0) {
|
let step
|
let operationStep
|
for (let i = 0; i < steps.length; i++) {
|
step = steps[i]
|
operationStep = {}
|
operationStep.id = step.id
|
operationStep.name = step.name
|
operationStep.stepNo = step.stepNo
|
operationStep.remark = step.remark
|
operationStep.index = step.index
|
this.stepList.push(operationStep)
|
}
|
} else {
|
this.stepList = []
|
}
|
})
|
} else {
|
// 初始化默认表单
|
this.initDefaultForm()
|
}
|
},
|
// 工序参数值的删除
|
delParam(id, index) {
|
const operationTemplate = {
|
technologyOperationId: this.dataForm.id,
|
technologyTemplateId: id
|
}
|
delOperationTemplate(operationTemplate).then((response) => {
|
if (response.data.code === 0) {
|
this.operationTemplateList.splice(index, 1)
|
this.$message.success('删除成功')
|
} else {
|
this.$message.success('删除失败')
|
}
|
})
|
},
|
checkboxGroupChange() {
|
capabilityArray.forEach((e) => {
|
this.dataForm[e] = false
|
})
|
this.checkboxGroup.forEach((item) => {
|
this.dataForm[item] = true
|
})
|
},
|
// 获取工序参数类型
|
getParamType() {
|
remote('technology_param').then((response) => {
|
if (response.data.code === 0) {
|
this.typeOptions = response.data.data
|
} else {
|
this.typeOptions = []
|
}
|
})
|
},
|
// 表格字段格式化
|
getParam(row, column, cellValue) {
|
for (let i = 0, len = this.typeOptions.length; i < len; i++) {
|
if (cellValue == this.typeOptions[i].value) {
|
return this.typeOptions[i].label
|
}
|
}
|
},
|
|
// 初始化默认表单
|
initDefaultForm() {
|
this.dataForm.id = 0
|
this.dataForm.operationNo = ''
|
this.dataForm.partFamilyName = ''
|
this.dataForm.name = ''
|
this.dataForm.productionCounting = false
|
this.dataForm.daq = false
|
this.dataForm.semiFinished = false
|
this.dataForm.inspection = false
|
this.dataForm.autoInspection = false
|
this.dataForm.materialCost = false
|
this.dataForm.params = []
|
this.dataForm.capabilityIds = []
|
this.dataForm.workCenter = null
|
this.dataForm.machRunFactor = 0
|
this.dataForm.machSetupTime = 0
|
this.dataForm.laborClassNo = null
|
this.dataForm.laborRunFactor = 0
|
this.dataForm.laborSetupTime = 0
|
this.dataForm.runTimeCodeDb = '2'
|
this.dataForm.crewSize = 1
|
this.fileList = []
|
this.operationTemplateList = []
|
this.stepList = []
|
this.operationParams = []
|
},
|
// 弹出工序参数模板dialog
|
addOperationTemplate() {
|
this.showOperationTemplate = true
|
},
|
// 添加时弹出工步dialog
|
addStep() {
|
this.showStep = true
|
this.isInsertStep = false
|
},
|
// 插入时弹出工步dialog
|
insertStep(row) {
|
this.showStep = true
|
this.isInsertStep = true
|
this.stepIndex = row.index
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
// 校验【机器运转因素】、【机器设置时间】、【劳力运转因素】、【劳力设置时间】中至少有一个字段的值须大于0
|
if (
|
this.dataForm.machRunFactor == 0 &&
|
this.dataForm.machSetupTime == 0 &&
|
this.dataForm.laborRunFactor == 0 &&
|
this.dataForm.laborSetupTime == 0
|
) {
|
this.$message.error(
|
'【机器运转因素】、【机器设置时间】、【劳力运转因素】、【劳力设置时间】中至少有一个字段的值须大于0'
|
)
|
this.isSubmit = false
|
} else {
|
// 【人工类别】为空时【班组人员】必须为空,否则必须大于0
|
let remindInfo = ''
|
let remindFlag = false
|
if (
|
this.dataForm.laborClassNo == null ||
|
this.dataForm.laborClassNo == ''
|
) {
|
if (
|
this.dataForm.crewSize != null &&
|
this.dataForm.crewSize != ''
|
) {
|
remindFlag = true
|
remindInfo = '【人工类别】为空时【班组人员】必须为空'
|
}
|
} else {
|
if (
|
this.dataForm.crewSize == 0 ||
|
!/(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]{1,6}$)/.test(
|
this.dataForm.crewSize
|
)
|
) {
|
remindFlag = true
|
remindInfo = '【班组人员】需大于0'
|
}
|
}
|
if (remindFlag) {
|
this.$message.error(remindInfo)
|
this.isSubmit = false
|
} else {
|
if (this.dataForm.id) {
|
putObj(this.dataForm)
|
.then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
this.$message.success('修改成功')
|
// this.$emit('refreshDataList')
|
} else {
|
this.$message.error('修改失败')
|
}
|
this.isSubmit = false
|
})
|
.catch((error) => {
|
this.isSubmit = false
|
console.log(error)
|
})
|
} else {
|
addObj(this.dataForm)
|
.then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
this.$message.success('添加成功')
|
// this.$emit('refreshDataList')
|
if (data.data) {
|
this.dataForm.id = data.data
|
}
|
} else {
|
this.$message.error('添加失败')
|
}
|
this.isSubmit = false
|
})
|
.catch((error) => {
|
this.isSubmit = false
|
console.log(error)
|
})
|
}
|
}
|
}
|
} else {
|
this.isSubmit = false
|
}
|
})
|
},
|
// 工序参数模板的选中结果返回
|
selectOperationTemplate(param) {
|
if (param.length > 0 && param) {
|
// 校验新添加的参数集模板是否重复添加
|
for (let j = 0, len = param.length; j < len; j++) {
|
for (
|
let i = 0, len = this.operationTemplateList.length;
|
i < len;
|
i++
|
) {
|
if (param[j].id == this.operationTemplateList[i].id) {
|
this.$message.error('存在重复参数集模板')
|
return
|
}
|
}
|
}
|
// 调用后端接口,保存模板
|
var templateIds = param.map(function(value, index) {
|
return value.id
|
})
|
var operationTemplate = {
|
templateIds: templateIds,
|
id: this.dataForm.id
|
}
|
saveOperationTemplate(operationTemplate).then((response) => {
|
var data = response.data
|
if (data.code === 0) {
|
for (let i = 0, len = param.length; i < len; i++) {
|
this.operationTemplateList.push(
|
Object.assign({
|
id: param[i].id,
|
templateName: param[i].templateName,
|
templateNo: param[i].templateNo,
|
templateType: param[i].templateType,
|
remark: param[i].remark
|
})
|
)
|
}
|
this.$message.success('添加成功')
|
} else {
|
this.$message.error('添加失败')
|
}
|
})
|
}
|
},
|
submitUpload() {
|
if (this.dataForm.id) {
|
this.paramDatas.operationId = this.dataForm.id
|
} else {
|
this.$message.error('请先保存工序信息')
|
return false
|
}
|
},
|
// 上传成功给newFileList
|
uploadSuccess(response, file, fileList) {
|
this.fileList = []
|
getObj(this.dataForm.id).then((response) => {
|
var attachments = response.data.data.attachments
|
// 渲染附件
|
this.fileList = []
|
if (attachments != null && attachments.length > 0) {
|
var attachment
|
var fileEl
|
for (var i = 0; i < attachments.length; i++) {
|
attachment = attachments[i]
|
fileEl = {}
|
fileEl.name = attachment.original
|
fileEl.url = attachment.path
|
fileEl.id = attachment.id
|
fileEl.fileName = attachment.fileName
|
this.fileList.push(fileEl)
|
}
|
}
|
})
|
},
|
handleRemove(file, fileList) {
|
removeFile(
|
Object.assign({
|
fileName: file.fileName
|
})
|
).then((response) => {})
|
},
|
handlePreview(file) {
|
window.open(file.url)
|
},
|
fetchCapabilityForOperation() {
|
fetchCapabilityForOperation().then((response) => {
|
const capes = response.data.data
|
const capacitieArr = []
|
let capacitie
|
for (var i = 0; i < capes.length; i++) {
|
capacitie = {}
|
capacitie.id = capes[i].id
|
capacitie.capabilityName = capes[i].capabilityName
|
capacitieArr.push(capacitie)
|
}
|
this.capacities = capacitieArr
|
})
|
},
|
|
initPartFamilySelect() {
|
loadPartFamily().then((response) => {
|
this.partFamilyOptions = response.data
|
})
|
},
|
// 选中某个模板
|
handleCurrentParamTemplateChange(val) {
|
// 根据模板id,去查询模板下的参数
|
if (val != null) {
|
getOperationParam(
|
Object.assign({
|
current: 1,
|
size: 999,
|
technologyOperationTemplateId: val.id
|
})
|
).then((response) => {
|
this.operationParams = response.data.data.records
|
})
|
} else {
|
this.operationParams = []
|
}
|
},
|
// 选中工步后返回工步
|
selectStep(param) {
|
if (param.length > 0) {
|
let len = this.stepList.length
|
// 拼接所有工步
|
const allSteps = []
|
let allStep
|
// 将原有工步放入allSteps
|
for (let i = 0; i < this.stepList.length; i++) {
|
// 添加时或者插入且原有工步index小于插入行的index时,将原有工步放入allSteps
|
if (
|
!this.isInsertStep ||
|
(this.isInsertStep && this.stepList[i].index < this.stepIndex)
|
) {
|
allStep = {}
|
allStep.technologyOperationId = this.dataForm.id
|
allStep.technologyStepId = this.stepList[i].id
|
allStep.sort = this.stepList[i].index
|
allSteps.push(allStep)
|
}
|
}
|
len = allSteps.length
|
// 将添加或插入的工步放入allSteps
|
for (let i = 0; i < param.length; i++) {
|
allStep = {}
|
allStep.technologyOperationId = this.dataForm.id
|
allStep.technologyStepId = param[i].id
|
allStep.sort = len + i + 1
|
allSteps.push(allStep)
|
}
|
len = allSteps.length
|
// 将原有工步放入allSteps,只针对插入的情况,存在未放入的原有工步
|
if (this.isInsertStep) {
|
let m = 0
|
for (let i = 0; i < this.stepList.length; i++) {
|
// 插入且原有工步index大于等于插入行的index时,将原有工步放入allSteps
|
if (this.stepList[i].index >= this.stepIndex) {
|
m++
|
allStep = {}
|
allStep.technologyOperationId = this.dataForm.id
|
allStep.technologyStepId = this.stepList[i].id
|
allStep.sort = len + m
|
allSteps.push(allStep)
|
}
|
}
|
}
|
// 保存所有工步
|
saveOperationStep(allSteps, this.dataForm.id).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const resSteps = resData.data
|
if (resSteps.length > 0) {
|
this.stepList = []
|
let operationStep
|
for (let i = 0; i < resSteps.length; i++) {
|
operationStep = {}
|
operationStep.id = resSteps[i].id
|
operationStep.name = resSteps[i].name
|
operationStep.stepNo = resSteps[i].stepNo
|
operationStep.remark = resSteps[i].remark
|
operationStep.index = resSteps[i].index
|
this.stepList.push(operationStep)
|
}
|
}
|
if (this.isInsertStep) {
|
this.$message.success('插入工步成功')
|
} else {
|
this.$message.success('添加工步成功')
|
}
|
} else {
|
if (this.isInsertStep) {
|
this.$message.error('插入工步失败')
|
} else {
|
this.$message.error('添加工步失败')
|
}
|
}
|
})
|
}
|
},
|
// 删除工步
|
handleDeleteStep(row, index) {
|
this.$confirm('是否确认删除工步编号:' + row.stepNo + '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
closeOnClickModal: false,
|
type: 'warning'
|
}).then(() => {
|
this.stepList.splice(index, 1)
|
const allSteps = []
|
let allStep
|
if (this.stepList && this.stepList.length > 0) {
|
for (let i = 0; i < this.stepList.length; i++) {
|
allStep = {}
|
allStep.technologyOperationId = this.dataForm.id
|
allStep.technologyStepId = this.stepList[i].id
|
// 大于删除行index的工步index需减去1
|
if (this.stepList[i].index > row.index) {
|
allStep.sort = this.stepList[i].index - 1
|
} else {
|
allStep.sort = this.stepList[i].index
|
}
|
|
allSteps.push(allStep)
|
}
|
}
|
// 保存allSteps
|
saveOperationStep(allSteps, this.dataForm.id).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const resSteps = resData.data
|
if (resSteps.length > 0) {
|
this.stepList = []
|
let operationStep
|
for (let i = 0; i < resSteps.length; i++) {
|
operationStep = {}
|
operationStep.id = resSteps[i].id
|
operationStep.name = resSteps[i].name
|
operationStep.stepNo = resSteps[i].stepNo
|
operationStep.remark = resSteps[i].remark
|
operationStep.index = resSteps[i].index
|
this.stepList.push(operationStep)
|
}
|
}
|
this.$message.success('删除工步成功')
|
} else {
|
this.$message.error('删除工步失败')
|
}
|
})
|
})
|
},
|
getSysParam(paramKey) {
|
getSysParam(paramKey).then((response) => {
|
var paramVal = response.data.data
|
if (response.data.code === 0) {
|
if (paramVal != null && paramVal === '1') {
|
this.isShowStepBusiness = true
|
this.$nextTick(() => {
|
this.rowDrop()
|
})
|
} else {
|
this.isShowStepBusiness = false
|
}
|
} else {
|
this.isShowStepBusiness = false
|
}
|
})
|
},
|
getWorkCenter() {
|
remote('work_center_type').then((response) => {
|
if (response.data.code === 0) {
|
this.workCenterOptions = response.data.data
|
this.workCenterOptions.forEach((item) => {
|
item.label = '(' + item.value + ') ' + item.label
|
})
|
}
|
})
|
},
|
getRunTimeCodeDb() {
|
remote('runtimecodedb_type').then((response) => {
|
if (response.data.code === 0) {
|
this.runTimeCodeDbOptions = response.data.data
|
}
|
})
|
},
|
// 获取IFS人工类别的数据字典
|
getLaborClassNo() {
|
/* getLaborClassNo().then((response) => {
|
if (response.data.code === 0) {
|
const _data = response.data.data
|
this.laborClassNoOptions = []
|
if (_data.length > 0) {
|
_data.forEach((item) => {
|
const laborClassNoOption = {
|
value: item.LC_NO,
|
label: item.LC_NO
|
}
|
this.laborClassNoOptions.push(laborClassNoOption)
|
})
|
}
|
}
|
}) */
|
remote('labor_class_type').then((response) => {
|
if (response.data.code === 0) {
|
this.laborClassNoOptions = response.data.data
|
} else {
|
this.laborClassNoOptions = []
|
}
|
})
|
}
|
},
|
|
created() {
|
this.dataForm.id = this.$route.params.id
|
this.init()
|
this.initPartFamilySelect()
|
this.getParamType()
|
this.getSysParam(sysParam.SHOW_STEP_BUSINESS)
|
this.getWorkCenter()
|
this.getRunTimeCodeDb()
|
this.getLaborClassNo()
|
this.getOutsideOpItem()
|
}
|
}
|
</script>
|
<style>
|
.operation-basic {
|
background-color: #fff;
|
height: 200px;
|
display: flex;
|
padding: 20px 30px;
|
border: 1px solid #ddd;
|
box-sizing: border-box;
|
}
|
|
.operation-detail {
|
overflow: hidden;
|
width: 100%;
|
height: 700px;
|
padding: 10px 20px;
|
display: flex;
|
border: 1px solid #ddd;
|
background-color: #fff;
|
margin-top: 10px;
|
box-sizing: border-box;
|
}
|
|
.operation-capacity {
|
background-color: #fff;
|
width: 40%;
|
float: left;
|
height: 100%;
|
border: 1px solid #ddd;
|
padding: 10px 20px;
|
}
|
|
.operation-param-list {
|
background-color: #fff;
|
width: calc(60% - 20px);
|
float: left;
|
height: 619px;
|
border: 1px solid #ddd;
|
padding: 10px 20px;
|
margin-left: 20px;
|
}
|
.operation-attachment {
|
background-color: #fff;
|
width: 100%;
|
height: 100%;
|
padding: 10px 20px;
|
border: 1px solid #ddd;
|
margin-left: 20px;
|
}
|
|
.operation-detail .el-tabs,
|
.operation-detail .el-card,
|
.operation-detail .el-card__body,
|
.operation-detail .el-transfer-panel,
|
.operation-detail .el-transfer-panel__body {
|
display: flex;
|
flex-direction: column;
|
}
|
|
.operation-detail .el-tabs__content,
|
.operation-detail .el-card__body,
|
.operation-detail .el-transfer,
|
.operation-detail .el-transfer-panel__body,
|
.operation-detail .el-transfer-panel__list {
|
flex: auto;
|
}
|
.form-content .first-row .el-form-item__content {
|
width: 120px;
|
}
|
</style>
|