index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="group pagePadding">
  3. <ex-table
  4. v-loading="loading"
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. searchList();
  16. "
  17. @screen-submit="
  18. pageInfo.curr = 1;
  19. searchList();
  20. "
  21. >
  22. <template #table-header="{}">
  23. <div style="width: 100%">
  24. <el-row>
  25. <el-col :span="24">
  26. <el-col
  27. :span="3"
  28. style="width: 66px; float: right"
  29. >
  30. <el-button
  31. type="primary"
  32. :size="searchSize"
  33. style="float: right"
  34. @click="searchList"
  35. >
  36. 刷新
  37. </el-button>
  38. </el-col>
  39. <el-col
  40. :span="3"
  41. style="width: 66px; float: right"
  42. v-if="powers.some((item) => item == '003')"
  43. >
  44. <el-button
  45. :size="searchSize"
  46. type="success"
  47. style="float: right"
  48. @click="openModal('add', false)"
  49. >
  50. 添加
  51. </el-button>
  52. </el-col>
  53. </el-col>
  54. </el-row>
  55. </div>
  56. </template>
  57. <template #status="{ scope }">
  58. <el-tag
  59. :size="tablebtnSize"
  60. :type="scope.row.status == '0' ? 'warning' : ''"
  61. v-text="
  62. (statusOptions.find((item) => item.id == scope.row.status) || {})
  63. .label || '--'
  64. "
  65. ></el-tag>
  66. </template>
  67. <template #operation="{ scope }">
  68. <el-tooltip
  69. v-if="powers.some((item) => item == '007')"
  70. effect="dark"
  71. content="详情"
  72. placement="top"
  73. >
  74. <i
  75. class="el-icon-view tb-icon"
  76. @click="openModal(scope.row.id, true)"
  77. ></i>
  78. </el-tooltip>
  79. <el-tooltip
  80. v-if="powers.some((item) => item == '005')"
  81. effect="dark"
  82. content="修改"
  83. placement="top"
  84. >
  85. <i
  86. class="el-icon-edit tb-icon"
  87. @click="openModal(scope.row.id, false)"
  88. ></i>
  89. </el-tooltip>
  90. <el-tooltip
  91. v-if="
  92. powers.some((item) => item == '004') && scope.row.status === '1'
  93. "
  94. effect="dark"
  95. content="禁用"
  96. placement="top"
  97. >
  98. <i
  99. class="el-icon-video-pause tb-icon"
  100. @click="changeStatus(scope.row.id, scope.row.status)"
  101. ></i>
  102. </el-tooltip>
  103. <el-tooltip
  104. v-if="
  105. powers.some((item) => item == '004') && scope.row.status === '0'
  106. "
  107. effect="dark"
  108. content="启用"
  109. placement="top"
  110. >
  111. <i
  112. class="el-icon-video-play tb-icon"
  113. @click="changeStatus(scope.row.id, scope.row.status)"
  114. ></i>
  115. </el-tooltip>
  116. </template>
  117. </ex-table>
  118. <no-auth v-else></no-auth>
  119. <!-- 弹窗 新增/修改 -->
  120. <add-edit
  121. :id="modelId"
  122. :show-model="showModel"
  123. :is-detail="isDetail"
  124. @refresh="searchList"
  125. @cancel="showModel = false"
  126. />
  127. </div>
  128. </template>
  129. <script>
  130. import addEdit from "./addEdit";
  131. import asyncRequest from "@/apis/service/interest/group";
  132. import mixinPage from "@/mixins/elPaginationHandle";
  133. import { mapGetters } from "vuex";
  134. import resToken from "@/mixins/resToken";
  135. export default {
  136. name: "group",
  137. mixins: [mixinPage, resToken],
  138. components: {
  139. addEdit,
  140. },
  141. computed: {
  142. //组件SIZE设置
  143. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  144. powers() {
  145. let tran =
  146. this.$store.getters.btnList.find(
  147. (item) => item.menu_route == "group"
  148. ) || {};
  149. if (tran && tran.action && tran.action.length > 0) {
  150. return tran.action;
  151. } else {
  152. return [];
  153. }
  154. },
  155. },
  156. data() {
  157. return {
  158. loading: true,
  159. showModel: false,
  160. isDetail: false,
  161. modelId: 0,
  162. parmValue: {
  163. loginName: "", // 账户
  164. fullName: "", // 姓名
  165. type: 2, // 用户类型(1运营人员 2物业人员)
  166. page: 1, // 页码
  167. size: 15, // 每页显示条数
  168. },
  169. // 状态
  170. statusOptions: [
  171. { id: 0, label: "禁用" },
  172. { id: 1, label: "启用" },
  173. ],
  174. // 表格 - 数据
  175. tableData: [],
  176. // 表格 - 参数
  177. table: {
  178. stripe: true,
  179. border: true,
  180. _defaultHeader_: ["setcol"]
  181. },
  182. // 表格 - 分页
  183. pageInfo: {
  184. size: 15,
  185. curr: 1,
  186. total: 0,
  187. },
  188. // 表格 - 列参数
  189. columns: [
  190. {
  191. prop: "group_name",
  192. label: "组名",
  193. },
  194. {
  195. prop: "userGroupList",
  196. label: "组员",
  197. },
  198. {
  199. prop: "group_remark",
  200. label: "备注",
  201. },
  202. {
  203. prop: "status",
  204. label: "状态",
  205. _slot_: "status",
  206. },
  207. {
  208. prop: "addtime",
  209. label: "创建时间",
  210. sortable: true,
  211. },
  212. {
  213. prop: "",
  214. label: "操作",
  215. fixed: "right",
  216. _noset_: true,
  217. _slot_: "operation",
  218. },
  219. ],
  220. };
  221. },
  222. mounted() {
  223. this.searchList();
  224. },
  225. methods: {
  226. restSearch() {
  227. // 表格 - 分页
  228. this.pageInfo = {
  229. size: 15,
  230. curr: 1,
  231. total: 0,
  232. };
  233. this.parmValue = {
  234. status: "", // 账户
  235. level: "", // 姓名
  236. role_name: "",
  237. page: 1, // 页码
  238. size: 10, // 每页显示条数
  239. };
  240. this.searchList();
  241. },
  242. // 新建/编辑/详情
  243. openModal(id, isDetail) {
  244. this.showModel = true;
  245. this.modelId = id;
  246. this.isDetail = isDetail;
  247. },
  248. /**
  249. * 启用/禁用
  250. * @param {String} id id
  251. * @param {String} status 0-禁用 1-启用
  252. */
  253. async changeStatus(id, status) {
  254. await this.$confirm(`确定要改为${status === "1" ? "禁用" : "启用"}?`, {
  255. confirmButtonText: "确定",
  256. cancelButtonText: "取消",
  257. type: "warning",
  258. })
  259. .then(async () => {
  260. const model = {
  261. id: id,
  262. status: status === "1" ? "0" : "1",
  263. };
  264. const res = await asyncRequest.status(model);
  265. if (res && res.code === 0) {
  266. this.$notify.success({
  267. title: "状态修改成功",
  268. message: "",
  269. });
  270. this.searchList();
  271. } else if (res && res.code >= 100 && res.code <= 104) {
  272. await this.logout();
  273. } else {
  274. this.$message.warning(res.message);
  275. }
  276. })
  277. .catch(() => {
  278. console.log("取消");
  279. });
  280. },
  281. // 刷新表格
  282. async searchList() {
  283. this.loading = true;
  284. const res = await asyncRequest.list(this.parmValue);
  285. if (res && res.code === 0 && res.data) {
  286. this.tableData = res.data.list;
  287. this.tableData.map((e) => {
  288. e.userGroupList = e.userlist.join(",");
  289. return e;
  290. });
  291. this.pageInfo.total = Number(res.data.count);
  292. } else if (res && res.code >= 100 && res.code <= 104) {
  293. await this.logout();
  294. } else {
  295. this.tableData = [];
  296. this.pageInfo.total = 0;
  297. }
  298. this.loading = false;
  299. },
  300. },
  301. };
  302. </script>
  303. <style lang="scss" scoped>
  304. </style>