notice.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. ref="crud"
  8. @row-del="rowDel"
  9. v-model="form"
  10. :permission="permissionList"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. :before-open="beforeOpen"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.notice_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. <template slot="fileListForm">
  31. <c-upload :basic="true" :data="form.fileList"></c-upload>
  32. </template>
  33. <template slot-scope="{row}"
  34. slot="category">
  35. <el-tag>{{ row.categoryName }}</el-tag>
  36. </template>
  37. </avue-crud>
  38. </basic-container>
  39. </template>
  40. <script>
  41. import {getList, remove, update, add, getNotice} from "@/api/desk/notice";
  42. import {mapGetters} from "vuex";
  43. export default {
  44. data() {
  45. return {
  46. form: {},
  47. query: {},
  48. loading: true,
  49. page: {
  50. pageSize: 10,
  51. currentPage: 1,
  52. total: 0
  53. },
  54. selectionList: [],
  55. option: {
  56. height: 'auto',
  57. calcHeight: 30,
  58. dialogWidth: 950,
  59. tip: false,
  60. searchShow: true,
  61. searchMenuSpan: 6,
  62. border: true,
  63. index: true,
  64. viewBtn: true,
  65. selection: true,
  66. excelBtn: true,
  67. dialogClickModal: false,
  68. column: [
  69. {
  70. label: "通知标题",
  71. prop: "title",
  72. span: 12,
  73. // row: true,
  74. search: true,
  75. rules: [{
  76. required: true,
  77. message: "请输入通知标题",
  78. trigger: "blur"
  79. }]
  80. }, {
  81. label: "发送范围",
  82. prop: "sendRange",
  83. span: 12
  84. },
  85. {
  86. label: "通知类型",
  87. type: "select",
  88. dicUrl: "/api/blade-system/dict/dictionary?code=notice",
  89. props: {
  90. label: "dictValue",
  91. value: "dictKey"
  92. },
  93. dataType: "number",
  94. slot: true,
  95. prop: "category",
  96. search: true,
  97. rules: [{
  98. required: true,
  99. message: "请输入通知类型",
  100. trigger: "blur"
  101. }]
  102. },
  103. {
  104. label: "通知时间",
  105. prop: "releaseTimeRange",
  106. type: "datetime",
  107. format: "yyyy-MM-dd hh:mm:ss",
  108. valueFormat: "yyyy-MM-dd hh:mm:ss",
  109. searchRange: true,
  110. hide: true,
  111. addDisplay: false,
  112. editDisplay: false,
  113. viewDisplay: false,
  114. search: true,
  115. rules: [{
  116. required: true,
  117. message: "请输入通知时间",
  118. trigger: "blur"
  119. }]
  120. },
  121. {
  122. label: "通知日期",
  123. prop: "releaseTime",
  124. type: "datetime",
  125. format: "yyyy-MM-dd hh:mm:ss",
  126. valueFormat: "yyyy-MM-dd hh:mm:ss",
  127. rules: [{
  128. required: true,
  129. message: "请输入通知日期",
  130. trigger: "click"
  131. }]
  132. },
  133. {
  134. label: "通知内容",
  135. prop: "content",
  136. component: 'AvueUeditor',
  137. options: {
  138. action: '/api/blade-resource/oss/endpoint/put-file',
  139. props: {
  140. res: "data",
  141. url: "link",
  142. }
  143. },
  144. hide: true,
  145. minRows: 6,
  146. span: 24,
  147. }, {
  148. hide: true,
  149. showColumn: false,
  150. label: "附件明细",
  151. prop: "fileList",
  152. span: 24,
  153. },
  154. ]
  155. },
  156. data: []
  157. };
  158. },
  159. computed: {
  160. ...mapGetters(["permission"]),
  161. permissionList() {
  162. return {
  163. addBtn: this.vaildData(this.permission.notice_add, false),
  164. viewBtn: this.vaildData(this.permission.notice_view, false),
  165. delBtn: this.vaildData(this.permission.notice_delete, false),
  166. editBtn: this.vaildData(this.permission.notice_edit, false)
  167. };
  168. },
  169. ids() {
  170. let ids = [];
  171. this.selectionList.forEach(ele => {
  172. ids.push(ele.id);
  173. });
  174. return ids.join(",");
  175. }
  176. },
  177. methods: {
  178. rowSave(row, done, loading) {
  179. add(row).then(() => {
  180. this.onLoad(this.page);
  181. this.$message({
  182. type: "success",
  183. message: "操作成功!"
  184. });
  185. done();
  186. }, error => {
  187. window.console.log(error);
  188. loading();
  189. });
  190. },
  191. rowUpdate(row, index, done, loading) {
  192. update(row).then(() => {
  193. this.onLoad(this.page);
  194. this.$message({
  195. type: "success",
  196. message: "操作成功!"
  197. });
  198. done();
  199. }, error => {
  200. window.console.log(error);
  201. loading();
  202. });
  203. },
  204. rowDel(row) {
  205. this.$confirm("确定将选择数据删除?", {
  206. confirmButtonText: "确定",
  207. cancelButtonText: "取消",
  208. type: "warning"
  209. })
  210. .then(() => {
  211. return remove(row.id);
  212. })
  213. .then(() => {
  214. this.onLoad(this.page);
  215. this.$message({
  216. type: "success",
  217. message: "操作成功!"
  218. });
  219. });
  220. },
  221. searchReset() {
  222. this.query = {};
  223. this.onLoad(this.page);
  224. },
  225. searchChange(params, done) {
  226. this.query = params;
  227. this.page.currentPage = 1;
  228. this.onLoad(this.page, params);
  229. done();
  230. },
  231. selectionChange(list) {
  232. this.selectionList = list;
  233. },
  234. selectionClear() {
  235. this.selectionList = [];
  236. this.$refs.crud.toggleSelection();
  237. },
  238. handleDelete() {
  239. if (this.selectionList.length === 0) {
  240. this.$message.warning("请选择至少一条数据");
  241. return;
  242. }
  243. this.$confirm("确定将选择数据删除?", {
  244. confirmButtonText: "确定",
  245. cancelButtonText: "取消",
  246. type: "warning"
  247. })
  248. .then(() => {
  249. return remove(this.ids);
  250. })
  251. .then(() => {
  252. this.onLoad(this.page);
  253. this.$message({
  254. type: "success",
  255. message: "操作成功!"
  256. });
  257. this.$refs.crud.toggleSelection();
  258. });
  259. },
  260. beforeOpen(done, type) {
  261. if (["edit", "view"].includes(type)) {
  262. getNotice(this.form.id).then(res => {
  263. this.form = res.data.data;
  264. });
  265. }
  266. done();
  267. },
  268. currentChange(currentPage) {
  269. this.page.currentPage = currentPage;
  270. },
  271. sizeChange(pageSize) {
  272. this.page.pageSize = pageSize;
  273. },
  274. refreshChange() {
  275. this.onLoad(this.page, this.query);
  276. },
  277. onLoad(page, params = {}) {
  278. const {releaseTimeRange} = this.query;
  279. let values = {
  280. ...params,
  281. };
  282. if (releaseTimeRange) {
  283. values = {
  284. ...params,
  285. releaseTime_datege: releaseTimeRange[0],
  286. releaseTime_datelt: releaseTimeRange[1],
  287. ...this.query
  288. };
  289. values.releaseTimeRange = null;
  290. }
  291. this.loading = true;
  292. getList(page.currentPage, page.pageSize, values).then(res => {
  293. const data = res.data.data;
  294. this.page.total = data.total;
  295. this.data = data.records;
  296. this.loading = false;
  297. this.selectionClear();
  298. });
  299. }
  300. }
  301. };
  302. </script>