customer.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="hui-flex hui-content">
  3. <div class="customer-test">
  4. <div class="test-item" v-for="(item,index) in $field.field.customerType" :key="item.id">
  5. <div class="name">{{item.name}}</div>
  6. <div class="label alibaba color-cyan">{{countItem(item)}}</div>
  7. </div>
  8. </div>
  9. <div class="customer-line"></div>
  10. <div class="hui-content-title">
  11. <div class="hui-title-item active">客户列表</div>
  12. </div>
  13. <div class="hui-flex-box hui-flex hui-table">
  14. <list-filter type="customer" @filter="filterInit"></list-filter>
  15. <div class="hui-content-insert">
  16. <el-button type="primary" size="medium" @click="insertCustomer">新增客户</el-button>
  17. <el-button type="info" size="medium" @click="downloadFile">标准模板下载</el-button>
  18. <el-button type="info" size="medium" @click="$refs.upload.reloadUpload()">批量导入</el-button>
  19. <customer-upload ref="upload" v-show="false" @changeFile="init"></customer-upload>
  20. </div>
  21. <div class="hui-flex-box">
  22. <el-table :data="tableData" row-key="id" border height="100%">
  23. <el-table-column label="序号" width="50">
  24. <template slot-scope="scope">
  25. <div style="text-align: center;">{{scope.$index + 1}}</div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="客户类型">
  29. <template slot-scope="scope">
  30. <span>{{$field.findTypeName('customerType',scope.row.type)}}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="客户名称" prop="name"></el-table-column>
  34. <el-table-column label="客户行业" prop="customerIndustry"></el-table-column>
  35. <el-table-column label="需求区间" prop="demand"></el-table-column>
  36. <el-table-column label="公海客户" width="100">
  37. <template slot-scope="scope">
  38. <div class="hui-table-operation">
  39. <el-switch v-model="scope.row.highSeas" :active-value="1" :inactive-value="2"
  40. @change="val=>putHighSeas(val,scope.row)">
  41. </el-switch>
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="跟进记录" width="100">
  46. <template slot-scope="scope">
  47. <div class="hui-table-operation">
  48. <span class="table-operation" @click="lookCustomer(scope.row,'followUpRecord')">
  49. 查看
  50. </span>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="邀请项目" width="150">
  55. <template slot-scope="scope">
  56. <div class="hui-table-operation" v-if="!scope.row.status">
  57. <span class="table-operation" @click="inviteCustomer(scope.row)">发送邀请</span>
  58. </div>
  59. <div class="hui-table-operation" v-if="scope.row.status === 3">
  60. <span class="table-operation" @click="inviteCustomer(scope.row)">重新邀请</span>
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="邀请状态" width="150">
  65. <template slot-scope="scope">
  66. <div v-if="!scope.row.status" class="hui-state">
  67. <span class="hui-state-bage hui-state-primary"></span>
  68. <span class="hui-state-label">待邀请</span>
  69. </div>
  70. <div v-if="scope.row.status == 1" class="hui-state">
  71. <span class="hui-state-bage hui-state-info"></span>
  72. <span class="hui-state-label">邀请中</span>
  73. </div>
  74. <div v-if="scope.row.status == 2" class="hui-state">
  75. <span class="hui-state-bage hui-state-success"></span>
  76. <span class="hui-state-label">通过邀请</span>
  77. </div>
  78. <div v-if="scope.row.status == 3" class="hui-state">
  79. <span class="hui-state-bage hui-state-error"></span>
  80. <span class="hui-state-label">拒绝邀请</span>
  81. </div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="操作" width="200">
  85. <template slot-scope="scope">
  86. <div class="hui-table-operation">
  87. <span class="table-operation" @click="lookCustomer(scope.row,'customer')">详情</span>
  88. <span class="table-operation" @click="updateCustomer(scope.row)">编辑</span>
  89. <span class="table-operation" @click="deleteCustomer(scope.row)">删除</span>
  90. </div>
  91. </template>
  92. </el-table-column>
  93. <template slot="empty">
  94. <empty description="暂无数据"></empty>
  95. </template>
  96. </el-table>
  97. </div>
  98. <div class="hui-content-pagination">
  99. <el-pagination :page-size="pageSize" :pager-count="9" layout="prev, pager, next" :total="totalCount"
  100. @current-change="currentChange">
  101. </el-pagination>
  102. </div>
  103. </div>
  104. <el-dialog :title="isUpdate?'编辑':'新增'" :visible.sync="visible" width="900px" :append-to-body="true">
  105. <edit v-if="visible" @callback="callback" :isUpdate="isUpdate" :detailId="detailId"></edit>
  106. </el-dialog>
  107. <el-drawer :title="type === 'customer'?'客户详情':'跟进列表'" :visible.sync="drawer" :size="400" :append-to-body="true">
  108. <detail v-if="drawer && type === 'customer'" :detailId="detailId"></detail>
  109. <follow-up-record-detail v-if="drawer && type === 'followUpRecord'" :detailId="detailId">
  110. </follow-up-record-detail>
  111. </el-drawer>
  112. </div>
  113. </template>
  114. <script>
  115. import {
  116. getCustomerListByPage,
  117. deleteCustomerById,
  118. updateCustomer,
  119. getCustomerCount
  120. } from '@/httpApi/crm'
  121. import {
  122. testPhone
  123. } from '@/httpApi/organization'
  124. import edit from '@/components/work/crm/customer/edit'
  125. import detail from '@/components/work/crm/customer/detail'
  126. import followUpRecordDetail from '@/components/work/crm/customer/followUpRecordDetail'
  127. import listFilter from '@/components/common/listFilter'
  128. import customerUpload from '@/components/work/crm/customer/customerUpload'
  129. import config from '@/config'
  130. export default {
  131. data() {
  132. return {
  133. tableData: [],
  134. currPage: 1,
  135. pageSize: 10,
  136. totalCount: 0,
  137. visible: false,
  138. detailId: '',
  139. isUpdate: false,
  140. drawer: false,
  141. type: 'customer',
  142. filterOption: {},
  143. countBox: []
  144. }
  145. },
  146. created() {
  147. this.init();
  148. },
  149. methods: {
  150. init() {
  151. let postData = {
  152. currPage: this.currPage,
  153. pageSize: this.pageSize,
  154. organizationId: this.$store.getters.organization.id,
  155. userId: this.$store.getters.user.id
  156. }
  157. postData = Object.assign(postData, this.filterOption);
  158. getCustomerListByPage(postData).then(res => {
  159. if (res.state) {
  160. this.tableData = res.data.dataList;
  161. this.totalCount = res.data.totalCount;
  162. }
  163. })
  164. getCustomerCount({
  165. organizationId: this.$store.getters.organization.id,
  166. userId: this.$store.getters.user.id
  167. }).then(res => {
  168. if (res.state) {
  169. this.countBox = res.data;
  170. }
  171. })
  172. },
  173. downloadFile() {
  174. window.location.href = config.baseURL + '/manager/client/downloadModel';
  175. },
  176. countItem(item) {
  177. let list = this.countBox.filter(node => node.type === item.id);
  178. if (list.length === 0) return 0;
  179. return list[0].number;
  180. },
  181. filterInit(option) {
  182. this.filterOption = option;
  183. this.currPage = 1;
  184. this.init();
  185. },
  186. currentChange(currPage) {
  187. this.currPage = currPage;
  188. this.init();
  189. },
  190. insertCustomer() {
  191. this.isUpdate = false;
  192. this.visible = true;
  193. },
  194. updateCustomer(val) {
  195. this.detailId = val.id;
  196. this.isUpdate = true;
  197. this.visible = true;
  198. },
  199. lookCustomer(val, type) {
  200. this.detailId = val.id;
  201. this.type = type;
  202. this.drawer = true;
  203. },
  204. putHighSeas(val, item) {
  205. updateCustomer({
  206. id: item.id,
  207. highSeas: val
  208. }).then(res => {
  209. if (res.state) {
  210. this.init();
  211. this.$message.success('操作成功');
  212. }
  213. })
  214. },
  215. inviteCustomer(user) {
  216. testPhone(user.phone).then(res => {
  217. if (res.state) {
  218. this.$confirm('是否邀请该客户至当前项目?', () => {
  219. this.$msg.send({
  220. dataId: user.id,
  221. identityId: 1
  222. }, {
  223. messageType: 2,
  224. userIds: res.data.id
  225. }).then(node => {
  226. if (node.state) {
  227. updateCustomer({
  228. id: user.id,
  229. status: 1
  230. }).then(res => {
  231. if (res.state) {
  232. this.init();
  233. this.$message.success('邀请成功');
  234. }
  235. })
  236. }
  237. })
  238. });
  239. } else {
  240. this.$message.warning('用户不存在,无法绑定');
  241. }
  242. })
  243. },
  244. deleteCustomer(val) {
  245. this.$confirm('确定要删除该客户?', () => {
  246. deleteCustomerById(val.id).then(res => {
  247. if (res.state) {
  248. this.init();
  249. this.$message.success('操作成功');
  250. }
  251. })
  252. });
  253. },
  254. callback(type) {
  255. if (type === 'init') this.init();
  256. this.visible = false;
  257. }
  258. },
  259. components: {
  260. edit,
  261. detail,
  262. followUpRecordDetail,
  263. listFilter,
  264. customerUpload
  265. },
  266. }
  267. </script>
  268. <style lang="scss">
  269. .customer-test {
  270. padding: 15px 20px;
  271. display: flex;
  272. .test-item {
  273. border-right: 1px solid $--color-border;
  274. width: 160px;
  275. margin-right: 20px;
  276. .name {
  277. font-size: 12px;
  278. opacity: 0.8;
  279. }
  280. .label {
  281. font-size: 16px;
  282. font-weight: 600;
  283. padding-top: 5px;
  284. }
  285. }
  286. }
  287. .customer-line {
  288. height: 12px;
  289. background: $--background;
  290. }
  291. </style>