index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--用户数据-->
  5. <el-col :span="24" :xs="24">
  6. <div class="panelCol">
  7. <div class="bgWhite">
  8. <div class="titleDiv">
  9. <span class="line"></span>
  10. <span class="title">客户信息列表</span>
  11. <el-button
  12. class="exportBtn"
  13. type="warning"
  14. icon="el-icon-download"
  15. size="mini"
  16. @click="handleExport"
  17. v-hasPermi="['business:customerInformation:download']"
  18. :loading="exportLoading"
  19. >导出</el-button>
  20. </div>
  21. <el-table v-loading="loading" :data="customerList">
  22. <el-table-column label="客户号" :width="cellWidth" align="center" prop="custid" />
  23. <el-table-column label="姓名" :width="cellWidth" align="center" prop="name" :show-overflow-tooltip="true" />
  24. <el-table-column label="证件类型" :width="cellWidth" align="center" >
  25. <template slot-scope="scope">
  26. <span v-if="scope.row.idcard!=undefined && scope.row.idcard!=''">身份证</span>
  27. <span v-else-if="scope.row.passport!=undefined && scope.row.passport!=''">护照</span>
  28. <span v-else-if="scope.row.dlicense!=undefined && scope.row.dlicense!=''">驾驶证</span>
  29. <span v-else-if="scope.row.otheridnumber!=undefined && scope.row.otheridnumber!=''">其它证件类型</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="证件号码" align="center" :show-overflow-tooltip="true">
  33. <template slot-scope="scope">
  34. <span v-if="scope.row.idcard && scope.row.idcard!=''">{{cardNo(scope.row.idcard)}}</span>
  35. <span v-else-if="scope.row.passport && scope.row.passport!=''">{{cardNo(scope.row.passport)}}</span>
  36. <span v-else-if="scope.row.dlicense && scope.row.dlicense!=''">{{cardNo(scope.row.dlicense)}}</span>
  37. <span v-else-if="scope.row.otheridnumber && scope.row.otheridnumber!=''">{{cardNo(scope.row.otheridnumber)}}</span>
  38. <span v-else></span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="性别" align="center" prop="gender" :width="cellWidthS">
  42. <template slot-scope="scope">
  43. <span v-if="scope.row.gender == 0">男</span>
  44. <span v-else>女</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="出生日期" align="center" :width="cellWidth">
  48. <template slot-scope="scope">
  49. <span>{{ parseTime(scope.row.birthday,'{yy}-{mm}-{dd}') }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="年龄" align="center" prop="age" :width="cellWidthS" />
  53. <el-table-column label="客户等级" align="center" prop="level" :width="cellWidthS">
  54. <template slot-scope="scope">
  55. <span>{{levelText(scope.row.custclass)}}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. label="操作"
  60. align="center"
  61. :width="cellWidthB"
  62. class-name="small-padding fixed-width"
  63. >
  64. <template slot-scope="scope">
  65. <el-button
  66. size="mini"
  67. icon="el-icon-copy-document"
  68. @click="toOverview(scope.row)"
  69. v-hasPermi="['business:customerInformation:overview']"
  70. >概览</el-button>
  71. <el-button
  72. v-if="scope.row.userId !== 1"
  73. size="mini"
  74. type="cyan"
  75. icon="el-icon-warning-outline"
  76. @click="toDetail(scope.row)"
  77. v-hasPermi="['business:customerInformation:detail']"
  78. >详情</el-button>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <!-- <div :class="{'hidden':hidden}" class="pagination-container">-->
  83. <!-- <el-pagination-->
  84. <!-- background-->
  85. <!-- :current-page="pageNum"-->
  86. <!-- :page-size="queryParams.pageSize"-->
  87. <!-- :layout="layout"-->
  88. <!-- :page-sizes="pageSizes"-->
  89. <!-- pager-count="11"-->
  90. <!-- :total="total"-->
  91. <!-- @size-change="sizeChange"-->
  92. <!-- @prev-click="currentChange"-->
  93. <!-- @next-click="currentChange"-->
  94. <!-- />-->
  95. <!-- </div>-->
  96. <div style="overflow: hidden;margin-top: 20px;">
  97. <div style="width: 330px;float: right;">
  98. <van-pagination
  99. v-model="queryParams.pageNum"
  100. :total-items="total"
  101. :show-page-size="7"
  102. force-ellipses
  103. @change="currentChange"
  104. >
  105. <template #prev-text>
  106. <i class="el-icon-arrow-left"></i>
  107. </template>
  108. <template #next-text>
  109. <i class="el-icon-arrow-right"></i>
  110. </template>
  111. </van-pagination>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </el-col>
  117. </el-row>
  118. </div>
  119. </template>
  120. <script>
  121. import { listCustomer,listExport } from "@/api/customerInformation/customerInformation.js";
  122. import Axios from 'axios'
  123. import { tansParams } from "@/utils/ruoyi";
  124. import Vue from 'vue';
  125. import { Pagination } from 'vant';
  126. import 'vant/lib/index.css'
  127. Vue.use(Pagination);
  128. export default {
  129. name: "UserInfoList",
  130. components: {
  131. [Pagination.name]: Pagination,
  132. },
  133. data() {
  134. return {
  135. // 遮罩层
  136. loading: false,
  137. // 总条数
  138. total: 0,
  139. // 用户表格数据
  140. // userList: null,
  141. customerList: [],
  142. // 查询参数
  143. queryParams: {
  144. pageSize: 10,
  145. pageNum: 1,
  146. // scrollId:'',
  147. },
  148. params:{},
  149. newQueryParams:{},
  150. cellWidth:'130',
  151. cellWidthS:'90',
  152. cellWidthB:'260',
  153. hidden:false,
  154. layout:'total, sizes, prev,pager,next',
  155. pageSizes:[10, 20, 30, 50],
  156. exportLoading:false,
  157. };
  158. },
  159. // watch: {
  160. // $route: {
  161. // handler: function(val, oldVal){
  162. // console.log(val);
  163. // },
  164. // // 深度观察监听
  165. // deep: true
  166. // }
  167. // },
  168. beforeRouteEnter(to, from, next) {
  169. console.log(from)
  170. if (from.name === 'Index') {
  171. next(vm => {
  172. vm.queryParams.pageNum = 1;
  173. vm.getList();
  174. })
  175. } else if (!from.name) { // 处理刷新页面时,获取动态表单方法未执行,导致表单无法加载
  176. next(vm => {
  177. vm.getList();
  178. })
  179. } else {
  180. // 详情返回时只更新列表数据,因为如果在详情页面做了操作,列表数据状态会改变,其他使用缓存
  181. next(vm => {
  182. vm.getList();
  183. })
  184. }
  185. },
  186. created() {
  187. // this.getList();
  188. },
  189. mounted() {
  190. var clientWidth = document.body.clientWidth;
  191. var that = this;
  192. if(clientWidth <= 1370){
  193. that.cellWidth='120';
  194. that.cellWidthS='80';
  195. that.cellWidthB='160';
  196. }else{
  197. that.cellWidth='160';
  198. that.cellWidthS='120';
  199. that.cellWidthB='280';
  200. }
  201. },
  202. methods: {
  203. /** 查询用户列表 */
  204. getList() {
  205. let that = this;
  206. that.loading = true;
  207. that.params = that.$route.query;
  208. console.log(that.$route.params)
  209. that.newQueryParams = {...that.queryParams,...that.params};
  210. if(that.newQueryParams.education){
  211. that.newQueryParams.education = that.newQueryParams.education.join("&");
  212. }
  213. console.log(that.newQueryParams)
  214. listCustomer(that.newQueryParams).then(response => {
  215. console.log(response);
  216. this.customerList = response.data.list;
  217. // if(response.data.scrollId != undefined && response.data.scrollId !=""){
  218. // that.queryParams.scrollId = response.data.scrollId;
  219. // }else{
  220. // that.queryParams.scrollId = '';
  221. // }
  222. this.total = response.data.total;
  223. this.loading = false;
  224. }
  225. );
  226. },
  227. currentChange(val){
  228. this.queryParams.pageNum = val;
  229. this.getList();
  230. },
  231. sizeChange(val){
  232. this.queryParams.pageSize = val;
  233. this.queryParams.pageNum = 1;
  234. this.queryParams.scrollId = '';
  235. this.getList();
  236. },
  237. /** 导出按钮操作 */
  238. handleExport() {
  239. var that = this;
  240. that.exportLoading = true;
  241. this.downloadNew('data/customer/export', that.newQueryParams, `customer_${new Date().getTime()}.csv`).then(response => {
  242. console.log(response);
  243. if(response){
  244. that.exportLoading = false;
  245. }
  246. })
  247. },
  248. genUrl(encoded, options) {
  249. const dataBlob = new Blob([`\ufeff${encoded}`], { type: 'text/plain;charset=utf-8' });//返回的格式
  250. return window.URL.createObjectURL(dataBlob);
  251. },
  252. toOverview(row){
  253. this.$router.push({ path:'/userInfoOverview', query: {id: row.id} })
  254. // this.$router.push({ name:'UserInfoOverview',params:{id: row.id} })
  255. },
  256. toDetail(row){
  257. this.$router.push({ path:'/userInfoDetails', query: {id: row.id} })
  258. // this.$router.push({ name:'UserInfoDetails',params:{id: row.id} })
  259. }
  260. }
  261. };
  262. </script>
  263. <style lang="scss" scoped>
  264. .titleDiv{
  265. height: 50px;
  266. line-height: 50px;
  267. .line{
  268. display: inline-block;
  269. height: 14px;
  270. width: 4px;
  271. border-radius: 2px;
  272. background: #013C89;
  273. vertical-align: middle;
  274. }
  275. .title{
  276. font-size: 16px;
  277. color: #013C89;
  278. margin-left: 14px;
  279. vertical-align: middle;
  280. }
  281. .exportBtn{
  282. float: right;
  283. margin-top: 10px;
  284. }
  285. }
  286. </style>
  287. <style>
  288. .van-pagination__item{
  289. min-width: 30px !important;
  290. height: 28px !important;
  291. border-radius: 2px;
  292. font-weight: bold;
  293. color: #606266;
  294. }
  295. .van-pagination__item--active{
  296. color: #FFF;
  297. background: #013C8A;
  298. }
  299. [class*=van-hairline]::after{
  300. border: none;
  301. }
  302. .van-pagination__item:active {
  303. color: #FFF;
  304. background-color: #013C8A;
  305. }
  306. </style>