123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669 |
- <template>
- <div class="app-container">
- <!-- 查询和其他操作 -->
- <div class="filter-container">
- <el-input
- v-model="listQuery.type.receivingWithdrawingPeople"
- clearable
- class="filter-item"
- size="small"
- style="width: 200px;"
- placeholder="请输入收款人姓名" />
- <!-- <el-input v-model="listQuery.type.receivingWithdrawingRegion" clearable class="filter-item" size="small"
- style="width: 200px;" placeholder="请输入收款地" /> -->
- <!-- <el-input v-model="listQuery.receiptPaymentDate" clearable class="filter-item" size="small"
- style="width: 200px;" placeholder="请输入收款日期" /> -->
- <el-select
- v-model="listQuery.type.receivingWithdrawingRegion"
- placeholder="请选择收款地"
- style="margin:0 20px;"
- size="small">
- <el-option v-for="(item, index) in placeList" :label="item.country" :value="item.country" :key="index"/>
- </el-select>
- <el-date-picker
- v-model="selectDate"
- style="margin-right:20px"
- size="small"
- type="daterange"
- value-format="yyyy-MM-dd"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"/>
- <el-button
- v-permission="['collectionPayment:collectionpayment:list']"
- class="filter-item"
- type="primary"
- size="mini"
- icon="el-icon-search"
- @click="handleFilter">查找</el-button>
- <el-button
- v-permission="['collectionPayment:collectionpayment:create']"
- class="filter-item"
- type="primary"
- size="mini"
- icon="el-icon-edit"
- @click="handleCreate">添加</el-button>
- <el-button
- v-permission="['collectionPayment:collectionpayment:create']"
- class="filter-item"
- type="primary"
- size="mini"
- icon="el-icon-edit"
- @click="exportlist">导出</el-button>
- <el-upload
- :on-change="importClick"
- :show-file-list="false"
- :auto-upload="false"
- style="margin-left: 8px;margin-bottom:0"
- class="filter-item"
- action=""
- accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel">
- <el-button
- v-permission="['collectionPayment:collectionpayment:create']"
- class="filter-item"
- type="primary"
- size="mini"
- icon="el-icon-edit">导入</el-button>
- </el-upload>
- </div>
- <!-- 查询结果 -->
- <el-table
- v-loading="listLoading"
- :data="list"
- :summary-method="getSummaries"
- size="small"
- element-loading-text="正在查询中。。。"
- border
- fit
- highlight-current-row
- show-summary
- @selection-change="handleSelectionChange">
- <el-table-column :selectable="selectInit" type="selection"/>
- <el-table-column type="index" label="序号">
- <template scope="scope">
- <span v-if="scope.$index < 9">0{{ scope.$index + 1 }}</span>
- <span v-else>{{ scope.$index + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" label="收款日期" prop="receiptPaymentDate">
- <template slot-scope="scope">
- {{ scope.row.receiptPaymentDate }}</template>
- </el-table-column>
- <el-table-column align="center" label="收款地" prop="receivingWithdrawingRegion" />
- <el-table-column align="center" label="付款人" prop="receivingWithdrawingPeople" />
- <el-table-column align="center" label="金额(欧元)" prop="deductionEuro" />
- <el-table-column align="center" label="金额(人民币)" prop="deductionRmb" />
- <el-table-column align="center" label="备注1" prop="remarks" />
- <el-table-column align="center" label="备注2" prop="remark" />
- <el-table-column align="center" label="状态" prop="status">
- <template slot-scope="scope">
- {{ scope.row.status == 1 ? '已作废' : '' }}</template>
- </el-table-column>
- <el-table-column align="center" label="操作人" prop="updatePeople" />
- <!-- <el-form-item label="操作人" prop="updatePeople">
- <el-input v-model="dataForm.updatePeople" />
- </el-form-item> -->
- <el-table-column align="center" label="操作" class-name="small-padding" width="250px">
- <template slot-scope="scope">
- <el-button
- v-permission="['collectionPayment:collectionpayment:edit']"
- type="primary"
- size="mini"
- @click="handleUpdate(scope.row)">编辑</el-button>
- <el-button
- v-permission="['collectionPayment:collectionpayment:edit']"
- type="primary"
- size="mini"
- @click="updateData1(scope.row)">作废</el-button>
- <!-- <el-button v-permission="['collectionPayment:collectionpayment:delete']" type="danger" size="mini"
- @click="handleDelete(scope.row)">删除</el-button> -->
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- :current-page="currentPage"
- :page-sizes="[100, 200, 300, 400,1000,1500,2000]"
- :page-size="100"
- :total="total"
- layout="total, sizes, prev, pager, next, jumper"
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"/>
- <!-- 添加或修改对话框 -->
- <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
- <el-form
- ref="dataForm"
- :rules="rules"
- :model="dataForm"
- status-icon
- label-position="left"
- label-width="150px"
- style="width: 400px; margin-left:50px;">
- <el-form-item label="id" prop="id" hidden>
- <el-input v-model="dataForm.id" />
- </el-form-item>
- <el-form-item label="付款人" prop="receivingWithdrawingPeople">
- <el-input v-model="dataForm.receivingWithdrawingPeople" />
- </el-form-item>
- <el-form-item label="收款地" prop="receivingWithdrawingRegion">
- <!-- <el-input v-model="dataForm.receivingWithdrawingRegion" /> -->
- <el-select v-model="dataForm.receivingWithdrawingRegion" placeholder="请选择收款地点" style="width:100%">
- <el-option
- v-for="(item, index) in placeList"
- :label="item.country"
- :value="item.country"
- :key="index"/>
- </el-select>
- </el-form-item>
- <el-form-item label="收款日期" prop="receiptPaymentDate">
- <!-- <el-input v-model="dataForm.receiptPaymentDate" /> -->
- <el-date-picker
- v-model="dataForm.receiptPaymentDate"
- type="date"
- class="tkdate"
- value-format="yyyy-MM-dd"
- style="width: 100%;"/>
- </el-form-item>
- <el-form-item label="金额(欧元)" prop="deductionEuro">
- <el-input v-model="dataForm.deductionEuro" />
- </el-form-item>
- <el-form-item label="金额(人民币)" prop="deductionRmb">
- <el-input v-model="dataForm.deductionRmb" />
- </el-form-item>
- <el-form-item label="备注1" prop="remarks">
- <el-input v-model="dataForm.remarks" />
- </el-form-item>
- <el-form-item label="备注2" prop="remark">
- <el-input v-model="dataForm.remark" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogFormVisible = false">取消</el-button>
- <el-button v-if="dialogStatus == 'create'" :loading="submiting" type="primary" @click="createData">确定
- </el-button>
- <el-button v-else :loading="submiting" type="primary" @click="updateData">确定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- dayjs,
- EventBus
- } from 'base-core-lib'
- import {
- listCountry
- } from '@/api/country'
- import {
- downloadFile
- } from '@/utils/batchDown'
- import {
- importWord,
- listCollectionPayment,
- createCollectionPayment,
- updateCollectionPayment,
- deleteCollectionPayment,
- exportXlsx
- } from '@/api/collectionPayment'
- // import {
- // exportXlsx
- // } from '@/model/export'
- import Pagination from '@/components/Pagination'
- import store from '@/store'
- export default {
- name: 'CollectionPayment',
- components: { Pagination },
- data() {
- return {
- isAllowExport: true,
- countryList: [],
- modification: [],
- selectDate: '',
- date: {
- year: dayjs().format('YYYY'),
- month: dayjs().format('MM')
- },
- accessoryTFs: false,
- fileList: [],
- appendixIdsAdd: '',
- excelFreightspace: [],
- fileTemp: null,
- placeList: [],
- list: null,
- total: 0,
- listLoading: true,
- listQuery: {
- page: 1,
- limit: 100,
- type: {
- businessType: 1,
- receivingWithdrawingPeople: '',
- receivingWithdrawingRegion: '',
- startDate: '',
- endDate: ''
- }
- },
- listPlace: {
- page: 1,
- limit: 2000,
- type: {
- country: ''
- }
- },
- dataForm: {
- id: undefined,
- updatePeople: store.getters.name
- },
- dialogFormVisible: false,
- submiting: false,
- dialogStatus: '',
- textMap: {
- update: '编辑',
- create: '创建'
- },
- rules: {
- }
- }
- },
- created() {
- this.getList()
- // let a = store.getters.name
- this.currentPage = 1
- },
- methods: {
- handleSizeChange(val) {
- debugger
- console.log(`每页 ${val} 条`)
- this.listQuery.limit = val
- this.getList()
- },
- handleCurrentChange(val) {
- this.listQuery.page = val
- console.log(`当前页: ${val}`)
- this.getList()
- },
- handleSelectionChange(val) {
- this.modification = val
- },
- selectInit(row) {
- return true
- },
- async exportlist() {
- if (this.modification.length == 0) {
- this.$message.warning('请选择要导出的条目!')
- } else {
- console.log('导出数据', this.modification)
- const _data = {
- collectionPaymentDTOList: this.modification
- }
- const {
- data
- } = await exportXlsx(_data).then((response) => {
- this.download(response.data.data)
- // downloadFile({
- // res: data,
- // fileName: `${
- // this.date.year + (this.date.month ? `-${this.date.month}` : '')
- // }付款信息`,
- // type: 'xls',
- // })
- if (response.status == '200') {
- }
- })
- }
- },
- importClick(file, fileList) {
- this.fileTemp = file.raw
- const fileName = file.raw.name
- const fileType = fileName.substring(fileName.lastIndexOf('.') + 1)
- // 判断上传文件格式
- if (this.fileTemp) {
- if (fileType == 'xlsx' || fileType == 'xls') {
- this.importf(this.fileTemp)
- } else {
- this.$message({
- type: 'warning',
- message: '附件格式错误,请删除后重新上传!'
- })
- }
- } else {
- this.$message({
- type: 'warning',
- message: '请上传附件!'
- })
- }
- },
- importf(obj) {
- this.countryList = []
- this.excelFreightspace = []
- // this.dialogVisible = true;
- const _this = this
- const inputDOM = this.$refs.inputer // 通过DOM取文件数据
- this.file = event.currentTarget.files[0]
- var rABS = false // 是否将文件读取为二进制字符串
- var f = this.file
- var reader = new FileReader()
- // if (!FileReader.prototype.readAsBinaryString) {
- FileReader.prototype.readAsBinaryString = function (f) {
- var binary = ''
- var rABS = false // 是否将文件读取为二进制字符串
- var pt = this
- var wb // 读取完成的数据
- var outdata
- var reader = new FileReader()
- reader.onload = function (e) {
- var bytes = new Uint8Array(reader.result)
- var length = bytes.byteLength
- for (var i = 0; i < length; i++) {
- binary += String.fromCharCode(bytes[i])
- }
- var XLSX = require('xlsx')
- if (rABS) {
- wb = XLSX.read(btoa(fixdata(binary)), { // 手动转化
- type: 'base64',
- cellDates: true
- })
- } else {
- wb = XLSX.read(binary, {
- type: 'binary'
- })
- }
- // outdata就是你想要的东西 excel导入的数据
- outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]])
- // excel 数据再处理
- const arr = []
- outdata.map(v => {
- // let jsonString = JSON.stringify(v).replace(/\*/g, '').replace(/\s/ig,'');
- const jsonString = JSON.stringify(v).replace(/\//g, '').replace(/\s/ig, '')
- v = JSON.parse(jsonString)
- const obj = {}
- debugger
- // xxx代表列名
- obj.receiptPaymentDate = v.收款日期
- obj.receivingWithdrawingRegion = v.收款地
- obj.receivingWithdrawingPeople = v.付款人
- obj.deductionEuro = v.金额EUR
- obj.deductionRmb = v.金额RMB
- obj.businessType = 1
- obj.remarks = v.备注1
- obj.remark = v.备注2
- obj.updatePeople = _this.$store.getters.name
- if (!obj.deductionEuro) {
- obj.deductionEuro = 0
- }
- if (!obj.deductionRmb) {
- obj.deductionRmb = 0
- }
- for (let i = 0; i < _this.placeList.length; i++) {
- _this.countryList.push(_this.placeList[i].country)
- }
- if (!_this.countryList.includes(obj.receivingWithdrawingRegion)) {
- _this.isAllowExport = false
- _this.$notify({
- title: '失败',
- message: '导入失败,导入数据中收款地在系统中不存在,请重新编辑',
- type: 'error'
- })
- return
- } else {
- _this.excelFreightspace.push(obj)
- _this.isAllowExport = true
- }
- })
- if (_this.excelFreightspace && _this.isAllowExport) {
- importWord(_this.excelFreightspace).then((response) => {
- if (response.status == '200') {
- _this.$notify({
- title: '成功',
- message: '导入成功',
- type: 'success'
- })
- _this.getList()
- }
- })
- }
- }
- reader.readAsArrayBuffer(f)
- }
- if (rABS) {
- reader.readAsArrayBuffer(f)
- } else {
- reader.readAsBinaryString(f)
- }
- },
- formatDate(numb, format) {
- const old = numb - 1
- const t = Math.round((old - Math.floor(old)) * 24 * 60 * 60)
- const time = new Date(1900, 0, old, 0, 0, t)
- const year = time.getFullYear()
- const month = time.getMonth() + 1
- const date = time.getDate()
- return year + format + (month < 10 ? '0' + month : month) + format + (date < 10 ? '0' + date : date) + ' 00:00:00'
- },
- getSummaries(param) {
- const { columns, data } = param
- const sums = []
- columns.forEach((column, index) => {
- if (index === 0) {
- sums[index] = '合计'
- return
- } else if (index == 5 || index == 6) {
- const values = data.map((item) => Number(item[column.property]))
- if (!values.every((value) => isNaN(value))) {
- sums[index] = values.reduce((prev, curr) => {
- const value = Number(curr)
- if (!isNaN(value)) {
- return prev + curr
- } else {
- return prev
- }
- }, 0)
- sums[index] += ''
- } else {
- sums[index] = '--'
- }
- } else {
- // sums[index] = "--";
- }
- })
- return sums
- },
- getList() {
- console.log(this.selectDate)
- listCountry(this.listPlace).then(response => {
- this.placeList = response.data.data.items
- })
- .catch(() => {
- this.placeList = []
- })
- this.listLoading = true
- console.log(this.selectDate)
- if (this.selectDate&&this.selectDate.length > 0) {
- this.listQuery.type.startDate = dayjs(this.selectDate[0]).format('YYYY-MM-DD')
- this.listQuery.type.endDate = dayjs(this.selectDate[1]).format('YYYY-MM-DD')
- } else {
- this.listQuery.type.startDate = ''
- this.listQuery.type.endDate = ''
- }
- listCollectionPayment(this.listQuery).then(response => {
- this.list = response.data.data.items
- this.total = response.data.data.total
- this.listLoading = false
- })
- .catch(() => {
- this.list = []
- this.total = 0
- this.listLoading = false
- })
- },
- handleFilter() {
- this.listQuery.page = 1
- this.getList()
- },
- resetForm() {
- this.dataForm = {
- id: undefined
- }
- },
- handleCreate() {
- this.resetForm()
- this.dialogStatus = 'create'
- this.dialogFormVisible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].clearValidate()
- })
- },
- createData() {
- this.$refs['dataForm'].validate(valid => {
- if (valid) {
- this.submiting = true
- this.dataForm.businessType = 1
- this.dataForm.updatePeople = this.$store.getters.name
- if (!this.dataForm.deductionEuro) {
- this.dataForm.deductionEuro = 0
- }
- if (!this.dataForm.deductionRmb) {
- this.dataForm.deductionRmb = 0
- }
- createCollectionPayment(this.dataForm).then(response => {
- this.list.unshift(response.data.data)
- this.dialogFormVisible = false
- this.$notify.success({
- title: '成功',
- message: '添加成功'
- })
- this.submiting = false
- })
- .catch(response => {
- this.$notify.error({
- title: '失败',
- message: response.data.errmsg
- })
- this.submiting = false
- })
- }
- })
- },
- handleUpdate(row) {
- this.dataForm = Object.assign({}, row)
- this.dialogStatus = 'update'
- this.dialogFormVisible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].clearValidate()
- })
- },
- handleUpdate1(row) {
- this.$confirm('此操作将永久作废该记录---' + row.id + '---, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteCollectionPayment(row.id).then(response => {
- this.$notify.success({
- title: '成功',
- message: '删除成功'
- })
- const index = this.list.indexOf(row)
- this.list.splice(index, 1)
- })
- .catch(response => {
- this.$notify.error({
- title: '失败',
- message: response.data.errmsg
- })
- })
- }).catch(() => {
- return false
- })
- },
- updateData() {
- this.$refs['dataForm'].validate(valid => {
- if (valid) {
- this.submiting = true
- this.dataForm.updatePeople = this.$store.getters.name
- updateCollectionPayment(this.dataForm).then(() => {
- for (const v of this.list) {
- if (v.id === this.dataForm.id) {
- const index = this.list.indexOf(v)
- this.list.splice(index, 1, this.dataForm)
- break
- }
- }
- this.dialogFormVisible = false
- this.submiting = false
- this.$notify.success({
- title: '成功',
- message: '更新成功'
- })
- })
- .catch(response => {
- this.$notify.error({
- title: '失败',
- message: response.data.errmsg
- })
- this.submiting = false
- })
- }
- })
- },
- updateData1(row) {
- this.dataForm.flag = 1
- this.dataForm.id = row.id
- updateCollectionPayment(this.dataForm).then(() => {
- this.submiting = false
- this.$notify.success({
- title: '成功',
- message: '更新成功'
- })
- this.getList()
- })
- .catch(response => {
- this.$notify.error({
- title: '失败',
- message: response.data.errmsg
- })
- this.submiting = false
- })
- },
- handleDelete(row) {
- this.$confirm('此操作将永久删除该记录---' + row.id + '---, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteCollectionPayment(row.id).then(response => {
- this.$notify.success({
- title: '成功',
- message: '删除成功'
- })
- const index = this.list.indexOf(row)
- this.list.splice(index, 1)
- })
- .catch(response => {
- this.$notify.error({
- title: '失败',
- message: response.data.errmsg
- })
- })
- }).catch(() => {
- return false
- })
- }
- }
- }
- </script>
- <style>
- </style>
|