index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  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. <el-icon style="color: red; cursor: pointer; font-size: 22px; transform: translateY(5px)" @click="deleteTop(item)" v-if="item.isTop === 1">
  21. <Flag />
  22. </el-icon>
  23. <el-icon style="color: #b5b5b5; cursor: pointer; font-size: 22px; transform: translateY(5px)" @click="addTop(item)" v-else><Flag /></el-icon>
  24. </div>
  25. </template>
  26. <template #address="{ item }">
  27. <span>{{ item.countryName }}</span>
  28. <span v-if="item.provinceName"> ,{{ item.provinceName }}</span>
  29. <span v-if="item.cityName"> ,{{ item.cityName }}</span>
  30. </template>
  31. <template #name="{ item }">
  32. <div style="cursor: pointer; color: #409eff" @click="handleClickName(item)">
  33. {{ item.name }}
  34. </div>
  35. </template>
  36. <template #tags="{ item }">
  37. <div style="width: 100%">
  38. <el-tag style="margin-right: 8px" type="success" v-for="(tag, index) in item.tag" closable :key="index" @close="tagClose(tag, item)">
  39. {{ dictValueLabel(tag, customerTag) }}
  40. </el-tag>
  41. <el-select
  42. v-if="item.addTagShow"
  43. v-model="addTag"
  44. style="width: 100%"
  45. @change="
  46. (val) => {
  47. return changeTag(val, item);
  48. }
  49. ">
  50. <el-option v-for="tag in customerTag" :key="tag.value" :label="tag.label" :value="tag.value" :disabled="judgeTagSelect(item.tag, tag.value)" />
  51. </el-select>
  52. <el-tag style="cursor: pointer" type="success" @click="showSelect(item)" v-else> + </el-tag>
  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>{{ item.createTime.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.createTime }}</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.createTime" 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.createTime }}</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: "0",
  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: 140,
  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. clickFollowUp(row);
  443. },
  444. },
  445. {
  446. attrs: {
  447. label: "认领客户",
  448. type: "primary",
  449. text: true,
  450. },
  451. el: "button",
  452. click() {
  453. ElMessageBox.confirm("是否确定认领该客户?", "提示", {
  454. confirmButtonText: "确定",
  455. cancelButtonText: "取消",
  456. type: "warning",
  457. }).then(() => {
  458. proxy
  459. .post("/customer/CustomerAllocation", {
  460. id: row.id,
  461. userId: useUserStore().user.userId,
  462. })
  463. .then(() => {
  464. ElMessage({
  465. message: "认领成功",
  466. type: "success",
  467. });
  468. getList();
  469. });
  470. });
  471. },
  472. },
  473. ];
  474. },
  475. },
  476. ];
  477. });
  478. let modalType = ref("add");
  479. let dialogVisible = ref(false);
  480. let openFollow = ref(false);
  481. let formData = reactive({
  482. data: {
  483. countryId: "China",
  484. },
  485. });
  486. let formPerson = reactive({
  487. data: {},
  488. });
  489. let formAllocation = reactive({
  490. data: {},
  491. });
  492. let formFollow = reactive({
  493. data: {},
  494. });
  495. const formOption = reactive({
  496. inline: true,
  497. labelWidth: 100,
  498. itemWidth: 100,
  499. rules: [],
  500. });
  501. const formConfig = computed(() => {
  502. return [
  503. {
  504. type: "input",
  505. prop: "name",
  506. label: "客户名称",
  507. required: true,
  508. itemWidth: 100,
  509. itemType: "text",
  510. },
  511. {
  512. type: "slot",
  513. slotName: "address",
  514. prop: "countryId",
  515. label: "详细地址",
  516. },
  517. {
  518. type: "input",
  519. prop: "customerCode",
  520. label: "客户代码",
  521. required: true,
  522. itemWidth: 100,
  523. itemType: "text",
  524. },
  525. {
  526. type: "select",
  527. label: "客户来源",
  528. prop: "source",
  529. itemWidth: 50,
  530. data: customerSource.value,
  531. },
  532. {
  533. type: "select",
  534. label: "客户类型",
  535. prop: "status",
  536. itemWidth: 50,
  537. data: customerStatus.value,
  538. },
  539. {
  540. type: "select",
  541. label: "业务员",
  542. prop: "userId",
  543. itemWidth: 100,
  544. data: userList.value,
  545. },
  546. {
  547. type: "select",
  548. label: "客户标签",
  549. prop: "tags",
  550. itemWidth: 100,
  551. multiple: true,
  552. data: customerTag.value,
  553. style: {
  554. width: "100%",
  555. },
  556. },
  557. {
  558. type: "slot",
  559. slotName: "person",
  560. label: "客户联系人",
  561. },
  562. ];
  563. });
  564. let rules = ref({
  565. name: [{ required: true, message: "请输入客户名称", trigger: "blur" }],
  566. name2: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  567. email: [{ required: true, message: "请输入电子邮箱", trigger: "blur" }],
  568. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  569. provinceId: [{ required: true, message: "请选择省/州", trigger: "change" }],
  570. cityId: [{ required: true, message: "请选择城市", trigger: "change" }],
  571. source: [{ required: true, message: "请选择客户来源", trigger: "change" }],
  572. status: [{ required: true, message: "请选择类型", trigger: "change" }],
  573. });
  574. const formConfigAllocation = computed(() => {
  575. return [
  576. {
  577. type: "select",
  578. label: "业务员",
  579. prop: "userId",
  580. itemWidth: 100,
  581. data: userList.value,
  582. },
  583. ];
  584. });
  585. const formConfigAFollow = computed(() => {
  586. return [
  587. {
  588. type: "date",
  589. itemType: "datetime",
  590. label: "跟进时间",
  591. prop: "date",
  592. itemWidth: 100,
  593. },
  594. {
  595. type: "input",
  596. itemType: "textarea",
  597. label: "跟进内容",
  598. prop: "content",
  599. itemWidth: 100,
  600. },
  601. {
  602. type: "slot",
  603. label: "上传附件",
  604. prop: "fileList",
  605. slotName: "fileSlot",
  606. },
  607. ];
  608. });
  609. let rulesPerson = ref({
  610. name: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  611. email: [{ required: true, message: "请输入电子邮箱", trigger: "blur" }],
  612. type: [{ required: true, message: "请选择类型", trigger: "change" }],
  613. contactNo: [{ required: true, message: "请输入联系号码", trigger: "blur" }],
  614. });
  615. let rulesFollow = ref({
  616. date: [{ required: true, message: "请选择跟进时间", trigger: "change" }],
  617. content: [{ required: true, message: "请输入跟进内容", trigger: "blur" }],
  618. });
  619. const submit = ref(null);
  620. const person = ref(null);
  621. const allocation = ref(null);
  622. const follow = ref(null);
  623. const getList = async (req) => {
  624. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  625. loading.value = true;
  626. proxy.post("/customer/page", sourceList.value.pagination).then((res) => {
  627. res.rows.forEach((x) => {
  628. x.addTagShow = false;
  629. if (x.tag) {
  630. x.tag = x.tag.split(",");
  631. } else {
  632. x.tag = [];
  633. }
  634. });
  635. sourceList.value.data = res.rows;
  636. sourceList.value.pagination.total = res.total;
  637. setTimeout(() => {
  638. loading.value = false;
  639. }, 200);
  640. });
  641. };
  642. const openModal = () => {
  643. modalType.value = "add";
  644. formData.data = {
  645. countryId: "China",
  646. tags: [],
  647. };
  648. getCityData(formData.data.countryId, "20");
  649. loadingOperation.value = false;
  650. dialogVisible.value = true;
  651. };
  652. const update = (row) => {
  653. modalType.value = "edit";
  654. loadingOperation.value = true;
  655. proxy.post("/customer/detail", { id: row.id }).then((res) => {
  656. if (res.tag) {
  657. res.tags = res.tag.split(",");
  658. } else {
  659. res.tags = [];
  660. }
  661. formData.data = res;
  662. getCityData(formData.data.countryId, "20");
  663. getCityData(formData.data.provinceId, "30");
  664. loadingOperation.value = false;
  665. });
  666. dialogVisible.value = true;
  667. };
  668. const countryData = ref([]);
  669. const provinceData = ref([]);
  670. const cityData = ref([]);
  671. const getCityData = (id, type, isChange) => {
  672. proxy.post("/areaInfo/list", { parentId: id }).then((res) => {
  673. if (type === "20") {
  674. provinceData.value = res;
  675. if (isChange) {
  676. formData.data.provinceId = "";
  677. formData.data.cityId = "";
  678. }
  679. } else if (type === "30") {
  680. cityData.value = res;
  681. if (isChange) {
  682. formData.data.cityId = "";
  683. }
  684. } else {
  685. countryData.value = res;
  686. }
  687. });
  688. };
  689. getCityData("0");
  690. const clickAddPerson = () => {
  691. if (formData.data.customerUserList && formData.data.customerUserList.length > 0) {
  692. formData.data.customerUserList.push({
  693. name: "",
  694. email: "",
  695. });
  696. } else {
  697. formData.data.customerUserList = [
  698. {
  699. name: "",
  700. email: "",
  701. },
  702. ];
  703. }
  704. };
  705. const submitAllocation = () => {
  706. allocation.value.handleSubmit(() => {
  707. proxy.post("/customer/CustomerAllocation", formAllocation.data).then(() => {
  708. ElMessage({
  709. message: "分配成功",
  710. type: "success",
  711. });
  712. openAllocation.value = false;
  713. getList();
  714. });
  715. });
  716. };
  717. const submitFollow = () => {
  718. follow.value.handleSubmit(() => {
  719. if (fileList.value && fileList.value.length > 0) {
  720. formFollow.data.fileList = fileList.value.map((item) => {
  721. return {
  722. id: item.raw.id,
  723. fileName: item.raw.fileName,
  724. fileUrl: item.raw.fileUrl,
  725. };
  726. });
  727. } else {
  728. formFollow.data.fileList = [];
  729. }
  730. proxy.post("/customerFollowRecords/" + modalType.value, formFollow.data).then(
  731. () => {
  732. ElMessage({
  733. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  734. type: "success",
  735. });
  736. openFollow.value = false;
  737. getList();
  738. },
  739. (err) => {
  740. console.log(err);
  741. }
  742. );
  743. });
  744. };
  745. const submitForm = () => {
  746. submit.value.handleSubmit(() => {
  747. if (formData.data.customerUserList && formData.data.customerUserList.length > 0) {
  748. formData.data.tag = formData.data.tags.join(",");
  749. submitLoading.value = true;
  750. proxy.post("/customer/" + modalType.value, formData.data).then(
  751. () => {
  752. ElMessage({
  753. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  754. type: "success",
  755. });
  756. dialogVisible.value = false;
  757. submitLoading.value = false;
  758. getList();
  759. },
  760. (err) => {
  761. console.log(err);
  762. submitLoading.value = false;
  763. }
  764. );
  765. } else {
  766. ElMessage("请添加客户联系人");
  767. }
  768. });
  769. };
  770. const getDict = () => {
  771. proxy.getDictOne(["customer_tag", "customer_source", "customer_status", "contact_type"]).then((res) => {
  772. customerTag.value = res["customer_tag"].map((x) => ({
  773. label: x.dictValue,
  774. value: x.dictKey,
  775. }));
  776. customerSource.value = res["customer_source"].map((x) => ({
  777. label: x.dictValue,
  778. value: x.dictKey,
  779. }));
  780. customerStatus.value = res["customer_status"].map((x) => ({
  781. label: x.dictValue,
  782. value: x.dictKey,
  783. }));
  784. contactType.value = res["contact_type"].map((x) => ({
  785. label: x.dictValue,
  786. value: x.dictKey,
  787. }));
  788. });
  789. proxy
  790. .get("/tenantUser/list", {
  791. pageNum: 1,
  792. pageSize: 10000,
  793. tenantId: useUserStore().user.tenantId,
  794. })
  795. .then((res) => {
  796. userList.value = res.rows.map((item) => {
  797. return {
  798. label: item.nickName,
  799. value: item.userId,
  800. };
  801. });
  802. });
  803. };
  804. getDict();
  805. getList();
  806. const handleClickName = (row) => {
  807. proxy.$router.push({
  808. path: "/customer/customer/portrait",
  809. query: {
  810. id: row.id,
  811. },
  812. });
  813. };
  814. const deleteFollow = (data) => {
  815. ElMessageBox.confirm("是否确认删除该跟进?", "提示", {
  816. confirmButtonText: "确定",
  817. cancelButtonText: "取消",
  818. type: "warning",
  819. }).then(() => {
  820. proxy
  821. .post("/customerFollowRecords/delete", {
  822. id: data.id,
  823. })
  824. .then(() => {
  825. ElMessage({
  826. message: "删除成功",
  827. type: "success",
  828. });
  829. getList();
  830. });
  831. });
  832. };
  833. const addTag = ref("");
  834. const judgeTagSelect = (data, val) => {
  835. if (data && data.length > 0) {
  836. if (data.includes(val)) {
  837. return true;
  838. }
  839. }
  840. return false;
  841. };
  842. const changeTag = (val, item) => {
  843. let data = {
  844. id: item.id,
  845. tag: JSON.parse(JSON.stringify(item.tag)),
  846. };
  847. data.tag.push(val);
  848. data.tag = data.tag.join(",");
  849. proxy.post("/customer/editTag", data).then(() => {
  850. ElMessage({
  851. message: "添加成功",
  852. type: "success",
  853. });
  854. item.addTagShow = false;
  855. addTag.value = "";
  856. getList();
  857. });
  858. };
  859. const tagClose = (val, item) => {
  860. let data = {
  861. id: item.id,
  862. tag: JSON.parse(JSON.stringify(item.tag)),
  863. };
  864. data.tag = data.tag.filter((row) => row !== val);
  865. if (data.tag && data.tag.length > 0) {
  866. data.tag = data.tag.join(",");
  867. } else {
  868. data.tag = "";
  869. }
  870. proxy.post("/customer/editTag", data).then(() => {
  871. ElMessage({
  872. message: "添加成功",
  873. type: "success",
  874. });
  875. item.addTagShow = false;
  876. addTag.value = "";
  877. getList();
  878. });
  879. };
  880. const showSelect = (item) => {
  881. item.addTagShow = true;
  882. };
  883. const clickFollowUp = (item) => {
  884. formFollow.data = {
  885. customerId: item.id,
  886. fileList: [],
  887. };
  888. fileList.value = [];
  889. modalType.value = "add";
  890. openFollow.value = true;
  891. openRecordMore.value = false;
  892. };
  893. const uploadFile = async (file) => {
  894. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  895. uploadData.value = res.uploadBody;
  896. file.id = res.id;
  897. file.fileName = res.fileName;
  898. file.fileUrl = res.fileUrl;
  899. return true;
  900. };
  901. const onPreviewFile = (file) => {
  902. window.open(file.raw.fileUrl, "_blank");
  903. };
  904. const getStyle = (val) => {
  905. if (val) {
  906. return "跟进记录: " + val.replace(/\n|\r\n/g, "<br>");
  907. } else {
  908. return "";
  909. }
  910. };
  911. const recordShow = (item) => {
  912. if (!(item.fileList && item.fileList.length > 0)) {
  913. proxy.post("/fileInfo/getList", { businessIdList: [item.id] }).then((fileObj) => {
  914. item.fileList = fileObj[item.id] || [];
  915. });
  916. }
  917. };
  918. const openFile = (path) => {
  919. window.open(path, "_blank");
  920. };
  921. const judgeWidth = (item, index) => {
  922. if (item && item.id) {
  923. let dom = document.querySelector(".getWidth" + item.id);
  924. if (dom) {
  925. let width = getComputedStyle(dom).width.replace("px", "");
  926. let num = parseInt(width / 118);
  927. let num2 = parseInt((width - 52) / 118);
  928. if (num2 === num) {
  929. if (index + 1 > num) {
  930. return "display: none";
  931. }
  932. } else {
  933. if (index + 1 >= num) {
  934. return "display: none";
  935. }
  936. }
  937. }
  938. }
  939. return "";
  940. };
  941. const recordList = ref([]);
  942. const rowData = ref({});
  943. const openRecordMore = ref(false);
  944. const queryParams = ref({
  945. total: 0,
  946. pageNum: 1,
  947. pageSize: 10,
  948. customerId: "",
  949. });
  950. const clickMore = (item) => {
  951. if (openRecordMore.value === false) {
  952. recordList.value = [];
  953. rowData.value = item;
  954. queryParams.value.customerId = item.id;
  955. }
  956. proxy.post("/customerFollowRecords/page", queryParams.value).then((res) => {
  957. recordList.value = recordList.value.concat(res.rows);
  958. queryParams.value.total = res.total;
  959. proxy.post("/fileInfo/getList", { businessIdList: res.rows.map((rows) => rows.id) }).then((fileObj) => {
  960. for (let i = 0; i < res.rows.length; i++) {
  961. recordList.value[parseInt(i + (queryParams.value.pageNum - 1) * queryParams.value.pageSize)].fileList =
  962. fileObj[recordList.value[parseInt(i + (queryParams.value.pageNum - 1) * queryParams.value.pageSize)].id] || [];
  963. }
  964. });
  965. });
  966. openRecordMore.value = true;
  967. };
  968. const infiniteScroll = () => {
  969. queryParams.value.pageNum++;
  970. clickMore();
  971. };
  972. const judgeTotal = () => {
  973. if (queryParams.value.pageNum * queryParams.value.pageSize >= queryParams.value.total) {
  974. return true;
  975. }
  976. return false;
  977. };
  978. const moreIndex = ref(0);
  979. const clickInformationMore = (item, index) => {
  980. moreIndex.value = index;
  981. if (item.contactJson) {
  982. item.contact = JSON.parse(item.contactJson);
  983. } else {
  984. item.contact = [];
  985. }
  986. formPerson.data = JSON.parse(JSON.stringify(item));
  987. openPerson.value = true;
  988. };
  989. const clickDelete = (index) => {
  990. formData.data.customerUserList.splice(index, 1);
  991. };
  992. const clickAddMoreInformation = () => {
  993. if (formPerson.data.contact && formPerson.data.contact.length > 0) {
  994. formPerson.data.contact.push({
  995. type: "",
  996. contactNo: "",
  997. });
  998. } else {
  999. formPerson.data.contact = [
  1000. {
  1001. type: "",
  1002. contactNo: "",
  1003. },
  1004. ];
  1005. }
  1006. };
  1007. const clickInformationDelete = (index) => {
  1008. formPerson.data.contact.splice(index, 1);
  1009. };
  1010. const submitPerson = () => {
  1011. person.value.validate((valid) => {
  1012. if (valid) {
  1013. formPerson.data.contactJson = JSON.stringify(formPerson.data.contact);
  1014. formData.data.customerUserList[moreIndex.value] = formPerson.data;
  1015. openPerson.value = false;
  1016. }
  1017. });
  1018. };
  1019. const deleteTop = (item) => {
  1020. proxy.post("/customerTop/delete", { customerId: item.id }).then(() => {
  1021. item.isTop = 0;
  1022. });
  1023. };
  1024. const addTop = (item) => {
  1025. proxy.post("/customerTop/add", { customerId: item.id }).then(() => {
  1026. item.isTop = 1;
  1027. });
  1028. };
  1029. </script>
  1030. <style lang="scss" scoped>
  1031. .tenant {
  1032. padding: 20px;
  1033. }
  1034. .infinite-scroll {
  1035. max-height: calc(89vh - 94px - 70px - 58px - 16px);
  1036. overflow-y: auto;
  1037. &::-webkit-scrollbar {
  1038. width: 0px;
  1039. }
  1040. }
  1041. </style>