zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<template>
  <div>
    <div class="search-form">
      <EditForm ref="form"
                formType="search"
                :inline="true"
                :list="formList"
                :buttons="buttons"
                :isShowAll="isShowAll"
                :formValues="formValues"
                :formRules="formRules"
                @updateValue="updateValue"
                @buttonAction="buttonAction"></EditForm>
    </div>
    
    <p class="export-excle">
      <el-button size="small"
                 type="primary"
                 v-if="powerControl.addControl"
                 @click="editDialog(1)">新增支付订单</el-button>
      
      <el-button size="small"
                 type="primary"
                 v-if="powerControl.moveControl"
                 @click="editDialog(2)">流水调整</el-button>
      
      <el-button size="small"
                 v-if="powerControl.exportControl"
                 @click="exportFile">导出</el-button>
    </p>
 
    <div class="list-content">
      <TableList :isAutoIndex="true"
                 :isPaddingRight="false"
                 :loading="loading"
                 :list="records"
                 :header="tableList"
                 :total="total"
                 :pageInfo="pageInfo"
                 @doAction="doAction"
                 @handleCurrentChange="handleCurrentChange"
                 @handleSizeChange="handleSizeChange"></TableList>
    </div>
 
    <!-- 查看 -->
    <HouseholdBagApplyPayRecords :serialno="rowSerialno"
                                 :dialogVisible="dialogVisible"
                                 :powerControl="powerControl"
                                 @doAction="dialogDoAction" />
 
    <!-- 新增流水 -->
    <div v-if="addVisible">
      <AddHouseholdBagPayRec :serialno="rowSerialno"
                            :dialogVisible="addVisible"
                            @doAction="value => editDialogDoAction(value, 1)" />
    </div>
 
    <!-- 调整流水 -->
    <div v-if="moveVisible">
      <MoveHouseholdBagPayRec :serialno="rowSerialno"
                            :dialogVisible="moveVisible"
                            @doAction="value => editDialogDoAction(value, 2)" />
    </div>
                                 
 
  </div>
</template>
<script>
/**
 * 返现佣金-客户签约管理页面
 */
 
import EditForm from './components/EditForm';
import TableList from '@comprehensive/components/TableList';
import HouseholdBagApplyPayRecords from '@comprehensive/components/HouseholdBagApplyPayRecords';
import AddHouseholdBagPayRec from '@comprehensive/components/AddHouseholdBagPayRec';
import MoveHouseholdBagPayRec from '@comprehensive/components/MoveHouseholdBagPayRec';
import { refundHouseholdBagApply, qryHouseholdBagApplyImages, cancelHouseholdBagApply, queryFileHouseholdBag, refundHouseholdBagCal } from '@/api/comprehensiveTransaction';
import qryHouseholdBagApplyList from '@comprehensive/model/qryHouseholdBagApplyList';
import getApplyListAll from '@comprehensive/model/getApplyListAll';
import {
  getProvinceCodeList,
  getCityCodeList,
  getAreaCodeList,
  exportHouseholdBagApplyList
} from '@comprehensive/serve/public';
import { alert } from '@comprehensive/utils/comm';
 
export default {
  name: 'LoanApply',
  components: {
    TableList,
    EditForm,
    HouseholdBagApplyPayRecords,
    AddHouseholdBagPayRec,
    MoveHouseholdBagPayRec
  },
  data() {
    return {
      title: '新增',
      form: {},
      dialogVisible: false,
      addVisible: false,
      moveVisible: false,
      // 是否显示详情页
      isShowList: true,
      formList: [],
      tableList: [],
      formRules: {},
      listModel: null,
      query: {},
      records: [],
      pageInfo: {
        currentPage: 1,
        pageSize: 10,
      },
      total: 0,
      serialNo: '',
      objectType: '',
      customerID: '',
      loading: false,
      uploading: false,
      // 是否显示所有表单项
      isShowAll: false,
      buttons: [
        { text: '重置', type: '' },
        { text: '搜索' },
        { type: 'fold', text: '展开' },
      ],
      uploadHeader: {
        'Content-Type': 'multipart/form-data; boundary=ReaquestHeader',
      },
      rowSerialno: null,
      newWindow: null,
      // 按钮权限控制
            powerControl:{
                addControl: false, // 新增
                payRecordsViewControl: false, // 查看流水
                cancelApplyFlowControl: false, // 查看流水-取消
                refundApplyControl: false, // 退款
                cancelApplyControl: false, // 取消申请
                exportControl: false, // 导出
        moveControl: false // 调整
            }
    };
  },
  created() {
    this.setPowerControl();
    this.init();
    this.getOptions()
  },
  methods: {
      setPowerControl() {
      let {powerControl} = this
      if (process.env.NODE_ENV !== 'development') {
        powerControl.addControl = this.window.top._server_addHouseholdBagPayRe
        powerControl.payRecordsViewControl = this.window.top._server_qryHouseholdBagApplyPayRecords
        powerControl.cancelApplyFlowControl = this.window.top._server_cancelHouseholdBagApplyPos
        powerControl.refundApplyControl = this.window.top._server_refundHouseholdBagApply
        powerControl.cancelApplyControl = this.window.top._server_cancelHouseholdBagApply
        powerControl.exportControl = this.window.top._server_exportHouseholdBagApplyList
        powerControl.moveControl = this.window.top._server_moveHouseholdBagPayRec
      } else {
        powerControl.addControl = true 
        powerControl.payRecordsViewControl = true
        powerControl.cancelApplyFlowControl = true
        powerControl.refundApplyControl = true
        powerControl.cancelApplyControl = true
        powerControl.exportControl = true
        powerControl.moveControl = true
      }
      this.powerControl = powerControl
    },
    // 页面初始化处理
    init() {
      const { query } = this.$route;
      this.query = query;
      const listModel = qryHouseholdBagApplyList();
      const formList = listModel.getFormList(query);
      this.tableList = listModel.getTableList();
      this.formRules = listModel.getFormRules();
      this.formList = formList;
      this.listModel = listModel;
 
      this.fetch();
      this.getApplyListAll();
    },
    editDialog(key) {
      switch (key) {
        case 1:
          this.addVisible = true;
          break;
        case 2:
          this.moveVisible = true;
          break;
        default:
          break;
      }
    },
    async exportFile() {
      const { pageInfo, formValues } = this
      const res = await exportHouseholdBagApplyList({ ...pageInfo, ...formValues })
      if(res.code == '00'){
        alert('提交成功',res.msg,() => {})
      }
    },
    // 表单事件回调
    doAction(name, item, { id, label }) {
      if (name === 'action') {
        // 取消申请
        if(id == 0) {
          this.cancelApply(item)
        }
        if (id == 1) {
          // 查看流水
          this.rowSerialno = item.serialno;
          this.dialogVisible = true;
        }
        if (id == 2) {
          // 退款
          this.refundApply(item);
        }
        if (id == 3) {
          // 查看合同
          this.qryHBImages(item.serialno);
        }
      }
    },
    // 更新表单数据
    updateValue(index, info) {
      const { formList } = this;
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index);
      }
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index];
        this.$set(formList, index, { ...preInfo, ...info });
        if (info.name === 'projectProvince') {
          this.getArea('projectCity', info.value);
        }
      }
    },
    // 表单按钮操作
    buttonAction(index, button) {
      let { listModel, isShowAll } = this;
      if (index === 0) {
        // 重置
        // this.formList = listModel.getFormList()
        this.init();
      }
      if (index === 1) {
        // 搜索
        this.pageInfo.currentPage = 1;
        this.fetch();
      }
      if (index === 2) {
        // 展开/收起
        this.isShowAll = !isShowAll;
      }
    },
    dialogDoAction(type) {
      if (type == 'close') {
        this.rowSerialno = '';
        this.dialogVisible = false;
      }
    },
    editDialogDoAction(status, key) {
      this.addVisible = false;
      this.moveVisible = false;
      if(status == 'succ') {
        this.fetch();
      }
    },
    // 查询项目管理列表
    async getApplyListAll() {
      const res = await getApplyListAll().request({});
      const { list } = res;
      this.updateValue('projectSerialno', { options: list });
    },
    // 退款
    async refundApply(item) {
      const res = await refundHouseholdBagCal({serialno: item.serialno})
      if(res.code === '00') {
        this.$confirm(`退款信息:客户${item.customername},退款${res.result.refundAmt}元,请确认是否退款`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            refundHouseholdBagApply({serialno: item.serialno}).then((res) => {
              if (res.code == '00') {
                this.$message({
                  type: 'success',
                  message: '退款成功!',
                });
              }
              this.fetch()
            });
          })
          .catch(() => {
          });
      }
    },
    // 取消申请
    cancelApply(item) {
      this.$confirm(`将取消客户${item.customername}申请请求,请确认`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          cancelHouseholdBagApply({serialno: item.serialno}).then((res) => {
            if (res.code == '00') {
              this.$message({
                type: 'success',
                message: '取消成功!',
              });
            }
            this.fetch()
          });
        })
        .catch(() => {
        });
    },
    // 查看合同
    qryHBImages(serialno) {
      qryHouseholdBagApplyImages({serialno: serialno}).then((res) => {
        if (res.code == '00') {
          const data = res.result.find(item => {
            return item.typeno === 'A001T004'
          })
          if(!data) {
            this.$message({
              message: '暂无可查看合同!',
            });
          } else {
            this.newWindow = window.open(
              `${process.env.VUE_APP_API_HOST}server/queryFile/${data.serialno}`,
              'newwindow',
              'height=700px, width=800px, top=100px,left=400px, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no'
            )
          }
        }
      });
    },
    // 获取当前列表数据
    async fetch() {
      try {
        this.loading = true;
        let { pageInfo, listModel, formValues, query, powerControl } = this;
        const { customerPhone, from } = query;
        const res = await listModel.request({ ...pageInfo, ...formValues });
        this.loading = false;
        const { list, total } = res;
        this.records = list.reduce((pre, curr) => {
          let arr = [];
          powerControl.cancelApplyControl && arr.push({ id: 0, label: '取消申请', disabled: curr.status != 0 && curr.status != 4 });
          powerControl.payRecordsViewControl && arr.push({ id: 1, label: '查看流水', disabled: false });
          arr.push({ id: 3, label: '查看合同', disabled: false });
          powerControl.refundApplyControl && arr.push({ id: 2, label: '退款', disabled: curr.status < 1 || curr.status > 3 });
          pre.push({
            ...curr,
            buttons: [...arr],
          });
 
          return pre;
        }, []);
        this.total = total;
      } catch (error) {
        this.loading = false;
      }
    },
    // 修改翻页条数
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.fetch();
    },
    // 修改翻页数
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val;
      this.fetch();
    },
    // 更新表单数据
    updateValue1(index, info) {
      const { formList } = this;
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index);
      }
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index];
        this.$set(formList, index, { ...preInfo, ...info });
      }
    },
    getOptions() {
      const { projectProvince = '', projectCity = '', regions = '' } = this.formValues;
      console.log('formValues:', this.formValues);
      
      this.getArea('projectProvince', '', projectProvince === '');
      if (projectProvince !== '') {
        this.getArea('projectCity', projectProvince, projectCity === '');
      }
      if (projectProvince !== '' && projectCity !== '') {
        this.getArea('regions', projectCity, regions === '');
      }
    },
 
    updateOptions(name, list, labelKey, valueKey, isResetValue = true) {
      const valueObj = isResetValue ? { value: '' } : {};
      this.updateValue(name, {
        options: list.map((item) => ({
          label: item[labelKey],
          value: item[valueKey],
        })),
        ...valueObj,
      });
    },
 
    async getArea(name, itmeNo, isResetValue = true) {
      if (name === 'projectProvince') {
        const { result } = await getProvinceCodeList();
        this.updateOptions(name, result, 'itemname', 'itemno', isResetValue);
      }
 
      if (name === 'projectCity') {
        const { result } = await getCityCodeList({
          codeNo: 'AreaCode',
          itmeNo,
        });
        this.updateOptions(name, result, 'itemname', 'itemno', isResetValue);
      }
 
      if (name === 'regions') {
        const { result } = await getAreaCodeList({
          codeNo: 'AreaCode',
          itmeNo,
        });
        this.updateOptions(name, result, 'itemname', 'itemno', isResetValue);
      }
    },
  },
  computed: {
    // 表单值信息
    formValues() {
      const { listModel, formList } = this;
      return listModel.getFormValues(formList);
    },
  },
  // watch: {
  //   $route() {
  //     this.init()
  //   }
  // }
};
</script>
<style lang="postcss" scoped>
.search-form {
  padding-top: 16px;
}
.list-content {
  font-size: 14px;
}
.export-excle {
  margin: 0 0 20px 0;
}
.message {
  font-size: 12px;
  color: #666666;
  padding: 10px 20px;
  background-color: #fafafa;
}
.upload-demo {
  display: inline-block;
  margin-left: 10px;
}
</style>