indexPage.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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 ExTable from "@/components/ExTableNew.vue";
  204. import statusList from "@/assets/js/statusList";
  205. import asyncRequest from "@/apis/service/${inputName}";
  206. import addEdit from "./addEdit";
  207. import { mapGetters } from "vuex";
  208. export default {
  209. name: '${compoenntName}',
  210. mixins: [mixinPage, resToken],
  211. components: {
  212. addEdit,
  213. ExTable,
  214. },
  215. computed: {
  216. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  217. powers() {
  218. let tran =
  219. this.$store.getters.btnList.find(
  220. (item) => item.menu_route == "${compoenntName}"
  221. ) || {};
  222. if (tran && tran.action && tran.action.length > 0) {
  223. return tran.action;
  224. } else {
  225. return [];
  226. }
  227. },
  228. },
  229. data() {
  230. return {
  231. sitem: null,
  232. // 状态
  233. statusOptions: [
  234. { id: "0", label: "禁用" },
  235. { id: "1", label: "启用" },
  236. ],
  237. statusList: statusList,
  238. loading: true,
  239. showModel: false,
  240. isDetail: false,
  241. modelId: 0,
  242. parmValue: {
  243. name: "", // 业务员名字
  244. username: "", // 账号
  245. status: "", //
  246. page: 1, // 页码
  247. size: 15, // 每页显示条数
  248. },
  249. tableData: [],
  250. passwordModel: false,
  251. passwordModelId: 0,
  252. isPasswordDetail: false,
  253. // 表格 - 数据
  254. tableData: [],
  255. // 表格 - 参数
  256. table: {
  257. stripe: true,
  258. border: true,
  259. _defaultHeader_: ["setcol"],
  260. },
  261. // 表格 - 分页
  262. pageInfo: {
  263. size: 15,
  264. curr: 1,
  265. total: 0,
  266. },
  267. // 表格 - 列参数
  268. columns: [
  269. {
  270. prop: "nickname",
  271. label: "真实姓名",
  272. },
  273. {
  274. prop: "role_name",
  275. label: "角色名称",
  276. },
  277. {
  278. prop: "mobile",
  279. label: "联系电话",
  280. },
  281. {
  282. prop: "email",
  283. label: "邮箱",
  284. },
  285. {
  286. prop: "status",
  287. label: "状态",
  288. _slot_: "status",
  289. width: "80px",
  290. },
  291. {
  292. prop: "addtime",
  293. label: "创建时间",
  294. sortable: true,
  295. },
  296. {
  297. prop: "",
  298. label: "操作",
  299. fixed: "right",
  300. _noset_: true,
  301. _slot_: "operation",
  302. },
  303. ],
  304. };
  305. },
  306. mounted() {
  307. this.searchList();
  308. },
  309. methods: {
  310. restSearch() {
  311. this.parmValue = {
  312. name: "", // 业务员名字
  313. username: "", // 账号
  314. status: "", //
  315. page: 1, // 页码
  316. size: 10, // 每页显示条数
  317. };
  318. this.searchList();
  319. },
  320. openModal(id, isDetail, sitem) {
  321. this.showModel = true;
  322. this.modelId = id;
  323. this.isDetail = isDetail;
  324. this.sitem = sitem;
  325. },
  326. async deleteById(id, status) {
  327. await this.$confirm("确定要删除?", {
  328. confirmButtonText: "确定",
  329. cancelButtonText: "取消",
  330. type: "warning",
  331. })
  332. .then(async () => {
  333. const model = {
  334. id: id,
  335. status: status === "1" ? "0" : "1",
  336. };
  337. const res = await asyncRequest.status(model);
  338. if (res && res.code === 0) {
  339. this.$notify.success({
  340. title: "删除成功",
  341. message: "",
  342. });
  343. this.searchList();
  344. } else if (res && res.code >= 100 && res.code <= 104) {
  345. await this.logout();
  346. } else {
  347. this.$message.warning(res.message);
  348. }
  349. })
  350. .catch(() => {
  351. console.log("取消");
  352. });
  353. },
  354. async searchList() {
  355. this.loading = true;
  356. const res = await asyncRequest.list(this.parmValue);
  357. if (res && res.code === 0 && res.data) {
  358. this.tableData = res.data.list;
  359. this.pageInfo.total = Number(res.data.count);
  360. } else if (res && res.code >= 100 && res.code <= 104) {
  361. await this.logout();
  362. } else {
  363. this.tableData = [];
  364. this.pageInfo.total = 0;
  365. }
  366. this.loading = false;
  367. },
  368. async statusConfirm(id, status) {
  369. let str= status === "1" ? "禁用" : "启用"
  370. await this.$confirm('确定要改为'+str+'?',{
  371. confirmButtonText: "确定",
  372. cancelButtonText: "取消",
  373. type: "warning",
  374. })
  375. .then(async () => {
  376. this.loading = true;
  377. const model = {
  378. id: id,
  379. status: status === "1" ? "0" : "1",
  380. };
  381. const res = await asyncRequest.status(model);
  382. if (res && res.code === 0) {
  383. this.loading = false;
  384. this.$notify.success({
  385. title: "状态修改成功!",
  386. message: "",
  387. });
  388. await this.searchList();
  389. } else if (res && res.code >= 100 && res.code <= 104) {
  390. await this.logout();
  391. } else {
  392. this.$message.warning(res.message);
  393. }
  394. })
  395. .catch(() => {
  396. console.log("取消");
  397. });
  398. },
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. .${compoenntName} {
  404. }
  405. </style>
  406. `;
  407. };