fc4a0aa6438602a7f5ffc44a659730c54e9408fd.svn-base 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <!--
  5. -->
  6. <!-- 操作按钮区域 -->
  7. <div class="table-operator">
  8. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  9. <a-dropdown v-if="selectedRowKeys.length > 0">
  10. <a-menu slot="overlay">
  11. <a-menu-item key="1" @click="batchDel">
  12. <a-icon type="delete"/>
  13. 删除
  14. </a-menu-item>
  15. </a-menu>
  16. <a-button style="margin-left: 8px"> 批量操作
  17. <a-icon type="down"/>
  18. </a-button>
  19. </a-dropdown>
  20. </div>
  21. <!-- table区域-begin -->
  22. <div>
  23. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  24. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  25. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  26. </div>
  27. <a-table
  28. ref="table"
  29. size="middle"
  30. bordered
  31. rowKey="id"
  32. :columns="columns"
  33. :dataSource="dataSource"
  34. :pagination="ipagination"
  35. :loading="loading"
  36. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  37. @change="handleTableChange">
  38. <span slot="action" slot-scope="text, record">
  39. <a @click="handleEdit(record)">编辑</a>
  40. <a-divider type="vertical"/>
  41. <a-dropdown>
  42. <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
  43. <a-menu slot="overlay">
  44. <a-menu-item>
  45. <a href="javascript:;" @click="handleDetail(record)">详情</a>
  46. </a-menu-item>
  47. <a-menu-item>
  48. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  49. <a>删除</a>
  50. </a-popconfirm>
  51. </a-menu-item>
  52. </a-menu>
  53. </a-dropdown>
  54. </span>
  55. </a-table>
  56. </div>
  57. <!-- table区域-end -->
  58. <!-- 表单区域 -->
  59. <sysDepart-modal ref="sysDepartModal" @ok="modalFormOk"></sysDepart-modal>
  60. </a-card>
  61. </template>
  62. <script>
  63. import SysDepartModal from './modules/DepartModal'
  64. /* import { filterObj } from '@/utils/util'
  65. , queryByFactories*/
  66. import {queryDepartTreeList} from '@/api/api'
  67. import {deleteAction} from '@/api/manage'
  68. // 表头
  69. const columns = [
  70. {
  71. title: '机构名称',
  72. dataIndex: 'departName',
  73. },
  74. {
  75. title: '机构类型',
  76. align: "center",
  77. dataIndex: 'orgType'
  78. },
  79. {
  80. title: '机构编码',
  81. dataIndex: 'orgCode'
  82. },
  83. {
  84. title: '手机号',
  85. dataIndex: 'mobile'
  86. },
  87. {
  88. title: '传真',
  89. dataIndex: 'fax'
  90. },
  91. {
  92. title: '地址',
  93. dataIndex: 'address'
  94. },
  95. {
  96. title: '排序',
  97. align: 'center',
  98. dataIndex: 'departOrder'
  99. },
  100. {
  101. title: '操作',
  102. align: "center",
  103. dataIndex: 'action',
  104. scopedSlots: {customRender: 'action'},
  105. }
  106. ];
  107. export default {
  108. name: "DepartList2",
  109. components: {
  110. SysDepartModal
  111. },
  112. data() {
  113. return {
  114. description: 'jeecg 生成SysDepart代码管理页面',
  115. // 查询条件
  116. queryParam: {},
  117. //数据集
  118. factories: '',
  119. dataSource: [],
  120. columns: columns,
  121. // 分页参数
  122. /* ipagination:{
  123. current: 1,
  124. pageSize: 5,
  125. pageSizeOptions: ['5', '10', '20'],
  126. showTotal: (total, range) => {
  127. return range[0] + "-" + range[1] + " 共" + total + "条"
  128. },
  129. showQuickJumper: true,
  130. showSizeChanger: true,
  131. total: 0
  132. },*/
  133. isorter: {
  134. column: 'createTime',
  135. order: 'desc',
  136. },
  137. loading: false,
  138. selectedRowKeys: [],
  139. selectedRows: [],
  140. url: {
  141. list: "/sys/sysDepart/list",
  142. delete: "/sys/sysDepart/delete",
  143. deleteBatch: "/sys/sysDepart/deleteBatch",
  144. },
  145. }
  146. },
  147. created() {
  148. this.loadData();
  149. },
  150. methods: {
  151. loadData() {
  152. this.dataSource = [];
  153. queryDepartTreeList().then((res) => {
  154. if (res.success) {
  155. this.dataSource = res.result;
  156. }
  157. })
  158. },
  159. getQueryField() {
  160. //TODO 字段权限控制
  161. var str = "id,";
  162. for (var a = 0; a < this.columns.length; a++) {
  163. str += "," + this.columns[a].dataIndex;
  164. }
  165. return str;
  166. },
  167. onSelectChange(selectedRowKeys, selectionRows) {
  168. this.selectedRowKeys = selectedRowKeys;
  169. this.selectionRows = selectionRows;
  170. },
  171. onClearSelected() {
  172. this.selectedRowKeys = [];
  173. this.selectionRows = [];
  174. },
  175. //TODO getQueryParams
  176. handleDelete: function (id) {
  177. var that = this;
  178. deleteAction(that.url.delete, {id: id}).then((res) => {
  179. if (res.success) {
  180. that.$message.success(res.message);
  181. that.loadData();
  182. } else {
  183. that.$message.warning(res.message);
  184. }
  185. });
  186. },
  187. handleDetail(record) {
  188. this.$refs.sysDepartModal.edit(record);
  189. this.$refs.sysDepartModal.title = "详情";
  190. this.$refs.sysDepartModal.disableSubmit = true;
  191. },
  192. batchDel: function () {
  193. if (this.selectedRowKeys.length <= 0) {
  194. this.$message.warning('请选择一条记录!');
  195. return;
  196. } else {
  197. var ids = "";
  198. for (var a = 0; a < this.selectedRowKeys.length; a++) {
  199. ids += this.selectedRowKeys[a] + ",";
  200. }
  201. var that = this;
  202. this.$confirm({
  203. title: "确认删除",
  204. content: "是否删除选中数据?",
  205. onOk: function () {
  206. deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
  207. if (res.success) {
  208. that.$message.success(res.message);
  209. that.loadData();
  210. that.onClearSelected();
  211. } else {
  212. that.$message.warning(res.message);
  213. }
  214. });
  215. }
  216. });
  217. }
  218. },
  219. handleEdit: function (record) {
  220. this.$refs.sysDepartModal.edit(record);
  221. this.$refs.sysDepartModal.title = "编辑";
  222. },
  223. handleAdd() {
  224. this.$refs.sysDepartModal.add();
  225. this.$refs.sysDepartModal.title = "新增";
  226. },
  227. handleTableChange(pagination, filters, sorter) {
  228. //分页、排序、筛选变化时触发
  229. console.log(sorter);
  230. //TODO 筛选
  231. if (Object.keys(sorter).length > 0) {
  232. this.isorter.column = sorter.field;
  233. this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
  234. }
  235. /*this.ipagination = pagination;*/
  236. this.loadData();
  237. },
  238. modalFormOk() {
  239. // 新增/修改 成功时,重载列表
  240. this.loadData();
  241. }
  242. }
  243. }
  244. </script>
  245. <style scoped>
  246. @import '~@assets/less/common.less'
  247. </style>