<template>
|
<el-dialog
|
v-diadrag
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="120px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="零件号" prop="partNo">
|
<el-input
|
v-model="dataForm.partNo"
|
placeholder="零件号"
|
:disabled="(dataForm.id != null && dataForm.id > 0) || status"
|
>
|
<!-- <el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openPartDialog()"
|
v-show="!dataForm.id"
|
></el-button> -->
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="名称" prop="partName">
|
<el-input
|
v-model="dataForm.partName"
|
placeholder="零件名称"
|
:disabled="status"
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openPartDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="零件类型" prop="materialType">
|
<el-select
|
v-model="dataForm.materialType"
|
filterable
|
clearable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in materialTypeOptions"
|
:value="item.value"
|
:label="item.label"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="单位" prop="unit">
|
<el-select
|
v-model="dataForm.unit"
|
filterable
|
clearable
|
placeholder="请选择"
|
style="width: 100%;"
|
:disabled="status"
|
>
|
<el-option
|
v-for="(item, index) in unitOptions"
|
:label="item.value"
|
:value="item.value"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="单位2" prop="sunit">
|
<el-select
|
v-model="dataForm.sunit"
|
filterable
|
clearable
|
placeholder="请选择"
|
style="width: 100%;"
|
:disabled="status"
|
>
|
<el-option
|
v-for="(item, index) in unitOptions"
|
:label="item.value"
|
:value="item.value"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="一级分类" prop="assortment">
|
<el-select
|
v-model="dataForm.assortment"
|
filterable
|
clearable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in assortmentOptions"
|
:key="index"
|
:label="item.value"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="二级分类" prop="category">
|
<el-select
|
v-model="dataForm.category"
|
filterable
|
clearable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in categoryOptions"
|
:key="index"
|
:label="item.value"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="三级分类" prop="threeLevelClassification">
|
<el-select
|
v-model="dataForm.threeLevelClassification"
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in threeLevelClassificationOptions"
|
:key="index"
|
:label="item.value"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12"
|
><el-form-item label="规格" prop="specs">
|
<el-input v-model="dataForm.specs" placeholder="规格"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="图号" prop="drawingNumber">
|
<el-input
|
v-model="dataForm.drawingNumber"
|
placeholder="图号"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="型号" prop="partModel">
|
<el-input
|
v-model="dataForm.partModel"
|
placeholder="型号"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
|
<!-- <el-col :span="12">-->
|
<!-- <el-form-item label="零件族" prop="partFamilyId">-->
|
<!-- <el-select-->
|
<!-- v-model="dataForm.partFamilyId"-->
|
<!-- filterable-->
|
<!-- clearable-->
|
<!-- placeholder="请选择"-->
|
<!-- @change="selectTestRule"-->
|
<!-- style="width: 100%;"-->
|
<!-- >-->
|
<!-- <el-option-->
|
<!-- v-for="(item, index) in partFamilyOptions"-->
|
<!-- :key="index"-->
|
<!-- :label="item.partFamilyName"-->
|
<!-- :value="item.id"-->
|
<!-- >-->
|
<!-- </el-option>-->
|
<!-- </el-select>-->
|
<!-- </el-form-item>-->
|
<!-- </el-col>-->
|
<el-col :span="12">
|
<el-form-item label="EAN编码" prop="ean">
|
<el-input v-model="dataForm.ean" placeholder="EAN编码"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="系统编号管理" prop="useSystemNo">
|
<el-select
|
v-model="dataForm.useSystemNo"
|
filterable
|
clearable
|
placeholder=""
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="item in booleanOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="检验规则" prop="testRuleId">
|
<el-select
|
v-model="dataForm.testRuleId"
|
filterable
|
clearable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in ruleOptions"
|
:key="index"
|
:label="item.ruleName"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="电压等级" prop="voltageLevel">
|
<el-input
|
v-model="dataForm.voltageLevel"
|
placeholder="电压等级"
|
></el-input> </el-form-item
|
></el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12"
|
><el-form-item label="重量" prop="weight">
|
<el-input v-model="dataForm.weight" placeholder="重量"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<!-- <el-form-item label="IFS启用批次管理" prop="lotTrackingIfs">-->
|
<!-- <el-select-->
|
<!-- v-model="dataForm.lotTrackingIfs"-->
|
<!-- placeholder="请选择"-->
|
<!-- style="width: 100%;"-->
|
<!-- >-->
|
<!-- <el-option-->
|
<!-- v-for="(item, index) in lotTrackingIfsOptions"-->
|
<!-- :key="index"-->
|
<!-- :label="item.label"-->
|
<!-- :value="item.value"-->
|
<!-- >-->
|
<!-- </el-option>-->
|
<!-- </el-select>-->
|
<!-- </el-form-item>-->
|
<el-form-item label="原材料检" prop="testRuleType">
|
<el-select
|
v-model="dataForm.testRuleType"
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option label="否" :value="0"> </el-option>
|
<el-option label="是" :value="1"> </el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="版本号" prop="engChgLevel">
|
<el-input
|
v-model="dataForm.engChgLevel"
|
placeholder="版本号"
|
:disabled="dataForm.id && dataForm.id != null ? true : false"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item
|
v-if="permissions.basic_has_ifs"
|
label="计划方法"
|
prop="planningMethod"
|
>
|
<el-select
|
v-model="dataForm.planningMethod"
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in planningMethodOptions"
|
:key="index"
|
:label="item.label + '、 ' + item.description"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="零件属性" prop="materialAttribute">
|
<el-select v-model="dataForm.materialAttribute">
|
<el-option
|
v-for="(item, index) in materialAttributeOptions"
|
:key="index"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="备注" prop="description">
|
<el-input
|
v-model="dataForm.description"
|
placeholder="备注"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="检验员" prop="examiner">
|
<el-select
|
v-model="dataForm.examiner"
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in examinerOptions"
|
:key="index"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="产品名称" prop="prodName">
|
<el-input
|
v-model="dataForm.prodName"
|
placeholder="产品名称"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="节距" prop="prodName">
|
<el-input
|
v-model="dataForm.partPitch"
|
placeholder="节距"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`dataFormSubmit`"
|
>确定</el-button
|
>
|
</span>
|
<part-dialog
|
:currshowlist.sync="showPart"
|
@listenToPartEvent="selectPart"
|
/>
|
</el-dialog>
|
</template>
|
<script>
|
import { addObj, dir, getObj, putObj } from '@/api/basic/part'
|
import { loadPartFamily, getObj as getPartFamily } from '@/api/basic/partFamily'
|
import PartDialog from '@/views/basic/part/part.vue'
|
import { getTestRuleList } from '../../../api/quality/testrule'
|
import { remote } from '@/api/admin/dict'
|
import { mapGetters } from 'vuex'
|
export default {
|
components: {
|
PartDialog
|
},
|
computed: {
|
...mapGetters(['permissions'])
|
},
|
data() {
|
return {
|
status: false,
|
visible: false,
|
loading: false,
|
showPart: false,
|
dataForm: {
|
id: 0,
|
partFamilyId: '',
|
partNo: '',
|
partName: '',
|
materialType: '4',
|
unit: '',
|
description: '',
|
category: '',
|
assortment: '',
|
specs: '',
|
drawingNumber: '',
|
ean: '',
|
testRuleId: '',
|
useSystemNo: true,
|
weight: 1,
|
voltageLevel: '',
|
lotTrackingIfs: false,
|
engChgLevel: '1',
|
planningMethod: 'A',
|
sunit: '',
|
partModel: '',
|
materialAttribute: '',
|
examiner: null,
|
prodName: null,
|
partPitch: null
|
},
|
dataRule: {
|
partNo: [
|
{ required: true, message: '零件号不能为空', trigger: 'blur' }
|
],
|
partName: [
|
{ required: true, message: '名称不能为空', trigger: 'blur' }
|
],
|
unit: [{ required: true, message: '单位不能为空', trigger: 'change' }],
|
engChgLevel: [
|
{ required: true, message: '版本号不能为空', trigger: 'blur' }
|
],
|
planningMethod: [
|
{ required: true, message: '计划方法不能为空', trigger: 'blur' }
|
],
|
materialType: [
|
{ required: true, message: '零件类型不能为空', trigger: 'change' }
|
],
|
materialAttribute: [
|
{ required: true, message: '零件属性不能为空', trigger: 'change' }
|
]
|
},
|
ruleOptions: [],
|
options: [],
|
unitOptions: [],
|
materialTypeOptions: [],
|
categoryOptions: [],
|
assortmentOptions: [],
|
partFamilyOptions: [],
|
booleanOptions: [
|
{ value: true, label: '是' },
|
{ value: false, label: '否' }
|
],
|
lotTrackingIfsOptions: [
|
{ value: false, label: '否' },
|
{ value: true, label: '是' }
|
],
|
planningMethodOptions: [],
|
materialAttributeOptions: [],
|
threeLevelClassificationOptions: [],
|
isSubmit: false,
|
examinerOptions: []
|
}
|
},
|
methods: {
|
init(id) {
|
this.status = false
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
getObj(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
})
|
}
|
})
|
},
|
|
openPartDialog() {
|
this.showPart = true
|
},
|
selectPart(param) {
|
if (param) {
|
this.status = true
|
this.dataForm.partNo = param.PART_NO
|
this.dataForm.unit = param.UNIT_MEAS
|
this.dataForm.partName = param.PART_DESC
|
}
|
},
|
selectTestRule(val) {
|
if (val) {
|
getPartFamily(val).then((response) => {
|
this.dataForm.testRuleId = response.data.data.testRuleId
|
})
|
} else {
|
this.dataForm.testRuleId = null
|
}
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
// 去除零件编号两边的空格
|
this.dataForm.partNo = this.dataForm.partNo.trim()
|
if (this.dataForm.id) {
|
console.log(this.dataForm)
|
putObj(this.dataForm)
|
.then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
.catch((error) => {
|
this.isSubmit = false
|
console.log(error)
|
})
|
} else {
|
addObj(this.dataForm)
|
.then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
.catch((error) => {
|
this.isSubmit = false
|
console.log(error)
|
})
|
}
|
} else {
|
this.isSubmit = false
|
}
|
})
|
},
|
initDirUnit(index) {
|
dir(index).then((res) => {
|
this.unitOptions = res.data.data
|
})
|
},
|
initDirMaterial(index) {
|
dir(index).then((res) => {
|
this.materialTypeOptions = res.data.data
|
})
|
},
|
initDirCategory(index) {
|
dir(index).then((res) => {
|
this.categoryOptions = res.data.data
|
})
|
},
|
initDirAssortment(index) {
|
dir(index).then((res) => {
|
this.assortmentOptions = res.data.data
|
})
|
},
|
getExaminerDict() {
|
remote('examiner_type').then((response) => {
|
if (response.data.code === 0) {
|
this.examinerOptions = response.data.data
|
} else {
|
this.examinerOptions = []
|
}
|
})
|
},
|
getPlanningMethodDict() {
|
remote('planning_method_type').then((response) => {
|
if (response.data.code === 0) {
|
this.planningMethodOptions = response.data.data
|
} else {
|
this.planningMethodOptions = []
|
}
|
})
|
},
|
getMaterialAttributeDict() {
|
remote('material_attribute').then((response) => {
|
if (response.data.code === 0) {
|
this.materialAttributeOptions = response.data.data
|
} else {
|
this.materialAttributeOptions = []
|
}
|
})
|
},
|
getThreeLevelClassificationDict() {
|
remote('three_classification_type').then((response) => {
|
if (response.data.code === 0) {
|
this.threeLevelClassificationOptions = response.data.data
|
} else {
|
this.threeLevelClassificationOptions = []
|
}
|
})
|
},
|
initPartFamilySelect() {
|
loadPartFamily().then((response) => {
|
this.partFamilyOptions = response.data
|
})
|
},
|
initTestRuleSelect() {
|
getTestRuleList().then((response) => {
|
this.ruleOptions = response.data
|
})
|
}
|
},
|
mounted() {
|
this.initDirUnit('unit')
|
this.initDirMaterial('material_type')
|
this.initDirCategory('category')
|
this.initDirAssortment('assortment')
|
this.initPartFamilySelect()
|
this.initTestRuleSelect()
|
this.getPlanningMethodDict()
|
this.getThreeLevelClassificationDict()
|
this.getMaterialAttributeDict()
|
this.getExaminerDict()
|
}
|
}
|
</script>
|