index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <ele-split-layout
  5. width="300px"
  6. allow-collapse
  7. :right-style="{ overflow: 'hidden' }"
  8. >
  9. <div>
  10. <div class="ele-border-lighter sys-organization-list">
  11. <AssetTree
  12. @handleNodeClick="handleNodeClick"
  13. id="17"
  14. ref="treeList"
  15. />
  16. </div>
  17. </div>
  18. <template v-slot:content>
  19. <div class="ele-border-lighter form-content" v-loading="loading">
  20. <contact-search @search="reload"> </contact-search>
  21. <!-- 数据表格 -->
  22. <ele-pro-table
  23. ref="table"
  24. :columns="columns"
  25. :datasource="datasource"
  26. height="calc(100vh - 300px)"
  27. full-height="calc(100vh - 116px)"
  28. tool-class="ele-toolbar-form"
  29. :selection.sync="selection"
  30. cache-key="eomContactPageTable"
  31. >
  32. <!-- 表头工具栏 -->
  33. <template v-slot:toolbar>
  34. <el-button
  35. size="small"
  36. type="primary"
  37. icon="el-icon-plus"
  38. class="ele-btn-icon"
  39. @click="openEdit('新建客户',{})"
  40. >
  41. 新建
  42. </el-button>
  43. <el-button
  44. size="small"
  45. type="danger"
  46. el-icon-delete
  47. class="ele-btn-icon"
  48. @click="allDelBtn"
  49. :disabled="selection?.length===0"
  50. >
  51. 批量删除
  52. </el-button>
  53. </template>
  54. <template v-slot:name="{ row }">
  55. <el-link type="primary" :underline="false" @click="openDetail(row)"> {{ row.name }}</el-link>
  56. </template>
  57. <!-- 操作列 -->
  58. <template v-slot:action="{ row }">
  59. <el-link
  60. type="primary"
  61. :underline="false"
  62. icon="el-icon-edit"
  63. @click="openEdit('编辑客户',row)"
  64. >
  65. 修改
  66. </el-link>
  67. <el-link
  68. v-if="row.status===2"
  69. type="primary"
  70. :underline="false"
  71. icon="el-icon-check"
  72. @click="enableOption(row)"
  73. >
  74. 启用
  75. </el-link>
  76. <el-link
  77. v-if="row.status===1"
  78. type="primary"
  79. :underline="false"
  80. icon="el-icon-close"
  81. @click="disableOption(row)"
  82. >
  83. 禁用
  84. </el-link>
  85. <el-popconfirm
  86. class="ele-action"
  87. title="确定要删除此客户信息吗?"
  88. @confirm="remove(row)"
  89. >
  90. <template v-slot:reference>
  91. <el-link
  92. type="danger"
  93. :underline="false"
  94. icon="el-icon-delete"
  95. >
  96. 删除
  97. </el-link>
  98. </template>
  99. </el-popconfirm>
  100. </template>
  101. </ele-pro-table>
  102. </div>
  103. </template>
  104. </ele-split-layout>
  105. </el-card>
  106. <AddContactDialog ref="addContactDialogRef" :categoryTreeList="treeList" @done="reload"></AddContactDialog>
  107. <ContactDetailDialog ref="contactDetailDialogRef"></ContactDetailDialog>
  108. <!-- 多选删除弹窗 -->
  109. <pop-modal :visible.sync="delVisible" content="是否确定删除?" @done="commitBtn"/>
  110. </div>
  111. </template>
  112. <script>
  113. import ContactSearch from './components/contactSearch.vue';
  114. import AddContactDialog from './components/addContactDialog.vue';
  115. import ContactDetailDialog from './components/contactDetailDialog.vue';
  116. import popModal from '@/components/pop-modal';
  117. import AssetTree from '@/components/AssetTree';
  118. import {contactDelete, contactPage, contactTypeTree, updateStatus} from '@/api/saleManage/contact';
  119. import dictMixins from '@/mixins/dictMixins';
  120. export default {
  121. mixins: [dictMixins],
  122. components: {
  123. AssetTree,
  124. ContactSearch,
  125. popModal,
  126. AddContactDialog,
  127. ContactDetailDialog,
  128. },
  129. data() {
  130. return {
  131. selection:[],
  132. delVisible:false,
  133. // 加载状态
  134. loading: false,
  135. columns: [
  136. {
  137. width: 45,
  138. type: 'selection',
  139. columnKey: 'selection',
  140. align: 'center'
  141. },
  142. {
  143. columnKey: 'index',
  144. label: '序号',
  145. type: 'index',
  146. width: 55,
  147. align: 'center',
  148. showOverflowTooltip: true,
  149. fixed: 'left'
  150. },
  151. {
  152. prop: 'code',
  153. label: '客户编码',
  154. align: 'center',
  155. showOverflowTooltip: true,
  156. minWidth: 140
  157. },
  158. {
  159. prop: 'name',
  160. label: '客户名称',
  161. align: 'center',
  162. slot: 'name',
  163. showOverflowTooltip: true,
  164. minWidth: 200
  165. },
  166. {
  167. prop: 'serialNo',
  168. label: '客户代码',
  169. align: 'center',
  170. showOverflowTooltip: true,
  171. minWidth: 140
  172. },
  173. {
  174. prop: 'phone',
  175. label: '客户电话',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 120
  179. },
  180. {
  181. prop: 'addressName',
  182. label: '单位地址',
  183. align: 'center',
  184. showOverflowTooltip: true,
  185. minWidth: 120,
  186. formatter: (_row, _column, cellValue) => {
  187. let addr = '' + _row.addressName ? _row.addressName.replaceAll(',', '') : '';
  188. addr += _row.address ? _row.address : '';
  189. return addr;
  190. }
  191. },
  192. {
  193. prop: 'linkName',
  194. label: '联系人',
  195. align: 'center',
  196. showOverflowTooltip: true,
  197. minWidth: 120
  198. },
  199. {
  200. prop: 'linkPhone',
  201. label: '联系人电话',
  202. align: 'center',
  203. showOverflowTooltip: true,
  204. minWidth: 120
  205. },
  206. {
  207. prop: 'status',
  208. label: '状态',
  209. align: 'center',
  210. showOverflowTooltip: true,
  211. minWidth: 100,
  212. formatter: (_row, _column, cellValue) => {
  213. return _row.status === 1 ? '启用' : '禁用';
  214. }
  215. },
  216. {
  217. prop: 'createUsername',
  218. label: '创建人',
  219. align: 'center',
  220. showOverflowTooltip: true,
  221. minWidth: 100
  222. },
  223. {
  224. prop: 'createTime',
  225. label: '创建时间',
  226. align: 'center',
  227. showOverflowTooltip: true,
  228. minWidth: 160,
  229. formatter: (_row, _column, cellValue) => {
  230. return this.$util.toDateString(cellValue);
  231. }
  232. },
  233. {
  234. columnKey: 'action',
  235. label: '操作',
  236. width: 200,
  237. align: 'center',
  238. resizable: false,
  239. slot: 'action',
  240. showOverflowTooltip: true,
  241. fixed: 'right',
  242. }
  243. ],
  244. current: {},
  245. curNodeData: {},
  246. treeList: [],
  247. treeLoading: false,
  248. formData: {},
  249. rootTreeId: null,
  250. defaultProps: {
  251. children: 'children',
  252. label: 'name'
  253. },
  254. showEdit: true,
  255. };
  256. },
  257. computed: {},
  258. created() {
  259. this.requestDict('客户状态');
  260. this.getTreeData();
  261. },
  262. methods: {
  263. /* 表格数据源 */
  264. datasource({ page, limit, where, order }) {
  265. return contactPage({
  266. pageNum: page,
  267. size: limit,
  268. ...where
  269. });
  270. },
  271. async getTreeData() {
  272. try {
  273. this.treeLoading = true;
  274. const res = await contactTypeTree({ type: 17 });
  275. this.treeLoading = false;
  276. if (res?.code === '0') {
  277. this.treeList = res.data;
  278. this.$nextTick(() => {
  279. // 默认高亮第一级树节点
  280. // if (this.treeList[0]) {
  281. // this.rootTreeId = this.treeList[0].id;
  282. // this.getDetail(this.treeList[0].id);
  283. // }
  284. });
  285. return this.treeList;
  286. }
  287. } catch (error) {}
  288. this.treeLoading = false;
  289. },
  290. handleNodeClick(data, node) {
  291. this.curNodeData = data;
  292. this.reload({ categoryId: data.id });
  293. },
  294. /* 刷新表格 */
  295. reload(where) {
  296. this.$refs.table.reload({ page: 1, where });
  297. },
  298. openEdit(row, type) {
  299. this.current = row;
  300. this.showEdit = true;
  301. this.$refs.addContactDialogRef.open(row, type, this.curNodeData.id);
  302. this.$refs.addContactDialogRef.$refs.form &&
  303. this.$refs.addContactDialogRef.$refs.form.clearValidate();
  304. },
  305. //批量删除
  306. allDelBtn(){
  307. if(this.selection.length===0) return
  308. this.delVisible=true
  309. },
  310. commitBtn(){
  311. console.log(this.selection)
  312. const dataId=this.selection.map(v=>v.id)
  313. contactDelete(dataId).then((res) => {
  314. this.$message.success('删除成功!');
  315. this.reload();
  316. });
  317. },
  318. remove(row) {
  319. contactDelete([row.id]).then((res) => {
  320. this.$message.success('删除成功!');
  321. this.reload();
  322. });
  323. },
  324. /** 启用客户 */
  325. enableOption(row) {
  326. updateStatus(row.id, 1)
  327. .then((msg) => {
  328. this.$message.success("客户启用成功");
  329. this.reload();
  330. })
  331. .catch((e) => {
  332. this.$message.error(e.message);
  333. });
  334. },
  335. /** 禁用客户 */
  336. disableOption(row) {
  337. updateStatus(row.id, 2)
  338. .then((msg) => {
  339. this.$message.success("客户禁用成功");
  340. this.reload();
  341. })
  342. .catch((e) => {
  343. this.$message.error(e.message);
  344. });
  345. },
  346. openDetail(row){
  347. this.$refs.contactDetailDialogRef.open(row);
  348. },
  349. }
  350. };
  351. </script>
  352. <style lang="scss" scoped>
  353. :deep(.el-link--inner){
  354. margin-left: 0px !important;
  355. }
  356. .sys-organization-list {
  357. height: calc(100vh - 264px);
  358. box-sizing: border-box;
  359. border-width: 1px;
  360. border-style: solid;
  361. overflow: auto;
  362. }
  363. .sys-organization-list :deep(.el-tree-node__content) {
  364. height: 40px;
  365. & > .el-tree-node__expand-icon {
  366. margin-left: 10px;
  367. }
  368. }
  369. </style>