DeleClient.vue 8.7 KB

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