index.vue 13 KB

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