Files
JY1.0/src/views/BasicData/WorkshopProcessMaintenance/index.vue
2020-02-12 16:31:46 +08:00

615 lines
22 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<el-row>
<el-col :span="7">
<el-card>
<el-row style="margin-bottom: 10px">
<span>工艺分类</span>
</el-row>
<el-row>
<el-button type="distribution" style="margin: 3px" icon="el-icon-circle-plus-outline" size="small" @click="addProcessClassification()">新增</el-button>
<el-button size="small" style="margin-left: 10px" type="warning" icon="el-icon-edit-outline" plain @click="editProcessClassification()">编辑</el-button>
<el-button size="small" style="margin-left: 10px" type="danger" icon="el-icon-delete" plain @click="delProcessClassification()">删除</el-button>
</el-row>
</el-card>
</el-col>
<el-col :span="17">
<el-card>
<div style="height: 37px"/>
<el-button type="primary" plain style="margin-left: 10px" icon="el-icon-circle-plus-outline" size="small" @click="addProcess">新增工艺名称</el-button>
</el-card>
</el-col>
</el-row>
<el-row>
<el-col :span="7">
<el-card>
<el-table
v-loading="loading1"
ref="multipleTable"
:data="tableData1"
size="mini"
highlight-current-row
stripe
border
tooltip-effect="dark"
style="width: 100%"
height="550">
<el-table-column align="center" label=" " width="50px">
<template slot-scope="scope">
<el-radio :label="scope.row.工艺分类流水号" v-model="radio" @change.native="getCurrentRow(scope.row.工艺分类流水号, scope.row.工艺分类名称)">
{{ a }}
</el-radio>
</template>
</el-table-column>
<el-table-column align="left" label="工艺分类">
<template slot-scope="scope">
{{ scope.row.工艺分类名称 }}
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="17">
<el-card >
<el-table
:data="tableData2"
:row-key="getRowKeys"
:row-style="abc"
:expand-row-keys="expands"
size="mini"
highlight-current-row
stripe
border
height="550"
width="100%"
@expand-change="searchTechnologicalRequirementsOfProcessNum">
<el-table-column type="expand" label="详情">
<template slot-scope="scope">
<el-table :data="tableData3" class="subTableHeader" border stripe size="mini" style="width: 40%">
<el-table-column label="工艺要求" align="center">
<template slot-scope="scope">
{{ scope.row.工艺要求 }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" >
<template slot-scope="scope">
<el-tooltip effect="dark" content="编辑" placement="top">
<div style="display: inline-block">
<el-button
size="mini"
type="text"
icon="el-icon-edit-outline"
@click="editTechnologicalRequirements(scope.row)"/>
</div>
</el-tooltip>
<el-tooltip effect="dark" content="删除" placement="top">
<div style="display: inline-block">
<el-button
size="mini"
type="text"
style="margin-left: 20px"
icon="el-icon-delete"
@click="delTechnologicalRequirements(scope.row)"/>
</div>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</template>
</el-table-column>
<el-table-column label="工艺名称" width="200">
<template slot-scope="scope">
{{ scope.row.工艺名称 }}
</template>
</el-table-column>
<el-table-column align="center" label="操作" >
<template slot-scope="scope">
<el-button
size="mini"
type="warning"
icon="el-icon-edit-outline"
plain
@click="editProcess(scope.row)">编辑工艺</el-button>
<el-button
size="mini"
type="danger"
plain
icon="el-icon-delete"
@click="delProcess(scope.row)">删除工艺</el-button>
<el-button
size="mini"
type="primary"
plain
icon="el-icon-circle-plus-outline"
@click="addTechnologicalRequirements(scope.row)">新增要求</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
<el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible1" title="新增工艺分类" center style="min-height: 300px" width="400px">
<el-form ref="form1" :model="form1" :rules="rules1" label-position="left" label-width="110px" >
<el-form-item label="工艺分类" prop="ProcessClassification">
<el-input v-model="form1.ProcessClassification" size="small" clearable style="width:200px"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="calloff"> </el-button>
<el-button type="primary" @click="submit1('form1')"> </el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible2" title="编辑工艺分类" center style="min-height: 300px" width="400px">
<el-form ref="form1" :model="form1" :rules="rules1" label-position="left" label-width="110px" >
<el-form-item label="工艺分类" prop="ProcessClassification">
<el-input v-model="form1.ProcessClassification" size="small" clearable style="width:200px"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="calloff"> </el-button>
<el-button type="primary" @click="submit1('form1')"> </el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible3" title="新增工艺" center style="min-height: 300px" width="400px">
<el-form ref="form2" :model="form2" :rules="rules2" label-position="left" label-width="110px" >
<el-form-item label="工艺名称" prop="Process">
<el-input v-model="form2.Process" size="small" clearable style="width:200px"/>
</el-form-item>
<el-form-item label="工艺名称简称" prop="ProcessShort">
<el-input v-model="form2.ProcessShort" size="small" clearable style="width:200px"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="calloff"> </el-button>
<el-button type="primary" @click="submit1('form2')"> </el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible4" title="编辑工艺" center style="min-height: 300px" width="400px">
<el-form ref="form2" :model="form2" :rules="rules2" label-position="left" label-width="110px" >
<el-form-item label="工艺名称" prop="Process">
<el-input v-model="form2.Process" size="small" clearable style="width:200px"/>
</el-form-item>
<el-form-item label="工艺名称简称" prop="ProcessShort">
<el-input v-model="form2.ProcessShort" size="small" clearable style="width:200px"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="calloff"> </el-button>
<el-button type="primary" @click="submit1('form2')"> </el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible5" title="新增工艺要求" center style="min-height: 300px" width="400px">
<el-form ref="form3" :model="form3" :rules="rules3" label-position="left" label-width="110px" >
<el-form-item label="工艺要求" prop="Process">
<el-input v-model="form3.TechnologicalRequirements" size="small" clearable style="width:200px"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="calloff"> </el-button>
<el-button type="primary" @click="submit1('form3')"> </el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible6" title="编辑工艺要求" center style="min-height: 300px" width="400px">
<el-form ref="form3" :model="form3" :rules="rules3" label-position="left" label-width="110px" >
<el-form-item label="工艺要求" prop="TechnologicalRequirements">
<el-input v-model="form3.TechnologicalRequirements" size="small" clearable style="width:200px"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="calloff"> </el-button>
<el-button type="primary" @click="submit1('form3')"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { searchProcessClassification, searchProcessNameOfProcessClassification, searchTechnologicalRequirementsOfProcessNum, searchProcessClassificationOfProcessClassificationNum, addProcessClassification, editProcessClassification, delProcessClassification, addProcess, delProcess, editProcess, addTechnologicalRequirements, editTechnologicalRequirements, delTechnologicalRequirements } from '@/api/BasicData/WorkshopProcessMaintenance'
export default {
data() {
return {
// 工艺分类所需变量
a: '',
expands: [],
tableData1: [],
ProcessNum: '',
loading1: false,
loading2: false,
loading3: false,
ProcessClassificationNum: '',
radio: null,
dialogFormVisible1: false,
dialogFormVisible2: false,
dialogFormVisible3: false,
dialogFormVisible4: false,
dialogFormVisible5: false,
dialogFormVisible6: false,
temp: null,
ProcessClassificationNumS: '',
form1: {
ProcessClassification: ''
},
form2: {
Process: '',
ProcessShort: ''
},
form3: {
TechnologicalRequirements: ''
},
rules1: {
ProcessClassification: [{ required: true, message: '请输入工艺分类名称', trigger: 'blur' }]
},
rules2: {
Process: [{ required: true, message: '请输入工艺名称', trigger: 'blur' }],
ProcessShort: [{ required: true, message: '请输入工艺名称简称', trigger: 'blur' }]
},
rules3: {
TechnologicalRequirements: [{ required: true, message: '请输入工艺要求', trigger: 'blur' }]
},
tableData2: [],
tableData3: [],
Num: [],
maxNum: '',
max: [],
code: ''
}
},
created() {
this.searchProcessClassification()
},
methods: {
abc() {
return {
height: '35px'
}
},
searchProcessClassification() {
this.loading1 = true
searchProcessClassification().then(response => {
this.loading1 = false
this.tableData1 = response.data
this.total1 = response.data
return this.tableData1
}).then(data => {
this.Num = data
this.max = []
for (let i = 0; i < this.Num.length; i++) {
this.max.push(this.Num[i].工艺分类流水号)
}
return this.max
}).then(data => {
const a = data
this.maxNum = a[0]
for (let j = 0; j < a.length; j++) {
if (this.maxNum < a[j]) {
this.maxNum = a[j]
}
}
return this.maxNum
}).then(data => {
const b = data
this.radio = b
return this.radio
}).then(data => {
const c = data
this.loading2 = true
searchProcessNameOfProcessClassification(c).then(response => {
this.loading2 = false
this.tableData2 = response.data
})
})
},
addProcessClassification() {
if (this.$refs['form1'] !== undefined) {
this.$refs['form1'].resetFields()
}
this.form1 = {}
this.dialogFormVisible1 = true
this.temp = 1
},
editProcessClassification() {
if (this.radio !== '') {
this.temp = 2
this.dialogFormVisible2 = true
searchProcessClassificationOfProcessClassificationNum(this.radio).then(response => {
this.form1.ProcessClassification = response.data[0].工艺分类名称
})
} else {
this.$message.warning('请选择工艺分类')
}
},
submitProcessClassification() {
editProcessClassification(this.radio, this.form1.ProcessClassification).then(response => {
if (response.data[0].result === '1') {
this.$message.success('信息更新成功')
this.dialogFormVisible2 = false
this.searchProcessClassification()
} else {
this.$message.error('信息更新失败')
}
})
},
submitaddProcessClassification() {
addProcessClassification(this.form1.ProcessClassification).then(response => {
if (response.data[0].result === '1') {
this.$message.success('增加成功')
this.searchProcessClassification()
this.dialogFormVisible1 = false
} else { this.$message.error('增加失败') }
})
},
submit1(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
if (this.temp === 1) {
this.submitaddProcessClassification()
this.form1 = {
ProcessClassification: ''
}
this.temp = null
} else if (this.temp === 2) {
this.submitProcessClassification()
this.form1 = {
ProcessClassification: ''
}
this.temp = null
} else if (this.temp === 3) {
this.submitaddProcess()
this.form2 = {
Process: '',
ProcessShort: ''
}
this.temp = null
} else if (this.temp === 4) {
this.submiteditProcess()
this.form2 = {
Process: '',
ProcessShort: ''
}
this.temp = null
} else if (this.temp === 5) {
this.submitTechnologicalRequirements()
this.form3 = {
TechnologicalRequirements: ''
}
this.temp = null
} else if (this.temp === 6) {
this.submiteditTechnologicalRequirements()
this.form3 = {
TechnologicalRequirements: ''
}
this.temp = null
}
}
})
},
delProcessClassification() {
if (this.radio !== '') {
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delProcessClassification(this.radio).then(response => {
if (response.data[0].result === '1') {
this.searchProcessClassification()
this.$message.success('删除成功')
} else {
this.$message.error('删除失败')
}
})
})
} else {
this.$message.warning('请选择工艺分类')
}
},
calloff() {
this.dialogFormVisible1 = false
this.dialogFormVisible2 = false
this.dialogFormVisible3 = false
this.dialogFormVisible4 = false
this.dialogFormVisible5 = false
this.dialogFormVisible6 = false
this.form1 = {
ProcessClassification: ''
}
this.form2 = {
Process: '',
ProcessShort: ''
}
this.form3 = {
TechnologicalRequirements: ''
}
},
getCurrentRow(row) {
searchProcessClassificationOfProcessClassificationNum(this.radio).then(response => {
this.form1.ProcessClassification = response.data[0].工艺分类名称
})
this.loading2 = true
searchProcessNameOfProcessClassification(row).then(response => {
this.loading2 = false
this.tableData2 = response.data
})
},
searchTechnologicalRequirementsOfProcessNum(row, expandedRows) {
// this.expands = []
// this.expands.push(row.工艺编号)
if (expandedRows.length > 1) {
expandedRows.shift()
}
this.loading3 = true
searchTechnologicalRequirementsOfProcessNum(row.工艺编号).then(response => {
this.loading3 = false
this.tableData3 = response.data
})
},
addProcess() {
if (this.$refs['form2'] !== undefined) {
this.$refs['form2'].resetFields()
}
if (this.radio !== '') {
this.form2.Process = ''
this.form2.ProcessShort = ''
this.dialogFormVisible3 = true
this.temp = 3
} else {
this.$message.warning('请选择一个工艺分类')
}
},
submitaddProcess() {
addProcess(this.radio, this.form2.Process, this.form2.ProcessShort).then(response => {
if (response.data[0].result === '1') {
this.$message.success('增加成功')
this.loading2 = true
searchProcessNameOfProcessClassification(this.radio).then(response => {
this.loading2 = false
this.tableData2 = response.data
})
this.dialogFormVisible3 = false
} else { this.$message.error('增加失败') }
})
},
editProcess(row) {
this.dialogFormVisible4 = true
this.temp = 4
this.form2.Process = row.工艺名称
this.form2.ProcessShort = row.工艺名称简称
this.ProcessNum = row.工艺编号
},
submiteditProcess() {
editProcess(this.ProcessNum, this.form2.Process, this.form2.ProcessShort).then(response => {
if (response.data[0].result === '1') {
this.$message.success('信息更新成功')
this.dialogFormVisible4 = true
searchProcessNameOfProcessClassification(this.radio).then(response => {
this.loading2 = false
this.tableData2 = response.data
})
this.dialogFormVisible4 = false
} else {
this.$message.error('信息更新失败')
}
})
},
getRowKeys(row) {
return row.工艺编号
},
delProcess(row) {
this.$confirm('此操作将永久删除' + row.工艺名称 + '行, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delProcess(row.工艺编号).then(response => {
if (response.data[0].result === '1') {
this.loading2 = true
searchProcessNameOfProcessClassification(this.radio).then(response => {
this.loading2 = false
this.tableData2 = response.data
})
this.$message.success('删除成功')
} else {
this.$message.error('删除失败')
}
})
})
},
addTechnologicalRequirements(row) {
if (this.$refs['form3'] !== undefined) {
this.$refs['form3'].resetFields()
}
this.ProcessNum = row.工艺编号
this.form3.TechnologicalRequirements = ''
this.dialogFormVisible5 = true
this.temp = 5
},
submitTechnologicalRequirements() {
if (this.form3.TechnologicalRequirements !== '') {
addTechnologicalRequirements(this.ProcessNum, this.form3.TechnologicalRequirements).then(response => {
if (response.data[0].result === '1') {
this.$message.success('增加成功')
this.loading3 = true
searchTechnologicalRequirementsOfProcessNum(this.ProcessNum).then(response => {
this.loading3 = false
this.tableData3 = response.data
})
this.dialogFormVisible5 = false
} else { this.$message.error('增加失败') }
})
} else {
this.$message.error('请输入工艺要求')
this.dialogFormVisible5 = false
}
},
editTechnologicalRequirements(row) {
this.temp = 6
this.dialogFormVisible6 = true
this.form3.TechnologicalRequirements = row.工艺要求
this.code = row.工艺要求流水号
this.ProcessNum = row.工艺编号
},
submiteditTechnologicalRequirements() {
editTechnologicalRequirements(this.code, this.form3.TechnologicalRequirements).then(response => {
if (response.data[0].result === '1') {
this.$message.success('信息更新成功')
this.loading3 = true
searchTechnologicalRequirementsOfProcessNum(this.ProcessNum).then(response => {
this.loading3 = false
this.tableData3 = response.data
})
this.dialogFormVisible6 = false
} else {
this.$message.error('信息更新失败')
}
})
},
delTechnologicalRequirements(row) {
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delTechnologicalRequirements(row.工艺要求流水号).then(response => {
if (response.data[0].result === '1') {
this.loading3 = true
searchTechnologicalRequirementsOfProcessNum(row.工艺编号).then(response => {
this.loading3 = false
this.tableData3 = response.data
})
this.$message.success('删除成功')
} else {
this.$message.error('删除失败')
}
})
})
}
}
}
</script>
<style scoped>
/*.el-card {*/
/* margin-top: 15px;*/
/* margin-left: 15px;*/
/* }!**!*/
</style>
<style lang="scss">
.subTableHeader {
th {
background: #8ff4ea !important;
color: black;
}
tr.el-table__row td {
background-color: #d8e5f6 !important;
}
tr.el-table__row.el-table__row--striped td {
background: #e9f0f9 !important;
}
}
</style>