<template>
|
<div id="financial">
|
<el-button type="primary" size="mini" @click="handleAdd" style="margin-bottom: 20px" v-if="stageShow">新增</el-button>
|
<el-form ref="ruleForm" :model="ruleForm" :show-message="false">
|
<el-table
|
v-loading="listLoading"
|
:data="ruleForm.tableData"
|
fit
|
stripe
|
highlight-current-row
|
size="small"
|
>
|
<el-table-column label=" " type="index" align="center" width="50px"> </el-table-column>
|
<el-table-column
|
v-for="(item, index) in items"
|
:label="item.label"
|
:prop="item.prop"
|
:key="item.key"
|
:width="item.width"
|
>
|
<!-- :render-header="renderHeader" -->
|
<template slot="header">
|
<span>
|
<span class="red-star"></span>
|
<span style="padding-left:8px">{{item.label}}</span>
|
</span>
|
</template>
|
<template slot-scope="scope">
|
<table-input
|
:row.sync="scope.row"
|
:row-index="scope.$index"
|
:row-key="item.prop"
|
:config="form[item.prop]"
|
></table-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="财务数据管理" fixed="right" width="140px" v-if="stageShow">
|
<template slot-scope="scope">
|
<el-button v-if="!scope.row.save" type="text" size="mini" @click="handleEdit(scope.row, scope.$index)">
|
修改
|
</el-button>
|
<el-button v-if="scope.row.save" type="text" size="mini" @click="handleSave(scope.row, scope.$index)">
|
保存
|
</el-button>
|
<el-button type="text" v-if="!scope.row.cancel" size="mini" @click="handleDelete(scope.row, scope.$index)">
|
删除
|
</el-button>
|
<el-button type="text" v-if="scope.row.cancel" size="mini" @click="handleCancel(scope.row,scope.$index)">
|
取消
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-form>
|
<pagination
|
v-show="total > 1"
|
:total="total"
|
:page.sync="listQuery.currentPage"
|
:limit.sync="listQuery.pageSize"
|
@pagination="initTable"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import TableInput from './TableInput'
|
import {
|
qryEnpFinancialData,
|
delEnpFinancialData,
|
addOrUpdateEnpFinancialData,
|
clickAddEnpFinancialData
|
} from '@/api/area/enterprise'
|
import Pagination from '@/components/Pagination'
|
import { mapState } from 'vuex'
|
export default {
|
components: { Pagination, TableInput },
|
props: ['objectNo', 'objectType'],
|
data: function() {
|
return {
|
// 分页
|
listLoading: true,
|
total: 0,
|
listQuery: {
|
currentPage: 1,
|
pageSize: 10
|
},
|
ruleForm: {
|
tableData: []
|
},
|
items: [
|
{ label: '财务数据类型', prop: 'financialtype', key: 1, width: 190 },
|
{ label: '开始时间', prop: 'begintime', key: 2, width: 190 },
|
{ label: '截止时间', prop: 'endtime', key: 3, width: 190 },
|
{ label: '营业收入', prop: 'operatingreceipt', key: 4, width: 190 },
|
{ label: '净利润', prop: 'netprofit', key: 5, width: 190 },
|
{ label: '扣非净利润', prop: 'nonnetprofit', key: 6, width: 190 },
|
{ label: '净资产', prop: 'netassets', key: 7, width: 190 },
|
{ label: '经营性现金流净额', prop: 'netoperatingcashflow', key: 8, width: 190 },
|
{ label: '对外担保金额', prop: 'externalguaranteeamount', key: 9, width: 190 },
|
{ label: '总资产', prop: 'totalassets', key: 10, width: 190 },
|
{ label: '总负债', prop: 'totalliability', key: 11, width: 190 },
|
{ label: '资产负债率(%)', prop: 'assetsliabilities', key: 12, width: 190 }
|
],
|
form: {
|
financialtype: '',
|
begintime: '',
|
endtime: '',
|
operatingreceipt: '',
|
netprofit: '',
|
nonnetprofit: '',
|
netassets: '',
|
netoperatingcashflow: '',
|
externalguaranteeamount: '',
|
totalassets: '',
|
totalliability: '',
|
assetsliabilities: '',
|
serialno: ''
|
},
|
row: {},
|
saveSuccess: true,
|
}
|
},
|
watch: {
|
objectNo: {
|
immediate: true,
|
handler(newVal) {
|
if (!this._.isEmpty(newVal)) {
|
this.initTable()
|
}
|
}
|
}
|
},
|
computed: {
|
...mapState({
|
enterpriseParams: state => state.risk.enterpriseParams
|
}),
|
stageShow() {
|
if (this.enterpriseParams.phaseno === '0040' || this.enterpriseParams.phaseno === '0050') {
|
return false
|
} else {
|
return true
|
}
|
}
|
},
|
methods: {
|
async initTable() {
|
let params = {
|
objectno: this.objectNo,
|
objecttype: this.objectType
|
}
|
Object.assign(params, this.listQuery)
|
let res = await qryEnpFinancialData(params)
|
this.ruleForm.tableData = res.result.records
|
this.total = res.result.total
|
this.ruleForm.tableData.forEach((item, key) => {
|
item = Object.assign({}, item, { save: false, cancel: false })
|
})
|
this.initForm()
|
this.listLoading = false
|
},
|
async initForm() {
|
let params = { serialno: this.objectNo }
|
Object.assign(this.row, this.form)
|
let res = await clickAddEnpFinancialData(params)
|
this._.merge(this.form, res.result)
|
},
|
// 修改
|
handleEdit(row, index) {
|
if (this._.find(this.ruleForm.tableData, { save: true })) {
|
this.$message.warning('请保存当前数据!')
|
return false
|
}
|
this.$set(this.ruleForm.tableData[index], 'save', true)
|
this.$set(this.ruleForm.tableData[index], 'cancel', true)
|
this.modifyRow = Object.assign({},row)
|
},
|
// 保存
|
handleSave(row, index) {
|
let params = {
|
objectno: this.objectNo,
|
objecttype: this.objectType
|
}
|
Object.keys(this.form).forEach(key => {
|
params[key] = row[key]
|
})
|
this.$refs['ruleForm'].validate(valid => {
|
if (valid) {
|
addOrUpdateEnpFinancialData(params).then(res => {
|
if (res.code === '00') {
|
this.$message.success('保存成功')
|
this.$set(this.ruleForm.tableData[index], 'save', false)
|
this.$set(this.ruleForm.tableData[index], 'cancel', false)
|
this.initTable()
|
}
|
})
|
} else {
|
this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
|
return false
|
}
|
})
|
},
|
// 删除
|
async handleDelete(row, index) {
|
if (row.newRow) {
|
this.ruleForm.tableData.splice(index, 1)
|
this.initTable()
|
return false
|
}
|
let confirm = await this.$confirm('此操作将永久删除该内容, 是否继续?', '删除确认', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
customClass: 'pro_messages_box',
|
confirmButtonClass: 'pro_messages_box_confirm',
|
cancelButtonClass: 'pro_messages_box_cancel',
|
center: true
|
})
|
.then(() => {
|
return true
|
})
|
.catch(() => {
|
return false
|
})
|
let params = { serialno: row.serialno }
|
if (confirm) {
|
let res = await delEnpFinancialData(params)
|
if (res.code === '00') {
|
this.$message.success('删除成功!')
|
this.initTable()
|
}
|
}
|
},
|
// 新增
|
handleAdd() {
|
if (this._.find(this.ruleForm.tableData, { save: true })) {
|
this.$message.warning('请保存当前数据!')
|
return false
|
}
|
Object.keys(this.form).forEach(key => {
|
this.row[key] = this.form[key].value
|
})
|
let params = {
|
save: true,
|
cancel: false,
|
newRow: true
|
}
|
Object.assign(params, this.row)
|
this.ruleForm.tableData.unshift(params)
|
},
|
// 取消
|
handleCancel(row, index) {
|
// console.log(row)
|
// console.log(this.modifyRow)
|
for (let key in row) {
|
if (row[key] !== this.modifyRow[key]) {
|
this.saveSuccess = false // 用户修改了数据
|
break
|
}
|
}
|
if (!this.saveSuccess) {
|
// 数据修改了
|
this.$confirm('检测到未保存的内容,是否保存当行修改?', '取消确认', {
|
distinguishCancelAndClose: true,
|
confirmButtonText: '保存',
|
cancelButtonText: '放弃修改',
|
customClass: 'pro_messages_box',
|
confirmButtonClass: 'pro_messages_box_confirm',
|
cancelButtonClass: 'pro_messages_box_cancel',
|
center: true
|
})
|
.then(() => {
|
// 保存
|
row.cancel = !row.cancel
|
row.save = !row.save
|
// this.$message.success('保存成功');
|
this.handleSave(row, index)
|
this.saveSuccess = true
|
})
|
.catch(() => {
|
for (let key in row) {
|
row[key] = this.modifyRow[key]
|
}
|
row.cancel = !row.cancel
|
row.save = !row.save
|
this.saveSuccess = true
|
})
|
} else {
|
// 数据未修改
|
row.cancel = !row.cancel
|
row.save = !row.save
|
}
|
},
|
// renderHeader (h,{column}) { // h即为cerateElement的简写
|
// return h(
|
// 'div',
|
// [
|
// [
|
// h('span', {
|
// style:'position:absolute;top:7px;left:12px;border:2px solid #FF4300;content:"";border-radius:50%;color:#FF4300;margin-right:5px;line-height:12px'
|
// }),
|
// h('span', column.label,
|
// {
|
// style: 'position:absolute;top:0px;left:0px;'
|
// })
|
// ],
|
// ],
|
// );
|
// },
|
}
|
}
|
</script>
|
|
<style lang="stylus" scoped>
|
#financial
|
>>> .el-form
|
.cell
|
div
|
&:nth-child(1)
|
line-height 18px
|
.el-form-item__content
|
.el-input--mini
|
// left 10px
|
.el-input__inner
|
// width 170px
|
// min-width 170px
|
font-size 14px
|
.red-star
|
display inline-block
|
width 5px
|
height 5px
|
border-radius 50%
|
vertical-align: middle;
|
// color: #F56C6C;
|
background-color #f56c66
|
margin-bottom 3px
|
</style>
|