zhangback
2025-11-18 3479ad5223c328be72a2b26ab66f9aeee64ec4b5
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
<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:tmsFinance:edit']"-->
        <!--            @click="handleUpdate">修改-->
        <!--        </el-button>-->
        <!--        <el-button-->
        <!--            type="danger"-->
        <!--            icon="Delete"-->
        <!--            :disabled="pageF.multiple"-->
        <!--            @click="handleDelete"-->
        <!--            v-hasPermi="['tms:tmsFinance:remove']"-->
        <!--        >删除-->
        <!--        </el-button>-->
        <el-button
            type="warning"
            plain
            icon="Download"
            @click="handleExport"
            v-hasPermi="['tms:tmsFinance:export']"
        >导出
        </el-button>
      </template>
      <template #menu-before="{row}">
        <el-link size="small" type="primary" v-if="row.status == 0" @click="handleConfirm(row)" class="link-btn"
                 :underline="false" icon="el-icon-pointer">确认
        </el-link>
        <el-link size="small" type="primary" v-if="[0,1].includes(row.status)" @click="handleCancel(row)" class="link-btn" :underline="false"
                 icon="el-icon-connection">作废
        </el-link>
        <el-link size="small" type="primary" v-if="[0,1].includes(row.status)" @click="handleAddFinanceDetail(row)" class="link-btn"
                 :underline="false" icon="el-icon-edit-pen">费用明细
        </el-link>
      </template>
    </avue-crud>
    <el-dialog :title="pageF.title" v-model="pageF.open" class="avue-dialog avue-dialog--top" width="80%">
      总费用 <el-input-number v-model="form.totalAmount" disabled readonly></el-input-number>
      <avue-crud style="margin-top: 10px "
          :option="financeTableOption"
          :data="boxTableData"
                 :permission="permissionList2"
                 @row-update="rowDetailUpdate"
                 @row-save="rowDetailSave"
      >
        <template #menu="{row}">
          <el-link size="small" type="primary" v-if="[0].includes(row.status)" @click="handleCancelDetail(row)" class="link-btn" :underline="false"
                   icon="el-icon-connection">作废
          </el-link>
        </template>
      </avue-crud>
    </el-dialog>
    
  </basicContainer>
</template>
 
<script setup name="tmsFinance" lang="ts">
import {
  TmsFinanceI,
  addTmsFinance,
  delTmsFinance,
  exportTmsFinance,
  getTmsFinance,
  listTmsFinance,
  updateTmsFinance,confirmFinance,cancelFinance
} from "@/api/tms/tmsFinance";
import {addTmsFinanceDetail, listTmsFinanceDetail,
  cancelFinanceDetail,
  updateTmsFinanceDetail} from "@/api/tms/tmsFinanceDetail"
 
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 {ElMessage, ElMessageBox} from "element-plus";
import {confirmOrder} from "@/api/tms/tmsDispatchOrder";
 
const {proxy} = useCurrentInstance();
const crudRef = ref();
 
const permissionList = computed(() => {
  return {
    addBtn: hasPermission(["tms:tmsFinance:add"]),
    delBtn: hasPermission(["tms:tmsFinance:remove"]),
    editBtn: hasPermission(["tms:tmsFinance:edit"]),
    viewBtn: hasPermission(["tms:tmsFinance:query"]),
  }
})
 
const permissionList2 = (key: any, row: any, index: any) => {
  if (key == 'addBtn') {
    return true
  }else if (key == 'editBtn') {
    return  [0].includes(row?.status)
  } else {
    return true;
  }
};
const data = reactive({
  form: <TmsFinanceI>{},
  queryParams: <TmsFinanceI & PageQueryInterface>{},
  page: <PagesInterface>{
    pageSize: 10,
    total: 0,
    currentPage: 1,
  },
  selectionList: [],
  boxTableData: []
})
const {queryParams, form, page, selectionList,boxTableData} = toRefs(data);
const option = ref({
  pageKey: 'TmsFinance',
  rowKey: 'id',
  addBtn: false,
  editBtn: false,
  delBtn: false,
  viewBtn: false,
  column: {
 
    systemCode: {
      label: '系统编号',
      hide: false,minWidth: 180,
      search: true,
    },
    dispatchNo: {
      label: '调度单号',minWidth: 150,
      search: true,
    },
    planName: {
      label: '应收方案名称',minWidth: 150,
      search: true,
    },
    customerName: {
      label: '客户',minWidth: 150,
      search: true,
    },
    projectName: {
      label: '项目名称',minWidth: 150,
      search: true,
    },
    vehicleProviderName: {
      label: '车辆服务商',minWidth: 150,
      search: false,
    },
    requiredVehicleTypes: {
      label: '要求车型',minWidth: 150,
      search: false,
      display: true, type: 'select', dicUrl: '/system/dict/data/type/license_type', dataType: 'string',
 
    },
    actualVehicleType: {
      label: '实际车型',minWidth: 150,
      search: false,
      display: true, type: 'select', dicUrl: '/system/dict/data/type/license_type', dataType: 'string',
    },
    mainDriverName: {
      label: '主驾驶员',minWidth: 150,
      search: false,
    },
 
    licensePlate: {
      label: '车牌号',minWidth: 150,
      search: false,
    },
 
    transportLine: {
      label: '运输线路',minWidth: 150, overHidden: true,
      search: false,
    },
 
    shipperName: {
      label: '发货人名称',minWidth: 150,
      search: false,
    },
    shipperRegionLabel: {
      label: '发货行政区域',minWidth: 150,
      search: false,
    },
 
    receiverName: {
      label: '收货人名称',
      search: false,minWidth: 150,
    },
    receiverRegionLabel: {
      label: '收货行政区域',
      search: false,minWidth: 150,
    },
    totalAmount: {
      label: '总金额',minWidth: 150,
      search: false,
    },
    confirmBy: {
      label: '费用确认人',minWidth: 150,
      search: false,
    },
    confirmTime: {
      label: '费用确认时间',minWidth: 180,
      search: false,
    },
    status: {
      label: '状态',minWidth: 150,
      search: false,fixed: 'right',
      display: true, type: 'select', dicUrl: '/system/dict/data/type/finance_status', dataType: 'string',
 
    },
    updateBy: {
      label: '更新人',
      search: false,minWidth: 150,
    },
    updateTime: {
      label: '更新时间',
      search: false,minWidth: 180,
    },
  }
})
 
 
const financeTableOption = ref({
  menu: true,
  addBtn: true,
  header: true, selection: false,
  viewBtn: false,
  delBtn: false,labelWidth:150,
  column: {
    feeType: {
      label: '费用名称',minWidth: 150,
      display: true,disabled: true,
      value: "99",
      type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/fee_type',
    },
    initialFeeAmount: {
      label: '初始登记费用金额',minWidth: 150,
      display: true,disabled: true,type: 'number',
    },
    actualFeeAmount: {
      label: '实际费用金额',minWidth: 150, type: 'number',
      display: true,
      rules: [
        {
          required: true,
          message: "实际费用金额不能为空", trigger: "change"
        }
      ],
    },
    feeVoucherUrl: {
      label: '费用凭证',
      display: true, hide:true,
      accept:'string',dataType: 'string',
      type: 'upload',
      action: '/common/upload2',
      propsHttp:{
        url: 'url',
        name: 'name',
        res: 'data',
      },
    },
    feeCreateTime: {
      label: '费用创建时间',minWidth: 180,
      display: false,
    },
    updateBy: {
      label: '更新人',minWidth: 150,
      display: false,
    },
    updateTime: {
      label: '更新时间',minWidth: 180,
      display: false,
 
    },
    status: {
      label: '状态',minWidth: 150, fixed: 'right',
      display: false,
      type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/finance_detail_status',
    },
  }
})
 
 
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: listTmsFinance,
  getDetailApi: getTmsFinance,
  exportApi: exportTmsFinance,
  deleteApi: delTmsFinance,
  addApi: addTmsFinance,
  updateApi: updateTmsFinance,
  handleUpdateFunc: () => {
    crudRef.value.rowEdit(selectionList.value[0]);
  },
  handleSelectionChangeFunc: (selection: any) => {
    selectionList.value = selection;
  },
  getBeginListFunc:()=>{
    queryParams.value.type = 0;
  }
})
 
const handleConfirm = (row: any) => {
  ElMessageBox.confirm("是否对调度单号" + row.dispatchNo + "的应收方案进行确认 ?", '系统提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    return confirmFinance(row.id);
  }).then(() => {
    onLoad(page.value);
    ElMessage({
      message: "操作成功!",
      type: 'success'
    })
  });
}
const handleCancel = (row: any) => {
  ElMessageBox.confirm("是否对调度单号" + row.dispatchNo + "的应收方案进行作废?", '系统提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    return cancelFinance(row.id);
  }).then(() => {
    onLoad(page.value);
    ElMessage({
      message: "操作成功!",
      type: 'success'
    })
  });
}
 
const handleAddFinanceDetail = (row:any) => {
 
  listTmsFinanceDetail({financeId:row.id,pageNum:1,pageSize: 9999}).then(res=>{
    boxTableData.value = res.rows || [];
    pageF.title = '费用明细';
    pageF.open = true;
    form.value = row;
  })
}
 
const rowDetailUpdate = (row:any,index:any,done:any, loading:any) => {
  updateTmsFinanceDetail( row).then(res=>{
    ElMessage({
      message: "修改成功!",
      type: 'success'
    })
    handleAddFinanceDetail(res.data);
    onLoad(page.value);
    done();
  }).catch(()=>{
    loading()
  })
}
const rowDetailSave = (row:any, done:any, loading:any) => {
row.financeId = form.value.id;
addTmsFinanceDetail({...row,dispatchOrderId:form.value.dispatchId,
  type: form.value.type,financeType:form.value.type
}).then(res=>{
  ElMessage({
    message: "新增成功!",
    type: 'success'
  })
  handleAddFinanceDetail(res.data);
  onLoad(page.value);
  done();
}).catch(()=>{
  loading()
})
}
 
const handleCancelDetail = (row: any) => {
  ElMessageBox.confirm("是否作废掉 " + row.$feeType + "确定 ?", '系统提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    return cancelFinanceDetail(row.id);
  }).then(() => {
    handleAddFinanceDetail(form.value);
    onLoad(page.value);
    ElMessage({
      message: "操作成功!",
      type: 'success'
    })
  });
}
 
</script>