listMatch.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <script setup>
  2. import { computed, ref } from "vue";
  3. import { ElMessage } from 'element-plus';
  4. const templateUrl = 'https://hzstatic.hzinsights.com/static/admin/excel/客户名单匹配模板.xlsx'
  5. const importUrl = import.meta.env.VITE_APP_API_ROOT+'/custom/list/match/import';
  6. const headerConfig = {
  7. Authorization:localStorage.getItem('auth')
  8. }
  9. const colList = [
  10. {
  11. label:'姓名',
  12. key:'UserName'
  13. },
  14. {
  15. label:'国际(区号)',
  16. key:'CountryCode'
  17. },
  18. {
  19. label:'手机号',
  20. key:'Mobile'
  21. },
  22. {
  23. label:'客户公司',
  24. key:'CompanyName'
  25. },
  26. {
  27. label:'系统客户',
  28. key:'SysCompanyName'
  29. },
  30. {
  31. label:'FICC状态',
  32. key:'FiccStatus'
  33. },
  34. {
  35. label:'FICC销售',
  36. key:'FiccSeller'
  37. },
  38. {
  39. label:'权益状态',
  40. key:'RaiStatus'
  41. },
  42. {
  43. label:'权益销售',
  44. key:'RaiSeller'
  45. }
  46. ]
  47. // 校验文件和大小
  48. function beforeUploadFile(file) {
  49. let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
  50. let size = file.size / 1024 / 1024;//M
  51. if (extension !== "xlsx" && extension !== "xls") {
  52. ElMessage.warning("只能上传后缀是.xlsx和.xls的文件");
  53. return false;
  54. }
  55. if (size > 10) {
  56. ElMessage.warning("文件大小不得超过10M");
  57. return false
  58. }
  59. }
  60. const fileList = ref([])
  61. const tableData = ref([]);
  62. const code = ref('')
  63. // 上传成功之后
  64. function handleSuccess(result) {
  65. let res = this.$parseData(result);
  66. if(res.Ret===200){
  67. tableData.value=res.Data.List||[]
  68. code.value=res.Data.Code
  69. }else{
  70. ElMessage.warning(res.Msg)
  71. }
  72. }
  73. const downloadUrl = computed(() => {
  74. const url=import.meta.env.VITE_APP_API_ROOT+'/custom/list/match/download'
  75. return url+'?Code='+code.value+'&'+localStorage.getItem('auth')
  76. })
  77. function handleDownLoadList(){
  78. let link = document.createElement("a");
  79. link.href=downloadUrl.value
  80. link.setAttribute("download", '客户名单匹配');
  81. link.style.display = "none"; //a标签隐藏
  82. document.body.appendChild(link);
  83. link.click();
  84. }
  85. </script>
  86. <template>
  87. <div class="custome-list-match-page">
  88. <div class="top-warp" style="margin-bottom: 30px">
  89. <a style="width: 100%" :href="templateUrl" download="客户名单匹配模板"
  90. ><el-button type="primary" plain style="margin-right: 15px"
  91. >下载模板</el-button
  92. ></a
  93. >
  94. <el-upload
  95. style="display: inline-block"
  96. :before-upload="beforeUploadFile"
  97. :headers="headerConfig"
  98. :file-list="fileList"
  99. :on-success="handleSuccess"
  100. :action="importUrl"
  101. accept=".xlsx"
  102. name="File"
  103. :show-file-list="false"
  104. >
  105. <el-button type="primary">导入名单</el-button>
  106. </el-upload>
  107. <el-button
  108. type="primary"
  109. plain
  110. style="float: right"
  111. :disabled="!code"
  112. @click="handleDownLoadList"
  113. >下载名单</el-button
  114. >
  115. <!-- <a style="width: 100%" :href="downloadUrl+'?Code='+code" download></a> -->
  116. </div>
  117. <el-table :data="tableData" border style="width: 100%" max-height="800">
  118. <el-table-column
  119. :prop="col.key"
  120. :label="col.label"
  121. v-for="col in colList"
  122. :key="col.label"
  123. align="center"
  124. >
  125. </el-table-column>
  126. </el-table>
  127. </div>
  128. </template>
  129. <style scoped lang="scss">
  130. .custome-list-match-page{
  131. background-color: #fff;
  132. border: 1px solid #ECECEC;
  133. padding: 30px;
  134. border-radius: 4px;
  135. min-height: 60vh;
  136. }
  137. </style>