indexPage.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. module.exports = function (compoenntName) {
  2. return `<template>
  3. <div class="${compoenntName} pagePadding">
  4. <el-row :gutter="10">
  5. <el-col :span="24" style="padding: 0 0 18px 0">
  6. <el-col :span="3">
  7. <el-input
  8. :size="searchSize"
  9. v-model="parmValue.loginName"
  10. :maxlength="40"
  11. placeholder="账户"
  12. ></el-input>
  13. </el-col>
  14. <el-col :span="3">
  15. <el-input
  16. :size="searchSize"
  17. v-model="parmValue.fullName"
  18. :maxlength="40"
  19. placeholder="姓名"
  20. ></el-input>
  21. </el-col>
  22. <el-col :span="3" style="width: 152px;">
  23. <el-button
  24. type="primary"
  25. :size="searchSize"
  26. @click="searchList"
  27. icon="el-icon-search"
  28. ></el-button>
  29. <el-button type="warning" :size="searchSize" @click="restSearch">
  30. 重置
  31. </el-button>
  32. </el-col>
  33. <el-col :span="3" style="width: 195px;float:right;">
  34. <el-button
  35. type="primary"
  36. :size="searchSize"
  37. style="float:right;margin-left:5px;"
  38. @click="searchList"
  39. >
  40. 刷新
  41. </el-button>
  42. <el-button
  43. type="success"
  44. :size="searchSize"
  45. style="float:right;"
  46. @click="openModal('add', false)"
  47. >
  48. 添加
  49. </el-button>
  50. </el-col>
  51. </el-col>
  52. </el-row>
  53. <el-table
  54. :data="tableData"
  55. stripe
  56. v-loading="loading"
  57. border
  58. :size="size"
  59. style="width: 100%;"
  60. >
  61. <el-table-column
  62. prop="loginName"
  63. label="账户"
  64. show-overflow-tooltip
  65. align="center"
  66. ></el-table-column>
  67. <el-table-column
  68. prop="fullName"
  69. label="姓名"
  70. show-overflow-tooltip
  71. align="center"
  72. ></el-table-column>
  73. <!-- <el-table-column
  74. prop="userId"
  75. label="所属用户"
  76. show-overflow-tooltip
  77. align="center"
  78. ></el-table-column> -->
  79. <el-table-column
  80. prop="tel"
  81. label="手机号"
  82. show-overflow-tooltip
  83. align="center"
  84. ></el-table-column>
  85. <el-table-column label="用户类型" show-overflow-tooltip align="center">
  86. <template slot-scope="scope">
  87. <el-tag type="success" :size="tablebtnSize" v-if="scope.row.type === 1">运营人员</el-tag>
  88. <el-tag type="warning" :size="tablebtnSize" v-else>物业人员</el-tag>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="状态" show-overflow-tooltip align="center">
  92. <template slot-scope="scope">
  93. <el-tooltip
  94. class="item"
  95. effect="dark"
  96. :content="scope.row.status === '1' ? '改为禁用' : '改为启用'"
  97. placement="top"
  98. >
  99. <el-tag
  100. :size="tablebtnSize"
  101. v-if="scope.row.status === '1'"
  102. type="success"
  103. @click="statusConfirm(scope.row.id, scope.row.status)"
  104. >启用</el-tag
  105. >
  106. <el-tag
  107. v-else
  108. :size="tablebtnSize"
  109. type="warning"
  110. @click="statusConfirm(scope.row.id, scope.row.status)"
  111. >禁用</el-tag
  112. >
  113. </el-tooltip>
  114. </template>
  115. </el-table-column>
  116. <el-table-column
  117. prop="createTime"
  118. label="创建时间"
  119. show-overflow-tooltip
  120. align="center"
  121. ></el-table-column>
  122. <el-table-column label="是否超管" show-overflow-tooltip align="center">
  123. <template slot-scope="scope">
  124. <el-tag type="warning" :size="tablebtnSize" v-if="scope.row.isAdmin === 0">否</el-tag>
  125. <el-tag type="success" :size="tablebtnSize" v-else>是</el-tag>
  126. </template>
  127. </el-table-column>
  128. <el-table-column fixed="right" label="操作" align="center" width="250">
  129. <template slot-scope="scope">
  130. <el-button
  131. type="success"
  132. :size="tablebtnSize"
  133. @click="openModal(scope.row.id, false)"
  134. >
  135. 修改
  136. </el-button>
  137. <el-button
  138. type="danger"
  139. :size="tablebtnSize"
  140. :disabled="scope.row.isAdmin === 1"
  141. @click="deleteById(scope.row.id)"
  142. >
  143. 删除
  144. </el-button>
  145. <el-button
  146. type="warning"
  147. :size="tablebtnSize"
  148. @click="openModal(scope.row.id, true)"
  149. >
  150. 详情
  151. </el-button>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <div
  156. class="Pagination"
  157. style="text-align: right;margin-top: 10px;"
  158. v-show="count > 0"
  159. >
  160. <el-pagination
  161. :size="searchSize"
  162. @size-change="handleSizeChange"
  163. @current-change="handlePageChange"
  164. :current-page="parmValue.page"
  165. :page-sizes="[10, 15, 20, 30, 40]"
  166. :page-size="parmValue.size"
  167. layout="total, sizes, prev, pager, next, jumper"
  168. :total="count"
  169. ></el-pagination>
  170. </div>
  171. <add-edit
  172. :showModel="showModel"
  173. :id="modelId"
  174. :isDetail="isDetail"
  175. @refresh="searchList"
  176. @cancel="showModel = false"
  177. ></add-edit>
  178. </div>
  179. </template>
  180. <script>
  181. import mixinPage from "@/mixins/elPaginationHandle";
  182. import asyncRequest from "@/apis/service/${compoenntName}";
  183. import addEdit from "./addEdit";
  184. import { mapGetters } from "vuex";
  185. export default {
  186. name: '${compoenntName}',
  187. computed: {
  188. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  189. },
  190. data() {
  191. return {
  192. loading: true,
  193. showModel: false,
  194. isDetail: false,
  195. modelId: 0,
  196. parmValue: {
  197. loginName: "", // 账户
  198. fullName: "", // 姓名
  199. type: 2, // 用户类型(1运营人员 2物业人员)
  200. page: 1, // 页码
  201. size: 10 // 每页显示条数
  202. },
  203. count: 0, // 总条数
  204. tableData: []
  205. };
  206. },
  207. mixins: [mixinPage],
  208. mounted() {
  209. this.searchList();
  210. },
  211. components: {
  212. addEdit
  213. },
  214. methods: {
  215. restSearch() {
  216. this.parmValue = {
  217. loginName: "", // 账户
  218. fullName: "", // 姓名
  219. type: 2, // 用户类型(1运营人员 2物业人员)
  220. page: 1, // 页码
  221. size: 10 // 每页显示条数
  222. };
  223. this.searchList();
  224. },
  225. openModal(id, isDetail) {
  226. this.showModel = true;
  227. this.modelId = id;
  228. this.isDetail = isDetail;
  229. },
  230. async deleteById(id) {
  231. await this.$confirm("确定要删除?", {
  232. confirmButtonText: "确定",
  233. cancelButtonText: "取消",
  234. type: "warning"
  235. })
  236. .then(async () => {
  237. let res = await asyncRequest.delete({ id });
  238. if (res.code === 0) {
  239. this.$notify.success({
  240. title: "删除成功",
  241. message: ""
  242. });
  243. this.searchList();
  244. }
  245. })
  246. .catch(() => {
  247. console.log("取消");
  248. });
  249. },
  250. async searchList() {
  251. this.loading = true;
  252. let res = await asyncRequest.list(this.parmValue);
  253. if (res.code === 0 && res.data) {
  254. this.tableData = res.data.list;
  255. this.count = Number(res.data.count);
  256. } else {
  257. this.tableData = [];
  258. this.count = 0;
  259. }
  260. this.loading = false;
  261. },
  262. async statusConfirm(id, status) {
  263. console.log(id, status);
  264. await this.$confirm(`确定要改为${ status === "1" ? "禁用" : "启用" } ?`, {
  265. confirmButtonText: "确定",
  266. cancelButtonText: "取消",
  267. type: "warning",
  268. })
  269. .then(async () => {
  270. this.loading = true;
  271. const model = {
  272. id: id,
  273. status: status === "1" ? "0" : "1",
  274. };
  275. const res = await asyncRequest.status(model);
  276. if (res.code === 0) {
  277. this.loading = false;
  278. this.$notify.success({
  279. title: "状态修改成功!",
  280. message: "",
  281. });
  282. await this.searchList();
  283. } else {
  284. this.loading = false;
  285. }
  286. })
  287. .catch(() => {
  288. console.log("取消");
  289. });
  290. },
  291. }
  292. }
  293. </script>
  294. <style lang="scss" scoped>
  295. .${compoenntName} {
  296. }
  297. </style>
  298. `;
  299. };