importGuideModal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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) 请先下载导入模板,模板中已标示出必填项</li>
  19. <li>2) 如果物流单号相同,则视为同一个发货单</li>
  20. <li>3) 同一个发货单可有多个不同类型的类型,包括易损件、电池、机油</li>
  21. </ul>
  22. <a-button type="link" icon="download" style="padding: 0 0 0 23px;" @click="handleExport">下载导入模板</a-button>
  23. </div>
  24. <div class="explain-item">
  25. <div class="explain-tit">
  26. <span>2</span>上传数据文件
  27. </div>
  28. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  29. <div style="overflow: hidden;padding-left: 23px;">
  30. <Upload
  31. id="importGuide-attachList"
  32. ref="importUpload"
  33. :maxNums="1"
  34. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  35. uploadType="attach"
  36. :action="attachAction"
  37. :uploadParams="uploadParams"
  38. upText="选择导入文件"
  39. @remove="resetSearchForm"
  40. @change="changeImport"></Upload>
  41. </div>
  42. </div>
  43. </div>
  44. <!-- 按钮 -->
  45. <div class="btn-con">
  46. <a-button
  47. type="primary"
  48. id="importGuide-nextStep"
  49. size="large"
  50. class="button-primary"
  51. @click="handlerNextStep"
  52. style="padding: 0 60px;">下一步</a-button>
  53. <a-button
  54. id="importGuide-cancel"
  55. size="large"
  56. class="button-cancel"
  57. @click="isShow=false"
  58. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  59. </div>
  60. </div>
  61. <!-- 导入 -->
  62. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  63. </a-modal>
  64. </template>
  65. <script>
  66. import ChooseImportModal from './chooseImportModal.vue'
  67. import { Upload } from '@/components'
  68. export default {
  69. name: 'ImportGuideModal',
  70. components: { ChooseImportModal, Upload },
  71. props: {
  72. openModal: { // 弹框显示状态
  73. type: Boolean,
  74. default: false
  75. },
  76. params: {
  77. type: Object,
  78. default: null
  79. }
  80. },
  81. data () {
  82. return {
  83. isShow: this.openModal, // 是否打开弹框
  84. openImportModal: false, // 导入
  85. attachAction: process.env.VUE_APP_API_BASE_URL + '/sendBill/importSendBill',
  86. paramsData: null,
  87. uploadParams: {
  88. savePathType: 'local'
  89. }
  90. }
  91. },
  92. methods: {
  93. // 清空数据
  94. resetSearchForm () {
  95. this.$refs.importUpload.setFileList() // 清空导入文件
  96. this.paramsData = null // 清空上传数据
  97. },
  98. // 下一步
  99. handlerNextStep () {
  100. if (this.paramsData) {
  101. this.openImportModal = true
  102. } else {
  103. this.$message.warning('添加文件后再进行下一步操作!')
  104. }
  105. },
  106. // 上传文件 change
  107. changeImport (file) {
  108. // console.log(file, JSON.parse(file))
  109. if (file && JSON.parse(file).length > 0) {
  110. this.paramsData = Object.assign({}, JSON.parse(file)[0] || null, this.params)
  111. } else {
  112. this.paramsData = null
  113. }
  114. },
  115. // 导入
  116. hanldeOk (obj) {
  117. this.$emit('ok', obj)
  118. this.isShow = false
  119. },
  120. // 关闭
  121. handleClose () {
  122. this.openImportModal = false
  123. this.isShow = false
  124. },
  125. // 下载模板
  126. handleExport () {
  127. const link = document.createElement('a')
  128. link.style.display = 'none'
  129. link.href = 'https://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/sendOutOrderImport.xlsx?t=' + new Date().getTime()
  130. link.setAttribute('download', '发货单信息导入模板' + '.xlsx')
  131. document.body.appendChild(link)
  132. link.click()
  133. document.body.removeChild(link)
  134. }
  135. },
  136. watch: {
  137. // 父页面传过来的弹框状态
  138. openModal (newValue, oldValue) {
  139. this.isShow = newValue
  140. },
  141. // 重定义的弹框状态
  142. isShow (newValue, oldValue) {
  143. if (!newValue) {
  144. this.$emit('close')
  145. this.resetSearchForm()
  146. }
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="less" scoped>
  152. .importGuide-modal{
  153. .importGuide-con{
  154. .explain-con{
  155. .explain-item{
  156. margin-bottom: 10px;
  157. .explain-tit{
  158. font-weight: bold;
  159. span{
  160. display: inline-block;
  161. width: 18px;
  162. height: 18px;
  163. line-height: 16px;
  164. text-align: center;
  165. margin-right: 5px;
  166. border-radius: 50%;
  167. border: 1px solid rgba(0, 0, 0, 0.3);
  168. }
  169. }
  170. p{
  171. margin: 8px 0;
  172. padding-left: 23px;
  173. }
  174. ul{
  175. list-style: none;
  176. padding: 0;
  177. padding-left: 23px;
  178. margin: 0;
  179. li{
  180. line-height: 26px;
  181. }
  182. }
  183. }
  184. #importGuide-attachList{
  185. width: 100%;
  186. }
  187. }
  188. .btn-con{
  189. margin: 10px 0 20px;
  190. text-align: center;
  191. .button-cancel{
  192. font-size: 12px;
  193. }
  194. }
  195. }
  196. }
  197. </style>