index.vue 11 KB

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