This commit is contained in:
chenjianan
2019-04-12 14:19:23 +08:00
5 changed files with 510 additions and 1 deletions

View File

@@ -0,0 +1,405 @@
<template>
<div>
<el-card>
<div>
<span>项目名称</span>
<el-select v-model="entryNameValue" clearable filterable placeholder="项目名称" size="small">
<el-option
v-for="item in entryName"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<span style="">机床型号</span>
<el-input v-model="machine" clearable size="small" style="width:200px" placeholder="请输入机床型号"/>
</div>
<div style="margin-top: 20px">
<span style="margin-top: 20px">开始日期</span>
<el-date-picker
v-model="startTime"
style="width: 205px;"
value-format="yyyy-MM-dd"
size="small"
type="date"
placeholder="请选择开始日期"/>
<span style="">结束日期</span>
<el-date-picker
v-model="endTime"
style="width: 205px;"
value-format="yyyy-MM-dd"
size="small"
type="date"
placeholder="请选择结束日期"/>
<el-button type="success" icon="el-icon-search" size="small" style="margin-left: 10px" @click="PageSize = 10;PageCurrent = 1;fetchTableData1()">查询</el-button>
<el-button type="primary" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px" @click="ADD()">增加</el-button>
</div>
</el-card>
<el-card>
<el-table
v-loading="listLoading"
:data="tableData1"
:row-key="getRowKeys"
:expand-row-keys="expands"
style="width: 100%"
height="500"
border
size="mini"
@expand-change="selectMachine">
<el-table-column type="expand">
<template slot-scope="scope">
<el-table :data="tableData2" border style="width: 612px; text-align: center" size="mini">
<el-table-column label="设备型号" align="center" width="150">
<template slot-scope="scope">
{{ scope.row.机床图号 }}
</template>
</el-table-column>
<el-table-column label="设备名称" align="center" width="160">
<template slot-scope="scope">
{{ scope.row.机床名称 }}
</template>
</el-table-column>
<el-table-column label="机床数量" align="center" width="100">
<template slot-scope="scope">
{{ scope.row.机床数量 }}
</template>
</el-table-column>
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button
size="mini"
type="warning"
icon="el-icon-edit"
@click="editMachine(scope.row);flag = 2">编辑</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="deleteMachine(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</template>
</el-table-column>
<el-table-column align="center" label="合同编号">
<template slot-scope="scope">
<template>
<el-tag slot="reference">{{ scope.row.合同编号 }}</el-tag>
</template>
</template>
</el-table-column>
<el-table-column align="center" label="项目名称">
<template slot-scope="scope">
{{ scope.row.项目名称 }}
</template>
</el-table-column>
<el-table-column align="center" label="项目下达日期">
<template slot-scope="scope">
{{ scope.row.合同签订日期 }}
</template>
</el-table-column>
<el-table-column align="center" label="合同信息备注" width="200">
<template slot-scope="scope">
{{ scope.row.合同信息备注 }}
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center">
<template slot-scope="scope">
<el-button
size="mini"
type="warning"
icon="el-icon-plus"
@click.stop="addMachine(scope.row);flag = 1">机床</el-button>
<el-button
size="mini"
type="primary"
icon="el-icon-edit"
@click.stop="handleEdit(scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click.stop="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="block" style="margin-top: 10px;">
<el-pagination
:current-page="PageCurrent"
:page-sizes="[10, 20, 30, 40]"
:page-size="PageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</el-card>
<!--新增合同信息对话框-->
<el-dialog :title="title" :visible.sync="dialogFormVisible1" center style="min-height: 300px" width="400px">
<el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="140px" class="demo-ruleForm">
<el-row>
<el-col :span="24">
<el-form-item label="项目名称" prop="EntryName">
<el-input v-model="form.EntryName" size="small" placeholder="请输入项目名称" style="width:200px"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="项目下达日期" prop="contractSigningDate">
<el-date-picker
v-model="form.contractSigningDate"
style="width: 200px"
value-format="yyyy-MM-dd"
size="small"
type="date"
placeholder="请选择项目下达日期"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input
v-model="form.remark"
style="width: 200px"
type="textarea"
autosize
placeholder="请输入项目介绍"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="callOff('form')">取消</el-button>
<el-button type="primary" @click="submit('form')"> </el-button>
</div>
</el-dialog>
<el-dialog :title="title1" :visible.sync="dialogFormVisible2" center style="min-height: 300px" width="450px">
<el-form ref="form1" :model="form1" :rules="rules1" label-width="140px">
<el-form-item label="设备型号" prop="设备型号">
<el-input v-model="form1.设备型号" size="small" placeholder="请输入设备型号" style="width:200px"/>
</el-form-item>
<el-form-item label="设备名称" prop="设备名称">
<el-input v-model="form1.设备名称" size="small" placeholder="请输入设备名称" style="width:200px"/>
</el-form-item>
<el-form-item label="机床数量" prop="机床数量">
<el-input-number :min="1" v-model="form1.机床数量" controls-position="right" style="width:200px" size="small"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="callOff2('form1')">取消</el-button>
<el-button type="primary" @click="submitMachine('form1')"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import elInput from 'element-ui/packages/input'
import { initProject, searchTable1, selectMachine, addList, editchar, delList, submitMachine, editMachine, delMachine } from '@/api/MarketingCenter/CreateProject'
export default {
components: {
elInput
},
data() {
return {
entryName: [],
entryNameValue: '',
machine: '',
startTime: '',
endTime: '',
PageCurrent: 1,
PageSize: 10,
total: null,
listLoading: false,
entryNameValue_check: 0,
startTime_check: 0,
endTime_check: 0,
machine_check: 0,
a: 1,
b: 1,
c: 1,
tableData1: [],
expands: [],
tableData2: [],
projectNum: '',
hetongID: '',
form: {
EntryName: '', // 项目名称
contractSigningDate: '',
remark: ''
},
dialogFormVisible1: false,
title: '',
rules: { // 表单验证规则
EntryName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
contractSigningDate: [{ required: true, message: '请选择项目下达日期', trigger: 'change' }]
},
dialogFormVisible2: false,
title1: '',
form1: {
设备型号: '',
设备名称: '',
机床数量: 1
},
rules1: { // 表单验证规则
设备型号: [{ required: true, message: '请输入设备型号', trigger: 'blur' }],
设备名称: [{ required: true, message: '请输入设备名称', trigger: 'blur' }]
},
temp: '',
flag: ''
}
},
created() {
this.init()
this.fetchTableData1()
},
methods: {
init() {
this.getSelect(initProject, ['项目名称', '项目流水号'], 'entryName')
},
handleSizeChange(val) {
this.PageCurrent = 1
this.PageSize = val
this.fetchTableData1()
},
handleCurrentChange(val) {
this.PageCurrent = val
this.fetchTableData1()
},
fetchTableData1() {
if (this.entryNameValue === '' || this.entryNameValue === null) { this.entryNameValue_check = 0 } else { this.entryNameValue_check = 1 }
if (this.startTime === '' || this.startTime === null) { this.startTime_check = 0 } else { this.startTime_check = 1 }
if (this.endTime === '' || this.endTime === null) { this.endTime_check = 0 } else { this.endTime_check = 1 }
if (this.machine === '' || this.machine === null) { this.machine_check = 0 } else { this.machine_check = 1 }
this.listLoading = true
this.getTable(searchTable1, [this.PageCurrent, this.PageSize, this.entryNameValue, this.entryNameValue_check, this.startTime_check, this.endTime_check, this.startTime, this.endTime, this.machine_check, this.machine], ['tableData1', 'total', 'listLoading'])
},
selectMachine(row) {
this.projectNum = row.项目流水号
if (this.a === 1) {
this.expands.push(row.项目流水号)
this.b = row.项目流水号
this.a = 0
} else {
if (this.b === row.项目流水号) {
this.expands = []
this.a = 1
} else {
this.expands = []
this.expands.push(row.项目流水号)
this.a = 0
this.b = row.项目流水号
}
}
selectMachine(row.项目流水号).then(response => {
this.tableData2 = response.data
})
},
getRowKeys(row) {
return row.项目流水号
},
ADD() {
this.addForm('form')
this.dialogFormVisible1 = true
this.temp = 1
this.title = '增加'
},
// 提交添加或者修改
submit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
if (this.temp === 1) {
this.addTableData1()
this.temp = null
} else if (this.temp === 2) {
this.chaEdit()
this.temp = null
}
}
})
},
addTableData1() {
addList(this.form.EntryName, this.form.remark, this.form.contractSigningDate).then(response => {
this.dialogFormVisible1 = false
if (response.data[0].result === '1') {
this.$message.success('添加成功')
this.title = ''
this.fetchTableData1()
} else {
this.$message.error('添加失败')
}
})
},
callOff() {
this.dialogFormVisible1 = false
this.dialogFormVisible2 = false
},
handleEdit(row) {
this.editForm(row, 'form')
this.title = '编辑'
this.dialogFormVisible1 = true
this.form.contractSigningDate = row.合同签订日期
this.form.contractNumber = row.合同编号
this.form.EntryName = row.项目名称
this.hetongID = row.项目流水号
this.form.remark = row.合同信息备注
this.temp = 2
},
chaEdit() {
editchar(this.form.EntryName, this.form.remark, this.hetongID, this.form.contractSigningDate).then(response => {
this.dialogFormVisible1 = false
if (response.data[0].result === '1') {
this.$message.success('信息更新成功')
this.fetchTableData1()
} else {
this.$message.error('信息更新失败')
}
})
},
handleDelete(row) {
this.deleteRow(delList, row.项目流水号, function() { this.fetchTableData1() })
},
addMachine(row) {
this.projectNum = row.项目流水号
this.dialogFormVisible2 = true
this.title1 = '新增'
this.addForm('form1')
},
submitMachine() {
function a() {
selectMachine(this.projectNum).then(response => {
this.tableData2 = response.data
})
this.dialogFormVisible2 = false
}
if (this.flag === 1) {
this.addTable(submitMachine, [this.projectNum, this.form1.设备型号, this.form1.设备名称, this.form1.机床数量], 'form1', a)
} else {
this.editTable(editMachine, [this.c, this.form1.设备型号, this.form1.设备名称, this.form1.机床数量], 'form1', a)
}
},
deleteMachine(row) {
function a() {
selectMachine(this.projectNum).then(response => {
this.tableData2 = response.data
})
}
this.deleteRow(delMachine, row.机床流水号, a)
},
editMachine(row) {
this.flag = 2
this.editForm(row, 'form1')
this.dialogFormVisible2 = true
this.title1 = '编辑'
this.c = row.机床流水号
this.form1.设备型号 = row.机床图号
this.form1.设备名称 = row.机床名称
},
callOff2() {
this.dialogFormVisible2 = false
}
}
}
</script>
<style scoped>
</style>