master-data-list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <template>
  2. <div :class="[$style.wrapHeight, $style.dataclass]">
  3. <div :class="$style.rowHeight">
  4. <MasterDataTree ref="masterTree" @treeSelect="treeSelect"></MasterDataTree>
  5. <div :class="$style.rightcard">
  6. <div v-if="groupId !== ''" :class="$style.row">
  7. <div>
  8. <a-button type="primary" @click="createMatters">
  9. 新建
  10. </a-button>
  11. <a-button
  12. :disabled="!nodeInfo.id || nodeInfo.id === '-1'"
  13. :class="$style.rowRight"
  14. @click="deleteRows"
  15. >
  16. 删除
  17. </a-button>
  18. </div>
  19. </div>
  20. <a-descriptions
  21. v-if="groupId !== '-1' && groupId !== ''"
  22. bordered
  23. :title="className"
  24. :column="2"
  25. >
  26. <a-descriptions-item v-for="(item, index) in orgList" :key="index" :label="item.org_name">
  27. <div :class="$style.labelItem">
  28. <a-button
  29. :class="$style.button"
  30. size="small"
  31. icon="plus"
  32. @click="systemTree(item.org_code, item.org_name)"
  33. ></a-button>
  34. <div v-if="item.checkList.length > 0" style="display: inline-block;">
  35. <a-tag
  36. v-for="(sysItem, sysIndex) in item.checkList"
  37. :key="sysIndex"
  38. color="#108ee9"
  39. :closable="sysItem.isShow"
  40. @close="closeTag(sysItem.id)"
  41. >
  42. {{ sysItem.org_name }}
  43. </a-tag></div
  44. >
  45. </div>
  46. </a-descriptions-item>
  47. </a-descriptions>
  48. </div>
  49. </div>
  50. <a-modal v-model="visible" :title="type === 'add' ? '新增' : '编辑'" width="800px" @ok="save">
  51. <a-form-model
  52. ref="ruleForm"
  53. :model="detailInfo"
  54. :rules="rules"
  55. :label-col="{ span: 4 }"
  56. :wrapper-col="{ span: 15 }"
  57. >
  58. <a-form-model-item label="代码" prop="code">
  59. <a-input v-model="detailInfo.code"></a-input>
  60. </a-form-model-item>
  61. <a-form-model-item label="名称" prop="name">
  62. <a-input v-model="detailInfo.name"></a-input>
  63. </a-form-model-item>
  64. <a-form-model-item label="排序号">
  65. <a-input v-model="detailInfo.weight"></a-input>
  66. </a-form-model-item>
  67. <a-form-model-item label="级别">
  68. <a-input value="公司" disabled></a-input>
  69. </a-form-model-item>
  70. <a-form-model-item label="所属分类">
  71. <a-input v-model="className" disabled></a-input>
  72. </a-form-model-item>
  73. <a-form-model-item label="备注">
  74. <a-textarea v-model="detailInfo.description" :rows="2"></a-textarea>
  75. </a-form-model-item>
  76. </a-form-model>
  77. </a-modal>
  78. <!--加载状态 -->
  79. <a-modal v-model="orgShow" :title="sysName" @ok="saveSys">
  80. <div v-if="confirmLoading" :class="$style.loading">
  81. <sd-loading></sd-loading>
  82. </div>
  83. <div v-else-if="systemData.length > 0">
  84. <a-tree
  85. checkable
  86. check-strictly
  87. :tree-data="systemData"
  88. :replace-fields="{
  89. children: 'children',
  90. title: 'org_name',
  91. }"
  92. @check="onCheck"
  93. />
  94. </div>
  95. <a-empty v-else />
  96. </a-modal>
  97. </div>
  98. </template>
  99. <script>
  100. import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins'
  101. import MasterDataTree from './master-data-tree.vue'
  102. import TableActionTypes from '@/common/services/table-action-types'
  103. import { message, Modal, Descriptions } from 'ant-design-vue'
  104. import MasterDataService from './master-data-service'
  105. import Vue from 'vue'
  106. import { getUserInfo } from '@/common/store-mixin'
  107. import sdLoading from '@/common/pages/sd-loading.vue'
  108. Vue.use(Descriptions)
  109. export default {
  110. name: 'MasterDataList',
  111. metaInfo: {
  112. title: '组织管理',
  113. },
  114. components: {
  115. MasterDataTree,
  116. sdLoading,
  117. },
  118. mixins: [auditAdvancedQueryMixins],
  119. data() {
  120. return {
  121. confirmLoading: false,
  122. orgList: [
  123. { org_name: '数字法制系统', org_code: '003001', checkList: [] },
  124. { org_name: '境外项目管理系统', org_code: '005002', checkList: [] },
  125. { org_name: '科技技改数字化项目管理系统', org_code: '002002', checkList: [] },
  126. { org_name: '燃料管理系统', org_code: '007002', checkList: [] },
  127. { org_name: '电力营销系统', org_code: '005004', checkList: [] },
  128. { org_name: '投资管理系统', org_code: '002001', checkList: [] },
  129. { org_name: '产业中台系统', org_code: '007001', checkList: [] },
  130. { org_name: '对标系统', org_code: '006003', checkList: [] },
  131. { org_name: '司库系统', org_code: '006001', checkList: [] },
  132. { org_name: '综合办公系统', org_code: '008001', checkList: [] },
  133. { org_name: '采购管理系统', org_code: '005003', checkList: [] },
  134. { org_name: '财务报表系统', org_code: '006004', checkList: [] },
  135. { org_name: '财务共享系统', org_code: '006002', checkList: [] },
  136. { org_name: 'ERP系统', org_code: '005001', checkList: [] },
  137. { org_name: '三重一大系统', org_code: '004001', checkList: [] },
  138. { org_name: 'JYKJ系统', org_code: '001001', checkList: [] },
  139. // { org_name: '司库系统', org_code: 'dsjsj00017', checkList: [] },
  140. // { org_name: '综合办公', org_code: 'dsjsj00018', checkList: [] },
  141. ],
  142. values: [
  143. {
  144. name: 'code',
  145. caption: '代码',
  146. dataType: 'string',
  147. required: true,
  148. value: '',
  149. },
  150. {
  151. name: 'name',
  152. caption: '名称',
  153. dataType: 'string',
  154. required: true,
  155. value: '',
  156. },
  157. {
  158. name: 'weight',
  159. caption: '排序号',
  160. dataType: 'string',
  161. value: '',
  162. },
  163. {
  164. name: 'lev',
  165. caption: '级别',
  166. dataType: 'string',
  167. required: true,
  168. value: 'COMPANY',
  169. },
  170. {
  171. name: 'parentId',
  172. caption: '分类',
  173. dataType: 'int',
  174. required: true,
  175. value: null,
  176. },
  177. {
  178. name: 'description',
  179. caption: '详情',
  180. dataType: 'string',
  181. value: '',
  182. },
  183. ],
  184. visible: false,
  185. orgShow: false,
  186. systemData: [],
  187. type: 'add',
  188. modalForm: {
  189. name: '',
  190. code: '',
  191. description: '',
  192. weight: '',
  193. level: '',
  194. },
  195. editnode: true,
  196. searchform: 'searchform',
  197. formData: {
  198. name: '',
  199. code: '',
  200. },
  201. parentId: null,
  202. actions: [
  203. // 新增
  204. {
  205. label: '新建',
  206. id: 'create',
  207. permission: null,
  208. type: TableActionTypes.primary,
  209. callback: this.createMatters,
  210. },
  211. {
  212. label: '删除',
  213. id: 'delete',
  214. permission: null,
  215. callback: this.deleteRows,
  216. },
  217. ],
  218. columns: [
  219. {
  220. dataIndex: 'id',
  221. sdHidden: true,
  222. },
  223. {
  224. title: '代码',
  225. dataIndex: 'code',
  226. },
  227. {
  228. title: '名称',
  229. dataIndex: 'name',
  230. scopedSlots: { customRender: 'name' },
  231. },
  232. {
  233. title: '排序',
  234. dataIndex: 'weight',
  235. },
  236. {
  237. title: '级别',
  238. dataIndex: 'level',
  239. },
  240. {
  241. title: '备注',
  242. dataIndex: 'description',
  243. },
  244. {
  245. title: '操作',
  246. dataIndex: 'opt',
  247. aligen: 'center',
  248. width: '150px',
  249. customRender: (text, record, index) => {
  250. return (
  251. <span>
  252. <a
  253. vOn:click={(evt) => {
  254. this.association(record.id)
  255. }}
  256. >
  257. 关联
  258. </a>{' '}
  259. <a
  260. vOn:click={(evt) => {
  261. this.detail(record.id)
  262. }}
  263. >
  264. 明细
  265. </a>
  266. </span>
  267. )
  268. },
  269. },
  270. ],
  271. expressions: [
  272. {
  273. dataType: 'str',
  274. name: 'parentId',
  275. op: 'eq',
  276. stringValue: '-1',
  277. },
  278. ],
  279. classListData: [],
  280. className: '',
  281. ifZb: '',
  282. detailInfo: {
  283. code: '',
  284. name: '',
  285. parentId: '',
  286. description: '',
  287. weight: 0,
  288. ifZb: '',
  289. lev: 'COMPANY',
  290. },
  291. treeData: [],
  292. groupId: '',
  293. rules: {
  294. code: [{ required: true, message: '编码不能为空', trigger: 'blur' }],
  295. name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
  296. },
  297. nodeInfo: {},
  298. sysName: '',
  299. sysCode: '',
  300. checkSysList: [],
  301. }
  302. },
  303. created() {
  304. this.getOrgTypeListData()
  305. },
  306. methods: {
  307. // 选择需要关联的数据
  308. onCheck(checkedKeys, info) {
  309. this.checkSysList = info.checkedNodes
  310. },
  311. // 获取需要关联的数据
  312. systemTree(code, name) {
  313. this.systemData = []
  314. this.sysName = name
  315. this.sysCode = code
  316. this.orgShow = true
  317. this.confirmLoading = true
  318. const params = {
  319. columns: 'sys_name,org_code,org_name,porg_code',
  320. maxResults: 9999,
  321. startPosition: 0,
  322. expressions: [
  323. {
  324. dataType: 'string',
  325. name: 'sys_code',
  326. op: 'eq',
  327. stringValue: code,
  328. },
  329. ],
  330. buttonExpressions: [],
  331. formId: 'iamoperationrecord',
  332. }
  333. // const data = [
  334. // {
  335. // correlation: 0,
  336. // id: 1,
  337. // org_code: 'admin',
  338. // org_name: '系统组织',
  339. // porg_code: 'null',
  340. // sys_code: 'dsjsj00001',
  341. // sys_name: '法律事务管理系统',
  342. // },
  343. // ]
  344. // this.systemData = this.toTree(data)
  345. MasterDataService.getSystemTree(params).then((res) => {
  346. if (res.data.data.length > 0) {
  347. res.data.data.map((item) => {
  348. if (item.correlation === 1) {
  349. item.disableCheckbox = true
  350. item.disable = true
  351. }
  352. })
  353. this.systemData = this.toTree(res.data.data)
  354. }
  355. this.confirmLoading = false
  356. })
  357. },
  358. // 保存关联数据
  359. saveSys() {
  360. const params = []
  361. this.checkSysList.forEach((val) => {
  362. const obj = {
  363. groupId: this.groupId,
  364. sysName: this.sysName,
  365. sysCode: this.sysCode,
  366. code: val.data.props.org_code,
  367. level: '公司',
  368. name: val.data.props.org_name,
  369. operation: getUserInfo().name,
  370. operationTime: new Date().getTime(),
  371. }
  372. params.push(obj)
  373. })
  374. MasterDataService.saveMasterData(params).then((res) => {
  375. // 保存成功后的回调
  376. message.success('保存成功', 1).then((res) => {
  377. this.orgShow = false
  378. this.getSystemData(this.groupId)
  379. })
  380. })
  381. },
  382. // 删除关联数据
  383. closeTag(id) {
  384. MasterDataService.revokeOrgData(id).then((res) => {
  385. // 保存成功后的回调
  386. message.success('删除成功', 1).then((res) => {
  387. this.getSystemData(this.groupId)
  388. })
  389. })
  390. },
  391. toTree(data) {
  392. const result = []
  393. const map = {}
  394. data.forEach((item) => {
  395. map[item.org_code] = item
  396. })
  397. data.forEach((item) => {
  398. const parent = map[item.porg_code]
  399. if (parent) {
  400. ;(parent.children || (parent.children = [])).push(item)
  401. } else {
  402. result.push(item)
  403. }
  404. })
  405. return result
  406. },
  407. exitSubmit() {
  408. const { id, code, name, parentId, description, weight, props } = this.detailInfo
  409. const params = {
  410. id: id,
  411. code: code,
  412. name: name,
  413. parentId: parentId,
  414. description: description,
  415. weight: weight,
  416. ifZb: props.ifzb,
  417. lev: props.lev,
  418. }
  419. MasterDataService.exitOrgData(params).then((res) => {
  420. message.success('修改成功')
  421. this.visible = false
  422. this.$refs.dataTable.refresh()
  423. this.$refs.masterTree.refreshKey()
  424. })
  425. },
  426. // 删除
  427. deleteRows() {
  428. if (!this.nodeInfo.id) return message.warning('请选择分类')
  429. if (this.nodeInfo.props.isEdit === 'false') return message.warning('不能删除系统数据')
  430. if (this.nodeInfo.children !== null && this.nodeInfo.children.length > 0)
  431. return message.warning('请先删除子节点')
  432. MasterDataService.deleteOrgData(this.nodeInfo.id).then(() => {
  433. message.success('删除成功')
  434. this.parentId = ''
  435. this.className = ''
  436. this.groupId = ''
  437. this.nodeInfo = {}
  438. for (const key in this.detailInfo) {
  439. this.detailInfo[key] = ''
  440. if (key === 'weight') {
  441. this.detailInfo[key] = 0
  442. } else if (key === 'lev') {
  443. this.detailInfo[key] = 'COMPANY'
  444. }
  445. }
  446. this.$refs.masterTree.refreshKey()
  447. })
  448. },
  449. save() {
  450. if (this.type === 'add') {
  451. this.$refs.ruleForm.validate((valid) => {
  452. if (valid) {
  453. this.detailInfo.parentId = this.parentId
  454. MasterDataService.saveOrgData(this.detailInfo).then((res) => {
  455. // 保存成功
  456. message.success('保存成功')
  457. this.visible = false
  458. for (const key in this.detailInfo) {
  459. this.detailInfo[key] = ''
  460. if (key === 'weight') {
  461. this.detailInfo[key] = 0
  462. } else if (key === 'lev') {
  463. this.detailInfo[key] = 'COMPANY'
  464. }
  465. }
  466. this.$refs.masterTree.refreshKey()
  467. })
  468. }
  469. })
  470. } else {
  471. this.exitSubmit()
  472. }
  473. },
  474. handleOk() {
  475. this.visible = false
  476. },
  477. // 获取分类
  478. getOrgTypeListData() {
  479. MasterDataService.getOrgTypeList().then((res) => {
  480. this.classListData = res.data
  481. })
  482. },
  483. createMatters() {
  484. // 请选择分类
  485. if (this.parentId === '') return message.warning('请选择分类')
  486. this.visible = true
  487. this.type = 'add'
  488. },
  489. onShowEdit(record) {
  490. this.visible = true
  491. this.type = 'edit'
  492. this.detailInfo = record
  493. },
  494. // 关联
  495. association(id) {
  496. const url = '#/masterdata-field-binding?id=' + id // 新页面要打开的路由地址
  497. // 新页面要打开的路由地址
  498. window.open(url, '_blank')
  499. },
  500. // 明细
  501. detail(id) {
  502. const url = '#/master-data-operate?id=' + id // 新页面要打开的路由地址
  503. // 新页面要打开的路由地址
  504. window.open(url, '_blank')
  505. },
  506. // 点击树
  507. treeSelect(id, node) {
  508. this.parentId = node.id
  509. if (id.length === 0 || id[0] === '-1') {
  510. this.groupId = '-1'
  511. this.nodeInfo = {}
  512. this.className = '组织机构'
  513. } else {
  514. this.groupId = id[0]
  515. this.nodeInfo = node
  516. this.getSystemData(id[0])
  517. this.className = node.text
  518. }
  519. },
  520. // 获取系统绑定数据
  521. getSystemData(id) {
  522. const params = {
  523. columns: 'id,code,groupId,sysName,name,sysCode',
  524. maxResults: 9999,
  525. startPosition: 0,
  526. expressions: [
  527. {
  528. dataType: 'str',
  529. name: 'sysCode',
  530. op: 'in',
  531. stringValues: [
  532. '003001',
  533. '005002',
  534. '002002',
  535. '007002',
  536. '005004',
  537. '002001',
  538. '007001',
  539. '006003',
  540. '006001',
  541. '008001',
  542. '005003',
  543. '006004',
  544. '006002',
  545. '005001',
  546. '004001',
  547. '001001',
  548. ],
  549. },
  550. {
  551. dataType: 'long',
  552. name: 'groupId',
  553. op: 'eq',
  554. longValue: id,
  555. },
  556. ],
  557. buttonExpressions: [],
  558. formId: 'iamOperationAssociationRecord',
  559. }
  560. MasterDataService.getSystemInfo(params).then((res) => {
  561. this.orgList.map((item) => {
  562. item.checkList = []
  563. res.data.data.forEach((val) => {
  564. if (item.org_code === val.sysCode) {
  565. val.isShow = true
  566. val.org_name = val.name
  567. item.checkList.push(val)
  568. }
  569. })
  570. })
  571. })
  572. },
  573. },
  574. }
  575. </script>
  576. <style module lang="scss">
  577. @use '@/common/design' as *;
  578. .loading {
  579. height: 300px;
  580. }
  581. .wrap-height {
  582. height: 100%;
  583. .row-height {
  584. display: flex;
  585. flex: auto;
  586. height: 100%;
  587. .rightcard {
  588. flex: 1;
  589. width: calc(100% - 20%);
  590. height: 100%;
  591. padding: 10px;
  592. overflow-y: auto;
  593. background: #fff;
  594. .label-item {
  595. display: flex;
  596. // align-items: center;
  597. justify-content: space-between;
  598. width: 300px;
  599. .button {
  600. margin-left: 15px;
  601. }
  602. }
  603. .card {
  604. height: 100%;
  605. }
  606. .row {
  607. display: flex;
  608. justify-content: flex-end;
  609. margin-bottom: 10px;
  610. .row-right {
  611. margin-left: 20px;
  612. }
  613. }
  614. }
  615. }
  616. }
  617. .dataclass {
  618. :global(.projectlist .ant-table-empty .ant-table-body) {
  619. overflow-x: hidden !important;
  620. }
  621. :global(span > .ant-btn:nth-child(2)) {
  622. color: #fff;
  623. background-color: #1890ff;
  624. border-color: #1890ff;
  625. }
  626. // :global(.ant-table-placeholder) {
  627. // width: auto;
  628. // }
  629. }
  630. </style>