index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <!--
  2. * @Descripttion: 分销员管理
  3. * @version: 1.0
  4. * @Author: zzx
  5. * @Date: 2024-11-09 16:08:16
  6. * @LastEditors: zzx tigerzouzx@foxmail.com
  7. * @LastEditTime: 2024-11-19 16:08:16
  8. -->
  9. <template>
  10. <div class="app-container">
  11. <el-card class="filter-container" shadow="hover">
  12. <div>
  13. <i class="el-icon-search"></i>
  14. <span>筛选搜索</span>
  15. <el-button style="float: right" type="primary" @click="handleSearchList()" size="small">
  16. 查询搜索
  17. </el-button>
  18. <el-button style="float: right; margin-right: 15px" @click="handleResetSearch()" size="small">
  19. 重置
  20. </el-button>
  21. </div>
  22. <div style="margin-top: 15px">
  23. <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
  24. <el-form-item label="分销员姓名:">
  25. <el-input v-model="listQuery.ecName" class="input-width" placeholder="请输入用户名称"
  26. clearable></el-input>
  27. </el-form-item>
  28. <el-form-item label="手机号:">
  29. <el-input v-model="listQuery.phone" class="input-width" placeholder="请输入手机号码"
  30. clearable></el-input>
  31. </el-form-item>
  32. <el-form-item label="分销员层级:">
  33. <el-select v-model="listQuery.level" clearable placeholder="请选择">
  34. <el-option v-for="item in options" :key="item.value" :label="item.label"
  35. :value="item.value">
  36. </el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="更新时间:">
  40. <el-date-picker v-model="date" size="small" value-format="yyyy-MM-dd HH:mm:ss"
  41. class="item-width-350 ml10" type="datetimerange" range-separator="至" start-placeholder="开始日期"
  42. end-placeholder="结束日期">
  43. </el-date-picker>
  44. </el-form-item>
  45. </el-form>
  46. </div>
  47. </el-card>
  48. <el-card class="operate-container" shadow="hover">
  49. <i class="el-icon-tickets"></i>
  50. <span>数据列表</span>
  51. </el-card>
  52. <div class="table-container">
  53. <el-table ref="adminTable" :data="list" style="width: 100%" v-loading="listLoading" border>
  54. <el-table-column label="分销员编号" width="100" align="center" prop="number"></el-table-column>
  55. <el-table-column label="分销员姓名" align="center">
  56. <template slot-scope="scope">
  57. {{ scope.row.userName }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="分销员层级" align="center">
  61. <template slot-scope="scope">
  62. <el-tag v-if="scope.row.type == 1 || scope.row.type == null" type="info">普通用户</el-tag>
  63. <el-tag v-else-if="scope.row.type == 2" type="success">一级分销</el-tag>
  64. <el-tag v-else="scope.row.type == 3" type="warning">二级分销</el-tag>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="手机号" align="center" prop="phone"></el-table-column>
  68. <el-table-column label="身份证号码" align="center" prop="card"></el-table-column>
  69. <el-table-column label="银行卡号" align="center" prop="bankCard"></el-table-column>
  70. <el-table-column label="开户行" align="center" prop="depositBank"></el-table-column>
  71. <!-- <el-table-column label="佣金比例%" align="center" prop="level"></el-table-column> -->
  72. <el-table-column label="更新人" align="center" prop="updateBy"></el-table-column>
  73. <el-table-column label="更新时间" align="center" prop="updateTime"></el-table-column>
  74. <el-table-column label="操作" width="400" align="center">
  75. <template slot-scope="scope">
  76. <el-button size="mini" type="primary" plain @click="checkQrCode(scope.row)">
  77. 查看二维码</el-button>
  78. <el-button size="mini" type="success" plain
  79. @click="checkJunior(scope.$index, scope.row)" v-if="scope.row.type != 3">查看下级</el-button>
  80. <el-button :disabled="scope.row.isWithdraw==0?isWithdraw=false:isWithdraw=true" size="mini" v-if="scope.row.isSelf == 1" type="info" plain
  81. @click="userEdit(scope.row)">编辑</el-button>
  82. <span v-if="isAdmin!=3">
  83. <el-button size="mini" v-if="scope.row.isSelf !=1" type="warning" plain @click="settingsCommission(scope.row)">
  84. {{ isAdmin!=3?'设置分销佣金':'查看分销佣金' }}
  85. </el-button>
  86. </span>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. </div>
  91. <div class="pagination-container">
  92. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  93. layout="total, sizes,prev, pager, next,jumper" :current-page.sync="listQuery.pageNum"
  94. :page-size="listQuery.pageSize" :page-sizes="[10, 15, 20]" :total="total">
  95. </el-pagination>
  96. </div>
  97. <el-dialog title="编辑分销员" :visible.sync="forbiddenDialogVisible" width="40%" :before-close="handleClose">
  98. <div class="tips" style="margin-bottom: 20px;margin-left: 52px;">请仔细核对个人信息,提现一次后,则不能进行修改,信息不对,会造成打款失败</div>
  99. <el-form :model="admin" ref="adminForm" :rules="rules" label-width="150px" size="small">
  100. <el-form-item label="分销员编号:">
  101. <el-input disabled v-model="admin.number" style="width: 250px"></el-input>
  102. </el-form-item>
  103. <el-form-item label="分销员姓名:" prop="userName">
  104. <el-input v-model="admin.userName" style="width: 250px"></el-input>
  105. </el-form-item>
  106. <el-form-item label="分销员层级:">
  107. <el-input type="text" disabled v-if="admin.type == 1 || admin.type == null" value="普通用户"
  108. style="width: 250px"></el-input>
  109. <el-input type="text" disabled v-else-if="admin.type == 2" value="一级分销"
  110. style="width: 250px"></el-input>
  111. <el-input type="text" disabled v-else="admin.type == 3" value="二级分销"
  112. style="width: 250px"></el-input>
  113. </el-form-item>
  114. <el-form-item label="手机号:">
  115. <el-input v-model="admin.phone" disabled type="number" style="width: 250px"></el-input>
  116. </el-form-item>
  117. <el-form-item label="身份证号码:" prop="card">
  118. <el-input v-model="admin.card" type="text" :rows="5" style="width: 250px"></el-input>
  119. </el-form-item>
  120. <el-form-item label="银行卡号:" prop="bankCard">
  121. <el-input v-model="admin.bankCard" type="text" :rows="5" style="width: 250px"></el-input>
  122. </el-form-item>
  123. <el-form-item label="开户行:" prop="depositBank">
  124. <el-input v-model="admin.depositBank" type="text" :rows="5" style="width: 250px"></el-input>
  125. </el-form-item>
  126. <el-form-item label="佣金比例:">
  127. <el-input disabled v-model="admin.level" type="text" :rows="5" style="width: 250px"></el-input>
  128. </el-form-item>
  129. </el-form>
  130. <span slot="footer" class="dialog-footer">
  131. <el-button @click="cancelEdit" size="small">取 消</el-button>
  132. <el-button type="primary" @click="confirmEdit" size="small">确 定</el-button>
  133. </span>
  134. </el-dialog>
  135. <el-dialog title="查看二维码" :visible.sync="checkQrCodeDialogVisible" width="40%">
  136. <div ref="posterContainer" class="qrCodeBox">
  137. <div class="bigImgBox">
  138. <img :src="qrCode_bg" class="qrCodeBg">
  139. <el-image class="qrCode" style="" :src="qrCodeImg">
  140. <div slot="error" class="image-slot">
  141. <i class="el-icon-loading"></i>
  142. </div>
  143. </el-image>
  144. </div>
  145. </div>
  146. <div style="text-align: center;margin-top: 20px;">
  147. <el-button type="success" @click="downloadQrCode" :loading="downloadingQrCode" lazy size="mini">下载二维码</el-button>
  148. </div>
  149. </el-dialog>
  150. </div>
  151. </template>
  152. <script>
  153. import { peopleList, getQrcode, peopleEdit } from "@/api/distribution";
  154. import { formatDate } from "@/utils/date";
  155. import html2canvas from 'html2canvas';
  156. import qrCode_bg from '@/assets/images/qrCode_bg.jpg'
  157. const defaultListQuery = {
  158. pageNum: 1,
  159. pageSize: 10,
  160. ecName: null,
  161. phone: null,
  162. startTime: '',
  163. endTime: '',
  164. level: ''
  165. };
  166. const defaultAdmin = {
  167. id: null,
  168. username: null,
  169. password: null,
  170. nickName: null,
  171. email: null,
  172. note: null,
  173. status: 1,
  174. };
  175. export default {
  176. name: "peopleManage",
  177. data() {
  178. return {
  179. isAdmin: null,
  180. isWithdraw: false,
  181. date: "",
  182. qrCodeImg: "",
  183. listQuery: Object.assign({}, defaultListQuery),
  184. list: null,
  185. total: null,
  186. listLoading: false,
  187. admin: Object.assign({}, defaultAdmin),
  188. forbiddenDialogVisible: false,
  189. checkQrCodeDialogVisible: false,
  190. options: [{
  191. value: 2,
  192. label: '一级'
  193. }, {
  194. value: 3,
  195. label: '二级'
  196. }],
  197. qrCode_bg,
  198. downloadingQrCode: false,
  199. rules: {
  200. userName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
  201. card: [{ required: true, message: '请输入身份证号', trigger: 'blur' }],
  202. bankCard: [{ required: true, message: '请输入银行卡号', trigger: 'blur' }],
  203. depositBank: [{ required: true, message: '请输入开户行', trigger: 'blur' }],
  204. }
  205. };
  206. },
  207. watch: {
  208. date(val) {
  209. if (val) {
  210. this.listQuery.startTime = Date.parse(val[0]);
  211. this.listQuery.endTime = Date.parse(val[1]);
  212. } else {
  213. this.listQuery.startTime = "";
  214. this.listQuery.endTime = "";
  215. }
  216. },
  217. },
  218. created() {
  219. this.isAdmin = localStorage.getItem("isAdmin");
  220. this.getList();
  221. },
  222. filters: {
  223. formatDateTime(time) {
  224. if (time == null || time === "") {
  225. return "N/A";
  226. }
  227. let date = new Date(time);
  228. return formatDate(date, "yyyy-MM-dd hh:mm:ss");
  229. },
  230. },
  231. methods: {
  232. // 编辑
  233. userEdit(row) {
  234. this.forbiddenDialogVisible = true;
  235. this.admin = row;
  236. },
  237. cancelEdit() {
  238. this.$refs["adminForm"].resetFields();
  239. this.forbiddenDialogVisible = false;
  240. },
  241. handleClose(){
  242. this.$refs["adminForm"].resetFields();
  243. this.forbiddenDialogVisible = false;
  244. },
  245. confirmEdit() {
  246. this.$refs.adminForm.validate(valid => {
  247. if (valid) {
  248. let data = {
  249. userName: this.admin.userName,
  250. adminUserId: this.admin.adminUserId,
  251. bankCard: this.admin.bankCard,
  252. card: this.admin.card,
  253. depositBank: this.admin.depositBank,
  254. }
  255. peopleEdit({ ...data }).then(res => {
  256. if (res.code == 200) {
  257. this.$message({
  258. message: '修改成功',
  259. type: 'success'
  260. });
  261. this.forbiddenDialogVisible = false;
  262. this.getList();
  263. }
  264. })
  265. }
  266. })
  267. },
  268. // 查看二维码
  269. checkQrCode(row) {
  270. this.checkQrCodeDialogVisible = true;
  271. getQrcode({ adminUserId: row.adminUserId, userId: row.id }).then(res => {
  272. const blob = new Blob([res.data], { type: 'image/png' });
  273. const objectUrl = URL.createObjectURL(blob);
  274. this.qrCodeImg = objectUrl;
  275. })
  276. },
  277. // 下载
  278. downloadQrCode() {
  279. this.downloadingQrCode = true;
  280. const posterContainer = this.$refs.posterContainer;
  281. html2canvas(posterContainer, {
  282. scale: 4 // 设置下载图片的分辨率
  283. }).then(canvas => {
  284. this.downloadingQrCode = false;
  285. const dataURL = canvas.toDataURL('image/png');
  286. const a = document.createElement('a');
  287. a.href = dataURL;
  288. a.download = '二维码海报.jpg';
  289. document.body.appendChild(a);
  290. a.click();
  291. document.body.removeChild(a);
  292. });
  293. },
  294. // 查看下级
  295. checkJunior(index, row) {
  296. this.$router.push({
  297. name: "junior",
  298. query: {
  299. adminUserId: row.adminUserId,
  300. },
  301. });
  302. },
  303. settingsCommission(row){
  304. this.$router.push({
  305. name: "setCommission",
  306. query: {
  307. adminUserId: row.adminUserId,
  308. }
  309. })
  310. },
  311. handleResetSearch() {
  312. this.date = ''
  313. this.listQuery = Object.assign({}, defaultListQuery);
  314. },
  315. handleSearchList() {
  316. this.listQuery.pageNum = 1;
  317. this.getList();
  318. },
  319. handleSizeChange(val) {
  320. this.listQuery.pageNum = 1;
  321. this.listQuery.pageSize = val;
  322. this.getList();
  323. },
  324. handleCurrentChange(val) {
  325. this.listQuery.pageNum = val;
  326. this.getList();
  327. },
  328. getList() {
  329. this.listLoading = true;
  330. peopleList(this.listQuery).then((response) => {
  331. this.listLoading = false;
  332. this.list = response.data.list;
  333. this.total = response.data.total;
  334. });
  335. },
  336. },
  337. };
  338. </script>
  339. <style scoped>
  340. .peoplePagination {
  341. margin-top: 10px;
  342. display: flex;
  343. justify-content: right;
  344. }
  345. .qrCodeBox {
  346. display: flex;
  347. align-items: center;
  348. justify-self: center;
  349. }
  350. .bigImgBox {
  351. position: relative;
  352. width: 260px;
  353. }
  354. .qrCodeBg {
  355. width: 260px;
  356. height: auto;
  357. /* border-radius: 6px; */
  358. }
  359. .qrCode {
  360. width: 100px;
  361. height:100px;
  362. position: absolute;
  363. top:233px;
  364. left: 80px;
  365. }
  366. </style>