index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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="['system:role:export']"
  18. >导出</el-button>
  19. </div>
  20. <el-table v-loading="loading" :data="customerList">
  21. <el-table-column label="客户号" :width="cellWidth" align="center" prop="custid" />
  22. <el-table-column label="姓名" :width="cellWidth" align="center" prop="name" :show-overflow-tooltip="true" />
  23. <el-table-column label="证件类型" :width="cellWidth" align="center" >
  24. <template slot-scope="scope">
  25. <span v-if="scope.row.idcard!=undefined && scope.row.idcard!=''">身份证</span>
  26. <span v-else-if="scope.row.passport!=undefined && scope.row.passport!=''">护照</span>
  27. <span v-else-if="scope.row.dlicense!=undefined && scope.row.dlicense!=''">驾驶证</span>
  28. <span v-else-if="scope.row.othernumber!=undefined && scope.row.othernumber!=''">其它证件类型</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="证件号码" align="center" :show-overflow-tooltip="true">
  32. <template slot-scope="scope">
  33. <span v-if="scope.row.idcard && scope.row.idcard!=''">{{scope.row.idcard}}</span>
  34. <span v-else-if="scope.row.passport && scope.row.passport!=''">{{scope.row.passport}}</span>
  35. <span v-else-if="scope.row.dlicense && scope.row.dlicense!=''">{{scope.row.dlicense}}</span>
  36. <span v-else-if="scope.row.othernumber && scope.row.othernumber!=''">{{scope.row.othernumber}}</span>
  37. <span v-else></span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="性别" align="center" prop="gender" :width="cellWidthS">
  41. <template slot-scope="scope">
  42. <span v-if="scope.row.gender == 0">男</span>
  43. <span v-else>女</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="出生日期" align="center" :width="cellWidth">
  47. <template slot-scope="scope">
  48. <span>{{ parseTime(scope.row.birthday,'{yy}-{mm}-{dd}') }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="年龄" align="center" prop="age" :width="cellWidthS" />
  52. <el-table-column label="客户等级" align="center" prop="level" :width="cellWidthS">
  53. <template slot-scope="scope">
  54. <span>{{levelText(scope.row.custclass)}}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. label="操作"
  59. align="center"
  60. :width="cellWidthB"
  61. class-name="small-padding fixed-width"
  62. >
  63. <template slot-scope="scope">
  64. <el-button
  65. size="mini"
  66. icon="el-icon-copy-document"
  67. @click="toOverview(scope.row)"
  68. v-hasPermi="['business:customerInformation:overview']"
  69. >概览</el-button>
  70. <el-button
  71. v-if="scope.row.userId !== 1"
  72. size="mini"
  73. type="cyan"
  74. icon="el-icon-warning-outline"
  75. @click="toDetail(scope.row)"
  76. v-hasPermi="['business:customerInformation:detail']"
  77. >详情</el-button>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <pagination
  82. v-show="total>0"
  83. :total="total"
  84. :page.sync="queryParams.pageNum"
  85. :limit.sync="queryParams.pageSize"
  86. @pagination="getList"
  87. />
  88. </div>
  89. </div>
  90. </el-col>
  91. </el-row>
  92. </div>
  93. </template>
  94. <script>
  95. import { listCustomer } from "@/api/customerInformation/customerInformation.js";
  96. import axios from 'axios'
  97. export default {
  98. name: "UserInfoList",
  99. data() {
  100. return {
  101. // 遮罩层
  102. loading: false,
  103. // 总条数
  104. total: 0,
  105. // 用户表格数据
  106. // userList: null,
  107. customerList: [],
  108. // 查询参数
  109. queryParams: {
  110. pageNum: 1,
  111. pageSize: 10
  112. },
  113. cellWidth:'130',
  114. cellWidthS:'90',
  115. cellWidthB:'260',
  116. };
  117. },
  118. // watch: {
  119. // $route: {
  120. // handler: function(val, oldVal){
  121. // console.log(val);
  122. // },
  123. // // 深度观察监听
  124. // deep: true
  125. // }
  126. // },
  127. beforeRouteEnter(to, from, next) {
  128. console.log(from)
  129. if (from.name === 'Index') {
  130. next(vm => {
  131. vm.getList();
  132. })
  133. } else if (!from.name) { // 处理刷新页面时,获取动态表单方法未执行,导致表单无法加载
  134. next(vm => {
  135. vm.getList();
  136. })
  137. } else {
  138. // 详情返回时只更新列表数据,因为如果在详情页面做了操作,列表数据状态会改变,其他使用缓存
  139. next(vm => {
  140. vm.getList();
  141. })
  142. }
  143. },
  144. created() {
  145. this.getList();
  146. },
  147. mounted() {
  148. var clientWidth = document.body.clientWidth;
  149. var that = this;
  150. if(clientWidth <= 1370){
  151. that.cellWidth='120';
  152. that.cellWidthS='80';
  153. that.cellWidthB='160';
  154. }else{
  155. that.cellWidth='160';
  156. that.cellWidthS='120';
  157. that.cellWidthB='280';
  158. }
  159. },
  160. methods: {
  161. /** 查询用户列表 */
  162. getList() {
  163. let that = this;
  164. that.loading = true;
  165. console.log(that.queryParams)
  166. Object.assign(
  167. that.queryParams,
  168. that.$route.params
  169. )
  170. // let params = Object.assign({pageNum: that.queryParams.pageNum}, this.$route.query )
  171. // console.log(params)
  172. // this.$router.push({params})
  173. if(that.queryParams.education){
  174. that.queryParams.education = that.queryParams.education.join("&");
  175. }
  176. // console.log(this.$route.params)
  177. listCustomer(that.queryParams).then(response => {
  178. console.log(response);
  179. this.customerList = response.data.list;
  180. this.total = response.data.total;
  181. this.loading = false;
  182. }
  183. );
  184. },
  185. /** 导出按钮操作 */
  186. handleExport() {
  187. this.download('system/user/export', {
  188. ...this.queryParams
  189. }, `user_${new Date().getTime()}.xlsx`)
  190. },
  191. toOverview(row){
  192. this.$router.push({ path:'/userInfoOverview', query: {id: row.id} })
  193. // this.$router.push({ name:'UserInfoOverview',params:{id: row.id} })
  194. },
  195. toDetail(row){
  196. this.$router.push({ path:'/userInfoDetails', query: {id: row.id} })
  197. // this.$router.push({ name:'UserInfoDetails',params:{id: row.id} })
  198. }
  199. }
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. .titleDiv{
  204. height: 50px;
  205. line-height: 50px;
  206. .line{
  207. display: inline-block;
  208. height: 14px;
  209. width: 4px;
  210. border-radius: 2px;
  211. background: #013C89;
  212. vertical-align: middle;
  213. }
  214. .title{
  215. font-size: 16px;
  216. color: #013C89;
  217. margin-left: 14px;
  218. vertical-align: middle;
  219. }
  220. .exportBtn{
  221. float: right;
  222. margin-top: 10px;
  223. }
  224. }
  225. </style>