123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <a-modal
- centered
- class="importGuide-modal"
- :footer="null"
- :maskClosable="false"
- title="导入费用明细"
- v-model="isShow"
- @cancel="isShow=false"
- :width="800">
- <div class="importGuide-con">
- <div class="explain-con">
- <div class="explain-item">
- <div class="explain-tit">
- <span>1</span>准备导入
- </div>
- <ul>
- <li>1) 导入的Excel文件中必须包含名为“记账类型”、“记账名称”、“费用承担方类型”、“费用承担方”、“费用承担金额”的列,且名称必须相同</li>
- <li>2) 其他列可根据实际情况填写,如果符合规则,系统会一起导入</li>
- </ul>
- <a-button type="link" icon="download" style="padding: 0 0 0 23px;" :loading="exportLoading" @click="handleExport">下载导入模板</a-button>
- </div>
- <div class="explain-item">
- <div class="explain-tit">
- <span>2</span>上传数据文件
- </div>
- <p>目前支持的文件类型*.xls,*.xlsx.</p>
- <div style="overflow: hidden;padding-left: 23px;">
- <Upload
- id="importGuide-attachList"
- ref="importUpload"
- :maxNums="1"
- fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
- uploadType="attach"
- :action="attachAction"
- :uploadParams="uploadParams"
- upText="选择导入文件"
- @remove="resetSearchForm"
- @change="changeImport"></Upload>
- </div>
- </div>
- </div>
- <!-- 按钮 -->
- <div class="btn-con">
- <a-button
- type="primary"
- id="importGuide-nextStep"
- size="large"
- class="button-primary"
- @click="handlerNextStep"
- style="padding: 0 60px;">下一步</a-button>
- <a-button
- id="importGuide-cancel"
- size="large"
- class="button-cancel"
- @click="isShow=false"
- style="padding: 0 60px;margin-left: 15px;">取消</a-button>
- </div>
- </div>
- <!-- 导入 -->
- <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
- </a-modal>
- </template>
- <script>
- import ChooseImportModal from './chooseImportModal.vue'
- import { Upload } from '@/components'
- export default {
- name: 'ImportGuideModal',
- components: { ChooseImportModal, Upload },
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- params: {
- type: Object,
- default: null
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- openImportModal: false, // 导入
- attachAction: process.env.VUE_APP_API_BASE_URL + '/expenseAcctDetail/importDetail',
- paramsData: null,
- uploadParams: {
- savePathType: 'local'
- },
- exportLoading: false
- }
- },
- methods: {
- // 清空数据
- resetSearchForm () {
- this.$refs.importUpload.setFileList() // 清空导入文件
- this.paramsData = null // 清空上传数据
- },
- // 下一步
- handlerNextStep () {
- if (this.paramsData) {
- this.openImportModal = true
- } else {
- this.$message.warning('添加文件后再进行下一步操作!')
- }
- },
- // 上传文件 change
- changeImport (file) {
- console.log(file, JSON.parse(file))
- if (file && JSON.parse(file).length > 0) {
- this.paramsData = Object.assign({}, JSON.parse(file)[0] || null, this.params)
- } else {
- this.paramsData = null
- }
- console.log(this.paramsData)
- },
- // 导入
- hanldeOk (obj) {
- if (obj && obj.length > 0) {
- this.$emit('ok', obj)
- this.isShow = false
- }
- },
- // 关闭
- handleClose () {
- this.openImportModal = false
- this.isShow = false
- },
- // 下载模板
- handleExport () {
- this.exportLoading = true
- setTimeout(() => {
- this.exportLoading = false
- }, 1000)
- const link = document.createElement('a')
- link.style.display = 'none'
- link.href = 'https://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/expenseAccountDetailImport.xlsx?t=' + new Date().getTime()
- link.setAttribute('download', '费用明细模板' + '.xlsx')
- document.body.appendChild(link)
- link.click()
- document.body.removeChild(link)
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.resetSearchForm()
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .importGuide-modal{
- .importGuide-con{
- .explain-con{
- .explain-item{
- margin-bottom: 10px;
- .explain-tit{
- font-weight: bold;
- span{
- display: inline-block;
- width: 18px;
- height: 18px;
- line-height: 16px;
- text-align: center;
- margin-right: 5px;
- border-radius: 50%;
- border: 1px solid rgba(0, 0, 0, 0.3);
- }
- }
- p{
- margin: 8px 0;
- padding-left: 23px;
- }
- ul{
- list-style: none;
- padding: 0;
- padding-left: 23px;
- margin: 0;
- li{
- line-height: 26px;
- }
- }
- }
- #importGuide-attachList{
- width: 100%;
- }
- }
- .btn-con{
- margin: 10px 0 20px;
- text-align: center;
- .button-cancel{
- font-size: 12px;
- }
- }
- }
- }
- </style>
|