indexPage.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. module.exports = function (inputName, compoenntName) {
  2. return `<template>
  3. <div class="${compoenntName} pagePadding">
  4. <div
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. >
  7. <ex-table
  8. v-loading="loading"
  9. :table="table"
  10. :data="tableData"
  11. :columns="columns"
  12. :page="pageInfo"
  13. :size="size"
  14. @page-curr-change="handlePageChange"
  15. @page-size-change="handleSizeChange"
  16. @screen-reset="
  17. pageInfo.curr = 1;
  18. parmValue.page = 1;
  19. searchList();
  20. "
  21. @screen-submit="
  22. pageInfo.curr = 1;
  23. parmValue.page = 1;
  24. searchList();
  25. "
  26. >
  27. <template #table-header="{}">
  28. <div style="width: 100%">
  29. <el-row style="padding: 0 0 0 80px">
  30. <el-col :span="24">
  31. <el-col :span="4" style="width: 120px">
  32. <el-select
  33. :size="searchSize"
  34. v-model="parmValue.status"
  35. filterable
  36. clearable
  37. placeholder="账号状态"
  38. style="width: 100%"
  39. @change="
  40. pageInfo.curr = 1;
  41. parmValue.page = 1;
  42. searchList();
  43. "
  44. >
  45. <el-option
  46. v-for="item in statusList"
  47. :key="'status' + item.code"
  48. :label="item.name"
  49. :value="item.code"
  50. />
  51. </el-select>
  52. </el-col>
  53. <el-col :span="4" style="width: 150px; padding: 0 0 0 10px">
  54. <el-input
  55. :size="searchSize"
  56. v-model="parmValue.name"
  57. :maxlength="40"
  58. placeholder="业务员姓名"
  59. />
  60. </el-col>
  61. <el-col :span="4" style="width: 160px; padding: 0 0 0 10px">
  62. <el-input
  63. :size="searchSize"
  64. v-model="parmValue.username"
  65. :maxlength="40"
  66. placeholder="手机号"
  67. />
  68. </el-col>
  69. <el-col :span="4" style="width: 54px">
  70. <el-button
  71. :size="searchSize"
  72. type="primary"
  73. class="fr"
  74. icon="el-icon-search"
  75. @click="searchList"
  76. /></el-col>
  77. <el-col
  78. :span="4"
  79. style="width: 66px"
  80. >
  81. <el-button
  82. type="warning"
  83. class="fr"
  84. :size="searchSize"
  85. @click="restSearch"
  86. >
  87. 重置
  88. </el-button>
  89. </el-col>
  90. <el-col
  91. :span="3"
  92. style="width: 66px; float: right"
  93. >
  94. <el-button
  95. :size="searchSize"
  96. type="primary"
  97. style="float: right; margin-left: 5px"
  98. @click="searchList"
  99. >
  100. 刷新
  101. </el-button>
  102. </el-col>
  103. </el-col>
  104. </el-row>
  105. </div>
  106. </template>
  107. <template #status="{ scope }">
  108. <el-tag
  109. :size="tablebtnSize"
  110. :type="scope.row.status == '0' ? 'warning' : ''"
  111. v-text="
  112. (statusOptions.find((item) => item.id == scope.row.status) || {})
  113. .label || '--'
  114. "
  115. ></el-tag>
  116. </template>
  117. <template #operation="{ scope }">
  118. <el-tooltip
  119. v-if="powers.some((item) => item == '002')"
  120. effect="dark"
  121. content="重置密码"
  122. placement="top"
  123. >
  124. <i
  125. class="el-icon-refresh-left tb-icon"
  126. @click="openPasswordModal(scope.row.id, false)"
  127. ></i>
  128. </el-tooltip>
  129. <el-tooltip
  130. v-if="powers.some((item) => item == '007')"
  131. effect="dark"
  132. content="详情"
  133. placement="top"
  134. >
  135. <i
  136. class="el-icon-view tb-icon"
  137. @click="openModal(scope.row.id, true, scope.row)"
  138. ></i>
  139. </el-tooltip>
  140. <el-tooltip
  141. v-if="powers.some((item) => item == '005')"
  142. effect="dark"
  143. content="修改"
  144. placement="top"
  145. >
  146. <i
  147. class="el-icon-edit tb-icon"
  148. @click="openModal(scope.row.id, false, scope.row)"
  149. ></i>
  150. </el-tooltip>
  151. <el-tooltip
  152. v-if="
  153. powers.some((item) => item == '004') && scope.row.status === '1'
  154. "
  155. effect="dark"
  156. content="禁用"
  157. placement="top"
  158. >
  159. <i
  160. class="el-icon-video-pause tb-icon"
  161. @click="statusConfirm(scope.row.id, scope.row.status)"
  162. ></i>
  163. </el-tooltip>
  164. <el-tooltip
  165. v-if="
  166. powers.some((item) => item == '004') && scope.row.status === '0'
  167. "
  168. effect="dark"
  169. content="启用"
  170. placement="top"
  171. >
  172. <i
  173. class="el-icon-video-play tb-icon"
  174. @click="statusConfirm(scope.row.id, scope.row.status)"
  175. ></i>
  176. </el-tooltip>
  177. </template>
  178. </ex-table>
  179. <add-edit
  180. :id="modelId"
  181. :sitem="sitem"
  182. :show-model="showModel"
  183. :is-detail="isDetail"
  184. @refresh="searchList"
  185. @cancel="showModel = false"
  186. />
  187. </div>
  188. <div v-else>
  189. <no-auth></no-auth>
  190. </div>
  191. <add-edit
  192. :showModel="showModel"
  193. :id="modelId"
  194. :isDetail="isDetail"
  195. @refresh="searchList"
  196. @cancel="showModel = false"
  197. ></add-edit>
  198. </div>
  199. </template>
  200. <script>
  201. import mixinPage from "@/mixins/elPaginationHandle";
  202. import resToken from "@/mixins/resToken";
  203. import statusList from "@/assets/js/statusList";
  204. import asyncRequest from "@/apis/service/${inputName}";
  205. import addEdit from "./addEdit";
  206. import { mapGetters } from "vuex";
  207. export default {
  208. name: '${compoenntName}',
  209. mixins: [mixinPage, resToken],
  210. components: {
  211. addEdit,
  212. },
  213. computed: {
  214. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  215. powers() {
  216. let tran =
  217. this.$store.getters.btnList.find(
  218. (item) => item.menu_route == "${compoenntName}"
  219. ) || {};
  220. if (tran && tran.action && tran.action.length > 0) {
  221. return tran.action;
  222. } else {
  223. return [];
  224. }
  225. },
  226. },
  227. data() {
  228. return {
  229. sitem: null,
  230. // 状态
  231. statusOptions: [
  232. { id: "0", label: "禁用" },
  233. { id: "1", label: "启用" },
  234. ],
  235. statusList: statusList,
  236. loading: true,
  237. showModel: false,
  238. isDetail: false,
  239. modelId: 0,
  240. parmValue: {
  241. name: "", // 业务员名字
  242. username: "", // 账号
  243. status: "", //
  244. page: 1, // 页码
  245. size: 15, // 每页显示条数
  246. },
  247. tableData: [],
  248. passwordModel: false,
  249. passwordModelId: 0,
  250. isPasswordDetail: false,
  251. // 表格 - 数据
  252. tableData: [],
  253. // 表格 - 参数
  254. table: {
  255. stripe: true,
  256. border: true,
  257. _defaultHeader_: ["setcol"],
  258. },
  259. // 表格 - 分页
  260. pageInfo: {
  261. size: 15,
  262. curr: 1,
  263. total: 0,
  264. },
  265. // 表格 - 列参数
  266. columns: [
  267. {
  268. prop: "nickname",
  269. label: "真实姓名",
  270. },
  271. {
  272. prop: "role_name",
  273. label: "角色名称",
  274. },
  275. {
  276. prop: "mobile",
  277. label: "联系电话",
  278. },
  279. {
  280. prop: "email",
  281. label: "邮箱",
  282. },
  283. {
  284. prop: "status",
  285. label: "状态",
  286. _slot_: "status",
  287. width: "80px",
  288. },
  289. {
  290. prop: "addtime",
  291. label: "创建时间",
  292. sortable: true,
  293. },
  294. {
  295. prop: "",
  296. label: "操作",
  297. fixed: "right",
  298. _noset_: true,
  299. _slot_: "operation",
  300. },
  301. ],
  302. };
  303. },
  304. mounted() {
  305. this.searchList();
  306. },
  307. methods: {
  308. restSearch() {
  309. this.parmValue = {
  310. name: "", // 业务员名字
  311. username: "", // 账号
  312. status: "", //
  313. page: 1, // 页码
  314. size: 10, // 每页显示条数
  315. };
  316. this.searchList();
  317. },
  318. openModal(id, isDetail, sitem) {
  319. this.showModel = true;
  320. this.modelId = id;
  321. this.isDetail = isDetail;
  322. this.sitem = sitem;
  323. },
  324. async deleteById(id, status) {
  325. await this.$confirm("确定要删除?", {
  326. confirmButtonText: "确定",
  327. cancelButtonText: "取消",
  328. type: "warning",
  329. })
  330. .then(async () => {
  331. const model = {
  332. id: id,
  333. status: status === "1" ? "0" : "1",
  334. };
  335. const res = await asyncRequest.status(model);
  336. if (res && res.code === 0) {
  337. this.$notify.success({
  338. title: "删除成功",
  339. message: "",
  340. });
  341. this.searchList();
  342. } else if (res && res.code >= 100 && res.code <= 104) {
  343. await this.logout();
  344. } else {
  345. this.$message.warning(res.message);
  346. }
  347. })
  348. .catch(() => {
  349. console.log("取消");
  350. });
  351. },
  352. async searchList() {
  353. this.loading = true;
  354. const res = await asyncRequest.list(this.parmValue);
  355. if (res && res.code === 0 && res.data) {
  356. this.tableData = res.data.list;
  357. this.pageInfo.total = Number(res.data.count);
  358. } else if (res && res.code >= 100 && res.code <= 104) {
  359. await this.logout();
  360. } else {
  361. this.tableData = [];
  362. this.pageInfo.total = 0;
  363. }
  364. this.loading = false;
  365. },
  366. async statusConfirm(id, status) {
  367. let str= status === "1" ? "禁用" : "启用"
  368. await this.$confirm('确定要改为'+str+'?',{
  369. confirmButtonText: "确定",
  370. cancelButtonText: "取消",
  371. type: "warning",
  372. })
  373. .then(async () => {
  374. this.loading = true;
  375. const model = {
  376. id: id,
  377. status: status === "1" ? "0" : "1",
  378. };
  379. const res = await asyncRequest.status(model);
  380. if (res && res.code === 0) {
  381. this.loading = false;
  382. this.$notify.success({
  383. title: "状态修改成功!",
  384. message: "",
  385. });
  386. await this.searchList();
  387. } else if (res && res.code >= 100 && res.code <= 104) {
  388. await this.logout();
  389. } else {
  390. this.$message.warning(res.message);
  391. }
  392. })
  393. .catch(() => {
  394. console.log("取消");
  395. });
  396. },
  397. }
  398. }
  399. </script>
  400. <style lang="scss" scoped>
  401. .${compoenntName} {
  402. }
  403. </style>
  404. `;
  405. };