enterpriseAnnouncement.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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.title"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="8">
  13. <a-form-item label="发布状态">
  14. <a-select v-model="queryParam.isRelease" placeholder="请选择发布状态">
  15. <a-select-option value="">请选择</a-select-option>
  16. <a-select-option value="0">未发布</a-select-option>
  17. <a-select-option value="1">已发布</a-select-option>
  18. </a-select>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="8">
  22. <span style="float: left;overflow: hidden;">
  23. <a-button type="primary" style="left: 10px" @click="searchQuery" icon="search">查询</a-button>
  24. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 20px">重置</a-button>
  25. </span>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. <!-- 新增 批量删除 -->
  31. <div class="table-add">
  32. <a-button @click="addAnn" type="primary">新增</a-button>
  33. <!-- 批量操作-----------------------------------
  34. v-if="selectedRowKeys.length > 0"
  35. ------------------------------------------------>
  36. <a-dropdown>
  37. <a-menu slot="overlay">
  38. <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
  39. </a-menu>
  40. <a-button style="margin-left:24px"> 批量操作 <a-icon type="down"/></a-button>
  41. </a-dropdown>
  42. </div>
  43. <div>
  44. <!-- 已选择 清空 -->
  45. <div class="ant-alert ant-alert-info" style="margin: 20px 0;background:#e6f7ff;">
  46. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
  47. <!-- {{ selectedRowKeys.length }} -->
  48. <a style="font-weight: 600">2</a>项
  49. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  50. </div>
  51. <!-- table -->
  52. <a-row>
  53. <a-table
  54. bordered
  55. :columns="columns"
  56. :dataSource="annList"
  57. :loading="loading"
  58. :pagination="pagination"
  59. :row-key="record => record.id"
  60. :rowSelection="rowSelection"
  61. @change="handleTableChange"
  62. >
  63. <!-- 发布 -->
  64. <span slot="isReleaseSlot" slot-scope="text, record">
  65. <a-tag color="orange" v-if="record.isRelease == '0'">
  66. 未发布
  67. </a-tag>
  68. <a-tag color="green" v-else>
  69. 已发布
  70. </a-tag>
  71. </span>
  72. <!-- 操作 -->
  73. <span slot="operationSlot" slot-scope="text, record">
  74. <a href="javascript:void(0);" @click="editAnn(record)"> 编辑 </a>
  75. <a-divider type="vertical" v-if="record.isRelease == '0'" />
  76. <!-- 判断是否发布 -->
  77. <a-popconfirm
  78. v-if="record.isRelease == '0'"
  79. title="确定发布吗?"
  80. @confirm="sendAnn(record.id)"
  81. ok-text="是"
  82. cancel-text="否"
  83. >
  84. <a href="javascript:void(0);" class="sendGr"> 发布 </a>
  85. </a-popconfirm>
  86. <!-- --------------------------------------------------- -->
  87. <a-divider type="vertical" v-if="record.isRelease == '1'" />
  88. <a-popconfirm
  89. v-if="record.isRelease == '1'"
  90. title="确定取消发布吗?"
  91. @confirm="saveAnn(record.id)"
  92. ok-text="是"
  93. cancel-text="否"
  94. >
  95. <a href="javascript:void(0);" class="sendGr"> 取消发布 </a>
  96. </a-popconfirm>
  97. <a-divider type="vertical" />
  98. <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="delAnn(record)">
  99. <a href="javascript:void(0);" class="delRed"> 删除 </a>
  100. </a-popconfirm>
  101. </span>
  102. </a-table>
  103. </a-row>
  104. </div>
  105. <addAnn-modal ref="AddAnnModal" @ok="modalFormOk" :fatherGetList="getAnnList"></addAnn-modal>
  106. </a-card>
  107. </template>
  108. <script>
  109. import AddAnnModal from '@views/oa/enter-ann/add/addAnnModal.vue'
  110. import {
  111. enterpriseEList,
  112. enterpriseEQueryById,
  113. enterpriseEReleseUpdate,
  114. enterpriseEDelete
  115. } from '@api/oa/cd-enterprise-announcement'
  116. export default {
  117. name: 'EnterpriseAnnouncement', // 企业公告
  118. components: {
  119. AddAnnModal
  120. },
  121. data () {
  122. return {
  123. id: '', // 唯一标识 双休绑定后自动生成,删除
  124. loading: false, // 表格加载
  125. // 表头
  126. columns: [
  127. {
  128. title: '标题',
  129. dataIndex: 'title',
  130. align: 'center'
  131. },
  132. {
  133. title: '类型',
  134. dataIndex: 'type',
  135. align: 'center'
  136. },
  137. {
  138. title: '创建人',
  139. dataIndex: 'createBy',
  140. align: 'center'
  141. },
  142. {
  143. title: '创建日期',
  144. dataIndex: 'createTime',
  145. align: 'center'
  146. },
  147. {
  148. title: '发布',
  149. dataIndex: 'isRelease',
  150. scopedSlots: { customRender: 'isReleaseSlot' },
  151. align: 'center'
  152. },
  153. {
  154. title: '操作',
  155. dataIndex: 'operation',
  156. scopedSlots: { customRender: 'operationSlot' },
  157. align: 'center',
  158. width: '20%'
  159. }
  160. ],
  161. annList: [], // 公告数据
  162. // 分页参数
  163. pagination: {
  164. total: 0,
  165. current: 0,
  166. pageSize: 0
  167. },
  168. showInfo: {}, // 编辑时回显的公告数据
  169. // 查询条件
  170. queryParam: {
  171. pageNo: '1', // 页码
  172. title: '', // 标题
  173. isRelease: '' // 是否发布
  174. }
  175. }
  176. },
  177. created () {
  178. this.getAnnList() // 渲染公告
  179. },
  180. methods: {
  181. // 查询日程计划列表(根据参数不同,传递对应的数据)
  182. getAnnList () {
  183. enterpriseEList(this.queryParam).then(res => {
  184. // console.log('>>>>', this.queryParam)
  185. if (res.success) {
  186. this.annList = res.result.records
  187. console.log('列表公告=====', this.annList)
  188. this.pagination = {
  189. total: res.result.total,
  190. current: res.result.current,
  191. pageSize: res.result.size
  192. }
  193. }
  194. })
  195. },
  196. // 查询按钮
  197. searchQuery () {
  198. this.getAnnList() // 渲染公告
  199. },
  200. searchReset () {
  201. // console.log('>>>>重置')
  202. this.queryParam.title = ''
  203. this.queryParam.isRelease = ''
  204. this.getAnnList()
  205. },
  206. // 新增 按钮
  207. addAnn () {
  208. console.log('点击新增,负责打开弹框,剩下功能在子组件的保存按钮')
  209. this.$refs.AddAnnModal.addModalVisible = true
  210. this.$refs.AddAnnModal.title = '新增企业公告'
  211. },
  212. // 点击编辑 回显
  213. editAnn (obj) {
  214. console.log('打开编辑弹框,剩下功能在子组件的保存按钮')
  215. this.$refs.AddAnnModal.addModalVisible = true
  216. this.$refs.AddAnnModal.title = '编辑企业公告'
  217. // 根据id查询公告
  218. enterpriseEQueryById({ id: obj.id }).then(res => {
  219. if (res.success) {
  220. console.log(res)
  221. this.$refs.AddAnnModal.annInfo = res.result
  222. this.$refs.AddAnnModal.getAnnFormInfo()
  223. }
  224. })
  225. },
  226. // 发布
  227. sendAnn (id) {
  228. enterpriseEReleseUpdate({ id: id, isRelease: '1' }).then(res => {
  229. console.log(res)
  230. this.$message.success('发布成功')
  231. this.getAnnList()
  232. })
  233. },
  234. // 删除公告
  235. delAnn (record) {
  236. console.log('点击公告对象', record)
  237. enterpriseEDelete({ id: record.id }).then(res => {
  238. if (res.success) {
  239. console.log(res)
  240. this.$message.success('删除成功')
  241. this.getAnnList()
  242. }
  243. })
  244. },
  245. // 取消发布
  246. saveAnn (id) {
  247. console.log('点击了取消发布')
  248. enterpriseEReleseUpdate({ id: id, isRelease: '0' }).then(res => {
  249. console.log(res)
  250. this.$message.success('取消发布')
  251. this.getAnnList() // 渲染公告
  252. })
  253. },
  254. // 批量删除
  255. batchDel () {},
  256. // 清空
  257. onClearSelected () {},
  258. // ??
  259. modalFormOk () {},
  260. // 分页、排序、筛选变化时触发
  261. handleTableChange (pagination, filters, sorter) {
  262. // console.log('当前页信息>>>>',pagination)
  263. this.queryParam.pageNo = pagination.current
  264. this.getAnnList()
  265. }
  266. },
  267. computed: {
  268. // 选中项
  269. rowSelection () {
  270. return {
  271. onChange: (selectedRowKeys, selectedRows) => {
  272. console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
  273. },
  274. getCheckboxProps: record => ({
  275. props: {
  276. disabled: record.title === 'Disabled User',
  277. // Column configuration not to be checked
  278. title: record.title
  279. }
  280. })
  281. }
  282. }
  283. },
  284. mounted () {}
  285. }
  286. </script>
  287. <style lang="less" scoped>
  288. @import '~@assets/less/common.less';
  289. </style>