增加模块
This commit is contained in:
206
src/views/BasicData/MaterialMaintenance/index.vue
Normal file
206
src/views/BasicData/MaterialMaintenance/index.vue
Normal file
@@ -0,0 +1,206 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<span>材料名称:</span>
|
||||
<el-input v-model="Material" placeholder="请输材料名称" size="small" style="width:200px" clearable/>
|
||||
<el-button type="success" icon="el-icon-search" size="small" style="margin-left: 15px" @click="pageCurrent = 1;pageSize = 10;featchMaterial()">查询</el-button>
|
||||
<el-button type="primary" icon="el-icon-circle-plus-outline" size="small" @click="add()">增加</el-button>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="tableData"
|
||||
style="width: 100%"
|
||||
height="580"
|
||||
highlight-current-row
|
||||
border>
|
||||
<el-table-column align="center" label="材料编号" width="110">
|
||||
<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="变更日期">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.操作日期 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="Edit(scope.row)">编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
@click="delMaterial(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 :visible.sync="dialogFormVisible" title="新增材料" center style="min-height: 200px" width="400px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="110px">
|
||||
<el-form-item label="材料名称" prop="MaterialName" style="display: inline-block">
|
||||
<el-input v-model="form.MaterialName" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="callOff()">取消</el-button>
|
||||
<el-button type="primary" size="small" @click="addMaterial('form')">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="dialogFormVisible2" title="编辑材料" center style="min-height: 200px" width="400px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="110px">
|
||||
<el-form-item label="材料名称" prop="MaterialName" style="display: inline-block">
|
||||
<el-input v-model="form.MaterialName" size="small" style="width:200px"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="callOff()">取消</el-button>
|
||||
<el-button type="primary" size="small" @click="editMaterial('form')">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { featchMaterial, addMaterial, delMaterial, editMaterial } from '@/api/BasicData/Materialmaintenance'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
ID: '',
|
||||
dialogFormVisible: false,
|
||||
dialogFormVisible2: false,
|
||||
tableData: [],
|
||||
Material: '', // 材质名称
|
||||
listLoading: false,
|
||||
pageCurrent: 1,
|
||||
pageSize: 10,
|
||||
total: null,
|
||||
form: {
|
||||
MaterialName: ''
|
||||
},
|
||||
rules: {
|
||||
MaterialName: [{ required: true, message: '请输入材料名称', trigger: 'blur' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.featchMaterial()
|
||||
},
|
||||
methods: {
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val
|
||||
this.pageCurrent = 1
|
||||
this.featchMaterial()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.pageCurrent = val
|
||||
this.featchMaterial()
|
||||
},
|
||||
featchMaterial() {
|
||||
featchMaterial(this.Material, this.pageCurrent, this.pageSize).then(response => {
|
||||
this.tableData = response.data.rows
|
||||
this.total = response.data.total
|
||||
})
|
||||
},
|
||||
callOff() {
|
||||
this.dialogFormVisible = false
|
||||
this.dialogFormVisible2 = false
|
||||
},
|
||||
add() {
|
||||
if (this.$refs['form'] !== undefined) {
|
||||
this.$refs['form'].resetFields()
|
||||
}
|
||||
this.dialogFormVisible = true
|
||||
},
|
||||
addMaterial(formName) {
|
||||
this.dialogFormVisible = false
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
addMaterial(this.form.MaterialName).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.featchMaterial()
|
||||
this.$message.success('添加成功')
|
||||
this.form = {}
|
||||
} else {
|
||||
this.$message.error('添加失败')
|
||||
this.form = {}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
delMaterial(row) {
|
||||
console.log(row)
|
||||
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
delMaterial(row.材料流水号).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.form.MaterialName = ''
|
||||
this.featchMaterial()
|
||||
this.$message.success('删除成功')
|
||||
} else {
|
||||
this.$message.error('删除失败')
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
Edit(row) {
|
||||
if (this.$refs['form'] !== undefined) {
|
||||
this.$refs['form'].resetFields()
|
||||
}
|
||||
this.dialogFormVisible2 = true
|
||||
this.form.MaterialName = row.材料
|
||||
this.ID = row.材料流水号
|
||||
},
|
||||
editMaterial(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
this.dialogFormVisible2 = false
|
||||
editMaterial(this.ID, this.form.MaterialName).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.featchMaterial()
|
||||
this.$message.success('编辑成功')
|
||||
this.form = {}
|
||||
} else {
|
||||
this.$message.error('编辑失败')
|
||||
this.form = {}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-card{
|
||||
margin-bottom:15px;
|
||||
}
|
||||
.el-date-editor{
|
||||
width:200px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user