多租户商城-商户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

379 lines
12 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="custom_page">
  3. <div class="content">
  4. <!-- 顶部搜索 -->
  5. <div class="toolbar">
  6. <!-- 顶部搜索 -->
  7. <el-form :inline="true" :model="formInline">
  8. <el-form-item label="分销员昵称">
  9. <el-input v-model="formInline.distributorName" maxlength="20" placeholder="请输入分销员昵称" />
  10. </el-form-item>
  11. <el-form-item label="分销员手机号">
  12. <el-input v-model="formInline.distributorPhone" maxlength="11" placeholder="请输入手机号" />
  13. </el-form-item>
  14. <el-form-item label="加入时间">
  15. <el-date-picker
  16. v-model="formInline.dates"
  17. type="daterange"
  18. range-separator="至"
  19. start-placeholder="开始时间"
  20. end-placeholder="结束时间"
  21. value-format="yyyy-MM-dd"
  22. />
  23. </el-form-item>
  24. <el-form-item label="分销员等级">
  25. <el-select v-model="formInline.distributorLevelId" placeholder="请选择分销员等级">
  26. <el-option
  27. v-for="(item,index) in humenList"
  28. :key="index"
  29. :label="item.levelName"
  30. :value="item.distributorLevelId"
  31. />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button type="primary" plain @click="search">查询</el-button>
  36. <el-button plain @click="clear">重置</el-button>
  37. <el-button type="success" plain @click="add">添加分销员</el-button>
  38. </el-form-item>
  39. </el-form>
  40. </div>
  41. <!-- 表格 -->
  42. <div class="content_table">
  43. <div class="table">
  44. <el-table
  45. :data="tableData"
  46. border
  47. :header-cell-style="{ background: '#EEF3FF', color: '#333333' }"
  48. style="width: 100%"
  49. >
  50. >
  51. <el-table-column prop="distributorName" label="分销员昵称" />
  52. <el-table-column prop="distributorPhone" label="分销员手机号" />
  53. <el-table-column prop="inviteesName" label="邀请人" />
  54. <el-table-column prop="levelName" label="分销员等级" />
  55. <el-table-column prop="total" label="累计客户" />
  56. <el-table-column prop="subordinate" label="累计下级" />
  57. <el-table-column prop="money" label="累计佣金(元 )" />
  58. <el-table-column label="操作" show-overflow-tooltip>
  59. <template slot-scope="scope">
  60. <div class="btnList">
  61. <el-button type="text" @click="edit(scope.row)">编辑</el-button>
  62. <el-button type="text" @click="del(scope.row)">清退</el-button>
  63. </div>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <div class="fenye">
  68. <el-pagination
  69. :current-page="currentPage"
  70. :page-sizes="[10, 20, 50, 100]"
  71. :page-size="10"
  72. layout="total, sizes, prev, pager, next, jumper"
  73. :total="total"
  74. @size-change="handleSizeChange"
  75. @current-change="handleCurrentChange"
  76. />
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. <!-- 分销员弹框 -->
  82. <el-dialog
  83. :visible.sync="isVisible.show"
  84. :title="isVisible.title"
  85. width="30%"
  86. center
  87. :close-on-click-modal="false"
  88. >
  89. <div>
  90. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  91. <el-form-item label="分销员昵称" prop="distributorName">
  92. <el-input v-model="form.distributorName" maxlength="20" :disabled="isVisible.index ===2" />
  93. </el-form-item>
  94. <el-form-item label="分销员手机号" prop="distributorPhone">
  95. <el-input
  96. v-if="distributorPhoneShow"
  97. :value="hidden(form.distributorPhone, 3, 3)"
  98. :disabled="isVisible.index ===2"
  99. maxlength="11"
  100. />
  101. <el-input
  102. v-else
  103. v-model="form.distributorPhone"
  104. :disabled="isVisible.index ===2"
  105. maxlength="11"
  106. />
  107. </el-form-item>
  108. <el-form-item label="分销员等级" prop="distributorLevelId">
  109. <el-select v-model="form.distributorLevelId" placeholder="请选择分销员等级">
  110. <el-option
  111. v-for="(item,index) in humenList"
  112. :key="index"
  113. :label="item.levelName"
  114. :value="item.distributorLevelId"
  115. />
  116. </el-select>
  117. </el-form-item>
  118. <el-form-item label="邀请人" prop="invitees">
  119. <el-select v-model="form.invitees" clearable placeholder="请选择邀请人">
  120. <el-option
  121. v-for="(item,index) in InviteList"
  122. :key="index"
  123. :label="item.distributorName"
  124. :value="item.distributorId"
  125. />
  126. </el-select>
  127. </el-form-item>
  128. </el-form>
  129. </div>
  130. <span slot="footer" class="dialog-footer">
  131. <el-button type="primary" @click="agreeEn">确定</el-button>
  132. <el-button @click="isVisible.show = false"> </el-button>
  133. </span>
  134. </el-dialog>
  135. <!-- 清退弹框 -->
  136. <el-dialog
  137. :visible.sync="isVisible.shows"
  138. :title="isVisible.title"
  139. center
  140. :close-on-click-modal="false"
  141. width="30%"
  142. >
  143. <div style="text-align: center;">
  144. <div class="unbindimg">
  145. <img src="../../../assets/images/tixing.png" alt srcset>
  146. </div>
  147. <div class="dialog_content">
  148. 清退之后用户将失去分销员身份
  149. 下级客户将会解绑关系确定要清退吗
  150. </div>
  151. </div>
  152. <span slot="footer" class="dialog-footer">
  153. <el-button @click="isVisible.shows = false">取消</el-button>
  154. <el-button type="primary" @click="agreeEn">确认</el-button>
  155. </span>
  156. </el-dialog>
  157. </div>
  158. </template>
  159. <script>
  160. import {
  161. getAllLevel,
  162. distributorGetAll,
  163. getAllInvitees,
  164. distributorAdd,
  165. distributorGetById,
  166. distributorUpdate,
  167. distributorDelete
  168. } from '@/api/distributor'
  169. import { hidden } from '@/utils';
  170. export default {
  171. data() {
  172. return {
  173. formInline: {
  174. distributorName: '',
  175. distributorPhone: '',
  176. dates: [],
  177. distributorLevelId: '',
  178. page: 1,
  179. pageSize: 10
  180. },
  181. form: {
  182. invitees: '', // 邀请人id
  183. distributorName: '', // 分销员名称
  184. distributorPhone: '', // 分销员手机号
  185. distributorLevelId: '' // 分销员等级id
  186. },
  187. isVisible: {},
  188. humenList: [],
  189. total: 1,
  190. tableData: [],
  191. currentPage: 1,
  192. InviteList: [],
  193. privacyTime: 0,
  194. distributorPhoneShow: false,
  195. rules: {
  196. distributorName: [
  197. { required: true, message: '请输入分销员昵称', trigger: 'blur' }
  198. ],
  199. distributorPhone: [
  200. { required: true, message: '请输入手机号', trigger: 'blur' },
  201. { min: 11, max: 11, message: "请输入11位手机号码", trigger: "blur" },
  202. {
  203. pattern: /^1[3456789]\d{9}$/,
  204. message: "请输入正确的手机号码"
  205. }
  206. ],
  207. distributorLevelId: [{ required: true, message: '请选择分销员等级', trigger: 'change' }],
  208. invitees: [{ required: true, message: '请选择邀请人', trigger: 'change' }],
  209. },
  210. }
  211. },
  212. created() {
  213. this.getAll(this.formInline)
  214. this.getAllPeo()
  215. this.getAllPeos()
  216. this.privacyTime = localStorage.getItem("privacyTime");
  217. },
  218. methods: {
  219. handleSizeChange(val) {
  220. this.formInline.pageSize = val
  221. this.getAll(this.formInline)
  222. },
  223. handleCurrentChange(val) {
  224. this.formInline.page = val
  225. this.getAll(this.formInline)
  226. },
  227. // 查询
  228. search() {
  229. this.total = 1
  230. this.formInline.page = 1
  231. this.getAll(this.formInline)
  232. },
  233. reset() {
  234. this.form = {
  235. invitees: '', // 邀请人id
  236. distributorName: '', // 分销员名称
  237. distributorPhone: '', // 分销员手机号
  238. distributorLevelId: '' // 分销员等级id
  239. }
  240. },
  241. // 添加分销员
  242. add() {
  243. this.isVisible = {
  244. show: true,
  245. title: '添加分销员',
  246. index: 1
  247. }
  248. this.distributorPhoneShow = false
  249. this.reset()
  250. },
  251. // 编辑
  252. async edit(row) {
  253. this.distributorPhoneShow = true
  254. const res = await distributorGetById({
  255. distributorId: row.distributorId
  256. })
  257. if (res.code === '') {
  258. this.form = res.data
  259. this.isVisible = {
  260. show: true,
  261. title: '编辑分销员',
  262. index: 2
  263. }
  264. }
  265. },
  266. async agreeEn() {
  267. if (this.isVisible.index === 1) {
  268. const res = await distributorAdd(this.form)
  269. if (res.code === '') {
  270. this.$message.success('新增成功')
  271. this.getAll(this.formInline)
  272. this.reset()
  273. this.isVisible.show = false
  274. }
  275. } else if (this.isVisible.index === 2) {
  276. const res = await distributorUpdate(this.form)
  277. if (res.code === '') {
  278. this.$message.success('编辑成功')
  279. this.getAll(this.formInline)
  280. this.reset()
  281. this.isVisible.show = false
  282. }
  283. } else if (this.isVisible.index === 3) {
  284. const res = await distributorDelete({
  285. distributorId: this.isVisible.distributorId
  286. })
  287. if (res.code === '') {
  288. this.$message.success('清退成功')
  289. this.getAll(this.formInline)
  290. this.reset()
  291. this.isVisible.shows = false
  292. }
  293. }
  294. },
  295. // 清退
  296. del(row) {
  297. this.isVisible = {
  298. shows: true,
  299. title: '清退',
  300. index: 3,
  301. distributorId: row.distributorId
  302. }
  303. },
  304. // 清除
  305. clear() {
  306. this.formInline = {
  307. orderFormid: '',
  308. distributorName: '',
  309. distributorPhone: '',
  310. dates: [],
  311. page: 1,
  312. pageSize: 10
  313. }
  314. this.getAll(this.formInline)
  315. },
  316. // 初始化查询所有数据
  317. async getAll(formInline) {
  318. const res = await distributorGetAll(formInline)
  319. this.tableData = res.data.list
  320. this.tableData.forEach((item) => {
  321. item.distributorPhone = hidden(item.distributorPhone, 3, 3)
  322. })
  323. this.total = res.data.total
  324. },
  325. // 初始化查询所有分销员
  326. async getAllPeo() {
  327. const res = await getAllLevel({ })
  328. this.humenList = res.data
  329. },
  330. // 初始化查询所有邀请人
  331. async getAllPeos() {
  332. const res = await getAllInvitees({ })
  333. this.InviteList = res.data
  334. },
  335. // 中间部分
  336. hidden(str, frontLen, endLen) {
  337. let endLenData = 0
  338. if (str.length !== 2) {
  339. endLenData = endLen
  340. }
  341. const len = str.length - frontLen - endLenData;
  342. let xing = '';
  343. for (let i = 0; i < len; i++) {
  344. xing += '*';
  345. }
  346. return (
  347. str.substring(0, frontLen) + xing + str.substring(str.length - endLenData)
  348. );
  349. // return str
  350. }
  351. }
  352. }
  353. </script>
  354. <style lang='scss' scoped>
  355. @import url("../../../styles/elDialog.scss");
  356. .custom_page {
  357. padding: 20px;
  358. background: #FFFFFF;
  359. border-radius: 10px;
  360. }
  361. .checkBoxStyle {
  362. margin-bottom: 20px;
  363. }
  364. .dialog_content {
  365. width: 275px;
  366. height: 46px;
  367. margin: auto;
  368. font-size: 16px;
  369. font-family: PingFang SC;
  370. font-weight: 400;
  371. color: #333333;
  372. line-height: 30px;
  373. margin-top: 25px;
  374. }
  375. </style>