index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <!--后续加按钮 生成订单 为0时才显示 hasGeneratedOrder:0,-->
  3. <div class="ele-body">
  4. <el-card shadow="never" v-loading="loading">
  5. <div class="switch">
  6. <div class="switch_left">
  7. <ul>
  8. <li
  9. v-for="item in tabOptions"
  10. :key="item.key"
  11. :class="{ active: activeComp == item.key }"
  12. @click="activeComp = item.key"
  13. >
  14. {{ item.name }}
  15. </li>
  16. </ul>
  17. </div>
  18. </div>
  19. <ele-split-layout
  20. width="210px"
  21. allow-collapse
  22. :right-style="{ overflow: 'hidden' }"
  23. v-if="activeComp == 'myContact'"
  24. >
  25. <div>
  26. <div
  27. class="ele-border-lighter sys-organization-list"
  28. style="margin-left: 10px"
  29. >
  30. <AssetTree
  31. @handleNodeClick="handleNodeClick"
  32. :defaultExpandedKeys="defaultExpandedKeys"
  33. :defaultExpandAll="false"
  34. id="17"
  35. :isFirstRefreshTable="false"
  36. ref="treeList"
  37. />
  38. </div>
  39. </div>
  40. <template v-slot:content>
  41. <div
  42. class="ele-border-lighter form-content"
  43. v-loading="loading"
  44. style="margin-right: 10px"
  45. >
  46. <contact-search @search="reload"> </contact-search>
  47. <!-- 数据表格 -->
  48. <ele-pro-table
  49. ref="table"
  50. :columns="columns"
  51. :datasource="datasource"
  52. height="calc(100vh - 365px)"
  53. style="margin-bottom: 15px"
  54. full-height="calc(100vh - 116px)"
  55. tool-class="ele-toolbar-form"
  56. :selection.sync="selection"
  57. cache-key="eomContactPageTable"
  58. >
  59. <!-- 表头工具栏 -->
  60. <template v-slot:toolbar>
  61. <!-- <el-button
  62. size="small"
  63. type="primary"
  64. icon="el-icon-plus"
  65. class="ele-btn-icon"
  66. @click="openEdit('新建客户', {})"
  67. >
  68. 新建
  69. </el-button> -->
  70. <el-button
  71. size="small"
  72. type="danger"
  73. el-icon-delete
  74. class="ele-btn-icon"
  75. @click="allDelBtn"
  76. :disabled="selection?.length === 0"
  77. >
  78. 批量删除
  79. </el-button>
  80. </template>
  81. <template v-slot:name="{ row }">
  82. <el-link
  83. type="primary"
  84. :underline="false"
  85. @click="openDetail(row)"
  86. >
  87. {{ row.name }}</el-link
  88. >
  89. </template>
  90. <!-- 操作列 -->
  91. <template v-slot:action="{ row }">
  92. <el-link
  93. type="primary"
  94. :underline="false"
  95. icon="el-icon-plus"
  96. @click="addOppo('add', row)"
  97. >
  98. 生成商机
  99. </el-link>
  100. <el-link
  101. type="primary"
  102. :underline="false"
  103. icon="el-icon-edit"
  104. @click="openEdit('编辑客户', row)"
  105. >
  106. 修改
  107. </el-link>
  108. <el-link
  109. v-if="row.status === 2"
  110. type="primary"
  111. :underline="false"
  112. icon="el-icon-check"
  113. @click="enableOption(row)"
  114. >
  115. 启用
  116. </el-link>
  117. <el-link
  118. v-if="row.status === 1"
  119. type="primary"
  120. :underline="false"
  121. icon="el-icon-close"
  122. @click="disableOption(row)"
  123. >
  124. 禁用
  125. </el-link>
  126. <el-popconfirm
  127. class="ele-action"
  128. title="确定要删除此客户信息吗?"
  129. @confirm="remove(row)"
  130. >
  131. <template v-slot:reference>
  132. <el-link
  133. type="danger"
  134. :underline="false"
  135. icon="el-icon-delete"
  136. >
  137. 删除
  138. </el-link>
  139. </template>
  140. </el-popconfirm>
  141. </template>
  142. </ele-pro-table>
  143. </div>
  144. </template>
  145. </ele-split-layout>
  146. <!-- <contactList v-if="activeComp == 'contactList' && $hasPermission('eom:contact:staff') "></contactList>-->
  147. <contactListAdmin v-if="activeComp == 'contactList'"></contactListAdmin>
  148. </el-card>
  149. <AddContactDialog
  150. ref="addContactDialogRef"
  151. :categoryTreeList="treeList"
  152. @done="reload"
  153. ></AddContactDialog>
  154. <ContactDetailDialog ref="contactDetailDialogRef"></ContactDetailDialog>
  155. <!-- 多选删除弹窗 -->
  156. <pop-modal
  157. :visible.sync="delVisible"
  158. content="是否确定删除?"
  159. @done="commitBtn"
  160. />
  161. <add-opportunity-dialog
  162. ref="opportunityRef"
  163. :categoryTreeList="treeList"
  164. @done="reload"
  165. ></add-opportunity-dialog>
  166. <drawer ref="drawerRef"></drawer>
  167. </div>
  168. </template>
  169. <script>
  170. import addOpportunityDialog from '@/views/saleManage/businessOpportunity/components/addOpportunityDialog.vue';
  171. import ContactSearch from './components/contactSearch.vue';
  172. import AddContactDialog from './components/addContactDialog.vue';
  173. import ContactDetailDialog from './components/contactDetailDialog.vue';
  174. import drawer from './components/drawer.vue';
  175. import contactList from './contactList.vue';
  176. import contactListAdmin from './contactListAdmin.vue';
  177. import popModal from '@/components/pop-modal';
  178. import AssetTree from '@/components/AssetTree';
  179. import {
  180. contactDelete,
  181. contactPage,
  182. contactTypeTree,
  183. updateStatus
  184. } from '@/api/saleManage/contact';
  185. import dictMixins from '@/mixins/dictMixins';
  186. export default {
  187. mixins: [dictMixins],
  188. components: {
  189. AssetTree,
  190. ContactSearch,
  191. popModal,
  192. AddContactDialog,
  193. ContactDetailDialog,
  194. contactListAdmin,
  195. contactList,
  196. addOpportunityDialog,
  197. drawer
  198. },
  199. data() {
  200. return {
  201. activeComp: 'myContact',
  202. tabOptions: [
  203. { key: 'myContact', name: '我的客户' },
  204. { key: 'contactList', name: '公海客户' }
  205. ],
  206. selection: [],
  207. defaultExpandedKeys: [],
  208. delVisible: false,
  209. // 加载状态
  210. loading: false,
  211. columns: [
  212. {
  213. width: 45,
  214. type: 'selection',
  215. columnKey: 'selection',
  216. align: 'center'
  217. },
  218. {
  219. columnKey: 'index',
  220. label: '序号',
  221. type: 'index',
  222. width: 55,
  223. align: 'center',
  224. showOverflowTooltip: true,
  225. fixed: 'left'
  226. },
  227. {
  228. prop: 'code',
  229. label: '客户编码',
  230. align: 'center',
  231. showOverflowTooltip: true,
  232. minWidth: 140
  233. },
  234. {
  235. prop: 'name',
  236. label: '客户名称',
  237. align: 'center',
  238. slot: 'name',
  239. showOverflowTooltip: true,
  240. minWidth: 200
  241. },
  242. {
  243. prop: 'serialNo',
  244. label: '客户代号',
  245. align: 'center',
  246. showOverflowTooltip: true,
  247. minWidth: 140
  248. },
  249. {
  250. prop: 'phone',
  251. label: '客户电话',
  252. align: 'center',
  253. showOverflowTooltip: true,
  254. minWidth: 120
  255. },
  256. {
  257. prop: 'addressName',
  258. label: '单位地址',
  259. align: 'center',
  260. showOverflowTooltip: true,
  261. minWidth: 120,
  262. formatter: (_row, _column, cellValue) => {
  263. let addr =
  264. '' + _row.addressName ? _row.addressName.replaceAll(',', '') : '';
  265. addr += _row.address ? _row.address : '';
  266. return addr;
  267. }
  268. },
  269. {
  270. prop: 'linkName',
  271. label: '联系人',
  272. align: 'center',
  273. showOverflowTooltip: true,
  274. minWidth: 120
  275. },
  276. {
  277. prop: 'linkPhone',
  278. label: '联系人电话',
  279. align: 'center',
  280. showOverflowTooltip: true,
  281. minWidth: 120
  282. },
  283. {
  284. prop: 'parentName',
  285. label: '上级单位',
  286. align: 'center',
  287. showOverflowTooltip: true,
  288. minWidth: 120
  289. },
  290. {
  291. prop: 'status',
  292. label: '状态',
  293. align: 'center',
  294. showOverflowTooltip: true,
  295. minWidth: 100,
  296. formatter: (_row, _column, cellValue) => {
  297. return _row.status === 1 ? '启用' : '禁用';
  298. }
  299. },
  300. {
  301. prop: 'createUsername',
  302. label: '创建人',
  303. align: 'center',
  304. showOverflowTooltip: true,
  305. minWidth: 100
  306. },
  307. {
  308. prop: 'createTime',
  309. label: '创建时间',
  310. align: 'center',
  311. showOverflowTooltip: true,
  312. minWidth: 160,
  313. formatter: (_row, _column, cellValue) => {
  314. return this.$util.toDateString(cellValue);
  315. }
  316. },
  317. {
  318. columnKey: 'action',
  319. label: '操作',
  320. width: 260,
  321. align: 'center',
  322. resizable: false,
  323. slot: 'action',
  324. showOverflowTooltip: true,
  325. fixed: 'right'
  326. }
  327. ],
  328. current: {},
  329. curNodeData: {},
  330. treeList: [],
  331. treeLoading: false,
  332. formData: {},
  333. rootTreeId: null,
  334. defaultProps: {
  335. children: 'children',
  336. label: 'name'
  337. },
  338. showEdit: true
  339. };
  340. },
  341. computed: {},
  342. created() {
  343. console.log(this.$hasPermission('eom:contact:staff'));
  344. console.log(this.$hasPermission('eom:contact:admin'));
  345. this.requestDict('客户状态');
  346. this.getTreeData();
  347. },
  348. methods: {
  349. /* 表格数据源 */
  350. datasource({ page, limit, where, order }) {
  351. return contactPage({
  352. pageNum: page,
  353. size: limit,
  354. type: 1,
  355. salesmanId: this.$store.state.user.info.userId,
  356. ...where
  357. });
  358. },
  359. async getTreeData() {
  360. try {
  361. this.treeLoading = true;
  362. const res = await contactTypeTree({ type: 17 });
  363. this.treeLoading = false;
  364. if (res?.code === '0') {
  365. this.treeList = res.data;
  366. this.$nextTick(() => {
  367. // console.log(this.treeList);
  368. this.defaultExpandedKeys = this.treeList?.map(
  369. (item) => item.id
  370. ) || [17];
  371. // 默认高亮第一级树节点
  372. // if (this.treeList[0]) {
  373. // this.rootTreeId = this.treeList[0].id;
  374. // this.getDetail(this.treeList[0].id);
  375. // }
  376. });
  377. return this.treeList;
  378. }
  379. } catch (error) {}
  380. this.treeLoading = false;
  381. },
  382. handleNodeClick(data, node) {
  383. this.curNodeData = data;
  384. this.reload({ categoryId: data.id });
  385. },
  386. /* 刷新表格 */
  387. reload(where) {
  388. this.$refs.table.reload({ page: 1, where });
  389. },
  390. openEdit(row, type) {
  391. this.current = row;
  392. this.showEdit = true;
  393. this.$refs.addContactDialogRef.open(row, type, this.curNodeData.id);
  394. this.$refs.addContactDialogRef.$refs.form &&
  395. this.$refs.addContactDialogRef.$refs.form.clearValidate();
  396. },
  397. addOppo(type, row) {
  398. this.$refs.opportunityRef.open(type, row, row.id);
  399. this.$refs.opportunityRef.$refs.form &&
  400. this.$refs.opportunityRef.$refs.form.clearValidate();
  401. },
  402. //批量删除
  403. allDelBtn() {
  404. if (this.selection.length === 0) return;
  405. this.delVisible = true;
  406. },
  407. commitBtn() {
  408. console.log(this.selection);
  409. const dataId = this.selection.map((v) => v.id);
  410. contactDelete(dataId).then((res) => {
  411. this.$message.success('删除成功!');
  412. this.reload();
  413. });
  414. },
  415. remove(row) {
  416. contactDelete([row.id]).then((res) => {
  417. this.$message.success('删除成功!');
  418. this.reload();
  419. });
  420. },
  421. /** 启用客户 */
  422. enableOption(row) {
  423. updateStatus(row.id, 1)
  424. .then((msg) => {
  425. this.$message.success('客户启用成功');
  426. this.reload();
  427. })
  428. .catch((e) => {
  429. this.$message.error(e.message);
  430. });
  431. },
  432. /** 禁用客户 */
  433. disableOption(row) {
  434. updateStatus(row.id, 2)
  435. .then((msg) => {
  436. this.$message.success('客户禁用成功');
  437. this.reload();
  438. })
  439. .catch((e) => {
  440. this.$message.error(e.message);
  441. });
  442. },
  443. openDetail(row) {
  444. // this.$refs.contactDetailDialogRef.open(row);
  445. this.$refs.drawerRef.open(row,'myList');
  446. }
  447. }
  448. };
  449. </script>
  450. <style lang="scss" scoped>
  451. :deep .el-card__body {
  452. padding: 0;
  453. }
  454. :deep(.el-link--inner) {
  455. margin-left: 0px !important;
  456. }
  457. .sys-organization-list {
  458. height: calc(100vh - 264px);
  459. box-sizing: border-box;
  460. border-width: 1px;
  461. border-style: solid;
  462. overflow: auto;
  463. }
  464. .sys-organization-list :deep(.el-tree-node__content) {
  465. height: 40px;
  466. & > .el-tree-node__expand-icon {
  467. margin-left: 10px;
  468. }
  469. }
  470. .switch_left ul .active {
  471. border-top: 4px solid var(--color-primary);
  472. color: var(--color-primary-5);
  473. }
  474. .switch {
  475. padding-bottom: 20px;
  476. }
  477. </style>