sen
6 天以前 394a36d43275129882942f6d03e1185c4ebc7f99
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
<template>
  <basicContainer>
    <avue-crud :option="option" :table-loading="pageF.loading" :data="tableData" :page="page"
      :permission="permissionList" :before-open="beforeOpen" v-model="form" v-model:search="queryParams" ref="crudRef"
      @row-update="rowUpdate" @row-save="rowSave" @refresh-change="refreshChange" @row-del="rowDel"
      @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
      @current-change="currentChange" @size-change="sizeChange" @on-load="onLoad">
      <template #menu-left>
        <!--        <el-button-->
        <!--            type="success"-->
        <!--            icon="Edit"-->
        <!--            :disabled="pageF.single"-->
        <!--            v-hasPermi="['tms:tmsApBill:edit']"-->
        <!--            @click="handleUpdate">修改-->
        <!--        </el-button>-->
        <!--        <el-button-->
        <!--            type="danger"-->
        <!--            icon="Delete"-->
        <!--            :disabled="pageF.multiple"-->
        <!--            @click="handleDelete"-->
        <!--            v-hasPermi="['tms:tmsApBill:remove']"-->
        <!--        >删除-->
        <!--        </el-button>-->
        <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['tms:tmsApBill:export']">导出
        </el-button>
      </template>
      <template #menu="{ row }">
        <!-- <el-link size="small" type="primary" v-if="row.status != 2"
                 @click="handleJs(row)" class="link-btn" :underline="false"
                 icon="el-icon-tickets">结算
        </el-link> -->
        <el-link size="small" type="primary" v-if="row.pushStatus == 3 || row.pushStatus == 4|| row.pushStatus == 0"
          @click="handleManualPush(row)" class="link-btn" underline="never" icon="el-icon-upload">手动推送
        </el-link>
        <el-link size="small" type="primary" v-if="row.status == 0" @click="handleEdit(row)" class="link-btn"
          :underline="false" icon="el-icon-edit">账单确认
        </el-link>
        <el-link size="small" type="primary" @click="handleView(row)" class="link-btn" :underline="false"
          icon="el-icon-view">查看
        </el-link>
        <!-- <el-link size="small" type="primary" @click="handleLog(row)" class="link-btn" :underline="false"
          icon="el-icon-tickets">日志
        </el-link> -->
 
        <el-link size="small" type="primary" @click="handleFlow(row)" class="link-btn" underline="never"
          icon="el-icon-document">
          审核日志
        </el-link>
      </template>
    </avue-crud>
 
    <el-dialog :title="pageF.title" v-model="pageF.open" class="avue-dialog avue-dialog--top" width="80%">
 
      <avue-form v-if="opt == 'js'" v-model="boxForm" ref="boxFormRef" :option="boxFormOption">
        <template #settleAmount>
          <avue-input-number :min="0" :max="form.actualSettlementAmount" v-model="boxForm.settleAmount"
            placeholder="请输入结算金额"></avue-input-number>
 
        </template>
      </avue-form>
      <el-descriptions :column="3" title="账单基本信息" border>
        <el-descriptions-item label="账单系统编号">{{ form.systemNo }}</el-descriptions-item>
        <el-descriptions-item label="账单名称">
          <div v-if="opt === 'edit'">
            <el-input v-model="form.billName" placeholder="请输入账单名称" />
          </div>
          <div v-else>{{ form.billName }}</div>
        </el-descriptions-item>
        <el-descriptions-item label="客户名称">{{ form.customerName }}</el-descriptions-item>
        <el-descriptions-item label="应结算金额">{{ form.settleAmount }}</el-descriptions-item>
        <el-descriptions-item label="减免金额">
          <div v-if="opt === 'edit'">
            <el-input-number :max="form.settleAmount" v-model="form.deductionAmount" placeholder="请输入减免金额"
              @change="deductionAmountChange" />
          </div>
          <div v-else>{{ form.deductionAmount }}</div>
        </el-descriptions-item>
        <el-descriptions-item label="实际结算金额" v-if="opt == 'edit'">{{ form.actualSettlementAmount }}</el-descriptions-item>
        <el-descriptions-item label="减免原因" v-if="opt == 'edit'">
          <div v-if="opt === 'edit'">
            <el-input v-model="form.reasonReduction" placeholder="请输入减免原因" />
          </div>
          <div v-else>{{ form.reasonReduction }}</div>
        </el-descriptions-item>
        <el-descriptions-item label="已结算金额" v-if="opt == 'js'">{{ form.settledAmount }}</el-descriptions-item>
        <el-descriptions-item label="待结算金额" v-if="opt == 'js'">{{ Number(form.settleAmount) -
          Number(form.settledAmount)}}</el-descriptions-item>
      </el-descriptions>
      <h3>关联明细</h3>
      <avue-crud :option="YSGenerateTableOption" ref="itemsTableRef" :data="form.items">
        <template #menu="{ row }">
          <el-link size="small" type="primary" @click="handleCancel(row)" class="link-btn" :underline="false"
            icon="el-icon-close">取消关联
          </el-link>
        </template>
 
      </avue-crud>
 
 
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" :loading="pageF.isUploading" v-if="opt == 'js'" @click="jsSubmit">确定</el-button>
          <el-button type="primary" :loading="pageF.isUploading" v-if="opt == 'edit'" @click="editSubmit">确定</el-button>
          <el-button @click="pageF.open = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog :title="pageF.title" v-model="open2" class="avue-dialog avue-dialog--top" width="80%">
 
      <avue-crud :option="logTableOption" ref="itemsTableRef2" :data="logTable">
 
      </avue-crud>
 
 
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="open2 = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>
 
 
  </basicContainer>
      <flowLogA ref="flowLogIshow" :isShow="true"  title="审核日志" :flowParams="flowParams"></flowLogA>
</template>
 
<script setup name="tmsApBill" lang="ts">
import {
  TmsApBillI,
  addTmsApBill,
  delTmsApBill,
  exportTmsApBill,
  getTmsApBill,
  listTmsApBill,
  updateTmsApBill, manualPushTmsApBill,getPayableAuditLog
} from "@/api/tms/tmsApBill";
import useCurrentInstance from "@/utils/useCurrentInstance";
import { computed, reactive, ref, toRefs } from "vue";
import { PagesInterface, PageQueryInterface } from "@/utils/globalInterface";
import { usePagePlus } from "@/hooks/usePagePlus";
import { hasPermission } from "@/utils/permissionUtils";
import { cancelArBill, getTmsArBill } from "@/api/tms/tmsArBill";
import { ElMessage, ElMessageBox } from "element-plus";
 
const { proxy } = useCurrentInstance();
const crudRef = ref();
 
const permissionList = computed(() => {
  return {
    addBtn: hasPermission(["tms:tmsApBill:add"]),
    delBtn: hasPermission(["tms:tmsApBill:remove"]),
    editBtn: hasPermission(["tms:tmsApBill:edit"]),
    viewBtn: hasPermission(["tms:tmsApBill:query"]),
  }
})
 
const data = reactive({
  form: <TmsApBillI>{},
  queryParams: <TmsApBillI & PageQueryInterface>{},
  page: <PagesInterface>{
    pageSize: 10,
    total: 0,
    currentPage: 1,
  },
  selectionList: [],
  opt: '',
  boxForm: <any>{},
  open2: false
})
const { queryParams, form, page, selectionList, opt, boxForm, open2 } = toRefs(data);
const option = ref({
  pageKey: 'TmsApBill',
  rowKey: 'id',
  viewBtn: false,
  addBtn: false,
  editBtn: false,
  delBtn: false,
  searchLabelWidth: 120,
  column: {
    // id: {
    //   label: '',
    //   addDisplay: true,
    //   editDisplay: false,
    //   viewDisplay: false,
    //   hide: true,
    //   search: false,
    // },
    systemNo: {
      label: '系统编号',
      hide: false, minWidth: 150,
      search: true,
    },
    billName: {
      label: '账单名称',
      hide: false,
      search: true, minWidth: 220,
      showOverflowTooltip: true
    },
    serviceProviderName: {
      label: '供应商名称',
      hide: false,
      search: true, minWidth: 220,
      showOverflowTooltip: true
 
    },
    dispatchCount: {
      label: '调度单数量',
      hide: false,
      search: false, minWidth: 120,
    },
    settleAmount: {
      label: '应结算金额', minWidth: 120,
      hide: false,
      search: false,
    },
    deductionAmount: {
      label: '减免金额', minWidth: 120,
      hide: false,
      search: false,
    },
    actualSettlementAmount: {
      label: '实际结算金额',
      hide: false,
      search: false, minWidth: 120,
    },
    settledAmount: {
      label: '已结算金额',
      hide: false,
      search: false, minWidth: 120,
    },
    pushTime: {
      label: '推送时间', display: false, searchRange: true, type: 'date',
      format: 'YYYY-MM-DD', hide: false, searchSpan: 6, minWidth: 150,
      valueFormat: 'YYYY-MM-DD',
    },
    invoiceStatus: {
      label: '开票状态', minWidth: 120, fixed: 'right',
      type: 'radio', dataType: 'string', dicUrl: '/system/dict/data/type/invoice_status',
 
      hide: false,
      search: true,
    },
    status: {
      label: '状态', minWidth: 120, fixed: 'right',
      type: 'radio', dataType: 'string', dicUrl: '/system/dict/data/type/ar_bill_status',
 
      hide: false,
      search: true,
    },
    pushStatus: {
      label: '推送状态',
      minWidth: 120,
      type: 'radio', dataType: 'string', dicUrl: '/system/dict/data/type/sys_push_status',
      hide: false,
      search: true,
      fixed: 'right'
    }
 
  }
})
 
const {
  tableData,
  pageF,
  rowSave,
  rowUpdate,
  rowDel,
  beforeOpen,
  searchChange,
  searchReset,
  selectionChange,
  onLoad,
  currentChange,
  sizeChange,
  handleDelete,
  handleExport,
  handleUpdate,
  refreshChange
} = usePagePlus({
  form: form,
  option: option,
  queryParams: queryParams,
  idKey: 'id',
  page: page.value,
  getListApi: listTmsApBill,
  getDetailApi: getTmsApBill,
  exportApi: exportTmsApBill,
  deleteApi: delTmsApBill,
  addApi: addTmsApBill,
  updateApi: updateTmsApBill,
  handleUpdateFunc: () => {
    crudRef.value.rowEdit(selectionList.value[0]);
  },
  handleSelectionChangeFunc: (selection: any) => {
    selectionList.value = selection;
  }
})
 
const YSGenerateTableOption = ref({
  menu: true,
  add: false,
  header: false,
  selection: false,
  rowKey: 'id',
  editBtn: false,
  viewBtn: false,
  delBtn: false,
  column: {
 
    projectName: {
      label: '项目名称',
    },
    dispatchNo: {
      label: '调度单号',
    },
    orderTime: {
      label: '下单时间',
    },
 
    estimateAmount: {
      label: '预估应收金额',
    },
    currency: {
      label: '币制',
    }
  }
})
 
 
const boxFormOption = ref({
  menuBtn: false,
  labelWidth: 120,
  column: {
 
    settleAmount: {
      label: '本次结算金额',
      type: 'number',
      display: true,
      rules: [
        {
          required: true,
          message: "金额不能为空", trigger: "change"
        }
      ],
    },
    remark: {
      label: '备注',
      display: true,
    },
    attachment: {
      label: '附件',
      display: true,
      span: 24,
      accept: 'string', dataType: 'string',
      type: 'upload',
      action: '/common/upload2',
    },
 
  }
})
const boxFormRef = ref();
const logTableOption = ref({
  menu: false,
  add: false,
  header: false,
  selection: false,
  rowKey: 'id',
 
  column: {
 
    settleAmount: {
      label: '结算金额',
    },
    createBy: {
      label: '处理人员',
    },
    attachment: {
      label: '附件下载',
      dataType: 'string',
      type: 'img'
    },
 
    remark: {
      label: '备注',
    },
    createTime: {
      label: '提交时间',
    },
  }
})
const logTable = ref<any>()
 
const handleJs = (row: any) => {
 
}
 
const handleView = (row: any) => {
  form.value.items = [];
  getTmsApBill(row.id).then((res: any) => {
    form.value = res.data || {};
    pageF.open = true;
    pageF.title = '应付账单确认';
    opt.value = 'edit'
  })
}
const handleLog = (row: any) => {
 
}
const handleEdit = (row: any) => {
  form.value.items = [];
  getTmsApBill(row.id).then((res: any) => {
    form.value = res.data || {};
    pageF.open = true;
    pageF.title = '应付账单确认';
    opt.value = 'edit'
  })
}
 
const jsSubmit = () => {
 
}
 
const editSubmit = () => {
 
}
const deductionAmountChange = (e: any) => {
  form.value.actualSettlementAmount = (Number(form.value.settleAmount) || 0) - (Number(form.value.deductionAmount) || 0);
}
const handleCancel = (row: any) => {
  ElMessageBox.confirm("是否对调度单号" + row.dispatchNo + "的应付费用取消关联?", '系统提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    return cancelArBill(row.id);
  }).then(() => {
    onLoad(page.value);
    ElMessage({
      message: "操作成功!",
      type: 'success'
    })
  });
}
const handleManualPush = (row: any) => {
  ElMessageBox.confirm(`确定要将账单【${row.billName}】手动推送到财务系统吗?`, '系统提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'info'
  }).then(() => {
    // 调用推送接口
    return manualPushTmsApBill(row.id);
  }).then((res) => {
    proxy.$message.success(res.msg);
    onLoad(page.value); // 刷新列表
  }).catch(() => {
    // 取消操作
  });
}
 
const flowLogIshow = ref()
const flowParams = ref([])
 
const handleFlow = (row: any) => {
  let data = {
    headId: row.id,
  }
  getPayableAuditLog(data).then((res) => {
    flowParams.value = res.rows
    flowLogIshow.value.openModel()
 
  })
}
</script>