index.vue 11 KB

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