index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. v-model="queryParams.customerCode"
  7. placeholder="请输入客户编码"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="客户名称" prop="customerName">
  14. <el-input
  15. v-model="queryParams.customerName"
  16. placeholder="请输入客户名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="手机号" prop="mobile">
  23. <el-input
  24. v-model="queryParams.mobile"
  25. placeholder="请输入客户手机号"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="所属部门" prop="deptId">
  32. <treeselect style="width:205.4px" v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属部门" />
  33. </el-form-item>
  34. <el-form-item label="员工姓名" prop="companyUserNickName">
  35. <el-input
  36. v-model="queryParams.companyUserNickName"
  37. placeholder="请输入员工姓名"
  38. clearable
  39. size="small"
  40. @keyup.enter.native="handleQuery"
  41. />
  42. </el-form-item>
  43. <el-form-item label="跟进类型" prop="visitType">
  44. <el-select v-model="queryParams.visitType" placeholder="请选择跟进类型" clearable size="small">
  45. <el-option
  46. v-for="item in typeOptions"
  47. :key="item.dictValue"
  48. :label="item.dictLabel"
  49. :value="item.dictValue"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="跟进阶段" prop="customerUserStatus">
  54. <el-select v-model="queryParams.customerUserStatus" placeholder="请选择跟进阶段" clearable size="small">
  55. <el-option
  56. v-for="item in customerUserStatusOptions"
  57. :key="item.dictValue"
  58. :label="item.dictLabel"
  59. :value="item.dictValue"
  60. />
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item label="跟进时间" prop="createTime">
  64. <el-date-picker
  65. style="width:205.4px"
  66. clearable size="small"
  67. v-model="dateRange"
  68. type="daterange"
  69. value-format="yyyy-MM-dd"
  70. start-placeholder="开始日期"
  71. end-placeholder="结束日期">
  72. </el-date-picker>
  73. </el-form-item>
  74. <el-form-item label="客户创建时间" prop="createTimeRange">
  75. <el-date-picker
  76. style="width:205.4px"
  77. clearable size="small"
  78. v-model="createTimeRange"
  79. type="daterange"
  80. value-format="yyyy-MM-dd"
  81. start-placeholder="开始日期"
  82. end-placeholder="结束日期">
  83. </el-date-picker>
  84. </el-form-item>
  85. <el-form-item label="领取时间" prop="receiveTimeRange">
  86. <el-date-picker
  87. style="width:205.4px"
  88. clearable size="small"
  89. v-model="receiveTimeRange"
  90. type="daterange"
  91. value-format="yyyy-MM-dd"
  92. start-placeholder="开始日期"
  93. end-placeholder="结束日期">
  94. </el-date-picker>
  95. </el-form-item>
  96. <el-form-item>
  97. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  98. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  99. </el-form-item>
  100. </el-form>
  101. <el-row :gutter="10" class="mb8">
  102. <el-col :span="1.5">
  103. <el-button
  104. type="warning"
  105. icon="el-icon-download"
  106. size="mini"
  107. @click="handleExport"
  108. v-hasPermi="['crm:customerVisit:export']"
  109. >导出</el-button>
  110. </el-col>
  111. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  112. </el-row>
  113. <el-table height="500" border v-loading="loading" :data="customerVisitList" @selection-change="handleSelectionChange">
  114. <el-table-column type="selection" width="55" align="center" />
  115. <el-table-column label="ID" align="center" prop="visitId" />
  116. <el-table-column label="所属公司" align="center" prop="companyName" />
  117. <el-table-column label="所属员工" align="center" prop="companyUserNickName" />
  118. <el-table-column label="客户编码" align="center" prop="customerCode" />
  119. <el-table-column label="客户名称" align="center" prop="customerName" />
  120. <el-table-column label="跟进类型" width="150" align="center" prop="visitType" >
  121. <template slot-scope="scope">
  122. <el-tag prop="status" v-for="(item, index) in typeOptions" v-if="scope.row.visitType==item.dictValue">{{item.dictLabel}}</el-tag>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="跟进阶段" width="150" align="center" prop="customerUserStatus" >
  126. <template slot-scope="scope">
  127. <el-tag prop="status" v-for="(item, index) in customerUserStatusOptions" v-if="scope.row.customerUserStatus==item.dictValue">{{item.dictLabel}}</el-tag>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="跟进内容" align="center" prop="content" />
  131. <el-table-column label="跟进照片" align="center" prop="photos" width="200px">
  132. <template slot-scope="scope">
  133. <el-image v-for="(img) in parsePhoto(scope.row.photos)"
  134. style="width: 30px; height: 30px;margin-right:5px"
  135. :src="img"
  136. :preview-src-list="parsePhoto(scope.row.photos)">
  137. </el-image>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="跟进时间" align="center" prop="createTime" />
  141. <el-table-column label="下次联系时间" align="center" prop="nextTime" width="180">
  142. <template slot-scope="scope">
  143. <span>{{ parseTime(scope.row.nextTime, '{y}-{m}-{d}') }}</span>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="操作" fixed="right" width="120px" align="center" class-name="small-padding fixed-width">
  147. <template slot-scope="scope">
  148. <el-button
  149. size="mini"
  150. type="text"
  151. @click="handleShow(scope.row)"
  152. v-hasPermi="['crm:customer:query']"
  153. >查看</el-button>
  154. <el-button
  155. size="mini"
  156. type="text"
  157. icon="el-icon-delete"
  158. @click="handleDelete(scope.row)"
  159. v-hasPermi="['crm:customerVisit:remove']"
  160. >删除</el-button>
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. <pagination
  165. v-show="total>0"
  166. :total="total"
  167. :page.sync="queryParams.pageNum"
  168. :limit.sync="queryParams.pageSize"
  169. @pagination="getList"
  170. />
  171. <el-drawer
  172. size="75%"
  173. :title="show.title" :visible.sync="show.open"
  174. >
  175. <customer-details ref="customerDetails" />
  176. </el-drawer>
  177. </div>
  178. </template>
  179. <script>
  180. import { listCustomerVisit, getCustomerVisit, delCustomerVisit, addCustomerVisit, updateCustomerVisit, exportCustomerVisit } from "@/api/crm/customerVisit";
  181. import customerDetails from '../components/customerDetails.vue';
  182. import { treeselect } from "@/api/company/companyDept";
  183. import Treeselect from "@riophae/vue-treeselect";
  184. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  185. export default {
  186. name: "CustomerVisit",
  187. components: { customerDetails,Treeselect },
  188. data() {
  189. return {
  190. customerUserStatusOptions:[],
  191. dateRange:[],
  192. defaultProps: {
  193. children: "children",
  194. label: "label",
  195. },
  196. // 部门树选项
  197. deptOptions: [],
  198. // 部门名称
  199. deptName: undefined,
  200. typeOptions:[],
  201. createTimeRange:[],
  202. receiveTimeRange:[],
  203. show:{
  204. title:"客户详情",
  205. open:false,
  206. },
  207. companys:[],
  208. // 遮罩层
  209. loading: true,
  210. // 选中数组
  211. ids: [],
  212. // 非单个禁用
  213. single: true,
  214. // 非多个禁用
  215. multiple: true,
  216. // 显示搜索条件
  217. showSearch: true,
  218. // 总条数
  219. total: 0,
  220. // 跟进表格数据
  221. customerVisitList: [],
  222. // 弹出层标题
  223. title: "",
  224. // 是否显示弹出层
  225. open: false,
  226. // 查询参数
  227. queryParams: {
  228. pageNum: 1,
  229. pageSize: 10,
  230. customerId: null,
  231. visitType: null,
  232. content: null,
  233. photos: null,
  234. nextTime: null,
  235. lng: null,
  236. lat: null,
  237. address: null,
  238. companyUserId: null,
  239. companyId: null
  240. },
  241. // 表单参数
  242. form: {},
  243. // 表单校验
  244. rules: {
  245. visitType: [
  246. { required: true, message: "类型 1 电话 2 微信不能为空", trigger: "change" }
  247. ],
  248. companyUserId: [
  249. { required: true, message: "销售ID不能为空", trigger: "blur" }
  250. ],
  251. createTime: [
  252. { required: true, message: "创建时间不能为空", trigger: "blur" }
  253. ],
  254. }
  255. };
  256. },
  257. watch: {
  258. // 根据名称筛选部门树
  259. deptName(val) {
  260. this.$refs.tree.filter(val);
  261. },
  262. },
  263. created() {
  264. this.getDicts("crm_customer_visit_type").then((response) => {
  265. this.typeOptions = response.data;
  266. });
  267. this.getDicts("crm_customer_user_status").then((response) => {
  268. this.customerUserStatusOptions = response.data;
  269. });
  270. this.getTreeselect();
  271. this.getList();
  272. },
  273. methods: {
  274. parsePhoto(photos){
  275. var imgs=[];
  276. if(photos!=null){
  277. imgs=photos.split(",");
  278. }
  279. return imgs;
  280. },
  281. getTreeselect() {
  282. treeselect().then((response) => {
  283. this.deptOptions = response.data;
  284. });
  285. },
  286. // 筛选节点
  287. filterNode(value, data) {
  288. if (!value) return true;
  289. return data.label.indexOf(value) !== -1;
  290. },
  291. // 节点单击事件
  292. handleNodeClick(data) {
  293. this.queryParams.deptId = data.id;
  294. this.getList();
  295. },
  296. handleShow(row){
  297. var that=this;
  298. that.show.open=true;
  299. setTimeout(() => {
  300. that.$refs.customerDetails.getDetails(row.customerId);
  301. }, 200);
  302. },
  303. /** 查询跟进列表 */
  304. getList() {
  305. this.loading = true;
  306. if(this.createTimeRange!=null&&this.createTimeRange.length==2){
  307. this.queryParams.createTimeRange=this.createTimeRange[0]+"--"+this.createTimeRange[1]
  308. }
  309. else{
  310. this.queryParams.createTimeRange=null;
  311. }
  312. if(this.receiveTimeRange!=null&&this.receiveTimeRange.length==2){
  313. this.queryParams.receiveTimeRange=this.receiveTimeRange[0]+"--"+this.receiveTimeRange[1]
  314. }
  315. else{
  316. this.queryParams.receiveTimeRange=null;
  317. }
  318. listCustomerVisit(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  319. this.customerVisitList = response.rows;
  320. this.total = response.total;
  321. this.loading = false;
  322. });
  323. },
  324. // 取消按钮
  325. cancel() {
  326. this.open = false;
  327. this.reset();
  328. },
  329. // 表单重置
  330. reset() {
  331. this.form = {
  332. visitId: null,
  333. customerId: null,
  334. visitType: null,
  335. content: null,
  336. photos: null,
  337. nextTime: null,
  338. lng: null,
  339. lat: null,
  340. address: null,
  341. companyUserId: null,
  342. createTime: null,
  343. companyId: null
  344. };
  345. this.resetForm("form");
  346. },
  347. /** 搜索按钮操作 */
  348. handleQuery() {
  349. this.queryParams.pageNum = 1;
  350. this.getList();
  351. },
  352. /** 重置按钮操作 */
  353. resetQuery() {
  354. this.resetForm("queryForm");
  355. this.dateRange = [];
  356. this.createTimeRange=[];
  357. this.receiveTimeRange=[];
  358. this.handleQuery();
  359. },
  360. // 多选框选中数据
  361. handleSelectionChange(selection) {
  362. this.ids = selection.map(item => item.visitId)
  363. this.single = selection.length!==1
  364. this.multiple = !selection.length
  365. },
  366. /** 新增按钮操作 */
  367. handleAdd() {
  368. this.reset();
  369. this.open = true;
  370. this.title = "添加跟进";
  371. },
  372. /** 修改按钮操作 */
  373. handleUpdate(row) {
  374. this.reset();
  375. const visitId = row.visitId || this.ids
  376. getCustomerVisit(visitId).then(response => {
  377. this.form = response.data;
  378. this.open = true;
  379. this.title = "修改跟进";
  380. });
  381. },
  382. /** 提交按钮 */
  383. submitForm() {
  384. this.$refs["form"].validate(valid => {
  385. if (valid) {
  386. if (this.form.visitId != null) {
  387. updateCustomerVisit(this.form).then(response => {
  388. if (response.code === 200) {
  389. this.msgSuccess("修改成功");
  390. this.open = false;
  391. this.getList();
  392. }
  393. });
  394. } else {
  395. addCustomerVisit(this.form).then(response => {
  396. if (response.code === 200) {
  397. this.msgSuccess("新增成功");
  398. this.open = false;
  399. this.getList();
  400. }
  401. });
  402. }
  403. }
  404. });
  405. },
  406. /** 删除按钮操作 */
  407. handleDelete(row) {
  408. const visitIds = row.visitId || this.ids;
  409. this.$confirm('是否确认删除跟进编号为"' + visitIds + '"的数据项?', "警告", {
  410. confirmButtonText: "确定",
  411. cancelButtonText: "取消",
  412. type: "warning"
  413. }).then(function() {
  414. return delCustomerVisit(visitIds);
  415. }).then(() => {
  416. this.getList();
  417. this.msgSuccess("删除成功");
  418. }).catch(function() {});
  419. },
  420. /** 导出按钮操作 */
  421. handleExport() {
  422. const queryParams = this.queryParams;
  423. this.$confirm('是否确认导出所有跟进数据项?', "警告", {
  424. confirmButtonText: "确定",
  425. cancelButtonText: "取消",
  426. type: "warning"
  427. }).then(function() {
  428. return exportCustomerVisit(queryParams);
  429. }).then(response => {
  430. this.download(response.msg);
  431. }).catch(function() {});
  432. }
  433. }
  434. };
  435. </script>