index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div id="">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. rowKey="userId"
  12. ref="tableList"
  13. :tableSets="tableSet"
  14. :tableData="tableData"
  15. :navText="navText"
  16. :loading="loading"
  17. >
  18. <template slot="customize">
  19. <el-button type="primary" @click="dialogVisibleVipOpen = true">
  20. 会员卡开通
  21. </el-button>
  22. <el-button type="primary" @click="batch(1)"> 会员充值 </el-button>
  23. <el-button type="primary" @click="batch(2)"> 会员恢复 </el-button>
  24. <el-button @click="batch(3)"> 注销会员 </el-button>
  25. <el-button @click="exportData"> 导出excel </el-button>
  26. </template>
  27. <template slot="btn" slot-scope="props">
  28. <el-button
  29. type="text"
  30. @click="addClick([props.scope.row.userId])"
  31. :disabled="props.scope.row.vipTag !== 1"
  32. >充值</el-button
  33. ><el-button type="text" @click="cancellation(props.scope.row)">{{
  34. props.scope.row.vipTag == 1
  35. ? "注销"
  36. : props.scope.row.vipTag == 2
  37. ? "恢复"
  38. : ""
  39. }}</el-button
  40. ><el-button type="text" @click="record(props.scope.row)"
  41. >记录</el-button
  42. >
  43. </template>
  44. </table-list>
  45. <pagination
  46. :total="total"
  47. :pageSize.sync="formData.pageSize"
  48. :currentPage.sync="formData.pageNum"
  49. @search="search"
  50. />
  51. <dislog
  52. :dialogVisible.sync="dialogVisible"
  53. @search="search"
  54. :activeData="activeData"
  55. ></dislog>
  56. <vip-open
  57. :dialogVisible.sync="dialogVisibleVipOpen"
  58. @search="search"
  59. ></vip-open>
  60. <record
  61. :dialogVisible.sync="dialogRecordVisible"
  62. @search="search"
  63. :activeData="activeData"
  64. ></record>
  65. </div>
  66. </template>
  67. <script>
  68. import { exportFn } from "@/utils/index.js";
  69. import dislog from "./dislog.vue";
  70. import vipOpen from "./vipOpen.vue";
  71. import record from "./record.vue";
  72. import searchBoxNew from "@/components/searchBoxNew";
  73. import tableList from "@/components/tableList";
  74. import pagination from "@/components/pagination";
  75. export default {
  76. name: "MembershipCard",
  77. components: { searchBoxNew, tableList, pagination, dislog, record, vipOpen },
  78. data() {
  79. return {
  80. loading: false,
  81. navText: {
  82. title: "会员卡",
  83. index: 0,
  84. ch: "条",
  85. num: true,
  86. choice: true,
  87. addHide: true,
  88. custom: false,
  89. openCheckMore: true,
  90. },
  91. formList: [
  92. {
  93. prop: "vipTag",
  94. placeholder: "会员状态",
  95. scope: "select",
  96. options: [
  97. {
  98. label: "已开通",
  99. value: 1,
  100. },
  101. {
  102. label: "已注销",
  103. value: 2,
  104. },
  105. ],
  106. },
  107. {
  108. prop: "telphone",
  109. placeholder: "输入手机号码",
  110. },
  111. {
  112. prop: "idCard",
  113. placeholder: "输入身份证号",
  114. },
  115. ],
  116. formData: {},
  117. tableSet: [
  118. {
  119. label: "会员状态",
  120. prop: "vipTag",
  121. hidden: true,
  122. scope: "isOptions",
  123. options: [
  124. {
  125. label: "已开通",
  126. value: 1,
  127. },
  128. {
  129. label: "已注销",
  130. value: 2,
  131. },
  132. ],
  133. },
  134. {
  135. label: "会员来源",
  136. prop: "vipFrom",
  137. hidden: true,
  138. scope: "isOptions",
  139. options: [
  140. {
  141. label: "云学堂PC",
  142. value: 1,
  143. },
  144. {
  145. label: "云学堂H5",
  146. value: 2,
  147. },
  148. {
  149. label: "云学堂小程序",
  150. value: 3,
  151. },
  152. {
  153. label: "e管证",
  154. value: 4,
  155. },
  156. {
  157. label: "教育智慧管理系统",
  158. value: 5,
  159. },
  160. {
  161. label: "中正总平台",
  162. value: 6,
  163. },
  164. ],
  165. },
  166. {
  167. label: "关联机构",
  168. prop: "tenantName",
  169. hidden: true,
  170. },
  171. {
  172. label: "姓名",
  173. prop: "realname",
  174. hidden: true,
  175. },
  176. {
  177. label: "性别",
  178. prop: "sex",
  179. hidden: true,
  180. scope: "isOptions",
  181. options: [
  182. {
  183. label: "男",
  184. value: 1,
  185. },
  186. {
  187. label: "女",
  188. value: 2,
  189. },
  190. ],
  191. },
  192. {
  193. label: "身份证号",
  194. prop: "idCard",
  195. hidden: true,
  196. },
  197. {
  198. label: "手机号码",
  199. prop: "telphone",
  200. hidden: true,
  201. },
  202. {
  203. label: "当前积分",
  204. prop: "pointsValue",
  205. hidden: true,
  206. },
  207. {
  208. label: "累计充值",
  209. prop: "rechargeMoney",
  210. hidden: true,
  211. },
  212. {
  213. label: "累计退款",
  214. prop: "refundMoney",
  215. hidden: true,
  216. },
  217. {
  218. label: "开通时间",
  219. prop: "vipOpenTime",
  220. hidden: true,
  221. scope: "aTimeList",
  222. },
  223. {
  224. label: "注销时间",
  225. prop: "vipCloseTime",
  226. hidden: true,
  227. scope: "aTimeList",
  228. },
  229. ],
  230. tableData: [],
  231. total: 0,
  232. dialogVisible: false,
  233. dialogRecordVisible: false,
  234. dialogVisibleVipOpen: false,
  235. activeData: {},
  236. };
  237. },
  238. created() {
  239. this.search(2);
  240. },
  241. methods: {
  242. exportData() {
  243. this.$api.appuserlistExport(this.formData).then((res) => {
  244. if (res.msg) {
  245. exportFn(res.msg, `导出数据`);
  246. } else {
  247. this.$message.error("导出失败");
  248. }
  249. });
  250. },
  251. batch(i) {
  252. if (this.$refs.tableList.allCheckData.length === 0) {
  253. this.$message.error("请勾选数据");
  254. return;
  255. }
  256. if (i == 1) {
  257. if (this.$refs.tableList.allCheckData.every((k) => k.vipTag === 1)) {
  258. this.addClick(this.$refs.tableList.allCheckData.map((k) => k.userId));
  259. } else {
  260. this.$message.error("只能对会员状态为已开通的会员进行充值");
  261. return;
  262. }
  263. } else if (i == 2 || i == 3) {
  264. const alist = this.$refs.tableList.allCheckData.filter((item) => {
  265. if (i == 2) {
  266. return item.vipTag == 2;
  267. }
  268. if (i == 3) {
  269. return item.vipTag == 1;
  270. }
  271. });
  272. if (alist.length === 0) {
  273. this.$message.warning(
  274. `选中的数据中不存在可${i == 2 ? "恢复" : "注销"}的会员`
  275. );
  276. return;
  277. }
  278. this.$confirm(`是否${i == 2 ? "恢复" : "注销"}选中的会员`, "提示", {
  279. confirmButtonText: "确定",
  280. cancelButtonText: "取消",
  281. type: "warning",
  282. })
  283. .then(() => {
  284. this.$api[
  285. i == 2 ? "appuserrestoreBatchVip" : "appusercloseBatchVip"
  286. ]({
  287. userIdList: alist.map((k) => k.userId),
  288. }).then((res) => {
  289. this.$message.success("操作成功");
  290. this.search(3);
  291. });
  292. })
  293. .catch(() => {});
  294. }
  295. },
  296. addClick(data) {
  297. this.activeData = {
  298. userIdList: data,
  299. };
  300. this.dialogVisible = true;
  301. },
  302. search(v) {
  303. this.loading = true;
  304. if (v === 2) {
  305. this.formData = {
  306. pageSize: 10,
  307. pageNum: 1,
  308. };
  309. this.$nextTick(() => {
  310. this.$refs.tableList.clearMoreActive();
  311. });
  312. }
  313. if (v === 3) {
  314. this.$nextTick(() => {
  315. this.$refs.tableList.clearMoreActive();
  316. });
  317. }
  318. this.$api
  319. .appuservipUserList(this.formData)
  320. .then((res) => {
  321. this.tableData = res.rows;
  322. this.total = res.total;
  323. this.navText.index = res.total;
  324. })
  325. .finally(() => {
  326. this.loading = false;
  327. });
  328. },
  329. init() {
  330. this.search(2);
  331. },
  332. //注销/恢复会员
  333. cancellation(row) {
  334. this.$alert(
  335. `确定${
  336. row.vipTag === 1 ? "注销" : row.vipTag === 2 ? "恢复" : ""
  337. }该会员吗?`,
  338. "提示",
  339. {
  340. dangerouslyUseHTMLString: true,
  341. }
  342. )
  343. .then(() => {
  344. this.$api[
  345. row.vipTag === 1
  346. ? "appusercloseBatchVip"
  347. : row.vipTag === 2
  348. ? "appuserrestoreBatchVip"
  349. : ""
  350. ]({
  351. userIdList: [row.userId],
  352. }).then((res) => {
  353. this.$message.success("操作成功");
  354. this.search(3);
  355. });
  356. })
  357. .catch(() => {});
  358. },
  359. record(data) {
  360. this.activeData = data || {};
  361. this.dialogRecordVisible = true;
  362. },
  363. },
  364. };
  365. </script>
  366. <style lang="scss" scoped></style>