LAPTOP-FO2T5SIU\35838 8 달 전
부모
커밋
8061716233

+ 2 - 1
src/views/receiveRefundsManagement/paymentManagement/paymentRegistration.vue

@@ -207,7 +207,8 @@ export default {
             const _this = this
             _this.AllData = []
             const data = {
-                contractId: this.contractId
+                contractId: this.contractId,
+                payType: 1
             }
             this.baseRequest('payListAll', data).then((res) => {
                 if (res.data) {

+ 141 - 10
src/views/receiveRefundsManagement/refundManagement/addRefund.vue

@@ -85,7 +85,7 @@
                       popper-class="statistic_base"
                       :popper-append-to-body="false"
                       :label="item.label"
-                      :value="item"
+                      :value="item.value"
                     />
                   </el-select>
                 </el-form-item>
@@ -108,12 +108,32 @@
             </el-row>
             <el-row class="handle-box">
               <el-col :span="24">
-                <el-table v-loading="loading" :data="AllData" row-class-name="g_table_row" stripe border>
-                  <el-table-column type="index" width="60" />
+                <el-table
+                  ref="eltable"
+                  v-loading="loading"
+                  :data="AllData"
+                  row-class-name="g_table_row"
+                  stripe
+                  border
+                  @selection-change="handleSelectionChange"
+                >
+                  <el-table-column type="selection" width="55" />
+                  <el-table-column type="index" width="60" label="序号" />
                   <el-table-column label="款项" prop="type" />
-                  <el-table-column label="已收(元)" prop="applicant" width="200" />
-                  <el-table-column label="扣除" prop="" />
-                  <el-table-column label="实退(元)" prop="" />
+                  <el-table-column label="已收(元)" prop="receivedAmount" width="200" />
+                  <el-table-column label="扣除" prop="deductible">
+                    <template slot-scope="scope">
+                      <el-form-item :prop="`${scope.$index}.deductible`">
+                        <el-input
+                          v-model="scope.row.deductible"
+                          type="number"
+                          :disabled="!scope.row.isSelected"
+                          @input="bigorsmall($event,scope.$index)"
+                        />
+                      </el-form-item>
+                    </template>
+                  </el-table-column>
+                  <el-table-column label="实退(元)" prop="actualRefundAmount" />
                 </el-table>
               </el-col>
             </el-row>
@@ -192,7 +212,7 @@
     </el-form>
     <div style="text-align: right">
       <el-button @click="cancel">取 消</el-button>
-      <el-button v-if="!isView" type="primary" @click="cancel">确 定</el-button>
+      <el-button v-if="!isView" type="primary" @click="confirmSubmit">确 定</el-button>
     </div>
 
   </div>
@@ -204,7 +224,10 @@ import BaseData from '@/views/base/baseData'
 import { upload } from '@/static/utils/channel'
 const form = {
     houseId: null,
-    buyerName: null
+    buyerName: null,
+    refundAmount: null,
+    deductible: null,
+    actualRefundAmount: null
 }
 export default {
     name: 'PaymentRegistration',
@@ -226,7 +249,8 @@ export default {
             idNumberOption: [],
             fileList: [],
             dateStr: '',
-            username: ''
+            username: '',
+            paymentOptions: []
         }
     },
     computed: {
@@ -288,8 +312,14 @@ export default {
             })
         },
         houseChange(val) {
-            this.form.customerManagementId = val.customerManagementId
+            const obj = this.houseOption.find(x => x.value === val)
+            if (obj) {
+                this.form.customerManagementId = obj.customerManagementId
+            } else {
+                this.form.customerManagementId = ''
+            }
             this.getBuyerName()
+            this.getPaymentList()
         },
         getBuyerName() {
             const postData = {
@@ -302,9 +332,62 @@ export default {
             }).catch((e) => {
             })
         },
+        getPaymentList() {
+            const _this = this
+            _this.AllData = []
+            _this.loading = true
+            const postData = {
+                customerManagementId: this.form.customerManagementId,
+                houseId: this.form.houseId
+            }
+            this.baseDetailRequest('getByCustomerManagementId', postData).then((res) => {
+                if (res.data) {
+                    res.data.forEach(item => {
+                        const json = _this.getItemJson(item)
+                        _this.AllData.push(json)
+                    })
+                }
+                _this.loading = false
+            }).catch((e) => {
+            })
+        },
         getItemJson: function(item) {
+            item.isSelected = false
             return item
         },
+        confirmSubmit() {
+            const _this = this
+            this.$refs.form.validate(valid => {
+                if (valid) {
+                    const extraData = {
+                        // 退款详情
+                        detailInfo: JSON.stringify(_this.paymentOptions),
+                        fileList: JSON.stringify(_this.fileList)
+                    }
+                    const postData = Object.assign({}, _this.form, extraData)
+                    this.baseRequest('', postData).then(res => {
+                        const data = res.data
+                        if (data.code == 200) {
+                            this.$notify({
+                                title: '处理成功',
+                                type: 'info'
+                            })
+                            this.cancel()
+                        } else {
+                            this.$notify({
+                                title: res.data.msg,
+                                type: 'error'
+                            })
+                        }
+                    }).catch((err) => {
+                        this.$message({
+                            message: err,
+                            type: 'error'
+                        })
+                    })
+                }
+            })
+        },
         cancel() {
             this.$emit('cancel')
         },
@@ -313,6 +396,51 @@ export default {
                 this.fileList.push(res)
             })
         },
+        bigorsmall(event, index) {
+            const _this = this
+            if (event.length === 0) {
+                _this.AllData[index].deductible = 0
+            }
+            // 扣除大于收款
+            if (event > this.AllData[index].receivedAmount) {
+                _this.AllData[index].deductible = 0
+                _this.AllData[index].actualRefundAmount = 0
+            } else {
+                const receivedAmount = this.AllData[index].receivedAmount
+                const actualRefundAmount = receivedAmount - event
+                _this.AllData[index].actualRefundAmount = actualRefundAmount
+            }
+            this.$refs.eltable.doLayout()
+            // 计算总扣除金额 总实退金额
+            let totalDeductible = 0
+            let totalActualRefundAmount = 0
+            _this.AllData.forEach((item) => {
+                totalDeductible += Number(item.deductible)
+                totalActualRefundAmount += Number(item.actualRefundAmount)
+            })
+            _this.form.deductible = totalDeductible
+            _this.form.actualRefundAmount = totalActualRefundAmount
+        },
+        handleSelectionChange(val) {
+            const _this = this
+            _this.paymentOptions = []
+            _this.multipleSelection = val
+            _this.paymentOptions = this.multipleSelection
+            const selectedID = val.map((e) => {
+                return e.uuid
+            })
+            // 应退金额
+            let totalReceivedAmount = 0
+            _this.AllData.forEach((item) => {
+                const index = selectedID.findIndex(e => e === item.uuid)
+                item.isSelected = index !== -1
+                if (index !== -1) {
+                    totalReceivedAmount += Number(item.receivedAmount)
+                }
+            })
+            console.log('totalReceivedAmount', totalReceivedAmount)
+            _this.form.refundAmount = totalReceivedAmount
+        },
         baseRequest(opUrl, postData) {
             return this.$channel.globeRequest('RefundManageController', opUrl, postData, 'project')
         },
@@ -321,6 +449,9 @@ export default {
         },
         baseBuyerRequest(opUrl, postData) {
             return this.$channel.globeRequest('BuyerController', opUrl, postData, 'project')
+        },
+        baseDetailRequest(opUrl, postData) {
+            return this.$channel.globeRequest('RefundDetailController', opUrl, postData, 'project')
         }
 
     }