ZN
4 天以前 1f0a0a7059d3ac240857ecf8612f9e6cb422b4d8
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
<template>
  <el-dialog v-model="visible" title="收款/退款" width="90%" append-to-body>
    <div class="section">
      <div class="section-title descriptions">基础资料</div>
      <el-form :model="form" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="单据编号">
              <el-input v-model="form.billNo" placeholder="使用系统编号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户">
              <el-select v-model="form.customerId" placeholder="请选择">
                <el-option v-for="c in customerOptions" :key="c.value" :label="c.label" :value="c.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="制单人">
              <el-select v-model="form.makerId" placeholder="请选择">
                <el-option v-for="u in userOptions" :key="u.value" :label="u.label" :value="u.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="制单日期">
              <el-date-picker v-model="form.makeDate" type="date" value-format="YYYY-MM-DD" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="申请部门">
              <el-select v-model="form.applyDeptId" placeholder="请选择">
                <el-option v-for="d in deptOptions" :key="d.value" :label="d.label" :value="d.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注">
              <el-input v-model="form.remark" maxlength="100" show-word-limit placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="附件">
              <el-upload :action="uploadUrl" :headers="uploadHeaders" name="files" :on-success="onUploadSuccess">
                <el-button>上传文件</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
 
    <div class="section">
      <div class="toolbar">
      <div class="section-title descriptions">付款列表</div>
        <el-input v-model="form.discountAmount" placeholder="优惠金额" style="width:240px" />
      </div>
      <el-table :data="form.paymentList" border>
        <el-table-column label="付款账号" minWidth="160">
          <template #default="scope">
            <el-input v-model="scope.row.accountNo" placeholder="请输入" />
          </template>
        </el-table-column>
        <el-table-column label="付款账号名称" minWidth="180">
          <template #default="scope">
            <el-select v-model="scope.row.accountName" placeholder="请选择">
              <el-option v-for="a in accountOptions" :key="a.value" :label="a.label" :value="a.label" />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="付款方式" minWidth="140">
          <template #default="scope">
            <el-select v-model="scope.row.payMethod" placeholder="请选择">
              <el-option v-for="m in payMethodOptions" :key="m.value" :label="m.label" :value="m.value" />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="实际付款金额" minWidth="160">
          <template #default="scope">
            <el-input v-model="scope.row.amount" placeholder="请输入" />
          </template>
        </el-table-column>
        <el-table-column label="手续费" minWidth="140">
          <template #default="scope">
            <el-input v-model="scope.row.fee" placeholder="请输入" />
          </template>
        </el-table-column>
        <el-table-column label="交易号/票据号" minWidth="180">
          <template #default="scope">
            <el-input v-model="scope.row.txNo" placeholder="请输入" />
          </template>
        </el-table-column>
        <el-table-column label="备注" minWidth="200">
          <template #default="scope">
            <el-input v-model="scope.row.remark" maxlength="30" show-word-limit placeholder="请输入" />
          </template>
        </el-table-column>
        <el-table-column label="操作" minWidth="120" fixed="right">
          <template #default="scope">
            <el-button link type="primary" @click="addPayment">新增一行</el-button>
            <el-button link type="danger" @click="removePayment(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="summary">合计</div>
    </div>
 
    <div class="section">
      <div class="section-container">
        <div class="section-title descriptions">源单信息</div>
      <div class="source-toolbar">
        <el-button @click="clearSource">清空</el-button>
        <el-button @click="selectSource">选择源单</el-button>
        <el-button type="primary" @click="autoWriteOff">自动核销</el-button>
      </div>
      </div>
      <el-table :data="form.sourceList" border>
        <el-table-column label="单据日期" minWidth="160" prop="billDate" />
        <el-table-column label="单据类型" minWidth="160" prop="billType" />
        <el-table-column label="单据编号" minWidth="200" prop="billNo" />
        <el-table-column label="单据金额" minWidth="120" prop="billAmount" />
        <el-table-column label="已核销金额" minWidth="120" prop="wroteAmount" />
        <el-table-column label="未核销金额" minWidth="120" prop="unWroteAmount" />
        <el-table-column label="本次核销金额" minWidth="160">
          <template #default="scope">
            <el-input v-model="scope.row.thisWriteOffAmount" />
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100" fixed="right">
          <template #default="scope">
            <el-button link type="danger" @click="removeSource(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="summary">合计</div>
    </div>
 
    <template #footer>
      <el-button type="primary" @click="submit">确认</el-button>
      <el-button @click="visible=false">取消</el-button>
    </template>
  </el-dialog>
</template>
 
<script setup>
import { ref } from 'vue';
import { getToken } from '@/utils/auth';
 
const visible = ref(false);
const form = ref({
  billNo: '',
  customerId: undefined,
  makerId: undefined,
  makeDate: '',
  applyDeptId: undefined,
  remark: '',
  discountAmount: '',
  paymentList: [{ accountNo: '', accountName: '', payMethod: '', amount: '', fee: '', txNo: '', remark: '' }],
  sourceList: [{ billDate: '', billType: '', billNo: '', billAmount: 0, wroteAmount: 0, unWroteAmount: 0, thisWriteOffAmount: '' }]
});
 
const customerOptions = ref([]);
const userOptions = ref([]);
const deptOptions = ref([]);
const accountOptions = ref([]);
const payMethodOptions = ref([]);
 
const uploadUrl = import.meta.env.VITE_APP_BASE_API + '/basic/customer-follow/upload';
const uploadHeaders = { Authorization: 'Bearer ' + getToken() };
 
function addPayment() {
  form.value.paymentList.push({ accountNo: '', accountName: '', payMethod: '', amount: '', fee: '', txNo: '', remark: '' });
}
function removePayment(i) {
  form.value.paymentList.splice(i, 1);
}
function removeSource(i) {
  form.value.sourceList.splice(i, 1);
}
function clearSource() {
  form.value.sourceList = [];
}
function selectSource() {}
function autoWriteOff() {}
function onUploadSuccess() {}
 
function open(payload) {
  visible.value = true;
}
function submit() {
  visible.value = false;
  emit('submitted');
}
 
defineExpose({ open });
</script>
 
<style scoped>
.section { background: #fff; border-radius: 8px; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.05); padding: 16px; margin-bottom: 16px; }
.section-title { font-weight: 600; margin-bottom: 12px; }
.descriptions {
  margin-bottom: 20px;
  display: inline-block;
  font-size: 1rem;
  font-weight: 600;
  padding-left: 12px;
  position: relative;
}
.descriptions::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1rem;
  background-color: #002FA7;
  border-radius: 2px;
}
.toolbar { margin-bottom: 10px; display: flex;     justify-content: space-between;
    align-items: center; }
.source-toolbar { margin-bottom: 10px; display: flex; gap: 8px; }
.summary { padding: 8px 12px; background: #fff7e6; color: #ad6800; }
.section-container{display: flex;align-items: center;justify-content: space-between; }
</style>