myLinks.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="8">
  8. <a-form-item label="名称">
  9. <a-input placeholder="请输入名称查询" v-model="queryParam.name"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <span>
  13. <a-col :md="6" :sm="12">
  14. <a-button type="primary" style="left: 10px" @click="searchQuery" icon="search">查询</a-button>
  15. </a-col>
  16. </span>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <!-- 新增 批量删除 -->
  21. <div class="table-add">
  22. <a-button @click="addOpen" type="primary">新增</a-button>
  23. <!-- 批量操作-->
  24. <a-dropdown v-if="selectedRowKeys.length > 0">
  25. <a-menu slot="overlay">
  26. <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
  27. </a-menu>
  28. <a-button style="margin-left:24px"> 批量操作 <a-icon type="down"/></a-button>
  29. </a-dropdown>
  30. </div>
  31. <div>
  32. <!-- 已选择 清空 -->
  33. <div class="ant-alert ant-alert-info" style="margin: 20px 0;background:#e6f7ff;">
  34. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
  35. <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
  36. >项
  37. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  38. </div>
  39. <!-- 友情链接表 -->
  40. <a-row>
  41. <a-table
  42. bordered
  43. :columns="columns"
  44. :dataSource="linksData"
  45. :loading="loading"
  46. :pagination="pagination"
  47. :row-key="record => record.id"
  48. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  49. @change="handleTableChange"
  50. >
  51. <!-- 发布 -->
  52. <span slot="isReleaseSlot" slot-scope="text, record">
  53. <a-tag color="#f50" v-if="record.isRelease == '0'">
  54. 未发布
  55. </a-tag>
  56. <a-tag color="#87d068" v-else>
  57. 已发布
  58. </a-tag>
  59. </span>
  60. <!-- 操作 -->
  61. <span slot="operationSlot" slot-scope="text, record">
  62. <a href="javascript:void(0);" @click="editLinks(record)"> 编辑 </a>
  63. <a-divider type="vertical" v-if="record.isRelease == '0'" />
  64. <!-- 判断是否发布 -->
  65. <a-popconfirm
  66. v-if="record.isRelease == '0'"
  67. title="确定发布吗?"
  68. @confirm="sendLinks(record.id)"
  69. ok-text="是"
  70. cancel-text="否"
  71. >
  72. <a href="javascript:void(0);" class="sendGr"> 发布 </a>
  73. </a-popconfirm>
  74. <!-- --------------------------------------------------- -->
  75. <a-divider type="vertical" v-if="record.isRelease == '1'" />
  76. <a-popconfirm
  77. v-if="record.isRelease == '1'"
  78. title="确定取消发布吗?"
  79. @confirm="saveLinks(record.id)"
  80. ok-text="是"
  81. cancel-text="否"
  82. >
  83. <a href="javascript:void(0);" class="sendGr"> 取消发布 </a>
  84. </a-popconfirm>
  85. <a-divider type="vertical" />
  86. <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="delLinks(record)">
  87. <a href="javascript:void(0);" class="delRed"> 删除 </a>
  88. </a-popconfirm>
  89. </span>
  90. </a-table>
  91. </a-row>
  92. </div>
  93. <!-- 新增弹框 组件 -->
  94. <addLinks-modal ref="AddLinksModal" :fatherGetList="getLinksList" @ok="modalFormOk"></addLinks-modal>
  95. </a-card>
  96. </template>
  97. <script>
  98. import AddLinksModal from '@views/oa/my-links/add/addLinksModal.vue'
  99. import { linksList, linksQueryById, linksDelete, linksReleseUpdate } from '@api/oa/cd_links'
  100. export default {
  101. name: 'MyLinks',
  102. components: {
  103. AddLinksModal
  104. },
  105. data () {
  106. return {
  107. selectedRowKeys: [],
  108. id: '', // 唯一标识 双休绑定后自动生成,删除
  109. loading: false, // 表格加载
  110. pagination: {
  111. total: 0,
  112. current: 0,
  113. pageSize: 0
  114. },
  115. queryParam: {
  116. pageNo: '1',
  117. name: '' // 名称
  118. // isRelease: '' // 是否发布
  119. },
  120. // 表头
  121. columns: [
  122. {
  123. title: '名称',
  124. dataIndex: 'name',
  125. align: 'center'
  126. },
  127. {
  128. title: '地址',
  129. dataIndex: 'link',
  130. align: 'center'
  131. },
  132. {
  133. title: '简要介绍',
  134. dataIndex: 'briefIntroduction',
  135. align: 'center'
  136. },
  137. {
  138. title: '创建人',
  139. dataIndex: 'createBy',
  140. align: 'center'
  141. },
  142. {
  143. title: '发布',
  144. dataIndex: 'isRelease',
  145. scopedSlots: { customRender: 'isReleaseSlot' },
  146. align: 'center'
  147. },
  148. {
  149. title: '操作',
  150. dataIndex: 'operation',
  151. scopedSlots: { customRender: 'operationSlot' },
  152. align: 'center',
  153. width: '20%'
  154. }
  155. ],
  156. // 链接数据
  157. linksData: []
  158. }
  159. },
  160. created () {
  161. this.getLinksList() // 友情链接
  162. },
  163. methods: {
  164. // 友情链接 查询
  165. getLinksList () {
  166. this.$nextTick(() => {
  167. linksList(this.queryParam).then(res => {
  168. // console.log('>>>>', this.queryParam)
  169. if (res.success) {
  170. this.linksData = res.result.records
  171. console.log('链接公告==', this.linksData)
  172. this.pagination = {
  173. total: res.result.total,
  174. current: res.result.current,
  175. pageSize: res.result.size
  176. }
  177. }
  178. })
  179. })
  180. },
  181. // 查询
  182. searchQuery () {
  183. this.getLinksList()
  184. },
  185. // 新增
  186. addOpen () {
  187. console.log('点击新增,负责打开弹框,剩下功能在子组件的保存按钮')
  188. // 拿到子组件的弹框 属性
  189. this.$refs.AddLinksModal.addLinksModVis = true
  190. this.$refs.AddLinksModal.title = '新增友情链接'
  191. },
  192. // 编辑
  193. editLinks (obj) {
  194. console.log('点击编辑,该链接是:', obj)
  195. this.$refs.AddLinksModal.addLinksModVis = true
  196. this.$refs.AddLinksModal.title = '编辑友情链接'
  197. // 根据 ID 查询对应友情链接 params:{id:''}
  198. linksQueryById({ id: obj.id }).then(res => {
  199. if (res.success) {
  200. console.log('根据id查询res:', res)
  201. this.$refs.AddLinksModal.linkInfo = res.result
  202. console.log('this.$refs.AddLinksModal.linkInfo:', this.$refs.AddLinksModal.linkInfo)
  203. this.$refs.AddLinksModal.getLinkInfo()
  204. }
  205. })
  206. },
  207. // 勾选
  208. onSelectChange (keys, rows) {
  209. this.selectedRowKeys = keys
  210. this.selectedRows = rows
  211. },
  212. // 批量删除
  213. batchDel () {},
  214. // 清空
  215. onClearSelected () {},
  216. // ??
  217. modalFormOk () {},
  218. // 分页、排序、筛选变化时触发
  219. handleTableChange (pagination, filters, sorter) {
  220. console.log('当前页信息>>>>', pagination)
  221. this.queryParam.pageNo = pagination.current
  222. this.getLinksList()
  223. },
  224. // 发布
  225. sendLinks (id) {
  226. console.log('发布')
  227. linksReleseUpdate({ id: id, isRelease: '1' }).then(res => {
  228. if (res.success) {
  229. this.getLinksList()
  230. this.$message.success('发布成功')
  231. }
  232. })
  233. },
  234. // 取消发布
  235. saveLinks (id) {
  236. console.log('取消发布')
  237. linksReleseUpdate({ id: id, isRelease: '0' }).then(res => {
  238. if (res.success) {
  239. this.$message.success('取消发布')
  240. this.getLinksList()
  241. }
  242. })
  243. },
  244. // 撤销
  245. backLinks (id) {
  246. console.log('点击了撤销')
  247. },
  248. // 操作 删除
  249. delLinks (record) {
  250. // console.log('点击了删除,需要发请求、确定提示、重新渲染')
  251. linksDelete({ id: record.id }).then(res => {
  252. if (res.success) {
  253. console.log('res', res)
  254. this.getLinksList()
  255. this.$message.success('删除成功')
  256. }
  257. })
  258. }
  259. },
  260. computed: {
  261. // 选中项
  262. rowSelection () {
  263. return {
  264. onChange: (selectedRowKeys, selectedRows) => {
  265. console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
  266. },
  267. getCheckboxProps: record => ({
  268. props: {
  269. disabled: record.title === 'Disabled User',
  270. // Column configuration not to be checked
  271. title: record.title
  272. }
  273. })
  274. }
  275. }
  276. },
  277. mounted () {}
  278. }
  279. </script>
  280. <style lang="less" scoped>
  281. @import '~@assets/less/common.less';
  282. </style>