| <template> | 
|   <GlobalWindow :title="param.id ? '编辑账户' : '新建账户'" :confirmWorking="subLoading" :visible.sync="isShowModal" | 
|     width="600px" @close="close" @confirm="handleSub"> | 
|     <el-form :model="param" ref="paramRef" :rules="rules"> | 
|       <el-form-item label="收支条目" prop="title"> | 
|         <el-input v-model="param.title" placeholder="请输入" v-trim /> | 
|       </el-form-item> | 
|       <el-form-item label="收款公司" prop="companyId"> | 
|         <el-select v-model="param.companyId" filterable clearable> | 
|           <el-option v-for="item in comList" :value="item.id" :label="item.name"></el-option> | 
|         </el-select> | 
|       </el-form-item> | 
|       <el-form-item label="收款类型" prop="type"> | 
|         <el-radio-group v-model="param.type"> | 
|           <el-radio :label="0">对公</el-radio> | 
|           <el-radio :label="1">个人</el-radio> | 
|         </el-radio-group> | 
|       </el-form-item> | 
|       <el-form-item label="账户名称" prop="name"> | 
|         <el-input v-model="param.name" placeholder="请输入" v-trim /> | 
|       </el-form-item> | 
|       <el-form-item label="开户银行" prop="bankName"> | 
|         <el-input v-model="param.bankName" placeholder="请输入" v-trim /> | 
|       </el-form-item> | 
|       <el-form-item label="银行账号" prop="bankNo"> | 
|         <el-input v-model="param.bankNo" placeholder="请输入" v-trim /> | 
|       </el-form-item> | 
|       <el-form-item label="状态" prop="status"> | 
|         <el-switch v-model="param.status" :active-value="0" :inactive-value="1"> | 
|         </el-switch> | 
|       </el-form-item> | 
|     </el-form> | 
|   </GlobalWindow> | 
| </template> | 
|   | 
| <script> | 
| import GlobalWindow from '@/components/common/GlobalWindow' | 
| import UploadAvatarImage from '@/components/common/UploadAvatarImage' | 
| import { create, updateById, detailById } from '@/api/business/ywAccount' | 
| import {  companyGetList } from '@/api/business/company' | 
| import { Message } from 'element-ui' | 
| export default { | 
|   components: { GlobalWindow, UploadAvatarImage }, | 
|   data() { | 
|     return { | 
|       isShowModal: false, | 
|       subLoading: false, | 
|       param: { | 
|         type: 0, | 
|         status: 0 | 
|       }, | 
|       comList: [], | 
|       rules: { | 
|         name: [{ required: true, message: '请输入' }], | 
|         title: [{ required: true, message: '请输入' }], | 
|         bankName: [{ required: true, message: '请输入' }], | 
|         bankNo: [{ required: true, message: '请输入' }], | 
|         status: [{ required: true, message: '请选择' }], | 
|         type: [{ required: true, message: '请选择' }], | 
|         companyId: [{ required: true, message: '请选择' }], | 
|       }, | 
|     } | 
|   }, | 
|   created() { | 
|     this.getCompany() | 
|   }, | 
|   methods: { | 
|     handleSub() { | 
|       const { param, subLoading } = this | 
|       this.$refs['paramRef'].validate((valid) => { | 
|         if (valid) { | 
|           let fn = param.id ? updateById : create | 
|           this.subLoading = true | 
|           fn(param).then(res => { | 
|             this.subLoading = false | 
|             this.$emit('success') | 
|             Message.success('保存成功') | 
|             this.close() | 
|           }).catch(() => { | 
|             this.subLoading = false | 
|           }) | 
|         } | 
|       }) | 
|     }, | 
|     getDetail(id) { | 
|       detailById(id).then(res => { | 
|         this.param = res | 
|       }) | 
|     }, | 
|     getCompany(){ | 
|       companyGetList({ | 
|         model: {type: 2}, | 
|         capacity: 9999, | 
|         page: 1 | 
|       }).then(res => { | 
|        this.comList = res.records || [] | 
|          | 
|       }) | 
|     }, | 
|     changeSel(e) { | 
|       if (e && e.length == 1) { | 
|         this.$set(this.param, 'catePId', e[0]) | 
|         this.$set(this.param, 'cateId', '') | 
|       } else if (e && e.length == 2) { | 
|         this.$set(this.param, 'catePId', e[0]) | 
|         this.$set(this.param, 'cateId', e[1]) | 
|       } else { | 
|         this.$set(this.param, 'catePId', '') | 
|         this.$set(this.param, 'cateId', '') | 
|       } | 
|       this.search() | 
|     }, | 
|     uploadAvatarSuccess(file) { | 
|       this.$set(this.param, 'imgurl', file.imgurl) | 
|       this.$set(this.param, 'imgurlfull', file.imgurlfull) | 
|     }, | 
|     close() { | 
|       this.isShowModal = false | 
|       this.$emit('close') | 
|     } | 
|   } | 
| } | 
| </script> | 
|   | 
| <style lang="scss" scoped></style> |