index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <div class="storeSet 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
  77. :span="4"
  78. style="width: 66px"
  79. >
  80. <el-button
  81. type="warning"
  82. class="fr"
  83. :size="searchSize"
  84. @click="restSearch"
  85. >
  86. 重置
  87. </el-button>
  88. </el-col>
  89. <el-col
  90. :span="3"
  91. style="width: 66px; float: right"
  92. >
  93. <el-button
  94. :size="searchSize"
  95. type="primary"
  96. style="float: right; margin-left: 5px"
  97. @click="searchList"
  98. >
  99. 刷新
  100. </el-button>
  101. </el-col>
  102. </el-col>
  103. </el-row>
  104. </div>
  105. </template>
  106. <template #status="{ scope }">
  107. <el-tag
  108. :size="tablebtnSize"
  109. :type="scope.row.status == '0' ? 'warning' : ''"
  110. v-text="
  111. (statusOptions.find((item) => item.id == scope.row.status) || {})
  112. .label || '--'
  113. "
  114. ></el-tag>
  115. </template>
  116. <template #operation="{ scope }">
  117. <el-tooltip
  118. v-if="powers.some((item) => item == '020')"
  119. effect="dark"
  120. content="重置密码"
  121. placement="top"
  122. >
  123. <i
  124. class="el-icon-refresh-left tb-icon"
  125. @click="openPasswordModal(scope.row.id, false)"
  126. ></i>
  127. </el-tooltip>
  128. <el-tooltip
  129. v-if="powers.some((item) => item == '007')"
  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((item) => item == '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((item) => item == '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((item) => item == '004') && 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. <add-edit
  191. :showModel="showModel"
  192. :id="modelId"
  193. :isDetail="isDetail"
  194. @refresh="searchList"
  195. @cancel="showModel = false"
  196. ></add-edit>
  197. </div>
  198. </template>
  199. <script>
  200. import mixinPage from "@/mixins/elPaginationHandle";
  201. import resToken from "@/mixins/resToken";
  202. import ExTable from "@/components/ExTableNew.vue";
  203. import statusList from "@/assets/js/statusList";
  204. import asyncRequest from "@/apis/service/purchaseIn/storeSet";
  205. import addEdit from "./addEdit";
  206. import { mapGetters } from "vuex";
  207. export default {
  208. name: "storeSet",
  209. mixins: [mixinPage, resToken],
  210. components: {
  211. addEdit,
  212. ExTable,
  213. },
  214. computed: {
  215. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  216. powers() {
  217. let tran =
  218. this.$store.getters.btnList.find(
  219. (item) => item.menu_route == "storeSet"
  220. ) || {};
  221. if (tran && tran.action && tran.action.length > 0) {
  222. return tran.action;
  223. } else {
  224. return [];
  225. }
  226. },
  227. },
  228. data() {
  229. return {
  230. sitem: null,
  231. // 状态
  232. statusOptions: [
  233. { id: "0", label: "禁用" },
  234. { id: "1", label: "启用" },
  235. ],
  236. statusList: statusList,
  237. loading: true,
  238. showModel: false,
  239. isDetail: false,
  240. modelId: 0,
  241. parmValue: {
  242. name: "", // 业务员名字
  243. username: "", // 账号
  244. status: "", //
  245. page: 1, // 页码
  246. size: 15, // 每页显示条数
  247. },
  248. tableData: [],
  249. passwordModel: false,
  250. passwordModelId: 0,
  251. isPasswordDetail: false,
  252. // 表格 - 数据
  253. tableData: [],
  254. // 表格 - 参数
  255. table: {
  256. stripe: true,
  257. border: true,
  258. _defaultHeader_: ["setcol"],
  259. },
  260. // 表格 - 分页
  261. pageInfo: {
  262. size: 15,
  263. curr: 1,
  264. total: 0,
  265. },
  266. // 表格 - 列参数
  267. columns: [
  268. {
  269. prop: "nickname",
  270. label: "真实姓名",
  271. },
  272. {
  273. prop: "role_name",
  274. label: "角色名称",
  275. },
  276. {
  277. prop: "mobile",
  278. label: "联系电话",
  279. },
  280. {
  281. prop: "email",
  282. label: "邮箱",
  283. },
  284. {
  285. prop: "status",
  286. label: "状态",
  287. _slot_: "status",
  288. width: "80px",
  289. },
  290. {
  291. prop: "addtime",
  292. label: "创建时间",
  293. sortable: true,
  294. },
  295. {
  296. prop: "",
  297. label: "操作",
  298. fixed: "right",
  299. _noset_: true,
  300. _slot_: "operation",
  301. },
  302. ],
  303. };
  304. },
  305. mounted() {
  306. this.searchList();
  307. },
  308. methods: {
  309. restSearch() {
  310. this.parmValue = {
  311. name: "", // 业务员名字
  312. username: "", // 账号
  313. status: "", //
  314. page: 1, // 页码
  315. size: 10, // 每页显示条数
  316. };
  317. this.searchList();
  318. },
  319. openModal(id, isDetail, sitem) {
  320. this.showModel = true;
  321. this.modelId = id;
  322. this.isDetail = isDetail;
  323. this.sitem = sitem;
  324. },
  325. async deleteById(id, status) {
  326. await this.$confirm("确定要删除?", {
  327. confirmButtonText: "确定",
  328. cancelButtonText: "取消",
  329. type: "warning",
  330. })
  331. .then(async () => {
  332. const model = {
  333. id: id,
  334. status: status === "1" ? "0" : "1",
  335. };
  336. const res = await asyncRequest.status(model);
  337. if (res && res.code === 0) {
  338. this.$notify.success({
  339. title: "删除成功",
  340. message: "",
  341. });
  342. this.searchList();
  343. } else if (res && res.code >= 100 && res.code <= 104) {
  344. await this.logout();
  345. } else {
  346. this.$message.warning(res.message);
  347. }
  348. })
  349. .catch(() => {
  350. console.log("取消");
  351. });
  352. },
  353. async searchList() {
  354. this.loading = true;
  355. const res = await asyncRequest.list(this.parmValue);
  356. if (res && res.code === 0 && res.data) {
  357. this.tableData = res.data.list;
  358. this.pageInfo.total = Number(res.data.count);
  359. } else if (res && res.code >= 100 && res.code <= 104) {
  360. await this.logout();
  361. } else {
  362. this.tableData = [];
  363. this.pageInfo.total = 0;
  364. }
  365. this.loading = false;
  366. },
  367. async statusConfirm(id, status) {
  368. let str = status === "1" ? "禁用" : "启用";
  369. await this.$confirm("确定要改为" + str + "?", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning",
  373. })
  374. .then(async () => {
  375. this.loading = true;
  376. const model = {
  377. id: id,
  378. status: status === "1" ? "0" : "1",
  379. };
  380. const res = await asyncRequest.status(model);
  381. if (res && res.code === 0) {
  382. this.loading = false;
  383. this.$notify.success({
  384. title: "状态修改成功!",
  385. message: "",
  386. });
  387. await this.searchList();
  388. } else if (res && res.code >= 100 && res.code <= 104) {
  389. await this.logout();
  390. } else {
  391. this.$message.warning(res.message);
  392. }
  393. })
  394. .catch(() => {
  395. console.log("取消");
  396. });
  397. },
  398. },
  399. };
  400. </script>
  401. <style lang="scss" scoped>
  402. .storeSet {
  403. }
  404. </style>