importGuideModal.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <a-modal
  3. centered
  4. class="importGuide-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="导入费用明细"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="800">
  11. <div class="importGuide-con">
  12. <div class="explain-con">
  13. <div class="explain-item">
  14. <div class="explain-tit">
  15. <span>1</span>准备导入
  16. </div>
  17. <ul>
  18. <li>1) 导入的Excel文件中必须包含名为“记账类型”、“记账名称”、“费用承担方类型”、“费用承担方”、“费用承担金额”的列,且名称必须相同</li>
  19. <li>2) 其他列可根据实际情况填写,如果符合规则,系统会一起导入</li>
  20. <li><a :href="filePath" style="margin: 5px 0 0 15px;display: block;">
  21. <a-icon type="download" style="padding-right: 5px;" />下载导入模板
  22. </a></li>
  23. </ul>
  24. </div>
  25. <div class="explain-item">
  26. <div class="explain-tit">
  27. <span>2</span>上传数据文件
  28. </div>
  29. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  30. <div style="overflow: hidden;padding-left: 23px;">
  31. <Upload
  32. id="importGuide-attachList"
  33. ref="importUpload"
  34. :maxNums="1"
  35. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  36. uploadType="attach"
  37. :action="attachAction"
  38. :uploadParams="uploadParams"
  39. upText="选择导入文件"
  40. @remove="resetSearchForm"
  41. @change="changeImport"></Upload>
  42. </div>
  43. </div>
  44. </div>
  45. <!-- 按钮 -->
  46. <div class="btn-con">
  47. <a-button
  48. type="primary"
  49. id="importGuide-nextStep"
  50. size="large"
  51. class="button-primary"
  52. @click="handlerNextStep"
  53. style="padding: 0 60px;">下一步</a-button>
  54. <a-button
  55. id="importGuide-cancel"
  56. size="large"
  57. class="button-cancel"
  58. @click="isShow=false"
  59. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  60. </div>
  61. </div>
  62. <!-- 导入 -->
  63. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  64. </a-modal>
  65. </template>
  66. <script>
  67. import ChooseImportModal from './chooseImportModal.vue'
  68. import { Upload } from '@/components'
  69. export default {
  70. name: 'ImportGuideModal',
  71. components: { ChooseImportModal, Upload },
  72. props: {
  73. openModal: { // 弹框显示状态
  74. type: Boolean,
  75. default: false
  76. },
  77. params: {
  78. type: Object,
  79. default: null
  80. }
  81. },
  82. data () {
  83. return {
  84. isShow: this.openModal, // 是否打开弹框
  85. openImportModal: false, // 导入
  86. attachAction: process.env.VUE_APP_API_BASE_URL + '/expenseAcctDetail/importDetail',
  87. paramsData: null,
  88. uploadParams: {
  89. savePathType: 'local'
  90. },
  91. exportLoading: false,
  92. filePath: location.protocol + '//' +location.host + '/templ/费用明细模板.xlsx' + '?a=' + new Date().getTime()
  93. }
  94. },
  95. methods: {
  96. // 清空数据
  97. resetSearchForm () {
  98. this.$refs.importUpload.setFileList() // 清空导入文件
  99. this.paramsData = null // 清空上传数据
  100. },
  101. // 下一步
  102. handlerNextStep () {
  103. if (this.paramsData) {
  104. this.openImportModal = true
  105. } else {
  106. this.$message.warning('添加文件后再进行下一步操作!')
  107. }
  108. },
  109. // 上传文件 change
  110. changeImport (file) {
  111. console.log(file, JSON.parse(file))
  112. if (file && JSON.parse(file).length > 0) {
  113. this.paramsData = Object.assign({}, JSON.parse(file)[0] || null, this.params)
  114. } else {
  115. this.paramsData = null
  116. }
  117. console.log(this.paramsData)
  118. },
  119. // 导入
  120. hanldeOk (obj) {
  121. if (obj && obj.length > 0) {
  122. this.$emit('ok', obj)
  123. this.isShow = false
  124. }
  125. },
  126. // 关闭
  127. handleClose () {
  128. this.openImportModal = false
  129. this.isShow = false
  130. }
  131. },
  132. watch: {
  133. // 父页面传过来的弹框状态
  134. openModal (newValue, oldValue) {
  135. this.isShow = newValue
  136. },
  137. // 重定义的弹框状态
  138. isShow (newValue, oldValue) {
  139. if (!newValue) {
  140. this.$emit('close')
  141. this.resetSearchForm()
  142. }
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="less" scoped>
  148. .importGuide-modal{
  149. .importGuide-con{
  150. .explain-con{
  151. .explain-item{
  152. margin-bottom: 10px;
  153. .explain-tit{
  154. font-weight: bold;
  155. span{
  156. display: inline-block;
  157. width: 18px;
  158. height: 18px;
  159. line-height: 16px;
  160. text-align: center;
  161. margin-right: 5px;
  162. border-radius: 50%;
  163. border: 1px solid rgba(0, 0, 0, 0.3);
  164. }
  165. }
  166. p{
  167. margin: 8px 0;
  168. padding-left: 23px;
  169. }
  170. ul{
  171. list-style: none;
  172. padding: 0;
  173. padding-left: 23px;
  174. margin: 0;
  175. li{
  176. line-height: 26px;
  177. }
  178. }
  179. }
  180. #importGuide-attachList{
  181. width: 100%;
  182. }
  183. }
  184. .btn-con{
  185. margin: 10px 0 20px;
  186. text-align: center;
  187. .button-cancel{
  188. font-size: 12px;
  189. }
  190. }
  191. }
  192. }
  193. </style>