index.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. :action-list="[
  12. {
  13. text: '添加客户',
  14. action: () => openModal(),
  15. },
  16. ]"
  17. @get-list="getList">
  18. <template #isTop="{ item }">
  19. <div>
  20. <img style="cursor: pointer; width: 20px; transform: translateY(5px)" :src="'/img/isTop.png'" @click="deleteTop(item)" v-if="item.isTop === 1" />
  21. <img style="cursor: pointer; width: 20px; transform: translateY(5px)" :src="'/img/noTop.png'" @click="addTop(item)" v-else />
  22. </div>
  23. </template>
  24. <template #address="{ item }">
  25. <span>{{ item.countryName }}</span>
  26. <span v-if="item.provinceName"> ,{{ item.provinceName }}</span>
  27. <span v-if="item.cityName"> ,{{ item.cityName }}</span>
  28. </template>
  29. <template #name="{ item }">
  30. <div style="cursor: pointer; color: #409eff" @click="handleClickName(item)">
  31. {{ item.name }}
  32. </div>
  33. </template>
  34. <template #tags="{ item }">
  35. <div style="width: 100%">
  36. <el-tag style="margin-right: 8px" type="success" v-for="(tag, index) in item.tag" closable :key="index" @close="tagClose(tag, item)">
  37. {{ dictValueLabel(tag, customerTag) }}
  38. </el-tag>
  39. <template v-if="item.tag.length !== customerTag.length">
  40. <el-select
  41. v-if="item.addTagShow"
  42. v-model="addTag"
  43. style="width: 100%"
  44. @change="
  45. (val) => {
  46. return changeTag(val, item);
  47. }
  48. ">
  49. <el-option v-for="tag in customerTag" :key="tag.value" :label="tag.label" :value="tag.value" :disabled="judgeTagSelect(item.tag, tag.value)" />
  50. </el-select>
  51. <el-tag style="cursor: pointer" type="success" @click="showSelect(item)" v-else> + </el-tag>
  52. </template>
  53. </div>
  54. </template>
  55. <template #follow="{ item }">
  56. <div :class="'getWidth' + item.id" style="width: 100%">
  57. <div style="width: 100%; display: flex">
  58. <template v-if="item.customerFollowRecordsList && item.customerFollowRecordsList.length > 0">
  59. <div
  60. :style="
  61. index > 2
  62. ? 'line-height: 32px; margin-right: 8px; padding: 0 8px; background-color: #eeeeee; border-radius: 4px; cursor: pointer; display: none'
  63. : 'line-height: 32px; margin-right: 8px; padding: 0 8px; background-color: #eeeeee; border-radius: 4px; cursor: pointer'
  64. "
  65. v-for="(record, index) in item.customerFollowRecordsList"
  66. :key="record.id">
  67. <el-popover placement="bottom" :width="300" trigger="hover" @show="recordShow(record)">
  68. <template #reference>
  69. <div>
  70. <span v-if="record.date">{{ record.date.substr(0, 10) }}</span>
  71. <el-icon style="margin-left: 8px; transform: translateY(2px)" @click="deleteFollow(record)"><DeleteFilled /></el-icon>
  72. </div>
  73. </template>
  74. <template #default>
  75. <div style="width: 100%">
  76. <div style="color: #909399; margin: 8px 0">跟进时间: {{ record.date }}</div>
  77. <div style="word-wrap: break-word; margin: 8px 0" v-html="getStyle(record.content)" v-if="record.content"></div>
  78. <div v-else>跟进记录:</div>
  79. <div style="margin: 8px 0; display: flex" v-if="record.fileList && record.fileList.length > 0">
  80. <div style="width: 36px">附件:</div>
  81. <div style="width: calc(100% - 36px)">
  82. <div v-for="(file, index) in record.fileList" :key="index">
  83. <a style="color: #409eff; cursor: pointer" @click="openFile(file.fileUrl)">{{ file.fileName }}</a>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. </el-popover>
  90. </div>
  91. <div
  92. style="line-height: 32px; margin-right: 8px; padding: 0 8px; background-color: #eeeeee; border-radius: 4px; cursor: pointer"
  93. @click="clickMore(item)"
  94. v-if="item.customerFollowRecordsList.length >= 3">
  95. 更多
  96. </div>
  97. </template>
  98. </div>
  99. </div>
  100. </template>
  101. </byTable>
  102. </div>
  103. <el-dialog :title="modalType == 'add' ? '新增' : '编辑'" v-if="dialogVisible" v-model="dialogVisible" width="800" v-loading="loadingOperation">
  104. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  105. <template #address>
  106. <el-row style="width: 100%">
  107. <el-col :span="8">
  108. <el-form-item prop="countryId">
  109. <el-select v-model="formData.data.countryId" placeholder="国家" @change="(val) => getCityData(val, '20', true)">
  110. <el-option v-for="item in countryData" :label="item.chineseName" :value="item.id"> </el-option>
  111. </el-select>
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="8">
  115. <el-form-item prop="provinceId">
  116. <el-select v-model="formData.data.provinceId" placeholder="省/洲" @change="(val) => getCityData(val, '30', true)">
  117. <el-option v-for="item in provinceData" :label="item.name" :value="item.id"> </el-option>
  118. </el-select>
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="8">
  122. <el-form-item prop="cityId">
  123. <el-select v-model="formData.data.cityId" placeholder="城市">
  124. <el-option v-for="item in cityData" :label="item.name" :value="item.id"> </el-option>
  125. </el-select>
  126. </el-form-item>
  127. </el-col>
  128. </el-row>
  129. <el-row style="margin-top: 20px; width: 100%">
  130. <el-col :span="24">
  131. <el-form-item prop="address">
  132. <el-input v-model="formData.data.address" type="textarea"> </el-input>
  133. </el-form-item>
  134. </el-col>
  135. </el-row>
  136. </template>
  137. <template #person>
  138. <div style="width: 100%">
  139. <el-button type="primary" @click="clickAddPerson">添 加</el-button>
  140. <el-table :data="formData.data.customerUserList" style="width: 100%; margin-top: 16px">
  141. <el-table-column label="联系人" width="160">
  142. <template #default="{ row, $index }">
  143. <div style="width: 100%">
  144. <el-form-item :prop="'customerUserList.' + $index + '.name'" :rules="rules.name2" :inline-message="true">
  145. <el-input v-model="row.name" placeholder="请输入联系人" />
  146. </el-form-item>
  147. </div>
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="电子邮箱">
  151. <template #default="{ row, $index }">
  152. <div style="width: 100%">
  153. <el-form-item :prop="'customerUserList.' + $index + '.email'" :rules="rules.email" :inline-message="true">
  154. <el-input v-model="row.email" placeholder="请输入电子邮箱" />
  155. </el-form-item>
  156. </div>
  157. </template>
  158. </el-table-column>
  159. <el-table-column align="center" label="操作" width="120" fixed="right">
  160. <template #default="{ row, $index }">
  161. <el-button type="primary" link @click="clickInformationMore(row, $index)">更多</el-button>
  162. <el-button type="primary" link @click="clickDelete($index)">删除</el-button>
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. </div>
  167. </template>
  168. </byForm>
  169. <template #footer>
  170. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  171. <el-button type="primary" @click="submitForm()" size="large" :loading="submitLoading">确 定</el-button>
  172. </template>
  173. </el-dialog>
  174. <el-dialog title="更多联系方式" v-model="openPerson" width="700">
  175. <el-form :label-position="'top'" :model="formPerson.data" :rules="rulesPerson" ref="person">
  176. <el-form-item label="联系人" prop="name">
  177. <el-input v-model="formPerson.data.name" />
  178. </el-form-item>
  179. <el-form-item label="电子邮箱" prop="email">
  180. <el-input v-model="formPerson.data.email" />
  181. </el-form-item>
  182. <el-form-item label="更多联系方式">
  183. <div style="width: 100%">
  184. <el-button type="primary" @click="clickAddMoreInformation">添 加</el-button>
  185. <el-table :data="formPerson.data.contact" style="width: 100%; margin-top: 16px">
  186. <el-table-column label="类型" width="180">
  187. <template #default="{ row, $index }">
  188. <div style="width: 100%">
  189. <el-form-item :prop="'contact.' + $index + '.type'" :rules="rulesPerson.type" :inline-message="true">
  190. <el-select v-model="row.type" placeholder="请选择类型" style="width: 100%">
  191. <el-option v-for="item in contactType" :key="item.value" :label="item.label" :value="item.value" />
  192. </el-select>
  193. </el-form-item>
  194. </div>
  195. </template>
  196. </el-table-column>
  197. <el-table-column label="联系号码">
  198. <template #default="{ row, $index }">
  199. <div style="width: 100%">
  200. <el-form-item :prop="'contact.' + $index + '.contactNo'" :rules="rulesPerson.contactNo" :inline-message="true">
  201. <el-input v-model="row.contactNo" placeholder="请输入联系号码" />
  202. </el-form-item>
  203. </div>
  204. </template>
  205. </el-table-column>
  206. <el-table-column align="center" label="操作" width="120" fixed="right">
  207. <template #default="{ $index }">
  208. <el-button type="primary" link @click="clickInformationDelete($index)">删除</el-button>
  209. </template>
  210. </el-table-column>
  211. </el-table>
  212. </div>
  213. </el-form-item>
  214. </el-form>
  215. <template #footer>
  216. <el-button @click="openPerson = false" size="large">取 消</el-button>
  217. <el-button type="primary" @click="submitPerson()" size="large">确 定</el-button>
  218. </template>
  219. </el-dialog>
  220. <el-dialog title="分配" v-model="openAllocation" width="300">
  221. <byForm :formConfig="formConfigAllocation" :formOption="formOption" v-model="formAllocation.data" ref="allocation"> </byForm>
  222. <template #footer>
  223. <el-button @click="openAllocation = false" size="large">取 消</el-button>
  224. <el-button type="primary" @click="submitAllocation()" size="large">确 定</el-button>
  225. </template>
  226. </el-dialog>
  227. <el-dialog title="添加跟进记录" v-if="openFollow" v-model="openFollow" width="500" destroy-on-close>
  228. <byForm :formConfig="formConfigAFollow" :formOption="formOption" v-model="formFollow.data" :rules="rulesFollow" ref="follow">
  229. <template #fileSlot>
  230. <div style="width: 100%">
  231. <el-upload
  232. v-model:fileList="fileList"
  233. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  234. :data="uploadData"
  235. multiple
  236. :before-upload="uploadFile"
  237. :on-preview="onPreviewFile">
  238. <el-button type="primary">文件上传</el-button>
  239. </el-upload>
  240. </div>
  241. </template>
  242. </byForm>
  243. <template #footer>
  244. <el-button @click="openFollow = false" size="large">取 消</el-button>
  245. <el-button type="primary" @click="submitFollow()" size="large">确 定</el-button>
  246. </template>
  247. </el-dialog>
  248. <el-dialog title="跟进记录" v-if="openRecordMore" v-model="openRecordMore" width="800" destroy-on-close>
  249. <div>
  250. <div style="padding: 8px 0">
  251. <el-button type="primary" @click="clickFollowUp(rowData)" plain>添加跟进记录</el-button>
  252. </div>
  253. <div style="padding-top: 16px">
  254. <div v-infinite-scroll="infiniteScroll" class="infinite-scroll" :infinite-scroll-disabled="judgeTotal()">
  255. <el-timeline>
  256. <el-timeline-item v-for="(record, index) in recordList" :key="index" :timestamp="record.date" hide-timestamp>
  257. <div>
  258. <div style="padding: 0 0 8px 0; display: flex; justify-content: space-between">
  259. <span>{{ dictValueLabel(record.createUser, userList) }}</span>
  260. <span>{{ record.date }}</span>
  261. </div>
  262. <div style="word-wrap: break-word; margin: 8px 0" v-html="getStyle(record.content)" v-if="record.content"></div>
  263. <div style="margin: 8px 0" v-else>跟进记录:</div>
  264. <div style="margin: 8px 0; display: flex" v-if="record.fileList && record.fileList.length > 0">
  265. <div style="width: 36px">附件:</div>
  266. <div style="width: calc(100% - 36px)">
  267. <div v-for="(file, index) in record.fileList" :key="index">
  268. <a style="color: #409eff; cursor: pointer" @click="openFile(file.fileUrl)">{{ file.fileName }}</a>
  269. </div>
  270. </div>
  271. </div>
  272. </div>
  273. </el-timeline-item>
  274. </el-timeline>
  275. </div>
  276. </div>
  277. </div>
  278. <template #footer>
  279. <el-button @click="openRecordMore = false" size="large">关 闭</el-button>
  280. </template>
  281. </el-dialog>
  282. </div>
  283. </template>
  284. <script setup>
  285. import { ElMessage, ElMessageBox } from "element-plus";
  286. import byTable from "@/components/byTable/index";
  287. import byForm from "@/components/byForm/index";
  288. import { computed, ref } from "vue";
  289. import useUserStore from "@/store/modules/user";
  290. const { proxy } = getCurrentInstance();
  291. const loading = ref(false);
  292. const loadingOperation = ref(false);
  293. const submitLoading = ref(false);
  294. const openPerson = ref(false);
  295. const openAllocation = ref(false);
  296. const customerTag = ref([]);
  297. const customerSource = ref([]);
  298. const customerStatus = ref([]);
  299. const contactType = ref([]);
  300. const userList = ref([]);
  301. const fileList = ref([]);
  302. const uploadData = ref({});
  303. const sourceList = ref({
  304. data: [],
  305. pagination: {
  306. total: 0,
  307. pageNum: 1,
  308. pageSize: 10,
  309. status: "",
  310. source: "",
  311. type: "",
  312. },
  313. });
  314. const selectConfig = computed(() => {
  315. return [
  316. {
  317. label: "客户状态",
  318. prop: "type",
  319. data: [
  320. {
  321. label: "公海",
  322. value: "0",
  323. },
  324. {
  325. label: "私海",
  326. value: "1",
  327. },
  328. ],
  329. },
  330. {
  331. label: "客户来源",
  332. prop: "source",
  333. data: customerSource.value,
  334. },
  335. {
  336. label: "客户类型",
  337. prop: "status",
  338. data: customerStatus.value,
  339. },
  340. ];
  341. });
  342. const config = computed(() => {
  343. return [
  344. {
  345. attrs: {
  346. label: "",
  347. slot: "isTop",
  348. fixed: "left",
  349. width: 60,
  350. align: "center",
  351. },
  352. },
  353. {
  354. attrs: {
  355. label: "客户名称",
  356. prop: "name",
  357. slot: "name",
  358. fixed: "left",
  359. width: 160,
  360. },
  361. },
  362. {
  363. attrs: {
  364. label: "所在城市",
  365. slot: "address",
  366. width: 160,
  367. },
  368. },
  369. {
  370. attrs: {
  371. label: "客户代码",
  372. prop: "customerCode",
  373. width: 120,
  374. },
  375. },
  376. {
  377. attrs: {
  378. label: "客户来源",
  379. prop: "source",
  380. width: 120,
  381. },
  382. render(type) {
  383. return proxy.dictValueLabel(type, customerSource.value);
  384. },
  385. },
  386. {
  387. attrs: {
  388. label: "客户类型",
  389. prop: "status",
  390. width: 120,
  391. },
  392. render(type) {
  393. return proxy.dictValueLabel(type, customerStatus.value);
  394. },
  395. },
  396. {
  397. attrs: {
  398. label: "客户标签",
  399. slot: "tags",
  400. width: 180,
  401. },
  402. },
  403. {
  404. attrs: {
  405. label: "业务员",
  406. prop: "userId",
  407. width: 140,
  408. },
  409. render(type) {
  410. let data = userList.value.filter((item) => item.value == type);
  411. if (data && data.length > 0) {
  412. return data[0].label;
  413. } else {
  414. return "";
  415. }
  416. },
  417. },
  418. {
  419. attrs: {
  420. label: "跟进",
  421. slot: "follow",
  422. "min-width": 440,
  423. },
  424. },
  425. {
  426. attrs: {
  427. label: "操作",
  428. width: 190,
  429. align: "center",
  430. fixed: "right",
  431. },
  432. renderHTML(row) {
  433. return [
  434. {
  435. attrs: {
  436. label: "分配",
  437. type: "primary",
  438. text: true,
  439. },
  440. el: "button",
  441. click() {
  442. formAllocation.data = {
  443. id: row.id,
  444. userId: row.userId,
  445. };
  446. openAllocation.value = true;
  447. },
  448. },
  449. {
  450. attrs: {
  451. label: "跟进",
  452. type: "primary",
  453. text: true,
  454. },
  455. el: "button",
  456. click() {
  457. clickFollowUp(row);
  458. },
  459. },
  460. {
  461. attrs: {
  462. label: "修改",
  463. type: "primary",
  464. text: true,
  465. },
  466. el: "button",
  467. click() {
  468. update(row);
  469. },
  470. },
  471. {
  472. attrs: {
  473. label: "删除",
  474. type: "primary",
  475. text: true,
  476. },
  477. el: "button",
  478. click() {
  479. ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
  480. confirmButtonText: "确定",
  481. cancelButtonText: "取消",
  482. type: "warning",
  483. }).then(() => {
  484. proxy
  485. .post("/customer/delete", {
  486. id: row.id,
  487. })
  488. .then(() => {
  489. ElMessage({
  490. message: "删除成功",
  491. type: "success",
  492. });
  493. getList();
  494. });
  495. });
  496. },
  497. },
  498. ];
  499. },
  500. },
  501. ];
  502. });
  503. let modalType = ref("add");
  504. let dialogVisible = ref(false);
  505. let openFollow = ref(false);
  506. let formData = reactive({
  507. data: {
  508. countryId: "China",
  509. },
  510. });
  511. let formPerson = reactive({
  512. data: {},
  513. });
  514. let formAllocation = reactive({
  515. data: {},
  516. });
  517. let formFollow = reactive({
  518. data: {},
  519. });
  520. const formOption = reactive({
  521. inline: true,
  522. labelWidth: 100,
  523. itemWidth: 100,
  524. rules: [],
  525. });
  526. const formConfig = computed(() => {
  527. return [
  528. {
  529. type: "input",
  530. prop: "name",
  531. label: "客户名称",
  532. required: true,
  533. itemWidth: 100,
  534. itemType: "text",
  535. },
  536. {
  537. type: "slot",
  538. slotName: "address",
  539. prop: "countryId",
  540. label: "详细地址",
  541. },
  542. {
  543. type: "input",
  544. prop: "customerCode",
  545. label: "客户代码",
  546. required: true,
  547. itemWidth: 100,
  548. itemType: "text",
  549. },
  550. {
  551. type: "select",
  552. label: "客户来源",
  553. prop: "source",
  554. itemWidth: 50,
  555. data: customerSource.value,
  556. },
  557. {
  558. type: "select",
  559. label: "客户类型",
  560. prop: "status",
  561. itemWidth: 50,
  562. data: customerStatus.value,
  563. },
  564. {
  565. type: "select",
  566. label: "业务员",
  567. prop: "userId",
  568. itemWidth: 100,
  569. data: userList.value,
  570. },
  571. {
  572. type: "select",
  573. label: "客户标签",
  574. prop: "tags",
  575. itemWidth: 100,
  576. multiple: true,
  577. data: customerTag.value,
  578. style: {
  579. width: "100%",
  580. },
  581. },
  582. {
  583. type: "slot",
  584. slotName: "person",
  585. label: "客户联系人",
  586. },
  587. ];
  588. });
  589. let rules = ref({
  590. name: [{ required: true, message: "请输入客户名称", trigger: "blur" }],
  591. name2: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  592. email: [{ required: true, message: "请输入电子邮箱", trigger: "blur" }],
  593. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  594. provinceId: [{ required: true, message: "请选择省/州", trigger: "change" }],
  595. cityId: [{ required: true, message: "请选择城市", trigger: "change" }],
  596. source: [{ required: true, message: "请选择客户来源", trigger: "change" }],
  597. status: [{ required: true, message: "请选择类型", trigger: "change" }],
  598. });
  599. const formConfigAllocation = computed(() => {
  600. return [
  601. {
  602. type: "select",
  603. label: "业务员",
  604. prop: "userId",
  605. itemWidth: 100,
  606. data: userList.value,
  607. },
  608. ];
  609. });
  610. const formConfigAFollow = computed(() => {
  611. return [
  612. {
  613. type: "date",
  614. itemType: "datetime",
  615. label: "跟进时间",
  616. prop: "date",
  617. itemWidth: 100,
  618. },
  619. {
  620. type: "input",
  621. itemType: "textarea",
  622. label: "跟进内容",
  623. prop: "content",
  624. itemWidth: 100,
  625. },
  626. {
  627. type: "slot",
  628. label: "上传附件",
  629. prop: "fileList",
  630. slotName: "fileSlot",
  631. },
  632. ];
  633. });
  634. let rulesPerson = ref({
  635. name: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  636. email: [{ required: true, message: "请输入电子邮箱", trigger: "blur" }],
  637. type: [{ required: true, message: "请选择类型", trigger: "change" }],
  638. contactNo: [{ required: true, message: "请输入联系号码", trigger: "blur" }],
  639. });
  640. let rulesFollow = ref({
  641. date: [{ required: true, message: "请选择跟进时间", trigger: "change" }],
  642. content: [{ required: true, message: "请输入跟进内容", trigger: "blur" }],
  643. });
  644. const submit = ref(null);
  645. const person = ref(null);
  646. const allocation = ref(null);
  647. const follow = ref(null);
  648. const getList = async (req) => {
  649. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  650. loading.value = true;
  651. proxy.post("/customer/page", sourceList.value.pagination).then((res) => {
  652. res.rows.forEach((x) => {
  653. x.addTagShow = false;
  654. if (x.tag) {
  655. x.tag = x.tag.split(",");
  656. } else {
  657. x.tag = [];
  658. }
  659. });
  660. sourceList.value.data = res.rows;
  661. sourceList.value.pagination.total = res.total;
  662. setTimeout(() => {
  663. loading.value = false;
  664. }, 200);
  665. });
  666. };
  667. const openModal = () => {
  668. modalType.value = "add";
  669. formData.data = {
  670. countryId: "China",
  671. tags: [],
  672. };
  673. getCityData(formData.data.countryId, "20");
  674. loadingOperation.value = false;
  675. dialogVisible.value = true;
  676. };
  677. const update = (row) => {
  678. modalType.value = "edit";
  679. loadingOperation.value = true;
  680. proxy.post("/customer/detail", { id: row.id }).then((res) => {
  681. if (res.tag) {
  682. res.tags = res.tag.split(",");
  683. } else {
  684. res.tags = [];
  685. }
  686. formData.data = res;
  687. getCityData(formData.data.countryId, "20");
  688. getCityData(formData.data.provinceId, "30");
  689. loadingOperation.value = false;
  690. });
  691. dialogVisible.value = true;
  692. };
  693. const countryData = ref([]);
  694. const provinceData = ref([]);
  695. const cityData = ref([]);
  696. const getCityData = (id, type, isChange) => {
  697. proxy.post("/areaInfo/list", { parentId: id }).then((res) => {
  698. if (type === "20") {
  699. provinceData.value = res;
  700. if (isChange) {
  701. formData.data.provinceId = "";
  702. formData.data.cityId = "";
  703. }
  704. } else if (type === "30") {
  705. cityData.value = res;
  706. if (isChange) {
  707. formData.data.cityId = "";
  708. }
  709. } else {
  710. countryData.value = res;
  711. }
  712. });
  713. };
  714. getCityData("0");
  715. const clickAddPerson = () => {
  716. if (formData.data.customerUserList && formData.data.customerUserList.length > 0) {
  717. formData.data.customerUserList.push({
  718. name: "",
  719. email: "",
  720. });
  721. } else {
  722. formData.data.customerUserList = [
  723. {
  724. name: "",
  725. email: "",
  726. },
  727. ];
  728. }
  729. };
  730. const submitAllocation = () => {
  731. allocation.value.handleSubmit(() => {
  732. proxy.post("/customer/CustomerAllocation", formAllocation.data).then(() => {
  733. ElMessage({
  734. message: "分配成功",
  735. type: "success",
  736. });
  737. openAllocation.value = false;
  738. getList();
  739. });
  740. });
  741. };
  742. const submitFollow = () => {
  743. follow.value.handleSubmit(() => {
  744. if (fileList.value && fileList.value.length > 0) {
  745. formFollow.data.fileList = fileList.value.map((item) => {
  746. return {
  747. id: item.raw.id,
  748. fileName: item.raw.fileName,
  749. fileUrl: item.raw.fileUrl,
  750. };
  751. });
  752. } else {
  753. formFollow.data.fileList = [];
  754. }
  755. proxy.post("/customerFollowRecords/" + modalType.value, formFollow.data).then(
  756. () => {
  757. ElMessage({
  758. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  759. type: "success",
  760. });
  761. openFollow.value = false;
  762. getList();
  763. },
  764. (err) => {
  765. console.log(err);
  766. }
  767. );
  768. });
  769. };
  770. const submitForm = () => {
  771. submit.value.handleSubmit(() => {
  772. if (formData.data.customerUserList && formData.data.customerUserList.length > 0) {
  773. formData.data.tag = formData.data.tags.join(",");
  774. submitLoading.value = true;
  775. proxy.post("/customer/" + modalType.value, formData.data).then(
  776. () => {
  777. ElMessage({
  778. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  779. type: "success",
  780. });
  781. dialogVisible.value = false;
  782. submitLoading.value = false;
  783. getList();
  784. },
  785. (err) => {
  786. console.log(err);
  787. submitLoading.value = false;
  788. }
  789. );
  790. } else {
  791. ElMessage("请添加客户联系人");
  792. }
  793. });
  794. };
  795. const getDict = () => {
  796. proxy.getDictOne(["customer_tag", "customer_source", "customer_status", "contact_type"]).then((res) => {
  797. customerTag.value = res["customer_tag"].map((x) => ({
  798. label: x.dictValue,
  799. value: x.dictKey,
  800. }));
  801. customerSource.value = res["customer_source"].map((x) => ({
  802. label: x.dictValue,
  803. value: x.dictKey,
  804. }));
  805. customerStatus.value = res["customer_status"].map((x) => ({
  806. label: x.dictValue,
  807. value: x.dictKey,
  808. }));
  809. contactType.value = res["contact_type"].map((x) => ({
  810. label: x.dictValue,
  811. value: x.dictKey,
  812. }));
  813. });
  814. proxy
  815. .get("/tenantUser/list", {
  816. pageNum: 1,
  817. pageSize: 10000,
  818. tenantId: useUserStore().user.tenantId,
  819. })
  820. .then((res) => {
  821. userList.value = res.rows.map((item) => {
  822. return {
  823. label: item.nickName,
  824. value: item.userId,
  825. };
  826. });
  827. });
  828. };
  829. getDict();
  830. getList();
  831. const handleClickName = (row) => {
  832. proxy.$router.push({
  833. path: "/customer/customer/portrait",
  834. query: {
  835. id: row.id,
  836. },
  837. });
  838. };
  839. const deleteFollow = (data) => {
  840. ElMessageBox.confirm("是否确认删除该跟进?", "提示", {
  841. confirmButtonText: "确定",
  842. cancelButtonText: "取消",
  843. type: "warning",
  844. }).then(() => {
  845. proxy
  846. .post("/customerFollowRecords/delete", {
  847. id: data.id,
  848. })
  849. .then(() => {
  850. ElMessage({
  851. message: "删除成功",
  852. type: "success",
  853. });
  854. getList();
  855. });
  856. });
  857. };
  858. const addTag = ref("");
  859. const judgeTagSelect = (data, val) => {
  860. if (data && data.length > 0) {
  861. if (data.includes(val)) {
  862. return true;
  863. }
  864. }
  865. return false;
  866. };
  867. const changeTag = (val, item) => {
  868. let data = {
  869. id: item.id,
  870. tag: JSON.parse(JSON.stringify(item.tag)),
  871. };
  872. data.tag.push(val);
  873. data.tag = data.tag.join(",");
  874. proxy.post("/customer/editTag", data).then(() => {
  875. ElMessage({
  876. message: "添加成功",
  877. type: "success",
  878. });
  879. item.addTagShow = false;
  880. addTag.value = "";
  881. getList();
  882. });
  883. };
  884. const tagClose = (val, item) => {
  885. let data = {
  886. id: item.id,
  887. tag: JSON.parse(JSON.stringify(item.tag)),
  888. };
  889. data.tag = data.tag.filter((row) => row !== val);
  890. if (data.tag && data.tag.length > 0) {
  891. data.tag = data.tag.join(",");
  892. } else {
  893. data.tag = "";
  894. }
  895. proxy.post("/customer/editTag", data).then(() => {
  896. ElMessage({
  897. message: "添加成功",
  898. type: "success",
  899. });
  900. item.addTagShow = false;
  901. addTag.value = "";
  902. getList();
  903. });
  904. };
  905. const showSelect = (item) => {
  906. item.addTagShow = true;
  907. };
  908. const clickFollowUp = (item) => {
  909. formFollow.data = {
  910. customerId: item.id,
  911. fileList: [],
  912. };
  913. fileList.value = [];
  914. modalType.value = "add";
  915. openFollow.value = true;
  916. openRecordMore.value = false;
  917. };
  918. const uploadFile = async (file) => {
  919. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  920. uploadData.value = res.uploadBody;
  921. file.id = res.id;
  922. file.fileName = res.fileName;
  923. file.fileUrl = res.fileUrl;
  924. return true;
  925. };
  926. const onPreviewFile = (file) => {
  927. window.open(file.raw.fileUrl, "_blank");
  928. };
  929. const getStyle = (val) => {
  930. if (val) {
  931. return "跟进记录: " + val.replace(/\n|\r\n/g, "<br>");
  932. } else {
  933. return "";
  934. }
  935. };
  936. const recordShow = (item) => {
  937. if (!(item.fileList && item.fileList.length > 0)) {
  938. proxy.post("/fileInfo/getList", { businessIdList: [item.id] }).then((fileObj) => {
  939. item.fileList = fileObj[item.id] || [];
  940. });
  941. }
  942. };
  943. const openFile = (path) => {
  944. window.open(path, "_blank");
  945. };
  946. const judgeWidth = (item, index) => {
  947. if (item && item.id) {
  948. let dom = document.querySelector(".getWidth" + item.id);
  949. if (dom) {
  950. let width = getComputedStyle(dom).width.replace("px", "");
  951. let num = parseInt(width / 118);
  952. let num2 = parseInt((width - 52) / 118);
  953. if (num2 === num) {
  954. if (index + 1 > num) {
  955. return "display: none";
  956. }
  957. } else {
  958. if (index + 1 >= num) {
  959. return "display: none";
  960. }
  961. }
  962. }
  963. }
  964. return "";
  965. };
  966. const recordList = ref([]);
  967. const rowData = ref({});
  968. const openRecordMore = ref(false);
  969. const queryParams = ref({
  970. total: 0,
  971. pageNum: 1,
  972. pageSize: 10,
  973. customerId: "",
  974. });
  975. const clickMore = (item) => {
  976. if (openRecordMore.value === false) {
  977. recordList.value = [];
  978. rowData.value = item;
  979. queryParams.value.customerId = item.id;
  980. }
  981. proxy.post("/customerFollowRecords/page", queryParams.value).then((res) => {
  982. recordList.value = recordList.value.concat(res.rows);
  983. queryParams.value.total = res.total;
  984. proxy.post("/fileInfo/getList", { businessIdList: res.rows.map((rows) => rows.id) }).then((fileObj) => {
  985. for (let i = 0; i < res.rows.length; i++) {
  986. recordList.value[parseInt(i + (queryParams.value.pageNum - 1) * queryParams.value.pageSize)].fileList =
  987. fileObj[recordList.value[parseInt(i + (queryParams.value.pageNum - 1) * queryParams.value.pageSize)].id] || [];
  988. }
  989. });
  990. });
  991. openRecordMore.value = true;
  992. };
  993. const infiniteScroll = () => {
  994. queryParams.value.pageNum++;
  995. clickMore();
  996. };
  997. const judgeTotal = () => {
  998. if (queryParams.value.pageNum * queryParams.value.pageSize >= queryParams.value.total) {
  999. return true;
  1000. }
  1001. return false;
  1002. };
  1003. const moreIndex = ref(0);
  1004. const clickInformationMore = (item, index) => {
  1005. queryParams.value.pageNum = 1;
  1006. moreIndex.value = index;
  1007. if (item.contactJson) {
  1008. item.contact = JSON.parse(item.contactJson);
  1009. } else {
  1010. item.contact = [];
  1011. }
  1012. formPerson.data = JSON.parse(JSON.stringify(item));
  1013. openPerson.value = true;
  1014. };
  1015. const clickDelete = (index) => {
  1016. formData.data.customerUserList.splice(index, 1);
  1017. };
  1018. const clickAddMoreInformation = () => {
  1019. if (formPerson.data.contact && formPerson.data.contact.length > 0) {
  1020. formPerson.data.contact.push({
  1021. type: "",
  1022. contactNo: "",
  1023. });
  1024. } else {
  1025. formPerson.data.contact = [
  1026. {
  1027. type: "",
  1028. contactNo: "",
  1029. },
  1030. ];
  1031. }
  1032. };
  1033. const clickInformationDelete = (index) => {
  1034. formPerson.data.contact.splice(index, 1);
  1035. };
  1036. const submitPerson = () => {
  1037. person.value.validate((valid) => {
  1038. if (valid) {
  1039. formPerson.data.contactJson = JSON.stringify(formPerson.data.contact);
  1040. formData.data.customerUserList[moreIndex.value] = formPerson.data;
  1041. openPerson.value = false;
  1042. }
  1043. });
  1044. };
  1045. const deleteTop = (item) => {
  1046. proxy.post("/customerTop/delete", { customerId: item.id }).then(() => {
  1047. item.isTop = 0;
  1048. });
  1049. };
  1050. const addTop = (item) => {
  1051. proxy.post("/customerTop/add", { customerId: item.id }).then(() => {
  1052. item.isTop = 1;
  1053. });
  1054. };
  1055. </script>
  1056. <style lang="scss" scoped>
  1057. .tenant {
  1058. padding: 20px;
  1059. }
  1060. .infinite-scroll {
  1061. max-height: calc(89vh - 94px - 70px - 58px - 16px);
  1062. overflow-y: auto;
  1063. &::-webkit-scrollbar {
  1064. width: 0px;
  1065. }
  1066. }
  1067. </style>