indexPage.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. module.exports = function (inputName, compoenntName) {
  2. return `<template>
  3. <div class="${compoenntName} pagePadding">
  4. <div
  5. v-if="powers.some((i)=> i == '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. (statusList.find((i)=>Number(i.code) == Number(scope.row.status)) || {})
  113. .name || '--'
  114. "
  115. ></el-tag>
  116. </template>
  117. <template #operation="{ scope }">
  118. <el-tooltip
  119. v-if="powers.some((i)=> i == '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. effect="dark"
  131. content="详情"
  132. placement="top"
  133. >
  134. <i
  135. class="el-icon-view tb-icon"
  136. @click="openModal(scope.row.id, true, scope.row)"
  137. ></i>
  138. </el-tooltip>
  139. <el-tooltip
  140. v-if="powers.some((i)=> i == '005')"
  141. effect="dark"
  142. content="修改"
  143. placement="top"
  144. >
  145. <i
  146. class="el-icon-edit tb-icon"
  147. @click="openModal(scope.row.id, false, scope.row)"
  148. ></i>
  149. </el-tooltip>
  150. <el-tooltip
  151. v-if="
  152. powers.some((i)=> i == '004') && scope.row.status + '' === '1'
  153. "
  154. effect="dark"
  155. content="禁用"
  156. placement="top"
  157. >
  158. <i
  159. class="el-icon-video-pause tb-icon"
  160. @click="statusConfirm(scope.row.id, scope.row.status)"
  161. ></i>
  162. </el-tooltip>
  163. <el-tooltip
  164. v-if="
  165. powers.some((i)=> i == '003') && scope.row.status + '' === '0'
  166. "
  167. effect="dark"
  168. content="启用"
  169. placement="top"
  170. >
  171. <i
  172. class="el-icon-video-play tb-icon"
  173. @click="statusConfirm(scope.row.id, scope.row.status)"
  174. ></i>
  175. </el-tooltip>
  176. </template>
  177. </ex-table>
  178. <add-edit
  179. :id="modelId"
  180. :sitem="sitem"
  181. :show-model="showModel"
  182. :is-detail="isDetail"
  183. @refresh="searchList"
  184. @cancel="showModel = false"
  185. />
  186. </div>
  187. <div v-else>
  188. <no-auth></no-auth>
  189. </div>
  190. </div>
  191. </template>
  192. <script>
  193. import mixinPage from "@/mixins/elPaginationHandle";
  194. import resToken from "@/mixins/resToken";
  195. import {statusList} from "@/assets/js/statusList";
  196. import asyncRequest from "@/apis/service/${inputName}";
  197. import addEdit from "./addEdit";
  198. import { mapGetters } from "vuex";
  199. export default {
  200. name: '${compoenntName}',
  201. mixins: [mixinPage, resToken],
  202. components: {
  203. addEdit,
  204. },
  205. computed: {
  206. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  207. powers() {
  208. const tran =
  209. this.$store.getters.btnList.find(
  210. (i)=> i.menu_route == "${compoenntName}"
  211. ) || {};
  212. const { action } = tran ?? {};
  213. return action ?? [];
  214. },
  215. },
  216. data() {
  217. return {
  218. sitem: null,
  219. // 状态
  220. statusList,
  221. loading: true,
  222. showModel: false,
  223. isDetail: false,
  224. modelId: 0,
  225. parmValue: {
  226. name: "", // 业务员名字
  227. username: "", // 账号
  228. status: "", //
  229. page: 1, // 页码
  230. size: 15, // 每页显示条数
  231. },
  232. tableData: [],
  233. passwordModel: false,
  234. passwordModelId: 0,
  235. isPasswordDetail: false,
  236. // 表格 - 数据
  237. tableData: [],
  238. // 表格 - 参数
  239. table: {
  240. stripe: true,
  241. border: true,
  242. _defaultHeader_: ["setcol"],
  243. },
  244. // 表格 - 分页
  245. pageInfo: {
  246. size: 15,
  247. curr: 1,
  248. total: 0,
  249. },
  250. // 表格 - 列参数
  251. columns: [
  252. {
  253. prop: "nickname",
  254. label: "真实姓名",
  255. },
  256. {
  257. prop: "role_name",
  258. label: "角色名称",
  259. },
  260. {
  261. prop: "mobile",
  262. label: "联系电话",
  263. },
  264. {
  265. prop: "email",
  266. label: "邮箱",
  267. },
  268. {
  269. prop: "status",
  270. label: "状态",
  271. _slot_: "status",
  272. width: "80px",
  273. },
  274. {
  275. prop: "addtime",
  276. label: "创建时间",
  277. ,
  278. },
  279. {
  280. prop: "",
  281. label: "操作",
  282. fixed: "right",
  283. _noset_: true,
  284. _slot_: "operation",
  285. },
  286. ],
  287. };
  288. },
  289. mounted() {
  290. this.searchList();
  291. },
  292. methods: {
  293. restSearch() {
  294. this.parmValue = {
  295. name: "", // 业务员名字
  296. username: "", // 账号
  297. status: "", //
  298. page: 1, // 页码
  299. size: 15, // 每页显示条数
  300. };
  301. // 表格 - 分页
  302. this.pageInfo = {
  303. size: 15,
  304. curr: 1,
  305. total: 0,
  306. };
  307. this.searchList();
  308. },
  309. openModal(id, isDetail, sitem) {
  310. this.showModel = true;
  311. this.modelId = id;
  312. this.isDetail = isDetail;
  313. this.sitem = sitem;
  314. },
  315. async deleteById(id, status) {
  316. await this.$confirm("确定要删除?", {
  317. confirmButtonText: "确定",
  318. cancelButtonText: "取消",
  319. type: "warning",
  320. })
  321. .then(async () => {
  322. const model = {
  323. ids: id
  324. };
  325. const {code,data} = await asyncRequest.delete(model);
  326. if (code === 1) {
  327. this.$notify.success({
  328. title: "删除成功",
  329. message: "",
  330. });
  331. this.searchList();
  332. }
  333. })
  334. .catch(() => {
  335. console.log("取消");
  336. });
  337. },
  338. async searchList() {
  339. this.loading = true;
  340. const {code,data} = await asyncRequest.list(this.parmValue);
  341. if (code === 1 ) {
  342. const {list,count}=data
  343. this.tableData = list;
  344. this.pageInfo.total = Number(count);
  345. } else {
  346. this.tableData = [];
  347. this.pageInfo.total = 0;
  348. }
  349. this.loading = false;
  350. },
  351. async statusConfirm(id, status) {
  352. let str= status + '' === "1" ? "禁用" : "启用"
  353. await this.$confirm('确定要改为'+str+'?',{
  354. confirmButtonText: "确定",
  355. cancelButtonText: "取消",
  356. type: "warning",
  357. })
  358. .then(async () => {
  359. this.loading = true;
  360. const model = {
  361. id: id,
  362. status: status + '' === "1" ? "0" : "1",
  363. };
  364. const {code} = await asyncRequest.status(model);
  365. if (code === 0) {
  366. this.loading = false;
  367. this.$notify.success({
  368. title: "状态修改成功!",
  369. message: "",
  370. });
  371. await this.searchList();
  372. }
  373. })
  374. .catch(() => {
  375. console.log("取消");
  376. });
  377. },
  378. }
  379. }
  380. </script>
  381. <style lang="scss" scoped>
  382. .${compoenntName} {
  383. }
  384. </style>
  385. `;
  386. };