noticepushrecord.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  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.noticepushrecord_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. </avue-crud>
  31. </basic-container>
  32. </template>
  33. <script>
  34. import {getList, getDetail, add, update, remove} from "@/api/estate/noticepushrecord";
  35. import {mapGetters} from "vuex";
  36. export default {
  37. props: {
  38. noticeId: {
  39. type: String
  40. }
  41. },
  42. data() {
  43. return {
  44. form: {},
  45. query: {},
  46. loading: true,
  47. page: {
  48. pageSize: 10,
  49. currentPage: 1,
  50. total: 0
  51. },
  52. selectionList: [],
  53. option: {
  54. height:'auto',
  55. calcHeight: 30,
  56. tip: false,
  57. searchShow: true,
  58. searchMenuSpan: 6,
  59. border: true,
  60. index: true,
  61. addBtn: true,
  62. viewBtn: true,
  63. editBtn: false,
  64. selection: true,
  65. dialogClickModal: false,
  66. column: [
  67. {
  68. label: "公告id",
  69. prop: "noticeId",
  70. hide: true,
  71. display: false,
  72. rules: [{
  73. required: true,
  74. message: "请输入公告id",
  75. trigger: "blur"
  76. }]
  77. },
  78. {
  79. label: "下发社区",
  80. prop: "agencyId",
  81. search: true,
  82. searchFilterable: true,
  83. filterable: true,
  84. cascaderItem: ['residentialId'],
  85. type: "select",
  86. remote: true,
  87. dicUrl: "/api/cyzh-community/agency/list?size=100&name={{key}}",
  88. dicFormatter:(res)=>{
  89. return res.data.records;//返回字典的层级结构
  90. },
  91. props: {
  92. label: "name",
  93. value: "id"
  94. },
  95. rules: [{
  96. required: true,
  97. message: "请选择下发社区",
  98. trigger: "blur"
  99. }],
  100. hide: true,
  101. viewDisplay: false,
  102. },
  103. {
  104. label: "所属小区",
  105. prop: "residentialId",
  106. type: "select",
  107. search: true,
  108. dicUrl: "/api/cyzh-community/residential/list?agencyId={{key}}&size=100",
  109. dicFormatter:(res)=>{
  110. return res.data.records;//返回字典的层级结构
  111. },
  112. // dicFlag: false,
  113. filterable: true,
  114. searchFilterable: true,
  115. props: {
  116. label: "name",
  117. value: "id"
  118. },
  119. rules: [{
  120. required: true,
  121. message: "请选择下发小区",
  122. trigger: "blur"
  123. }],
  124. hide: true,
  125. viewDisplay: false,
  126. },
  127. {
  128. label: "下发社区",
  129. prop: "agencyName",
  130. editDisplay: false,
  131. addDisplay: false,
  132. },
  133. {
  134. label: "下发小区",
  135. prop: "residentialName",
  136. editDisplay: false,
  137. addDisplay: false,
  138. },
  139. ]
  140. },
  141. data: []
  142. };
  143. },
  144. computed: {
  145. ...mapGetters(["permission"]),
  146. permissionList() {
  147. return {
  148. addBtn: this.vaildData(this.permission.noticepushrecord_add, false),
  149. viewBtn: this.vaildData(this.permission.noticepushrecord_view, false),
  150. delBtn: this.vaildData(this.permission.noticepushrecord_delete, false),
  151. editBtn: this.vaildData(this.permission.noticepushrecord_edit, false)
  152. };
  153. },
  154. ids() {
  155. let ids = [];
  156. this.selectionList.forEach(ele => {
  157. ids.push(ele.id);
  158. });
  159. return ids.join(",");
  160. }
  161. },
  162. methods: {
  163. rowSave(row, done, loading) {
  164. row.noticeId = this.noticeId;
  165. add(row).then(() => {
  166. this.onLoad(this.page);
  167. this.$message({
  168. type: "success",
  169. message: "操作成功!"
  170. });
  171. done();
  172. }, error => {
  173. loading();
  174. window.console.log(error);
  175. });
  176. },
  177. rowUpdate(row, index, done, loading) {
  178. row.noticeId = this.noticeId;
  179. update(row).then(() => {
  180. this.onLoad(this.page);
  181. this.$message({
  182. type: "success",
  183. message: "操作成功!"
  184. });
  185. done();
  186. }, error => {
  187. loading();
  188. console.log(error);
  189. });
  190. },
  191. rowDel(row) {
  192. this.$confirm("确定将选择数据删除?", {
  193. confirmButtonText: "确定",
  194. cancelButtonText: "取消",
  195. type: "warning"
  196. })
  197. .then(() => {
  198. return remove(row.id);
  199. })
  200. .then(() => {
  201. this.onLoad(this.page);
  202. this.$message({
  203. type: "success",
  204. message: "操作成功!"
  205. });
  206. });
  207. },
  208. handleDelete() {
  209. if (this.selectionList.length === 0) {
  210. this.$message.warning("请选择至少一条数据");
  211. return;
  212. }
  213. this.$confirm("确定将选择数据删除?", {
  214. confirmButtonText: "确定",
  215. cancelButtonText: "取消",
  216. type: "warning"
  217. })
  218. .then(() => {
  219. return remove(this.ids);
  220. })
  221. .then(() => {
  222. this.onLoad(this.page);
  223. this.$message({
  224. type: "success",
  225. message: "操作成功!"
  226. });
  227. this.$refs.crud.toggleSelection();
  228. });
  229. },
  230. beforeOpen(done, type) {
  231. if (["edit", "view"].includes(type)) {
  232. getDetail(this.form.id).then(res => {
  233. this.form = res.data.data;
  234. });
  235. }
  236. done();
  237. },
  238. searchReset() {
  239. this.query = {};
  240. this.onLoad(this.page);
  241. },
  242. searchChange(params, done) {
  243. this.query = params;
  244. this.page.currentPage = 1;
  245. this.onLoad(this.page, params);
  246. done();
  247. },
  248. selectionChange(list) {
  249. this.selectionList = list;
  250. },
  251. selectionClear() {
  252. this.selectionList = [];
  253. this.$refs.crud.toggleSelection();
  254. },
  255. currentChange(currentPage){
  256. this.page.currentPage = currentPage;
  257. },
  258. sizeChange(pageSize){
  259. this.page.pageSize = pageSize;
  260. },
  261. refreshChange() {
  262. this.onLoad(this.page, this.query);
  263. },
  264. onLoad(page, params = {}) {
  265. params["noticeId"] = this.noticeId
  266. this.loading = true;
  267. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  268. const data = res.data.data;
  269. this.page.total = data.total;
  270. this.data = data.records;
  271. this.loading = false;
  272. this.selectionClear();
  273. });
  274. }
  275. }
  276. };
  277. </script>
  278. <style>
  279. </style>