index.vue 30 KB

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