index.vue 12 KB

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