| <template> | 
|     <GlobalWindow width="100%" :title="title" :visible.sync="visible" :confirm-working="isWorking" @close="close" | 
|                   @confirm="confirm"> | 
|         <div class="main"> | 
|             <div class="main_content"> | 
|                 <el-form :model="form" label-position="top" ref="form" :rules="rules"> | 
|                     <div class="head"> | 
|                         <div class="m_title">基础信息</div> | 
|                     </div> | 
|                     <div class="list"> | 
|                         <el-form-item label="关联合同" prop="contractId"> | 
|                             <el-select v-model="form.contractId" @change="changeContract" placeholder="请选择"> | 
|                                 <el-option v-for="(item, index) in contract" :key="index" :value="item.id" :label="item.code"></el-option> | 
|                             </el-select> | 
|                         </el-form-item> | 
|                         <el-form-item label="收款方" prop="renterName"> | 
|                             <el-input v-model="form.renterName" disabled placeholder="收款方" v-trim /> | 
|                         </el-form-item> | 
|                         <el-form-item label="房源" prop="ywContractRoomList"> | 
|                             <el-select v-model="form.ywContractRoomList" multiple placeholder="请选择"> | 
|                                 <el-option | 
|                                     v-for="(item, index) in houseList" | 
|                                     :key="index" | 
|                                     :value="item.id" | 
|                                     :label="item.projectName + item.buildingName + item.floorName + item.roomName" /> | 
|                             </el-select> | 
|                         </el-form-item> | 
|                         <el-form-item label="费用类型" prop="costType"> | 
|                             <el-select v-model="form.costType" placeholder="请选择"> | 
|                                 <el-option :value="0" label="租赁费"></el-option> | 
|                                 <el-option :value="1" label="物业费"></el-option> | 
|                                 <el-option :value="2" label="租赁押金"></el-option> | 
|                                 <el-option :value="3" label="物业证金"></el-option> | 
|                                 <el-option :value="4" label="水电费"></el-option> | 
|                                 <el-option :value="5" label="杂项费"></el-option> | 
|                                 <el-option :value="6" label="其他"></el-option> | 
|                             </el-select> | 
|                         </el-form-item> | 
|                         <el-form-item label="计费周期" prop="date"> | 
|                             <el-date-picker | 
|                                 type="daterange" | 
|                                 range-separator="至" | 
|                                 v-model="form.date" | 
|                                 @change="changeDate" | 
|                                 start-placeholder="开始日期" | 
|                                 end-placeholder="结束日期" | 
|                                 value-format="yyyy-MM-dd" | 
|                                 placeholder="请选择" /> | 
|                         </el-form-item> | 
|                         <el-form-item label="应付金额" prop="totleFee"> | 
|                             <el-input v-model="form.totleFee" placeholder="请输入应收金额" v-trim /> | 
|                         </el-form-item> | 
|                         <el-form-item label="应付日期" prop="planPayDate"> | 
|                             <el-date-picker type="date" v-model="form.planPayDate" value-format="yyyy-MM-dd" placeholder="请选择" /> | 
|                         </el-form-item> | 
|                         <el-form-item label="所属公司" prop="companyId"> | 
|                             <el-select v-model="form.companyId" placeholder="请选择"> | 
|                                 <el-option | 
|                                     v-for="(item, index) in comparyList" | 
|                                     :key="index" | 
|                                     :value="item.id" | 
|                                     :label="item.name" /> | 
|                             </el-select> | 
|                         </el-form-item> | 
|                         <el-form-item style="width: 100%;" label="账单备注" prop="remark"> | 
|                             <el-input type="textarea" :rows="5" v-model="form.remark" placeholder="请输入" /> | 
|                         </el-form-item> | 
|                     </div> | 
|                 </el-form> | 
|             </div> | 
|         </div> | 
|         <div class="file_wrap"> | 
|             <div class="head"> | 
|                 <div>账单附件</div> | 
|                 <el-upload class="upload-demo" :show-file-list="false" :data="uploadData" :action="uploadImgUrl" | 
|                            :on-success="uploadAvatarSuccess" :before-upload="beforeUpload" :on-error="uploadError"> | 
|                     <el-button icon="el-icon-plus" plain>添加附件</el-button> | 
|                 </el-upload> | 
|             </div> | 
|             <el-table :data="form.multifileList" stripe> | 
|                 <el-table-column prop="originname" label="附件名称" align="center" min-width="100" show-overflow-tooltip /> | 
|                 <el-table-column prop="userName" label="操作人" align="center" min-width="100" show-overflow-tooltip /> | 
|                 <el-table-column prop="createTime" label="操作时间" align="center" min-width="100" show-overflow-tooltip /> | 
|                 <el-table-column label="操作" align="center" min-width="100"> | 
|                     <template slot-scope="{row}"> | 
|                         <span class="cu red" @click="dele(row.imgaddr)">删除</span> | 
|                     </template> | 
|                 </el-table-column> | 
|             </el-table> | 
|         </div> | 
|     </GlobalWindow> | 
| </template> | 
|   | 
| <script> | 
|   import GlobalWindow from '@/components/common/GlobalWindow' | 
|   import BaseOpera from '@/components/base/BaseOpera' | 
|   import { rules } from './config' | 
|   import { create } from '@/api/bill' | 
|   import { list as listAll } from '@/api/contract' | 
|   import { companyList } from '@/api/company' | 
|   import { Message, Loading } from 'element-ui' | 
|   import { getContractRoom } from '@/api/house' | 
|   import { mapState } from 'vuex' | 
|   export default { | 
|     name: 'bullEditFu', | 
|     components: { | 
|       GlobalWindow | 
|     }, | 
|     computed: { | 
|       ...mapState(['userInfo']) | 
|     }, | 
|     extends: BaseOpera, | 
|     data () { | 
|       return { | 
|         form: { | 
|           contractId: '', | 
|           renterName: '', | 
|           renterId: '', | 
|           costType: '', | 
|           type: '', | 
|           companyId: '', | 
|           remark: '', | 
|           startDate: '', | 
|           endDate: '', | 
|           totleFee: '', | 
|           planPayDate: '', | 
|           multifileList: [], | 
|           ywContractRoomList: [], | 
|           date: [], | 
|           RoomName: '' | 
|         }, | 
|         rules, | 
|         loadingInstance: null, | 
|         uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/visitsAdmin/cloudService/public/uploadBatch', | 
|         fileList: [], | 
|         uploadData: { | 
|           folder: 'YW_CONTRACT_BILL' | 
|         }, | 
|         contract: [], | 
|         payerList: [], | 
|         comparyList: [], | 
|         houseList: [] | 
|       } | 
|     }, | 
|     methods: { | 
|       open (title, target) { | 
|         this.title = title | 
|         this.form.multifileList = [] | 
|         this.getListAll() | 
|         this.getCompanyList() | 
|         this.visible = true | 
|         // 新建 | 
|         if (target == null) { | 
|           this.$nextTick(() => { | 
|             this.$refs.form.resetFields() | 
|             this.form[this.configData['field.id']] = null | 
|           }) | 
|           return | 
|         } | 
|         // 编辑 | 
|         this.$nextTick(() => { | 
|           for (const key in this.form) { | 
|             this.form[key] = target[key] | 
|           } | 
|         }) | 
|       }, | 
|       changeContract (e) { | 
|         this.form.renterName = this.contract.filter(item => { | 
|           if (item.id === e) { | 
|             return item | 
|           } | 
|         })[0].renterName | 
|         this.getHouseDate() | 
|       }, | 
|       getHouseDate () { | 
|         getContractRoom({ contractId: this.form.contractId, type: 0 }) | 
|           .then(res => { | 
|             this.houseList = res | 
|           }) | 
|       }, | 
|       confirm () { | 
|         this.$refs.form.validate((valid) => { | 
|           if (!valid) return | 
|           this.isWorking = true | 
|           let obj = JSON.parse(JSON.stringify(this.form)) | 
|           obj.ywContractRoomList = obj.ywContractRoomList.map(id => { | 
|             return { roomId: id } | 
|           }) | 
|           obj.feeType = 0 | 
|           obj.billType = 1 | 
|           create(obj) | 
|             .then(() => { | 
|               this.visible = false | 
|               this.$tip.apiSuccess('新建成功') | 
|               this.$emit('success') | 
|             }) | 
|             .finally(() => { | 
|               this.isWorking = false | 
|             }) | 
|         }) | 
|       }, | 
|       dele (imgaddr) { | 
|         this.form.multifileList.forEach((item, index) => { | 
|           if (imgaddr === item.imgaddr) { | 
|             this.form.multifileList.splice(index, 1) | 
|           } | 
|         }) | 
|       }, | 
|       openHouse () { | 
|         this.$refs.selectHouse.open('选择房源', { contractId: this.form.contractId, type: 0 }) | 
|       }, | 
|       getCompanyList () { | 
|         companyList({}) | 
|           .then(res => { | 
|             this.comparyList = res | 
|           }) | 
|       }, | 
|       getListAll () { | 
|         listAll({}) | 
|           .then(res => { | 
|             console.log(res) | 
|             this.contract = res | 
|           }) | 
|       }, | 
|       changeDate (e) { | 
|         if (!e || e.length === 0) { | 
|           this.form.startDate = '' | 
|           this.form.endDate = '' | 
|         } else { | 
|           this.form.startDate = e[0] | 
|           this.form.endDate = e[1] | 
|         } | 
|       }, | 
|       beforeUpload (file) { | 
|         this.loadingInstance = Loading.service({ | 
|           lock: true, | 
|           text: 'Loading', | 
|           spinner: 'el-icon-loading', | 
|           background: 'rgba(0, 0, 0, 0.7)' | 
|         }) | 
|       }, | 
|       uploadError () { | 
|         this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭 | 
|           if (this.loadingInstance) { | 
|             this.loadingInstance.close() | 
|           } | 
|         }) | 
|       }, | 
|       getDay () { | 
|         const now = new Date(); | 
|         const year = now.getFullYear(); | 
|         const month = now.getMonth() + 1; // 加1使其从1开始 | 
|         const day = now.getDate(); | 
|         const hours = now.getHours(); | 
|         const minutes = now.getMinutes(); | 
|         const seconds = now.getSeconds(); | 
|         return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')} ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; | 
|       }, | 
|       uploadAvatarSuccess (file) { | 
|         this.$nextTick(() => { | 
|           if (this.loadingInstance) { | 
|             this.loadingInstance.close() | 
|           } | 
|         }) | 
|         const item = file.data[0] | 
|         this.form.multifileList.push({ ...item, fileurl: item.imgaddr, name: item.originname, userName: this.userInfo.realname, createTime: this.getDay() }) | 
|       }, | 
|       close () { | 
|         this.$emit('close') | 
|       } | 
|     } | 
|   } | 
| </script> | 
|   | 
| <style lang="scss" scoped> | 
|     @import '@/assets/style/variables.scss'; | 
|      | 
|      | 
|     .cost_tabs { | 
|         justify-content: flex-start; | 
|         border: none; | 
|          | 
|         .tab { | 
|             height: 36px; | 
|             line-height: 36px; | 
|             font-size: 14px; | 
|         } | 
|     } | 
|      | 
|     .main { | 
|         display: flex; | 
|         margin-bottom: 20px; | 
|          | 
|         .main_content { | 
|             flex: 1; | 
|             margin-right: 20px; | 
|              | 
|             .head { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: space-between; | 
|                  | 
|                 .tabs { | 
|                     display: flex; | 
|                     margin-bottom: 20px; | 
|                     align-items: center; | 
|                     justify-content: center; | 
|                      | 
|                     .tab { | 
|                         height: 14px; | 
|                         line-height: 14px; | 
|                         cursor: pointer; | 
|                         border: 1px solid #ebebeb; | 
|                         padding: 12px 24px; | 
|                     } | 
|                      | 
|                     .active { | 
|                         font-weight: 500; | 
|                         color: $primary-color; | 
|                         border: 1px solid $primary-color; | 
|                     } | 
|                 } | 
|             } | 
|              | 
|             .list { | 
|                 display: flex; | 
|                 flex-wrap: wrap; | 
|                  | 
|                 .el-form-item { | 
|                     width: 33.33%; | 
|                     box-sizing: border-box; | 
|                     padding: 0 12px; | 
|                 } | 
|             } | 
|         } | 
|          | 
|         .main_house { | 
|             width: 320px; | 
|             padding: 24px 12px; | 
|             border: 1px solid #c3c6cd; | 
|             border-radius: 2px; | 
|              | 
|             .title { | 
|                 font-size: 16px; | 
|                 font-weight: 500; | 
|                 margin-bottom: 30px; | 
|             } | 
|         } | 
|          | 
|     } | 
|      | 
|     .total { | 
|         display: flex; | 
|         justify-content: space-between; | 
|         align-items: center; | 
|         height: 32px; | 
|         background-color: #e7e9f5; | 
|          | 
|         span { | 
|             width: 160px; | 
|             text-align: center; | 
|         } | 
|     } | 
|      | 
|     .file_wrap { | 
|         padding: 20px 16px; | 
|         border: 1px solid #c3c6cd; | 
|         border-radius: 2px; | 
|          | 
|         .head { | 
|             display: flex; | 
|             justify-content: space-between; | 
|             align-items: center; | 
|         } | 
|     } | 
|      | 
|     .m_title { | 
|         font-weight: 500; | 
|         font-size: 14px; | 
|         margin-bottom: 15px; | 
|         margin-top: 10px; | 
|     } | 
| </style> |