Files
JY1.0/src/views/PurchasingCenter/SupplierManagement/index.vue
sujiaqi 244db8d7c4 a
2020-02-10 10:26:17 +08:00

664 lines
25 KiB
Vue

<template>
<div class="app-container">
<el-card>
<el-form ref="form1" :model="form1" label-position="right" label-width="70px" class="searchForm">
<el-row>
<el-col style="width: 250px">
<el-form-item label="供应商">
<el-input v-model="supplierName" placeholder="供应商名称" size="small" clearable/>
</el-form-item>
</el-col>
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="法人">-->
<!-- <el-input v-model="businessNature" placeholder="法人" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="受托人">-->
<!-- <el-input v-model="registeredCapital" placeholder="受托人" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="邮编">-->
<!-- <el-input v-model="deliveryPeriod" placeholder="邮编" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="税号">-->
<!-- <el-input v-model="taxNumber" placeholder="税号" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="电子信箱">-->
<!-- <el-input v-model="email" placeholder="电子信箱" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="电话号码">-->
<!-- <el-input v-model="telephone" placeholder="电话号码" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="开户行">-->
<!-- <el-input v-model="bank" placeholder="开户行" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="帐号">-->
<!-- <el-input v-model="account" placeholder="帐号" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="地址">-->
<!-- <el-input v-model="address" placeholder="地址" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="传真">-->
<!-- <el-input v-model="fax" placeholder="传真" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col style="width: 250px">-->
<!-- <el-form-item label="主要产品">-->
<!-- <el-input v-model="mainProduction" placeholder="主要产品" size="small" clearable/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col style="width: 250px;margin:2px 0 0 15px">
<el-button type="primary" size="small" icon="el-icon-search" plain @click="pageCurrent = 1;fetchData()">查询</el-button>
<el-button type="warning" size="small" icon="el-icon-circle-plus-outline" plain style="margin-left:10px" @click="handleAdd()">新增供应商</el-button>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card>
<div style="display: inline-block;margin-bottom: 5px">供应商列表</div>
<el-table :data="List" stripe highlight-current-row border style="width: 100%;max-height: 600px;" height="500" size="mini" @row-click="rowClick">
<el-table-column label="供应商名称" align="center" fixed="left" min-width="250">
<template slot-scope="scope">
{{ scope.row.供应商名称 }}
</template>
</el-table-column>
<el-table-column label="主要产品" align="center" min-width="150">
<template slot-scope="scope">
{{ scope.row.主要产品 }}
</template>
</el-table-column>
<el-table-column label="开户行" align="center" min-width="150" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.开户行 }}
</template>
</el-table-column>
<el-table-column label="帐号" align="center" min-width="100" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.帐号 }}
</template>
</el-table-column>
<el-table-column label="税号" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.税号 }}
</template>
</el-table-column>
<el-table-column label="电话号码" align="center" min-width="120">
<template slot-scope="scope">
{{ scope.row.电话号码 }}
</template>
</el-table-column>
<el-table-column label="电子信箱" align="center" min-width="120">
<template slot-scope="scope">
{{ scope.row.电子信箱 }}
</template>
</el-table-column>
<el-table-column label="地址" align="center" min-width="150">
<template slot-scope="scope">
{{ scope.row.地址 }}
</template>
</el-table-column>
<el-table-column label="传真" align="center" min-width="120">
<template slot-scope="scope">
{{ scope.row.传真 }}
</template>
</el-table-column>
<el-table-column label="法人" align="center" min-width="80">
<template slot-scope="scope">
{{ scope.row.企业性质 }}
</template>
</el-table-column>
<el-table-column label="受托人" align="center" min-width="80">
<template slot-scope="scope">
{{ scope.row.注册资本 }}
</template>
</el-table-column>
<el-table-column label="邮编" align="center" min-width="80">
<template slot-scope="scope">
{{ scope.row.货期 }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="190">
<template slot-scope="scope">
<el-button type="text" size="mini" plain icon="el-icon-edit" @click="handleEdit(scope.row)"/>
<el-button type="text" size="mini" plain icon="el-icon-delete" @click="handleDelete(scope.row)"/>
</template>
</el-table-column>
</el-table>
<div class="block" style="margin-top: 10px;">
<el-pagination
:current-page="pageCurrent"
:page-sizes="[10, 20, 30, 40, 100]"
:page-size="pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</el-card>
<el-card>
<div style="display: inline-block;margin-bottom: 20px;width:90%">供应商联系人列表</div>
<el-button type="warning" size="small" icon="el-icon-circle-plus-outline" plain style="margin-bottom:10px;float:right" @click="handleAdd2()">新增联系人</el-button>
<el-table :data="List1" border stripe size="mini">
<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">
{{ scope.row.职务 }}
</template>
</el-table-column>
<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">
{{ scope.row.手机 }}
</template>
</el-table-column>
<el-table-column label="传真" align="center" >
<template slot-scope="scope">
{{ scope.row.传真 }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="200">
<template slot-scope="scope">
<el-button type="primary" size="mini" icon="el-icon-edit" style="margin-left:10px" @click="handleEdit2(scope.row)">编辑</el-button>
<el-button type="danger" size="mini" icon="el-icon-delete" @click="handleDelete2(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<el-dialog v-el-drag-dialog :title="title" :visible.sync="dialogFormVisible" center style="min-height: 300px" width="800px">
<el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="110px" class="demo-ruleForm">
<el-row>
<el-col :span="12">
<el-form-item label="供应商名称" prop="供应商名称">
<el-input
v-model="form.供应商名称"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="法人" prop="企业性质">
<el-input
v-model="form.企业性质"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="邮编" prop="货期">
<el-input
v-model="form.货期"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="受托人" prop="注册资本">
<el-input
v-model="form.注册资本"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="税号" prop="税号">
<el-input
v-model="form.税号"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开户行" prop="开户行">
<el-input
v-model="form.开户行"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="帐号" prop="帐号">
<el-input
v-model="form.帐号"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电子信箱" prop="电子信箱">
<el-input
v-model="form.电子信箱"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="地址" prop="地址">
<el-input
v-model="form.地址"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电话号码" prop="电话号码">
<el-input
v-model="form.电话号码"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="传真" prop="传真">
<el-input
v-model="form.传真"
size="small"
style="width: 200px;"
clearable/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取消</el-button>
<el-button v-show="title==='新增供应商'" type="primary" @click="submitAdd('form')">确定</el-button>
<el-button v-show="title==='编辑'" type="primary" @click="submitEdit('form')">确定</el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :title="title2" :visible.sync="dialogFormVisible2" center style="min-height: 300px" width="400px">
<el-form ref="form2" :model="form2" :rules="rules2" label-position="right" label-width="80px" class="demo-ruleForm">
<el-form-item label="姓名" prop="姓名">
<el-input v-model="form2.姓名" size="small" clearable/>
</el-form-item>
<el-form-item label="职务" prop="职务">
<el-input v-model="form2.职务" size="small" clearable/>
</el-form-item>
<el-form-item label="电话" prop="电话">
<el-input v-model="form2.电话" size="small" clearable/>
</el-form-item>
<el-form-item label="手机" prop="手机">
<el-input v-model="form2.手机" size="small" clearable/>
</el-form-item>
<el-form-item label="传真" prop="传真">
<el-input v-model="form2.传真" size="small" clearable/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取消</el-button>
<el-button v-show="title2==='增加'" type="primary" @click="submitAdd2('form2')">确定</el-button>
<el-button v-show="title2==='编辑'" type="primary" @click="submitEdit2('form2')">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { searchData, addTable, editTable, deleteData, getName, addPerson, editPerson, deletePerson } from '@/api/PurchasingCenter/SupplierManagement'
export default {
data() {
return {
mainProduction: '', // 主要产品
form1: {},
supplierName: '',
businessNature: '',
creationDate: '',
registeredCapital: '',
taxNumber: '',
email: '',
address: '',
account: '',
bank: '',
telephone: '',
fax: '',
deliveryPeriod: '',
check1: 0,
check2: 0,
check3: 0,
check4: 0,
check5: 0,
check6: 0,
check7: 0,
check8: 0,
check9: 0,
check10: 0,
check11: 0,
check12: 0,
List: [],
pageCurrent: 1,
pageSize: 100,
total: 0,
title: '',
dialogFormVisible: false,
form: {
供应商名称: '',
企业性质: '',
创立日期: '',
注册资本: '',
税号: '',
开户行: '',
帐号: '',
电子信箱: '',
地址: '',
电话号码: '',
传真: '',
货期: ''
},
rules: {
供应商名称: [{ required: true, message: '请填写供应商名称', change: 'blur' }]
},
supplierSerialNumber: '',
List1: [],
dialogFormVisible2: false,
title2: '',
form2: {
姓名: '',
职务: '',
电话: '',
手机: '',
传真: '',
供应商流水号: '',
供应商联系人流水号: ''
},
rules2: {
姓名: [{ required: true, message: '请填写联系人姓名', change: 'blur' }]
}
}
},
mounted() {
this.fetchData()
},
methods: {
fetchData() {
let check1
this.List1 = []
this.supplierName ? this.check1 = 1 : this.check1 = 0
this.businessNature ? this.check2 = 1 : this.check2 = 0
this.creationDate ? this.check3 = 1 : this.check3 = 0
this.registeredCapital ? this.check4 = 1 : this.check4 = 0
this.taxNumber ? this.check5 = 1 : this.check5 = 0
this.bank ? this.check6 = 1 : this.check6 = 0
this.account ? this.check7 = 1 : this.check7 = 0
this.email ? this.check8 = 1 : this.check8 = 0
this.address ? this.check9 = 1 : this.check9 = 0
this.telephone ? this.check10 = 1 : this.check10 = 0
this.fax ? this.check11 = 1 : this.check11 = 0
this.deliveryPeriod ? this.check12 = 1 : this.check12 = 0
this.mainProduction ? check1 = 1 : check1 = 0
searchData(this.check1, this.supplierName, this.check2, this.businessNature, this.check3, this.creationDate, this.check4, this.registeredCapital, this.check5, this.taxNumber, this.check6, this.bank, this.check7, this.account, this.check8, this.email, this.check9, this.address, this.check10, this.telephone, this.check11, this.fax, this.check12, this.deliveryPeriod, this.pageCurrent, this.pageSize, check1, this.mainProduction).then(response => {
this.List = response.data.rows
this.total = response.data.total
})
},
handleAdd() {
if (this.$refs['form'] !== undefined) {
this.$refs['form'].resetFields()
}
this.dialogFormVisible = true
this.title = '新增供应商'
this.form.供应商名称 = ''
this.form.企业性质 = ''
this.form.创立日期 = ''
this.form.注册资本 = ''
this.form.税号 = ''
this.form.开户行 = ''
this.form.帐号 = ''
this.form.电子信箱 = ''
this.form.地址 = ''
this.form.电话号码 = ''
this.form.传真 = ''
this.form.货期 = ''
this.supplierSerialNumber = ''
},
submitAdd(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
addTable(this.form.供应商名称, this.form.企业性质, this.form.创立日期, this.form.注册资本, this.form.税号, this.form.开户行, this.form.帐号, this.form.电子信箱, this.form.地址, this.form.电话号码, this.form.传真, this.form.货期).then(response => {
if (Number(response.data.output[0].output1) === 0) {
this.$message.warning('该供应商已存在')
} else if (response.data.result[0].result === '1') {
this.$message.success('增加成功')
this.dialogFormVisible = false
this.pageCurrent = 1
this.pageSize = 100
this.fetchData()
} else { this.$message.error('增加失败') }
})
} else {
console.log('error submit!!')
return false
}
})
},
handleEdit(row) {
console.log(row)
if (this.$refs['form'] !== undefined) {
this.$refs['form'].resetFields()
}
this.dialogFormVisible = true
this.title = '编辑'
this.form.供应商名称 = row.供应商名称
this.form.企业性质 = row.企业性质
this.form.创立日期 = row.创立日期
this.form.注册资本 = row.注册资本
this.form.税号 = row.税号
this.form.开户行 = row.开户行
this.form.帐号 = row.帐号
this.form.电子信箱 = row.电子信箱
this.form.地址 = row.地址
this.form.电话号码 = row.电话号码
this.form.传真 = row.传真
this.form.货期 = row.货期
this.supplierSerialNumber = row.供应商流水号
},
submitEdit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
editTable(this.form.供应商名称, this.form.企业性质, this.form.创立日期, this.form.注册资本, this.form.税号, this.form.开户行, this.form.帐号, this.form.电子信箱, this.form.地址, this.supplierSerialNumber, this.form.传真, this.form.货期, this.form.电话号码).then(response => {
if (response.data[0].result === '1') {
this.$message.success('编辑成功')
this.dialogFormVisible = false
this.pageCurrent = 1
this.pageSize = 100
this.fetchData()
} else { this.$message.error('编辑失败') }
})
} else {
console.log('error submit!!')
return false
}
})
},
cancel() { // 取消
this.dialogFormVisible = false
},
handleDelete(row) {
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteData(row.供应商流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('删除成功')
this.pageCurrent = 1
this.pageSize = 100
this.fetchData()
} else { this.$message.error('删除失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
handleSizeChange(val) {
this.pageSize = val
this.pageCurrent = 1
this.fetchData()
},
handleCurrentChange(val) {
this.pageCurrent = val
this.fetchData()
},
rowClick(row) {
this.List1 = []
this.form2.供应商流水号 = row.供应商流水号
getName(this.form2.供应商流水号).then(response => {
this.List1 = response.data
})
},
handleAdd2() {
if (this.$refs['form2'] !== undefined) {
this.$refs['form2'].resetFields()
}
this.dialogFormVisible2 = true
this.title2 = '增加'
this.form2.姓名 = ''
this.form2.职务 = ''
this.form2.电话 = ''
this.form2.手机 = ''
this.form2.传真 = ''
},
submitAdd2(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
addPerson(this.form2.姓名, this.form2.职务, this.form2.电话, this.form2.手机, this.form2.传真, this.form2.供应商流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('增加成功')
this.dialogFormVisible2 = false
getName(this.form2.供应商流水号).then(response => {
this.List1 = response.data
})
} else { this.$message.error('增加失败') }
})
} else {
console.log('error submit!!')
return false
}
})
},
handleEdit2(row) {
if (this.$refs['form2'] !== undefined) {
this.$refs['form2'].resetFields()
}
this.dialogFormVisible2 = true
this.title2 = '编辑'
this.form2.姓名 = row.姓名
this.form2.职务 = row.职务
this.form2.电话 = row.电话
this.form2.手机 = row.手机
this.form2.传真 = row.传真
this.form2.供应商联系人流水号 = row.供应商联系人流水号
},
submitEdit2(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
editPerson(this.form2.姓名, this.form2.职务, this.form2.电话, this.form2.手机, this.form2.传真, this.form2.供应商联系人流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('编辑成功')
this.dialogFormVisible2 = false
getName(this.form2.供应商流水号).then(response => {
this.List1 = response.data
})
} else { this.$message.error('编辑失败') }
})
} else {
console.log('error submit!!')
return false
}
})
},
handleDelete2(row) {
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deletePerson(row.供应商联系人流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('删除成功')
getName(this.form2.供应商流水号).then(response => {
this.List1 = response.data
})
} else { this.$message.error('删除失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
}
}
}
</script>
<style scoped>
.el-card{
margin-bottom: 0px;
}
.el-date-editor{
width:200px
}
.el-select{
width:200px
}
.el-input{
width:170px
}
span{
margin: 10px 0 10px 10px;
}
.searchForm .el-form-item{
margin-bottom: 5px;
}
</style>