0c6e2a5a7bdfce32227ea50464d4b826cd50cb58.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template xmlns:background-color="http://www.w3.org/1999/xhtml">
  2. <a-row :gutter="10">
  3. <a-col :md="12" :sm="24">
  4. <a-card :bordered="false">
  5. <!-- 按钮操作区域 -->
  6. <a-row style="margin-left: 14px">
  7. <a-button @click="handleAdd(1)" type="primary">添加部门</a-button>
  8. <a-button @click="handleAdd(2)" type="primary">添加下级</a-button>
  9. <a-button type="primary" icon="download" @click="handleExportXls('部门信息')">导出</a-button>
  10. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  11. <a-button type="primary" icon="import">导入</a-button>
  12. </a-upload>
  13. <a-button title="删除多条数据" @click="batchDel" type="default">批量删除</a-button>
  14. <!--<a-button @click="refresh" type="default" icon="reload" :loading="loading">刷新</a-button>-->
  15. </a-row>
  16. <div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
  17. <a-alert type="info" :showIcon="true">
  18. <div slot="message">
  19. 当前选择:<span v-if="this.currSelected.title">{{ getCurrSelectedTitle() }}</span>
  20. <a v-if="this.currSelected.title" style="margin-left: 10px" @click="onClearSelected">取消选择</a>
  21. </div>
  22. </a-alert>
  23. <a-input-search @search="onSearch" style="width:100%;margin-top: 10px" placeholder="请输入部门名称"/>
  24. <!-- 树-->
  25. <a-col :md="10" :sm="24">
  26. <template>
  27. <a-dropdown :trigger="[this.dropTrigger]" @visibleChange="dropStatus">
  28. <span style="user-select: none">
  29. <a-tree
  30. checkable
  31. multiple
  32. @select="onSelect"
  33. @check="onCheck"
  34. @rightClick="rightHandle"
  35. :selectedKeys="selectedKeys"
  36. :checkedKeys="checkedKeys"
  37. :treeData="departTree"
  38. :checkStrictly="checkStrictly"
  39. :expandedKeys="iExpandedKeys"
  40. :autoExpandParent="autoExpandParent"
  41. @expand="onExpand"/>
  42. </span>
  43. <!--新增右键点击事件,和增加添加和删除功能-->
  44. <a-menu slot="overlay">
  45. <a-menu-item @click="handleAdd(3)" key="1">添加</a-menu-item>
  46. <a-menu-item @click="handleDelete" key="2">删除</a-menu-item>
  47. <a-menu-item @click="closeDrop" key="3">取消</a-menu-item>
  48. </a-menu>
  49. </a-dropdown>
  50. </template>
  51. </a-col>
  52. </div>
  53. </a-card>
  54. <!---- author:os_chengtgen -- date:20190827 -- for:切换父子勾选模式 =======------>
  55. <div class="drawer-bootom-button">
  56. <a-dropdown :trigger="['click']" placement="topCenter">
  57. <a-menu slot="overlay">
  58. <a-menu-item key="1" @click="switchCheckStrictly(1)">父子关联</a-menu-item>
  59. <a-menu-item key="2" @click="switchCheckStrictly(2)">取消关联</a-menu-item>
  60. <a-menu-item key="3" @click="checkALL">全部勾选</a-menu-item>
  61. <a-menu-item key="4" @click="cancelCheckALL">取消全选</a-menu-item>
  62. <a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
  63. <a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
  64. </a-menu>
  65. <a-button>
  66. 树操作 <a-icon type="up" />
  67. </a-button>
  68. </a-dropdown>
  69. </div>
  70. <!---- author:os_chengtgen -- date:20190827 -- for:切换父子勾选模式 =======------>
  71. </a-col>
  72. <a-col :md="12" :sm="24">
  73. <a-tabs defaultActiveKey="1">
  74. <a-tab-pane tab="基本信息" key="1" >
  75. <a-card :bordered="false" v-if="selectedKeys.length>0">
  76. <a-form-model ref="form" :model="model" :rules="validatorRules">
  77. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="departName" label="机构名称">
  78. <a-input placeholder="请输入机构/部门名称" v-model="model.departName" />
  79. </a-form-model-item>
  80. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="上级部门">
  81. <a-tree-select
  82. style="width:100%"
  83. :dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
  84. :treeData="treeData"
  85. :disabled="disable"
  86. v-model="model.parentId"
  87. placeholder="无">
  88. </a-tree-select>
  89. </a-form-model-item>
  90. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgCode" label="机构编码">
  91. <a-input disabled placeholder="请输入机构编码" v-model="model.orgCode" />
  92. </a-form-model-item>
  93. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgCategory" label="机构类型">
  94. <template v-if="orgCategoryDisabled">
  95. <a-radio-group v-model="model.orgCategory" placeholder="请选择机构类型">
  96. <a-radio value="1">
  97. 公司
  98. </a-radio>
  99. </a-radio-group>
  100. </template>
  101. <template v-else>
  102. <a-radio-group v-model="model.orgCategory" placeholder="请选择机构类型">
  103. <a-radio value="2">
  104. 部门
  105. </a-radio>
  106. <a-radio value="3">
  107. 岗位
  108. </a-radio>
  109. </a-radio-group>
  110. </template>
  111. </a-form-model-item>
  112. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="排序">
  113. <a-input-number v-model="model.departOrder" />
  114. </a-form-model-item>
  115. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="手机号">
  116. <a-input placeholder="请输入手机号" v-model="model.mobile" />
  117. </a-form-model-item>
  118. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="地址">
  119. <a-input placeholder="请输入地址" v-model="model.address"/>
  120. </a-form-model-item>
  121. <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="备注">
  122. <a-textarea placeholder="请输入备注" v-model="model.memo"/>
  123. </a-form-model-item>
  124. </a-form-model>
  125. <div class="anty-form-btn">
  126. <a-button @click="emptyCurrForm" type="default" htmlType="button" icon="sync">重置</a-button>
  127. <a-button @click="submitCurrForm" type="primary" htmlType="button" icon="form">保存</a-button>
  128. </div>
  129. </a-card>
  130. <a-card v-else >
  131. <a-empty>
  132. <span slot="description"> 请先选择一个部门! </span>
  133. </a-empty>
  134. </a-card>
  135. </a-tab-pane>
  136. <a-tab-pane tab="部门权限" key="2" forceRender>
  137. <depart-auth-modal ref="departAuth"/>
  138. </a-tab-pane>
  139. </a-tabs>
  140. </a-col>
  141. <depart-modal ref="departModal" @ok="loadTree"></depart-modal>
  142. </a-row>
  143. </template>
  144. <script>
  145. import DepartModal from './modules/DepartModal'
  146. import {queryDepartTreeList, searchByKeywords, deleteByDepartId} from '@/api/api'
  147. import {httpAction, deleteAction} from '@/api/manage'
  148. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  149. import DepartAuthModal from './modules/DepartAuthModal'
  150. // 表头
  151. const columns = [
  152. {
  153. title: '机构名称',
  154. dataIndex: 'departName'
  155. },
  156. {
  157. title: '机构类型',
  158. align: 'center',
  159. dataIndex: 'orgType'
  160. },
  161. {
  162. title: '机构编码',
  163. dataIndex: 'orgCode',
  164. },
  165. {
  166. title: '手机号',
  167. dataIndex: 'mobile'
  168. },
  169. {
  170. title: '传真',
  171. dataIndex: 'fax'
  172. },
  173. {
  174. title: '地址',
  175. dataIndex: 'address'
  176. },
  177. {
  178. title: '排序',
  179. align: 'center',
  180. dataIndex: 'departOrder'
  181. },
  182. {
  183. title: '操作',
  184. align: 'center',
  185. dataIndex: 'action',
  186. scopedSlots: {customRender: 'action'}
  187. }
  188. ]
  189. export default {
  190. name: 'DepartList',
  191. mixins: [JeecgListMixin],
  192. components: {
  193. DepartAuthModal,
  194. DepartModal
  195. },
  196. data() {
  197. return {
  198. iExpandedKeys: [],
  199. loading: false,
  200. autoExpandParent: true,
  201. currFlowId: '',
  202. currFlowName: '',
  203. disable: true,
  204. treeData: [],
  205. visible: false,
  206. departTree: [],
  207. rightClickSelectedKey: '',
  208. rightClickSelectedOrgCode: '',
  209. hiding: true,
  210. model: {},
  211. dropTrigger: '',
  212. depart: {},
  213. columns: columns,
  214. disableSubmit: false,
  215. checkedKeys: [],
  216. selectedKeys: [],
  217. autoIncr: 1,
  218. currSelected: {},
  219. allTreeKeys:[],
  220. checkStrictly: true,
  221. labelCol: {
  222. xs: {span: 24},
  223. sm: {span: 5}
  224. },
  225. wrapperCol: {
  226. xs: {span: 24},
  227. sm: {span: 16}
  228. },
  229. graphDatasource: {
  230. nodes: [],
  231. edges: []
  232. },
  233. validatorRules: {
  234. departName: [{required: true, message: '请输入机构/部门名称!'}],
  235. orgCode: [{required: true, message: '请输入机构编码!'}],
  236. orgCategory:[{required: true, message: '请输入机构类型!'}],
  237. mobile:[{validator: this.validateMobile}]
  238. },
  239. url: {
  240. delete: '/sys/sysDepart/delete',
  241. edit: '/sys/sysDepart/edit',
  242. deleteBatch: '/sys/sysDepart/deleteBatch',
  243. exportXlsUrl: "sys/sysDepart/exportXls",
  244. importExcelUrl: "sys/sysDepart/importExcel",
  245. },
  246. orgCategoryDisabled:false,
  247. }
  248. },
  249. computed: {
  250. importExcelUrl: function () {
  251. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  252. }
  253. },
  254. methods: {
  255. loadData() {
  256. this.refresh();
  257. },
  258. loadTree() {
  259. var that = this
  260. that.treeData = []
  261. that.departTree = []
  262. queryDepartTreeList().then((res) => {
  263. if (res.success) {
  264. //部门全选后,再添加部门,选中数量增多
  265. this.allTreeKeys = [];
  266. for (let i = 0; i < res.result.length; i++) {
  267. let temp = res.result[i]
  268. that.treeData.push(temp)
  269. that.departTree.push(temp)
  270. that.setThisExpandedKeys(temp)
  271. that.getAllKeys(temp);
  272. // console.log(temp.id)
  273. }
  274. this.loading = false
  275. }
  276. })
  277. },
  278. setThisExpandedKeys(node) {
  279. if (node.children && node.children.length > 0) {
  280. this.iExpandedKeys.push(node.key)
  281. for (let a = 0; a < node.children.length; a++) {
  282. this.setThisExpandedKeys(node.children[a])
  283. }
  284. }
  285. },
  286. refresh() {
  287. this.loading = true
  288. this.loadTree()
  289. },
  290. // 右键操作方法
  291. rightHandle(node) {
  292. this.dropTrigger = 'contextmenu'
  293. console.log(node.node.eventKey)
  294. this.rightClickSelectedKey = node.node.eventKey
  295. this.rightClickSelectedOrgCode = node.node.dataRef.orgCode
  296. },
  297. onExpand(expandedKeys) {
  298. console.log('onExpand', expandedKeys)
  299. this.iExpandedKeys = expandedKeys
  300. this.autoExpandParent = false
  301. },
  302. backFlowList() {
  303. this.$router.back(-1)
  304. },
  305. // 右键点击下拉框改变事件
  306. dropStatus(visible) {
  307. if (visible == false) {
  308. this.dropTrigger = ''
  309. }
  310. },
  311. // 右键下拉关闭下拉框
  312. closeDrop() {
  313. this.dropTrigger = ''
  314. },
  315. addRootNode() {
  316. this.$refs.nodeModal.add(this.currFlowId, '')
  317. },
  318. batchDel: function () {
  319. console.log(this.checkedKeys)
  320. if (this.checkedKeys.length <= 0) {
  321. this.$message.warning('请选择一条记录!')
  322. } else {
  323. var ids = ''
  324. for (var a = 0; a < this.checkedKeys.length; a++) {
  325. ids += this.checkedKeys[a] + ','
  326. }
  327. var that = this
  328. this.$confirm({
  329. title: '确认删除',
  330. content: '确定要删除所选中的 ' + this.checkedKeys.length + ' 条数据,以及子节点数据吗?',
  331. onOk: function () {
  332. deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
  333. if (res.success) {
  334. that.$message.success(res.message)
  335. that.loadTree()
  336. that.onClearSelected()
  337. } else {
  338. that.$message.warning(res.message)
  339. }
  340. })
  341. }
  342. })
  343. }
  344. },
  345. onSearch(value) {
  346. let that = this
  347. if (value) {
  348. searchByKeywords({keyWord: value}).then((res) => {
  349. if (res.success) {
  350. that.departTree = []
  351. for (let i = 0; i < res.result.length; i++) {
  352. let temp = res.result[i]
  353. that.departTree.push(temp)
  354. }
  355. } else {
  356. that.$message.warning(res.message)
  357. }
  358. })
  359. } else {
  360. that.loadTree()
  361. }
  362. },
  363. nodeModalOk() {
  364. this.loadTree()
  365. },
  366. nodeModalClose() {
  367. },
  368. hide() {
  369. console.log(111)
  370. this.visible = false
  371. },
  372. onCheck(checkedKeys, info) {
  373. console.log('onCheck', checkedKeys, info)
  374. this.hiding = false
  375. //---- author:os_chengtgen -- date:20190827 -- for:切换父子勾选模式 =======------
  376. if(this.checkStrictly){
  377. this.checkedKeys = checkedKeys.checked;
  378. }else{
  379. this.checkedKeys = checkedKeys
  380. }
  381. //---- author:os_chengtgen -- date:20190827 -- for:切换父子勾选模式 =======------
  382. },
  383. onSelect(selectedKeys, e) {
  384. console.log('selected', selectedKeys, e)
  385. this.hiding = false
  386. let record = e.node.dataRef
  387. console.log('onSelect-record', record)
  388. this.currSelected = Object.assign({}, record)
  389. this.model = this.currSelected
  390. this.selectedKeys = [record.key]
  391. this.model.parentId = record.parentId
  392. this.setValuesToForm(record)
  393. this.$refs.departAuth.show(record.id);
  394. },
  395. // 触发onSelect事件时,为部门树右侧的form表单赋值
  396. setValuesToForm(record) {
  397. if(record.orgCategory == '1'){
  398. this.orgCategoryDisabled = true;
  399. }else{
  400. this.orgCategoryDisabled = false;
  401. }
  402. },
  403. getCurrSelectedTitle() {
  404. return !this.currSelected.title ? '' : this.currSelected.title
  405. },
  406. onClearSelected() {
  407. this.hiding = true
  408. this.checkedKeys = []
  409. this.currSelected = {}
  410. this.selectedKeys = []
  411. this.$refs.departAuth.departId = ''
  412. },
  413. handleNodeTypeChange(val) {
  414. this.currSelected.nodeType = val
  415. },
  416. notifyTriggerTypeChange(value) {
  417. this.currSelected.notifyTriggerType = value
  418. },
  419. receiptTriggerTypeChange(value) {
  420. this.currSelected.receiptTriggerType = value
  421. },
  422. submitCurrForm() {
  423. this.$refs.form.validate(valid => {
  424. if (valid) {
  425. if (!this.currSelected.id) {
  426. this.$message.warning('请点击选择要修改部门!')
  427. return
  428. }
  429. httpAction(this.url.edit, this.currSelected, 'post').then((res) => {
  430. if (res.success) {
  431. this.$message.success('保存成功!')
  432. this.loadTree()
  433. } else {
  434. this.$message.error(res.message)
  435. }
  436. })
  437. }
  438. })
  439. },
  440. emptyCurrForm() {
  441. this.$refs.form.resetFields();
  442. this.model={}
  443. },
  444. nodeSettingFormSubmit() {
  445. this.$refs.form.validate(valid => {
  446. if (valid) {
  447. console.log('Received values of form: ', this.model)
  448. }
  449. })
  450. },
  451. openSelect() {
  452. this.$refs.sysDirectiveModal.show()
  453. },
  454. handleAdd(num) {
  455. if (num == 1) {
  456. this.$refs.departModal.add()
  457. this.$refs.departModal.title = '新增'
  458. } else if (num == 2) {
  459. let key = this.currSelected.key
  460. if (!key) {
  461. this.$message.warning('请先点击选中上级部门!')
  462. return false
  463. }
  464. this.$refs.departModal.add(this.selectedKeys)
  465. this.$refs.departModal.title = '新增'
  466. } else {
  467. this.$refs.departModal.add(this.rightClickSelectedKey)
  468. this.$refs.departModal.title = '新增'
  469. }
  470. },
  471. handleDelete() {
  472. var that = this
  473. this.$confirm({
  474. title: '确认删除',
  475. content: '确定要删除此部门以及子节点数据吗?',
  476. onOk: function () {
  477. deleteByDepartId({id: that.rightClickSelectedKey}).then((resp) => {
  478. if (resp.success) {
  479. //删除成功后,去除已选中中的数据
  480. that.checkedKeys.splice(that.checkedKeys.findIndex(key => key === that.rightClickSelectedKey), 1);
  481. that.$message.success('删除成功!')
  482. that.loadTree()
  483. //删除后同步清空右侧基本信息内容
  484. let orgCode=that.model.orgCode;
  485. if(orgCode && orgCode === that.rightClickSelectedOrgCode){
  486. that.onClearSelected()
  487. }
  488. } else {
  489. that.$message.warning('删除失败!')
  490. }
  491. })
  492. }
  493. })
  494. },
  495. selectDirectiveOk(record) {
  496. console.log('选中指令数据', record)
  497. this.nodeSettingForm.setFieldsValue({directiveCode: record.directiveCode})
  498. this.currSelected.sysCode = record.sysCode
  499. },
  500. getFlowGraphData(node) {
  501. this.graphDatasource.nodes.push({
  502. id: node.id,
  503. text: node.flowNodeName
  504. })
  505. if (node.children.length > 0) {
  506. for (let a = 0; a < node.children.length; a++) {
  507. let temp = node.children[a]
  508. this.graphDatasource.edges.push({
  509. source: node.id,
  510. target: temp.id
  511. })
  512. this.getFlowGraphData(temp)
  513. }
  514. }
  515. },
  516. //---- author:os_chengtgen -- date:20190827 -- for:切换父子勾选模式 =======------
  517. expandAll () {
  518. this.iExpandedKeys = this.allTreeKeys
  519. },
  520. closeAll () {
  521. this.iExpandedKeys = []
  522. },
  523. checkALL () {
  524. this.checkStriccheckStrictlytly = false
  525. this.checkedKeys = this.allTreeKeys
  526. },
  527. cancelCheckALL () {
  528. //this.checkedKeys = this.defaultCheckedKeys
  529. this.checkedKeys = []
  530. },
  531. switchCheckStrictly (v) {
  532. if(v==1){
  533. this.checkStrictly = false
  534. }else if(v==2){
  535. this.checkStrictly = true
  536. }
  537. },
  538. getAllKeys(node) {
  539. // console.log('node',node);
  540. this.allTreeKeys.push(node.key)
  541. if (node.children && node.children.length > 0) {
  542. for (let a = 0; a < node.children.length; a++) {
  543. this.getAllKeys(node.children[a])
  544. }
  545. }
  546. }
  547. //---- author:os_chengtgen -- date:20190827 -- for:切换父子勾选模式 =======------
  548. },
  549. created() {
  550. this.currFlowId = this.$route.params.id
  551. this.currFlowName = this.$route.params.name
  552. // this.loadTree()
  553. },
  554. }
  555. </script>
  556. <style scoped>
  557. .ant-card-body .table-operator {
  558. margin: 15px;
  559. }
  560. .anty-form-btn {
  561. width: 100%;
  562. text-align: center;
  563. }
  564. .anty-form-btn button {
  565. margin: 0 5px;
  566. }
  567. .anty-node-layout .ant-layout-header {
  568. padding-right: 0
  569. }
  570. .header {
  571. padding: 0 8px;
  572. }
  573. .header button {
  574. margin: 0 3px
  575. }
  576. .ant-modal-cust-warp {
  577. height: 100%
  578. }
  579. .ant-modal-cust-warp .ant-modal-body {
  580. height: calc(100% - 110px) !important;
  581. overflow-y: auto
  582. }
  583. .ant-modal-cust-warp .ant-modal-content {
  584. height: 90% !important;
  585. overflow-y: hidden
  586. }
  587. #app .desktop {
  588. height: auto !important;
  589. }
  590. /** Button按钮间距 */
  591. .ant-btn {
  592. margin-left: 3px
  593. }
  594. .drawer-bootom-button {
  595. /*position: absolute;*/
  596. bottom: 0;
  597. width: 100%;
  598. border-top: 1px solid #e8e8e8;
  599. padding: 10px 16px;
  600. text-align: left;
  601. left: 0;
  602. background: #fff;
  603. border-radius: 0 0 2px 2px;
  604. }
  605. </style>