index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="客户编码" prop="customerCode">
  5. <el-input
  6. style="width:220px"
  7. v-model="queryParams.customerCode"
  8. placeholder="请输入客户编码"
  9. clearable
  10. size="small"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item label="客户名称" prop="customerName">
  15. <el-input
  16. style="width:220px"
  17. v-model="queryParams.customerName"
  18. placeholder="请输入客户名称"
  19. clearable
  20. size="small"
  21. @keyup.enter.native="handleQuery"
  22. />
  23. </el-form-item>
  24. <el-form-item label="手机" prop="mobile">
  25. <el-input
  26. style="width:220px"
  27. v-model="queryParams.mobile"
  28. placeholder="请输入手机"
  29. clearable
  30. size="small"
  31. @keyup.enter.native="handleQuery"
  32. />
  33. </el-form-item>
  34. <el-form-item label="所属部门" prop="deptId">
  35. <treeselect style="width:220px" v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属部门" />
  36. </el-form-item>
  37. <el-form-item label="客户状态" prop="status">
  38. <el-select style="width:220px" v-model="queryParams.status" placeholder="请选择客户状态" clearable size="small">
  39. <el-option
  40. v-for="item in statusOptions"
  41. :key="item.dictValue"
  42. :label="item.dictLabel"
  43. :value="item.dictValue"
  44. />
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="跟进阶段" prop="visitStatus">
  48. <el-select style="width:220px" multiple filterable v-model="visitStatusArr" placeholder="请选择跟进阶段" clearable size="small">
  49. <el-option
  50. v-for="item in visitStatusOptions"
  51. :key="item.dictValue"
  52. :label="item.dictLabel"
  53. :value="item.dictValue"
  54. />
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item label="客户类型" prop="customerLevel">
  58. <el-select style="width:220px" filterable v-model="queryParams.customerLevel" placeholder="请选择客户类型" clearable size="small">
  59. <el-option
  60. v-for="item in customerLevelOptions"
  61. :key="item.dictValue"
  62. :label="item.dictLabel"
  63. :value="item.dictValue"
  64. />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="客户标签" prop="tags">
  68. <el-select style="width:220px" multiple filterable v-model="tagIds" placeholder="请选择客户标签" clearable size="small">
  69. <el-option
  70. v-for="item in tagsOptions"
  71. :key="item.dictLabel"
  72. :label="item.dictLabel"
  73. :value="item.dictLabel"
  74. />
  75. </el-select>
  76. </el-form-item>
  77. <!-- <el-form-item label="是否认领" prop="isReceive">
  78. <el-select v-model="queryParams.isReceive" placeholder="请选择是否认领" clearable size="small">
  79. <el-option
  80. v-for="item in receiveOptions"
  81. :key="item.dictValue"
  82. :label="item.dictLabel"
  83. :value="item.dictValue"
  84. />
  85. </el-select>
  86. </el-form-item> -->
  87. <!-- <el-form-item label="员工姓名" prop="companyUserNickName">
  88. <el-input
  89. style="width:220px"
  90. v-model="queryParams.companyUserNickName"
  91. placeholder="请输入员工姓名"
  92. clearable
  93. size="small"
  94. @keyup.enter.native="handleQuery"
  95. />
  96. </el-form-item> -->
  97. <el-form-item label="员工姓名" prop="companyUserNickName">
  98. <el-select style="width:220px" filterable v-model="queryParams.companyUserNickName" placeholder="请选择员工" clearable size="small">
  99. <el-option
  100. v-for="item in CompanyUserNames"
  101. :key="item.userId"
  102. :label="item.nickName"
  103. :value="item.nickName"
  104. />
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item label="创建时间" prop="createTime">
  108. <el-date-picker
  109. style="width:220px"
  110. clearable size="small"
  111. v-model="dateRange"
  112. type="daterange"
  113. value-format="yyyy-MM-dd"
  114. start-placeholder="开始日期"
  115. end-placeholder="结束日期">
  116. </el-date-picker>
  117. </el-form-item>
  118. <el-form-item label="客户来源" prop="source">
  119. <el-select style="width:220px" filterable multiple v-model="sourceArr" placeholder="请选择客户来源" clearable size="small">
  120. <el-option
  121. v-for="item in sourceOptions"
  122. :key="item.dictValue"
  123. :label="item.dictLabel"
  124. :value="item.dictValue"
  125. />
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="是否下单" prop="isBuy">
  129. <el-select style="width:220px" filterable v-model="queryParams.isBuy" placeholder="请选择是否下单" clearable size="small">
  130. <el-option key="1" label="是" value="1" />
  131. <el-option key="0" label="否" value="0" />
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item label="历史订单" prop="isHisOrder">
  135. <el-select style="width:220px" filterable v-model="queryParams.isHisOrder" placeholder="请选择历史订单" clearable size="small">
  136. <el-option key="1" label="是" value="1" />
  137. <el-option key="0" label="否" value="0" />
  138. </el-select>
  139. </el-form-item>
  140. <el-form-item>
  141. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  142. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  143. </el-form-item>
  144. </el-form>
  145. <el-row :gutter="10" class="mb8">
  146. <el-col :span="1.5">
  147. <el-button
  148. type="success"
  149. icon="el-icon-edit"
  150. size="mini"
  151. :disabled="multiple"
  152. @click="handleAssign"
  153. v-hasPermi="['crm:customer:assignToUser']"
  154. >客户分配</el-button>
  155. </el-col>
  156. <el-col :span="1.5">
  157. <el-button
  158. type="success"
  159. size="mini"
  160. @click="handleAssignList"
  161. v-hasPermi="['crm:customerAssign:list']"
  162. >分配历史记录</el-button>
  163. </el-col>
  164. <el-col :span="1.5">
  165. <el-button
  166. type="success"
  167. size="mini"
  168. :disabled="multiple"
  169. @click="handleEditScource"
  170. v-hasPermi="['crm:customer:editScource']"
  171. >修改客户来源</el-button>
  172. </el-col>
  173. <el-col :span="1.5">
  174. <el-button
  175. type="success"
  176. size="mini"
  177. :disabled="multiple"
  178. @click="handleSendBatchSms"
  179. v-hasPermi="['crm:customer:sendBatchSms']"
  180. >批量发送短信</el-button>
  181. </el-col>
  182. <el-col :span="1.5">
  183. <el-button
  184. type="success"
  185. icon="el-icon-edit"
  186. size="mini"
  187. @click="handleAddScource"
  188. v-hasPermi="['crm:customer:source']"
  189. >客户来源</el-button>
  190. </el-col>
  191. <el-col :span="1.5">
  192. <el-button
  193. type="warning"
  194. icon="el-icon-download"
  195. size="mini"
  196. @click="handleExport"
  197. v-hasPermi="['crm:customer:export']"
  198. >导出</el-button>
  199. </el-col>
  200. <el-col :span="1.5">
  201. <el-button
  202. type="warning"
  203. icon="el-icon-upload2"
  204. size="mini"
  205. @click="handleImport"
  206. v-hasPermi="['crm:customer:importVisit']"
  207. >导入跟进阶段</el-button>
  208. </el-col>
  209. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  210. </el-row>
  211. <el-tabs type="card" v-model="queryParams.isReceive" @tab-click="handleClick">
  212. <el-tab-pane label="未领取" name="0"></el-tab-pane>
  213. <el-tab-pane label="已领取" name="1"></el-tab-pane>
  214. </el-tabs>
  215. <el-table height="500" border v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
  216. <el-table-column type="selection" width="55" align="center" />
  217. <el-table-column label="客户编码" align="center" prop="customerCode" />
  218. <el-table-column label="客户名称" align="center" prop="customerName" :show-overflow-tooltip="true">
  219. <template slot-scope="scope">
  220. <el-link @click="handleShow(scope.row)" :underline="false" type="primary" >{{scope.row.customerName}}</el-link>
  221. </template>
  222. </el-table-column>
  223. <el-table-column label="手机" width="120px" align="center" prop="mobile" >
  224. <template slot-scope="scope">
  225. {{scope.row.mobile}}
  226. </template>
  227. </el-table-column>
  228. <el-table-column label="客户来源" align="center" prop="source">
  229. <template slot-scope="scope">
  230. <el-tag prop="status" v-for="(item, index) in sourceOptions" v-if="scope.row.source==item.dictValue">{{item.dictLabel}}</el-tag>
  231. </template>
  232. </el-table-column>
  233. <el-table-column label="客户类型" width="200" align="center" prop="customerLevel">
  234. <template slot-scope="scope">
  235. <el-tag v-for="(item, index) in customerLevelOptions" v-if="scope.row.customerLevel===item.dictValue">{{item.dictLabel}}</el-tag>
  236. </template>
  237. </el-table-column>
  238. <el-table-column label="标签" align="center" prop="tags" />
  239. <el-table-column label="备注" align="center" prop="remark" />
  240. <el-table-column label="进线客户详情" align="center" :show-overflow-tooltip="true" prop="registerDesc" />
  241. <el-table-column label="领取时间" align="center" prop="receiveTime" />
  242. <el-table-column label="进线客户提交日期" align="center" prop="registerSubmitTime" />
  243. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  244. </el-table-column>
  245. <el-table-column label="认领人" align="center" prop="companyUserNickName" :show-overflow-tooltip="true">
  246. </el-table-column>
  247. <!-- <el-table-column label="最后一次跟进时间" align="center" prop="receiveTime" width="180"> -->
  248. <!-- </el-table-column> -->
  249. <el-table-column label="入公海时间" align="center" prop="poolTime" width="180">
  250. </el-table-column>
  251. <el-table-column label="成交总价" align="center" prop="payMoney"/>
  252. <el-table-column label="成交类型" align="center" prop="orderType">
  253. <template slot-scope="scope">
  254. <el-tag v-for="item in orderTypeOptions" v-if="scope.row.orderType === item.dictValue">{{item.dictLabel}}</el-tag>
  255. </template>
  256. </el-table-column>
  257. <el-table-column label="最新下单时间" align="center" prop="orderTime" width="180"></el-table-column>
  258. <el-table-column label="跟进阶段" width="200" align="center" prop="visitStatus">
  259. <template slot-scope="scope">
  260. <el-tag prop="visitStatus" v-for="(item, index) in visitStatusOptions" v-if="scope.row.visitStatus==item.dictValue">{{item.dictLabel}}</el-tag>
  261. </template>
  262. </el-table-column>
  263. <el-table-column label="跟进类型" align="center" prop="visitType">
  264. <template slot-scope="scope">
  265. <el-tag v-for="item in visitTypeOptions" v-if="scope.row.visitType === item.dictValue">{{item.dictLabel}}</el-tag>
  266. </template>
  267. </el-table-column>
  268. <el-table-column label="跟进内容" align="center" prop="visitContent"/>
  269. <el-table-column label="最新跟进时间" align="center" prop="visitTime" width="180"></el-table-column>
  270. <el-table-column label="操作" align="center" fixed="right" width="120px" class-name="small-padding fixed-width">
  271. <template slot-scope="scope">
  272. <!-- <el-button
  273. size="mini"
  274. type="text"
  275. icon="el-icon-edit"
  276. @click="handleUpdate(scope.row)"
  277. v-hasPermi="['crm:customer:edit']"
  278. >修改</el-button> -->
  279. <el-button
  280. size="mini"
  281. type="text"
  282. @click="handleShow(scope.row)"
  283. v-hasPermi="['crm:customer:query']"
  284. >查看</el-button>
  285. <el-button
  286. v-if="scope.row.isReceive==1"
  287. size="mini"
  288. type="text"
  289. @click="handleRecover(scope.row)"
  290. v-hasPermi="['crm:customer:recover']"
  291. >回收公海</el-button>
  292. <!-- <el-button
  293. size="mini"
  294. type="text"
  295. @click="handleAssign(scope.row)"
  296. v-hasPermi="['crm:customer:assign']"
  297. >分配客户</el-button> -->
  298. <el-button
  299. size="mini"
  300. type="text"
  301. icon="el-icon-mouse"
  302. @click="handleSwitchToTop(scope.row)"
  303. v-hasPermi="['crm:customer:switchToTop']"
  304. >{{ scope.row.isTop === 1 ? '取消置顶' : '置顶' }}</el-button>
  305. </template>
  306. </el-table-column>
  307. </el-table>
  308. <pagination
  309. v-show="total>0"
  310. :total="total"
  311. :page.sync="queryParams.pageNum"
  312. :limit.sync="queryParams.pageSize"
  313. @pagination="getList"
  314. />
  315. <el-drawer
  316. size="75%"
  317. :title="show.title" :visible.sync="show.open"
  318. >
  319. <customer-details ref="customerDetails" />
  320. </el-drawer>
  321. <el-dialog :title="addSms.title" :visible.sync="addSms.open" width="1000px" append-to-body>
  322. <add-batch-sms ref="sms" @close="closeSms()"></add-batch-sms>
  323. </el-dialog>
  324. <el-dialog :title="source.title" :visible.sync="source.open" width="1000px" append-to-body>
  325. <edit-source ref="editSource" @close="closeSource()"></edit-source>
  326. </el-dialog>
  327. <el-dialog :title="customerSource.title" :visible.sync="customerSource.open" width="1000px" append-to-body>
  328. <customer-source ref="customerSource" @close="closeSource()"></customer-source>
  329. </el-dialog>
  330. <el-dialog :title="assignList.title" :visible.sync="assignList.open" width="1000px" append-to-body>
  331. <customer-assign-list ref="assignList" @close="closeAssignList"></customer-assign-list>
  332. </el-dialog>
  333. <el-dialog :title="assign.title" :visible.sync="assign.open" width="800px" append-to-body>
  334. <assign-user ref="assignUser" @close="closeAssign" />
  335. </el-dialog>
  336. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  337. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  338. <i class="el-icon-upload"></i>
  339. <div class="el-upload__text">
  340. 将文件拖到此处,或
  341. <em>点击上传</em>
  342. </div>
  343. <div class="el-upload__tip" slot="tip">
  344. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  345. </div>
  346. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  347. </el-upload>
  348. <div slot="footer" class="dialog-footer">
  349. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  350. <el-button @click="upload.open = false">取 消</el-button>
  351. </div>
  352. </el-dialog>
  353. <el-dialog title="导入结果" :close-on-press-escape="false" :close-on-click-modal="false" :visible.sync="importMsgOpen" width="500px" append-to-body>
  354. <div class="import-msg" v-html="importMsg">
  355. </div>
  356. </el-dialog>
  357. </div>
  358. </template>
  359. <script>
  360. import {
  361. assignToUser,
  362. recover,
  363. receive,
  364. getCustomerList,
  365. addCustomer,
  366. updateCustomer,
  367. getCustomerDetails,
  368. exportCustomer,
  369. importVisitTemplate,
  370. switchToTop
  371. } from "@/api/crm/customer";
  372. import { getToken } from "@/utils/auth";
  373. import customerDetails from '../components/customerDetails.vue';
  374. import {getCitys} from "@/api/store/city";
  375. import { treeselect } from "@/api/company/companyDept";
  376. import {getAllCompanyUserName} from "@/api/company/companyUser";
  377. import Treeselect from "@riophae/vue-treeselect";
  378. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  379. import addBatchSms from '../components/addBatchSms.vue';
  380. import editSource from '../components/editSource.vue';
  381. import customerSource from '../components/customerSource.vue';
  382. import customerAssignList from '../components/customerAssignList.vue';
  383. import assignUser from '../components/assignUser.vue';
  384. import {customerLevelOptions} from "@/api/crm/customerLevel";
  385. export default {
  386. name: "Customer",
  387. components: {assignUser,customerAssignList,addBatchSms,editSource, customerDetails,Treeselect,customerSource },
  388. data() {
  389. return {
  390. upload: {
  391. // 是否显示弹出层(用户导入)
  392. open: false,
  393. // 弹出层标题(用户导入)
  394. title: "",
  395. // 是否禁用上传
  396. isUploading: false,
  397. // 设置上传的请求头部
  398. headers: { Authorization: "Bearer " + getToken() },
  399. // 上传的地址
  400. url: process.env.VUE_APP_BASE_API + "/crm/customer/importVisitData",
  401. },
  402. importMsgOpen:false,
  403. importMsg:"",
  404. tagIds:[],
  405. tagsOptions:[],
  406. CompanyUserNames:[],
  407. assignList:{
  408. title:"分配历史记录",
  409. open:false,
  410. },
  411. orderTypeOptions: [],
  412. visitTypeOptions:[],
  413. visitStatusOptions:[],
  414. customerSource:{
  415. open:false,
  416. title:"客户来源"
  417. },
  418. source:{
  419. open:false,
  420. title:"修改客户来源"
  421. },
  422. dateRange:[],
  423. addSms:{
  424. open:false,
  425. title:"批量发短信"
  426. },
  427. assign:{
  428. title:"分配客户",
  429. open:false,
  430. },
  431. defaultProps: {
  432. children: "children",
  433. label: "label",
  434. },
  435. // 部门树选项
  436. deptOptions: undefined,
  437. // 部门名称
  438. deptName: undefined,
  439. cityIds:[],
  440. citys:[],
  441. tags:[],
  442. visitStatusArr:[],
  443. ctsTypeArr:[],
  444. sourceArr:[],
  445. inputVisible: false,
  446. inputValue: '',
  447. receiveOptions:[],
  448. statusOptions:[],
  449. typeOptions:[],
  450. sourceOptions:[],
  451. sexOptions:[],
  452. show:{
  453. title:"客户详情",
  454. open:false,
  455. },
  456. // 遮罩层
  457. loading: true,
  458. // 选中数组
  459. ids: [],
  460. // 非单个禁用
  461. single: true,
  462. // 非多个禁用
  463. multiple: true,
  464. // 显示搜索条件
  465. showSearch: true,
  466. // 总条数
  467. total: 0,
  468. // 客户表格数据
  469. customerList: [],
  470. // 弹出层标题
  471. title: "",
  472. // 是否显示弹出层
  473. open: false,
  474. // 查询参数
  475. queryParams: {
  476. pageNum: 1,
  477. pageSize: 10,
  478. customerCode: null,
  479. customerName: null,
  480. mobile: null,
  481. sex: null,
  482. weixin: null,
  483. userId: null,
  484. createUserId: null,
  485. receiveUserId: null,
  486. customerUserId: null,
  487. address: null,
  488. location: null,
  489. detailAddress: null,
  490. lng: null,
  491. lat: null,
  492. status: null,
  493. isReceive: null,
  494. deptId: null,
  495. isDel: null,
  496. customerType: null,
  497. receiveTime: null,
  498. poolTime: null,
  499. companyId: null,
  500. isLine: null,
  501. source: null,
  502. tags: null,
  503. tagList:[],
  504. visitStatus:null,
  505. customerLevel: null,
  506. },
  507. // 表单参数
  508. form: {
  509. province:null,
  510. city:null,
  511. district:null,
  512. },
  513. // 表单校验
  514. rules: {
  515. customerName: [
  516. { required: true, message: "客户名称不能为空", trigger: "blur" }
  517. ],
  518. mobile: [
  519. { required: true, message: "手机号不能为空", trigger: "blur" }
  520. ],
  521. sex: [
  522. { required: true, message: "性别不能为空", trigger: "blur" }
  523. ],
  524. source: [
  525. { required: true, message: "客户来源不能为空", trigger: "blur" }
  526. ],
  527. },
  528. customerLevelOptions: []
  529. };
  530. },
  531. watch: {
  532. // 根据名称筛选部门树
  533. deptName(val) {
  534. this.$refs.tree.filter(val);
  535. },
  536. },
  537. created() {
  538. this.getDicts("store_order_type").then((response) => {
  539. this.orderTypeOptions = response.data;
  540. });
  541. this.getDicts("crm_customer_visit_type").then((response) => {
  542. this.visitTypeOptions = response.data;
  543. });
  544. this.getDicts("crm_customer_user_status").then((response) => {
  545. this.visitStatusOptions = response.data;
  546. });
  547. this.getDicts("crm_customer_source").then((response) => {
  548. this.sourceOptions = response.data;
  549. });
  550. this.getDicts("common_sex").then((response) => {
  551. this.sexOptions = response.data;
  552. });
  553. this.getDicts("crm_customer_source").then((response) => {
  554. this.sourceOptions = response.data;
  555. });
  556. this.getDicts("common_sex").then((response) => {
  557. this.sexOptions = response.data;
  558. });
  559. this.getDicts("crm_customer_status").then((response) => {
  560. this.statusOptions = response.data;
  561. });
  562. this.getDicts("crm_customer_type").then((response) => {
  563. this.typeOptions = response.data;
  564. });
  565. this.getDicts("crm_customer_is_receive").then((response) => {
  566. this.receiveOptions = response.data;
  567. });
  568. this.getDicts("crm_customer_tag").then((response) => {
  569. this.tagsOptions = response.data;
  570. });
  571. this.getTreeselect();
  572. this.getCitys();
  573. this.getList();
  574. this.getCustomerLevelOptions();
  575. this.getAllCompanyUserName();
  576. },
  577. methods: {
  578. getCustomerLevelOptions(){
  579. customerLevelOptions().then((response) => {
  580. this.customerLevelOptions = response.data;
  581. });
  582. },
  583. handleShow(row){
  584. this.show.open=true;
  585. var that=this;
  586. setTimeout(() => {
  587. that.$refs.customerDetails.getDetails(row.customerId);
  588. }, 200);
  589. },
  590. handleAssignList(){
  591. this.assignList.open=true;
  592. var that=this;
  593. setTimeout(() => {
  594. that.$refs.assignList.getData();
  595. }, 200);
  596. },
  597. closeAssignList(){
  598. this.assignList.open=false;
  599. this.getList();
  600. },
  601. handleAddScource(){
  602. this.customerSource.open=true;
  603. var that=this;
  604. setTimeout(() => {
  605. that.$refs.customerSource.getData();
  606. }, 200);
  607. },
  608. closeCustomerSource(){
  609. this.customerSource.open=false;
  610. this.getList();
  611. },
  612. changeVal() {
  613. console.log(1)
  614. this.$forceUpdate();//解决点击计数器失效问题
  615. },
  616. handleEditScource(){
  617. this.source.open=true;
  618. var that=this;
  619. setTimeout(() => {
  620. that.$refs.editSource.handleEdit(that.ids);
  621. }, 200);
  622. },
  623. closeSource(){
  624. this.source.open=false;
  625. this.getList();
  626. },
  627. closeSms(){
  628. this.addSms.open=false;
  629. },
  630. handleSendBatchSms(){
  631. const customerIds = this.ids;
  632. this.addSms.open=true;
  633. var that=this;
  634. setTimeout(() => {
  635. console.log(customerIds)
  636. that.$refs.sms.reset(customerIds);
  637. }, 500);
  638. },
  639. handleClick(tab, event) {
  640. this.queryParams.isReceive=tab.name;
  641. this.getList();
  642. },
  643. handleAssign(){
  644. var that=this;
  645. var ids=this.ids;
  646. that.assign.open=true;
  647. setTimeout(() => {
  648. if(that.queryParams.isReceive=="0"){
  649. that.$refs.assignUser.init(ids,2);
  650. }
  651. else if(that.queryParams.isReceive=="1"){
  652. that.$refs.assignUser.init(ids,3);
  653. }
  654. }, 200);
  655. },
  656. closeAssign(){
  657. this.assign.open=false;
  658. this.getList();
  659. },
  660. handleRecover(row) {
  661. this.$confirm('是否确认回收客户"' + row.customerName + '"?', "警告", {
  662. confirmButtonText: "确定",
  663. cancelButtonText: "取消",
  664. type: "warning"
  665. }).then(function() {
  666. var data={customerUserId:row.customerUserId}
  667. return recover(data);
  668. }).then(() => {
  669. this.getList();
  670. this.msgSuccess("操作成功");
  671. }).catch(function() {});
  672. },
  673. handleReceive(row) {
  674. this.$confirm('是否确认认领客户"' + row.customerName + '"?', "警告", {
  675. confirmButtonText: "确定",
  676. cancelButtonText: "取消",
  677. type: "warning"
  678. }).then(function() {
  679. var data={customerId:row.customerId}
  680. return receive(data);
  681. }).then(() => {
  682. this.getList();
  683. this.msgSuccess("操作成功");
  684. }).catch(function() {});
  685. },
  686. handleSwitchToTop(row) {
  687. switchToTop(row.customerId).then(response => {
  688. const {code} = response
  689. if (code === 200) {
  690. this.msgSuccess(row.isTop === 0 ? "已置顶" : "已取消置顶");
  691. this.getList();
  692. }
  693. })
  694. },
  695. getTreeselect() {
  696. treeselect().then((response) => {
  697. this.deptOptions = response.data;
  698. });
  699. },
  700. // 筛选节点
  701. filterNode(value, data) {
  702. if (!value) return true;
  703. return data.label.indexOf(value) !== -1;
  704. },
  705. // 节点单击事件
  706. handleNodeClick(data) {
  707. this.queryParams.deptId = data.id;
  708. this.getList();
  709. },
  710. handleCityChange(value) {
  711. console.log(value);
  712. var nodes=this.$refs.citySelect.getCheckedNodes();
  713. this.form.address=nodes[0].pathLabels[0]+"-"+nodes[0].pathLabels[1]+"-"+nodes[0].pathLabels[2];
  714. this.form.cityIds=value.toString();
  715. console.log(this.form.address);
  716. },
  717. getCitys(){
  718. getCitys().then(res => {
  719. this.loading = false;
  720. this.citys=res.data;
  721. })
  722. },
  723. /** 查询客户列表 */
  724. getList() {
  725. this.loading = true;
  726. if(this.visitStatusArr.length>0){
  727. this.queryParams.visitStatus=this.visitStatusArr.toString();
  728. }
  729. else{
  730. this.queryParams.visitStatus=null
  731. }
  732. if(this.ctsTypeArr.length>0){
  733. this.queryParams.customerType=this.ctsTypeArr.toString();
  734. }
  735. else{
  736. this.queryParams.customerType=null
  737. }
  738. if(this.sourceArr.length>0){
  739. this.queryParams.source=this.sourceArr.toString();
  740. }
  741. else{
  742. this.queryParams.source=null
  743. }
  744. if(this.tagIds.length>0){
  745. this.queryParams.tags=this.tagIds.toString();
  746. }
  747. else{
  748. this.queryParams.tags=null
  749. }
  750. getCustomerList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  751. this.customerList = response.rows;
  752. this.total = response.total;
  753. this.loading = false;
  754. });
  755. },
  756. // 取消按钮
  757. cancel() {
  758. this.open = false;
  759. this.reset();
  760. },
  761. // 表单重置
  762. reset() {
  763. this.form = {
  764. customerId: null,
  765. customerCode: null,
  766. customerName: null,
  767. mobile: null,
  768. sex: null,
  769. weixin: null,
  770. remark: null,
  771. userId: null,
  772. createUserId: null,
  773. receiveUserId: null,
  774. customerUserId: null,
  775. address: null,
  776. location: null,
  777. detailAddress: null,
  778. lng: null,
  779. lat: null,
  780. createTime: null,
  781. updateTime: null,
  782. status: 0,
  783. isReceive: null,
  784. deptId: null,
  785. isDel: null,
  786. customerType: null,
  787. receiveTime: null,
  788. poolTime: null,
  789. companyId: null,
  790. isLine: null,
  791. source: null,
  792. tags: null
  793. };
  794. this.tags=[];
  795. this.cityIds=[];
  796. this.resetForm("form");
  797. },
  798. /** 搜索按钮操作 */
  799. handleQuery() {
  800. this.queryParams.pageNum = 1;
  801. this.getList();
  802. },
  803. /** 重置按钮操作 */
  804. resetQuery() {
  805. this.resetForm("queryForm");
  806. this.handleQuery();
  807. },
  808. // 多选框选中数据
  809. handleSelectionChange(selection) {
  810. this.ids = selection.map(item => item.customerId)
  811. this.single = selection.length!==1
  812. this.multiple = !selection.length
  813. },
  814. /** 新增按钮操作 */
  815. handleAdd() {
  816. this.reset();
  817. this.open = true;
  818. this.title = "添加客户";
  819. },
  820. /** 修改按钮操作 */
  821. handleUpdate(row) {
  822. this.reset();
  823. var that=this;
  824. const customerId = row.customerId || this.ids.toString()
  825. var data={customerId:customerId}
  826. getCustomerDetails(data).then(response => {
  827. this.form = response.data;
  828. if(this.form.status!=null){
  829. this.form.status = this.form.status.toString();
  830. }
  831. if(this.form.customerType!=null){
  832. this.form.customerType = this.form.customerType.toString();
  833. }
  834. if(this.form.sex!=null){
  835. this.form.sex = this.form.sex.toString();
  836. }
  837. if(this.form.source!=null){
  838. this.form.source = this.form.source.toString();
  839. }
  840. if(this.form.tags!=null){
  841. this.tags = this.form.tags.split(",")
  842. }
  843. console.log(this.form.cityIds)
  844. if(this.form.cityIds!=null){
  845. var ids=this.form.cityIds.split(",");
  846. this.cityIds=[];
  847. ids.forEach(element => {
  848. var id=parseInt(element);
  849. that.cityIds.push(id)
  850. });
  851. }
  852. this.open = true;
  853. this.title = "修改客户";
  854. });
  855. },
  856. /** 提交按钮 */
  857. submitForm() {
  858. this.$refs["form"].validate(valid => {
  859. if (valid) {
  860. if (this.form.customerId != null) {
  861. updateCustomer(this.form).then(response => {
  862. if (response.code === 200) {
  863. this.msgSuccess("修改成功");
  864. this.open = false;
  865. this.getList();
  866. }
  867. });
  868. } else {
  869. addCustomer(this.form).then(response => {
  870. if (response.code === 200) {
  871. this.msgSuccess("新增成功");
  872. this.open = false;
  873. this.getList();
  874. }
  875. });
  876. }
  877. }
  878. });
  879. },
  880. /** 删除按钮操作 */
  881. handleDelete(row) {
  882. const customerIds = row.customerId || this.ids;
  883. this.$confirm('是否确认删除客户编号为"' + customerIds + '"的数据项?', "警告", {
  884. confirmButtonText: "确定",
  885. cancelButtonText: "取消",
  886. type: "warning"
  887. }).then(function() {
  888. return delLineCustomer(customerIds);
  889. }).then(() => {
  890. this.getList();
  891. this.msgSuccess("删除成功");
  892. }).catch(function() {});
  893. },
  894. /** 导出按钮操作 */
  895. /** 导出按钮操作 */
  896. handleExport() {
  897. const queryParams = this.queryParams;
  898. this.$confirm('是否确认导出所有客户数据项?', "警告", {
  899. confirmButtonText: "确定",
  900. cancelButtonText: "取消",
  901. type: "warning"
  902. }).then(function() {
  903. return exportCustomer(queryParams);
  904. }).then(response => {
  905. this.download(response.msg);
  906. }).catch(function() {});
  907. },
  908. /** 导入按钮操作 */
  909. handleImport() {
  910. this.upload.title = "客户跟进情况导入";
  911. this.upload.open = true;
  912. },
  913. /** 下载模板操作 */
  914. importTemplate() {
  915. importVisitTemplate().then((response) => {
  916. this.download(response.msg);
  917. });
  918. },
  919. // 文件上传中处理
  920. handleFileUploadProgress(event, file, fileList) {
  921. this.upload.isUploading = true;
  922. },
  923. // 文件上传成功处理
  924. handleFileSuccess(response, file, fileList) {
  925. this.upload.open = false;
  926. this.upload.isUploading = false;
  927. this.$refs.upload.clearFiles();
  928. this.importMsgOpen=true;
  929. this.importMsg=response.msg
  930. this.getList();
  931. },
  932. // 提交上传文件
  933. submitFileForm() {
  934. this.$refs.upload.submit();
  935. },
  936. getAllCompanyUserName(){
  937. getAllCompanyUserName().then(response => {
  938. this.CompanyUserNames = response.data;
  939. });
  940. }
  941. }
  942. };
  943. </script>
  944. <style>
  945. .el-tag + .el-tag {
  946. margin-left: 10px;
  947. }
  948. .button-new-tag {
  949. margin-left: 10px;
  950. height: 32px;
  951. line-height: 30px;
  952. padding-top: 0;
  953. padding-bottom: 0;
  954. }
  955. .input-new-tag {
  956. width: 90px;
  957. margin-left: 10px;
  958. vertical-align: bottom;
  959. }
  960. .el-dialog__wrapper{
  961. z-index: 100000;
  962. }
  963. </style>