DeleClient.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div>
  3. <div class="communal-list">
  4. <div class="communal-title">
  5. <div>客户资料</div>
  6. <div class="communal-box">
  7. <el-input @input="Inquireclick()" placeholder="城市/名称/联系人" v-model="input" clearable
  8. style="width: 350px;">
  9. </el-input>
  10. <router-link to="/home/DeleClientOperation">
  11. <el-button type="primary" style="margin-left: 10px;">新增</el-button>
  12. </router-link>
  13. </div>
  14. </div>
  15. <template>
  16. <el-table :data="tableDatas.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border
  17. style="width: 100%" v-loading="loading" element-loading-text="拼命加载中...">
  18. <el-table-column prop="num" label="序 号" width="55">
  19. <template slot-scope="scope">
  20. {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="clientName" label="客户姓名">
  24. </el-table-column>
  25. <el-table-column prop="companyName" label="所属公司">
  26. </el-table-column>
  27. <el-table-column prop="sex" label="性别" width="50">
  28. <template slot-scope="sex">
  29. <span v-if="sex.row.sex == 0">男</span>
  30. <span v-else-if="sex.row.sex == 1">女</span>
  31. <span v-else>未填写</span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="marriage" label="婚姻状态" width="80">
  35. <template slot-scope="marriage">
  36. <span v-if="marriage.row.marriage == 0">未设置</span>
  37. <span v-else-if="marriage.row.marriage == 1">未婚</span>
  38. <span v-else-if="marriage.row.marriage == 2">已婚</span>
  39. <span v-else-if="marriage.row.marriage == 3">离异</span>
  40. <span v-else-if="marriage.row.marriage == 4">丧偶</span>
  41. <span v-else>未设置</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column prop="landlinePhone" label="客户座机">
  45. </el-table-column>
  46. <el-table-column prop="tel" label="客户手机号" width="200">
  47. </el-table-column>
  48. <el-table-column prop="idNo" label="身份证号码" width="200">
  49. </el-table-column>
  50. <el-table-column prop="passportNo" label="护照号码" width="200">
  51. </el-table-column>
  52. <el-table-column label="操作">
  53. <template slot-scope="scope">
  54. <el-button size="mini" @click="upDate(scope.$index, scope.row)">编辑</el-button>
  55. <el-button size="mini" type="danger" @click="del(scope.$index, scope.row)">删除</el-button>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. </template>
  60. <div class="block">
  61. <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
  62. :current-page="currentPage" :page-sizes="[10, 12, 15, 20]" :page-size="pageSize"
  63. layout="total, sizes, prev, pager, next" :total="tableDatas.length">
  64. </el-pagination>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. loading: false,
  74. tableDatas: [],
  75. tableData: [],
  76. currentPage: 1, // 当前页码
  77. pageSize: 12,// 每页的数据条数
  78. input: '',
  79. token: '',
  80. userId: 0
  81. }
  82. },
  83. methods: {
  84. //每页条数改变时触发 选择一页显示多少行
  85. handleSizeChange(val) {
  86. this.currentPage = 1;
  87. this.pageSize = val;
  88. },
  89. //当前页改变时触发 跳转其他页
  90. handleCurrentChange(val) {
  91. this.currentPage = val;
  92. },
  93. DeleClient() {
  94. this.loading = true
  95. var url = "/api/CRM/GetClientList"
  96. var that = this
  97. this.$axios({
  98. method: 'post',
  99. url: url,
  100. headers: {
  101. Authorization: 'Bearer ' + this.token
  102. },
  103. data: {
  104. portType: 1,
  105. PageIndex: 0,
  106. PageSize: 0,
  107. City: '',
  108. Name: '',
  109. Contact: '',
  110. ContactPhone: '',
  111. }
  112. }).then(function (res) {
  113. console.log(res)
  114. if (res.data.code == 200) {
  115. that.tableData = res.data.data;
  116. that.tableDatas = that.tableData;
  117. if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
  118. if (that.currentPage > 1) {
  119. that.currentPage = that.currentPage - 1;
  120. }
  121. }
  122. }
  123. that.loading = false
  124. }).catch(function (error) {
  125. that.loading = false
  126. that.$message.error("网络错误,请稍后重试");
  127. });
  128. },
  129. //搜索框处理
  130. Inquireclick() {
  131. var newarr = [];
  132. if (this.input == "") {
  133. newarr = this.tableData;
  134. } else {
  135. for (var i = 0; i < this.tableData.length; i++) {
  136. if (this.tableData[i].city.indexOf(this.input) != -1) {
  137. newarr.push(this.tableData[i]);
  138. } else if (this.tableData[i].name.indexOf(this.input) != -1) {
  139. newarr.push(this.tableData[i]);
  140. } else if (this.tableData[i].contact.indexOf(this.input) != -1) {
  141. newarr.push(this.tableData[i]);
  142. }
  143. }
  144. }
  145. this.tableDatas = newarr;
  146. this.currentPage = 1;
  147. },
  148. upDate(index, row) {
  149. this.$router.push({
  150. path: "/home/visaEdit",
  151. query: { id: row.id }
  152. })
  153. },
  154. del(index, row) {
  155. var url = "/api/CRM/"
  156. var that = this
  157. this.$axios({
  158. method: 'post',
  159. url: url,
  160. headers: {
  161. Authorization: 'Bearer ' + this.token
  162. },
  163. data: {
  164. Id: row.id,
  165. DeleteUserId: this.userId
  166. }
  167. }).then(function (res) {
  168. console.log(res)
  169. if (res.data.code == 200) {
  170. that.$message({
  171. message: '删除成功',
  172. type: 'success'
  173. });
  174. that.DeleClient();
  175. } else {
  176. that.$message.error('删除失败!');
  177. }
  178. that.loading = false
  179. }).catch(function (error) {
  180. that.loading = false
  181. that.$message.error("网络错误,请稍后重试");
  182. });
  183. }
  184. },
  185. mounted() {
  186. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  187. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  188. this.DeleClient();
  189. }
  190. }
  191. </script>
  192. <style>
  193. .communal-list {
  194. background-color: #fff;
  195. padding: 10px;
  196. box-shadow: 0 0 5px #0005;
  197. border-radius: 10px;
  198. }
  199. .communal-title {
  200. display: flex;
  201. font-size: 17px;
  202. font-weight: 600;
  203. color: #555;
  204. margin-top: 8px;
  205. margin-bottom: 10px;
  206. justify-content: space-between;
  207. align-items: center;
  208. }
  209. .communal-box {
  210. display: flex;
  211. }
  212. .communal-box>button {
  213. margin-left: 10px;
  214. padding: 8px 20px;
  215. }
  216. </style>