TrackEdit.vue
3.6 KB
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
<template>
<template>
<BasicDrawer
@register="register"
v-bind="$attrs"
title="收入款单"
width="30%"
:isDetail="true"
@ok="handleSubmit"
@visible-change="handleShow"
:showDetailBack="false"
okText="保存"
showFooter
:destroyOnClose="true"
>
<div>
<div style="font-size: 15px">客户扣款金额$</div>
<a-input v-model:value="input1" placeholder="请输入" :disabled="status === 10" auto-size />
<div style="margin: 16px 0"></div>
<div>上传扣款单</div
><a-space direction="vertical" style="width: 100%" size="large">
<a-upload
v-model:file-list="fileList"
:beforeUpload="beforeUpload"
list-type="picture"
:max-count="1"
:action="updateDeductUrl"
@change="handleChange"
:disabled="status === 10"
>
<a-button> 上传扣款单 </a-button>
</a-upload>
</a-space>
</div>
<!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
<template #appendFooter>
<!-- <a-button type="primary" @click="onGoCheckDetail"> 申请权限</a-button> -->
</template>
</BasicDrawer>
</template>
</template>
<script lang="ts" setup>
import { BasicDrawer, useDrawerInner } from '@/components/Drawer';
import { defineComponent, ref, computed, unref, toRaw, reactive } from 'vue';
import { getEmailList } from '/@/api/sys/config';
import { UploadOutlined } from '@ant-design/icons-vue';
import type { UploadProps } from 'ant-design-vue';
import { updateDeduct } from '@/api/project/invoice';
import { useMessage } from '/@/hooks/web/useMessage';
const emit = defineEmits(['success']);
const fileList = ref<UploadProps['fileList']>([]);
const input1 = ref(0);
const deductUrl = ref();
const id = ref();
const invoiceNo = ref();
const uploadUrl = ref('http://47.104.8.35:8081/api/localStorage/upload_file_oss?name=');
const updateDeductUrl = ref('http://47.104.8.35:8081/api/localStorage/upload_file_oss?name=');
const deductUrlOld = ref();
const { createMessage } = useMessage();
const { error } = createMessage;
const status = ref();
const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => {
status.value = data.data.status;
id.value = data.data.id;
invoiceNo.value = data.data.invoiceNo;
input1.value = data.data.deductAmount;
deductUrl.value = data.data.deductUrl;
deductUrlOld.value = data.data.deductUrl;
});
function handleChange(info) {
if (info.file.status == 'done') {
updateDeductUrl.value = info.file.response.data.fileUrl;
deductUrl.value = updateDeductUrl.value;
}
if (info.fileList.length == 0) {
info.file = null;
deductUrl.value = '';
}
}
function beforeUpload(info) {
updateDeductUrl.value = uploadUrl.value + info.name;
}
function handleShow() {
// if (!visible) {
// input1.value = 0;
// deductUrl.value = '';
// updateDeductUrl.value = '';
// fileList.value = [];
// }
// input1.value = '';
// deductUrl.value = '';
// updateDeductUrl.value = '';
// fileList.value = [];
}
//完成编辑
async function handleSubmit() {
if (!input1.value) {
error('选项不能为空');
} else {
await updateDeduct({
id: id.value,
invoiceNo: invoiceNo.value,
deductAmount: input1.value,
deductUrl: deductUrl.value,
});
fileList.value = [];
emit('success');
closeDrawer();
}
}
</script>