indexPage.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. effect="dark"
  95. :content="scope.row.status === '1' ? '改为禁用' : '改为启用'"
  96. placement="top"
  97. >
  98. <el-tag
  99. :size="tablebtnSize"
  100. v-if="scope.row.status === '1'"
  101. type="success"
  102. @click="statusConfirm(scope.row.id, scope.row.status)"
  103. >启用</el-tag
  104. >
  105. <el-tag
  106. v-else
  107. :size="tablebtnSize"
  108. type="warning"
  109. @click="statusConfirm(scope.row.id, scope.row.status)"
  110. >禁用</el-tag
  111. >
  112. </el-tooltip>
  113. </template>
  114. </el-table-column>
  115. <el-table-column
  116. prop="createTime"
  117. label="创建时间"
  118. show-overflow-tooltip
  119. align="center"
  120. ></el-table-column>
  121. <el-table-column label="是否超管" show-overflow-tooltip align="center">
  122. <template slot-scope="scope">
  123. <el-tag type="warning" :size="tablebtnSize" v-if="scope.row.isAdmin === 0">否</el-tag>
  124. <el-tag type="success" :size="tablebtnSize" v-else>是</el-tag>
  125. </template>
  126. </el-table-column>
  127. <el-table-column fixed="right" label="操作" align="center" width="250">
  128. <template slot-scope="scope">
  129. <el-button
  130. type="success"
  131. :size="tablebtnSize"
  132. @click="openModal(scope.row.id, false)"
  133. >
  134. 修改
  135. </el-button>
  136. <el-button
  137. type="danger"
  138. :size="tablebtnSize"
  139. :disabled="scope.row.isAdmin === 1"
  140. @click="deleteById(scope.row.id)"
  141. >
  142. 删除
  143. </el-button>
  144. <el-button
  145. type="warning"
  146. :size="tablebtnSize"
  147. @click="openModal(scope.row.id, true)"
  148. >
  149. 详情
  150. </el-button>
  151. </template>
  152. </el-table-column>
  153. </el-table>
  154. <div
  155. class="Pagination"
  156. style="text-align: right;margin-top: 10px;"
  157. v-show="count > 0"
  158. >
  159. <el-pagination
  160. :size="searchSize"
  161. @size-change="handleSizeChange"
  162. @current-change="handlePageChange"
  163. :current-page="parmValue.page"
  164. :page-sizes="[10, 15, 20, 30, 40]"
  165. :page-size="parmValue.size"
  166. layout="total, sizes, prev, pager, next, jumper"
  167. :total="count"
  168. ></el-pagination>
  169. </div>
  170. <add-edit
  171. :showModel="showModel"
  172. :id="modelId"
  173. :isDetail="isDetail"
  174. @refresh="searchList"
  175. @cancel="showModel = false"
  176. ></add-edit>
  177. </div>
  178. </template>
  179. <script>
  180. import mixinPage from "@/mixins/elPaginationHandle";
  181. import asyncRequest from "@/apis/caixiaoService/${compoenntName}";
  182. import addEdit from "./addEdit";
  183. import { mapGetters } from "vuex";
  184. export default {
  185. name: '${compoenntName}',
  186. computed: {
  187. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  188. },
  189. data() {
  190. return {
  191. loading: true,
  192. showModel: false,
  193. isDetail: false,
  194. modelId: 0,
  195. parmValue: {
  196. loginName: "", // 账户
  197. fullName: "", // 姓名
  198. type: 2, // 用户类型(1运营人员 2物业人员)
  199. page: 1, // 页码
  200. size: 10 // 每页显示条数
  201. },
  202. count: 0, // 总条数
  203. tableData: []
  204. };
  205. },
  206. mixins: [mixinPage],
  207. mounted() {
  208. this.searchList();
  209. },
  210. components: {
  211. addEdit
  212. },
  213. methods: {
  214. restSearch() {
  215. this.parmValue = {
  216. loginName: "", // 账户
  217. fullName: "", // 姓名
  218. type: 2, // 用户类型(1运营人员 2物业人员)
  219. page: 1, // 页码
  220. size: 10 // 每页显示条数
  221. };
  222. this.searchList();
  223. },
  224. openModal(id, isDetail) {
  225. this.showModel = true;
  226. this.modelId = id;
  227. this.isDetail = isDetail;
  228. },
  229. async deleteById(id) {
  230. await this.$confirm("确定要删除?", {
  231. confirmButtonText: "确定",
  232. cancelButtonText: "取消",
  233. type: "warning"
  234. })
  235. .then(async () => {
  236. let res = await asyncRequest.delete({ id });
  237. if (res.code === 0) {
  238. this.$notify.success({
  239. title: "删除成功",
  240. message: ""
  241. });
  242. this.searchList();
  243. }
  244. })
  245. .catch(() => {
  246. console.log("取消");
  247. });
  248. },
  249. async searchList() {
  250. this.loading = true;
  251. let res = await asyncRequest.list(this.parmValue);
  252. if (res.code === 0 && res.data) {
  253. this.tableData = res.data.list;
  254. this.count = Number(res.data.count);
  255. } else {
  256. this.tableData = [];
  257. this.count = 0;
  258. }
  259. this.loading = false;
  260. },
  261. async statusConfirm(id, status) {
  262. console.log(id, status);
  263. let str= status === "1" ? "禁用" : "启用"
  264. await this.$confirm('确定要改为'+str, {
  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. };