index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
  4. <el-form-item label="分销商名称" label-width="90px">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入分销商名称"
  8. clearable
  9. style="width: 240px;"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="分销商类型">
  14. <el-select
  15. v-model="queryParams.type"
  16. placeholder="分销商类型"
  17. clearable
  18. style="width: 140px"
  19. >
  20. <el-option
  21. v-for="dict in dict.type.distribution_type"
  22. :key="dict.value"
  23. :label="dict.label"
  24. :value="dict.value"
  25. />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  30. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="primary"
  37. plain
  38. icon="el-icon-plus"
  39. size="mini"
  40. @click="handleAdd"
  41. v-hasPermi="['personnelMr:personnelMr:add']"
  42. >新增</el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button
  46. type="success"
  47. plain
  48. icon="el-icon-setting"
  49. size="mini"
  50. @click="openSet"
  51. v-hasPermi="['personnelMr:personnelMr:set']"
  52. >提现设置</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="warning"
  57. plain
  58. icon="el-icon-s-tools"
  59. size="mini"
  60. @click="codeSet"
  61. v-hasPermi="['personnelMr:personnelMr:codeSet']"
  62. >推广码海报设置</el-button>
  63. </el-col>
  64. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  65. </el-row>
  66. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  67. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  68. <el-table-column label="分销商名称" align="center" prop="name" />
  69. <el-table-column label="分销商类型" align="center" prop="type">
  70. <template slot-scope="scope">
  71. <dict-tag :options="dict.type.distribution_type" :value="scope.row.type"/>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="负责人" align="center" prop="contact" />
  75. <el-table-column label="账号/联系电话" align="center" prop="mobile" />
  76. <el-table-column label="被扫次数" align="center" prop="scanCounts" />
  77. <el-table-column label="佣金总额" align="center" prop="brokerageTotal">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.brokerageTotal">¥{{ scope.row.brokerageTotal }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="待提现" align="center" prop="withdrawTotal">
  83. <template slot-scope="scope">
  84. <span v-if="scope.row.withdrawTotal">¥{{ scope.row.withdrawTotal }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="是否可提现" align="center" prop="allowWithdraw">
  88. <template slot-scope="scope">
  89. <dict-tag :options="dict.type.user_allow_withdraw" :value="scope.row.allowWithdraw"/>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="状态" align="center">
  93. <template slot-scope="scope">
  94. <el-switch
  95. @change="ionlineApi(scope.row)"
  96. v-model="scope.row.switchValue"
  97. :active-value="1"
  98. active-color="#13ce66"
  99. inactive-color="#ff4949">
  100. </el-switch>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="销售人员" align="center" prop="salePerson" />
  104. <el-table-column label="添加时间" align="center" prop="createTime" width="160">
  105. <template slot-scope="scope">
  106. <span>{{ parseTime(scope.row.createTime) }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
  110. <template slot-scope="scope">
  111. <el-button
  112. size="mini"
  113. type="text"
  114. @click="handleUpdate(scope.row)"
  115. v-hasPermi="['personnelMr:personnelMr:edit']"
  116. >修改</el-button>
  117. <el-button
  118. size="mini"
  119. type="text"
  120. @click="resettingApi(scope.row)"
  121. v-hasPermi="['personnelMr:personnelMr:resetting']"
  122. >重置密码</el-button>
  123. <el-button
  124. size="mini"
  125. type="text"
  126. @click="handleCode(scope.row, 'img')"
  127. v-hasPermi="['personnelMr:personnelMr:code']"
  128. >推广码</el-button>
  129. <el-button
  130. size="mini"
  131. type="text"
  132. @click="handleDelete(scope.row,scope.index)"
  133. v-hasPermi="['personnelMr:personnelMr:delete']"
  134. >删除</el-button>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. <pagination
  139. v-show="total>0"
  140. :total="total"
  141. :page.sync="queryParams.pageNum"
  142. :limit.sync="queryParams.pageSize"
  143. @pagination="getList"
  144. />
  145. <!-- 新增/编辑弹框 -->
  146. <add-and-edit
  147. ref="addAndEdit"
  148. :dict="dict"
  149. @getList="getList"
  150. />
  151. <!-- 海报设置 -->
  152. <promotion-code ref="promotionCode"></promotion-code>
  153. <el-dialog
  154. title="推广码"
  155. :visible.sync="visibleStatus"
  156. width="400px"
  157. :destroy-on-close="true"
  158. :close-on-click-modal="false"
  159. >
  160. <div style="display: flex;justify-content: center;">
  161. <div id="capture" style="width: 300px; height: 544px; position: relative;background-size: cover;background-repeat: no-repeat;box-shadow: 0px 0px 20px 2px rgba(221,221,221,0.5);border-radius: 10px;" :style="{backgroundImage:'url('+newObj.posterImg+')'}">
  162. <el-image
  163. style="width: 80px; height: 80px; position: absolute; bottom: 10px; right: 10px;"
  164. :src="newObj.url"
  165. fit="fill"
  166. />
  167. </div>
  168. </div>
  169. <div slot="footer" class="dialog-footer">
  170. <el-button @click="visibleStatus = false">取 消</el-button>
  171. <el-button :loading="getShareImgBase64Loading" type="primary" @click="getShareImgBase64(newObj)">
  172. {{ getShareImgBase64Loading ? '下载中':'下 载' }}</el-button>
  173. </div>
  174. </el-dialog>
  175. <el-dialog
  176. title="提现设置"
  177. :visible.sync="setStatus"
  178. width="650px"
  179. :destroy-on-close="true"
  180. :close-on-click-modal="false"
  181. >
  182. <el-form :model="setForm" ref="setForm" :rules="setFormRules" label-width="120px">
  183. <el-form-item label="类型:" prop="type">
  184. <el-radio-group v-model="setForm.type">
  185. <el-radio label="1">按实值</el-radio>
  186. <el-radio label="2">按比例</el-radio>
  187. </el-radio-group>
  188. </el-form-item>
  189. <el-form-item label="提现手续费" prop="serviceCharge">
  190. <el-input
  191. type="number"
  192. v-model="setForm.serviceCharge"
  193. placeholder="请输入提现手续费"
  194. clearable
  195. @change="changePriceAmount('serviceCharge')"
  196. style="width: 260px;"
  197. >
  198. <template slot="append">{{ setForm.type == 2 ? '%' : '元' }}</template>
  199. </el-input>
  200. </el-form-item>
  201. <el-form-item label="提现门槛" prop="withdrawMinMoney">
  202. <div>
  203. <el-input
  204. type="number"
  205. v-model="setForm.withdrawMinMoney"
  206. placeholder="请输入提现门槛,最低0.3元"
  207. clearable
  208. @change="changePriceAmount('withdrawMinMoney')"
  209. style="width: 260px;"
  210. >
  211. </el-input>
  212. <span style="margin-left: 5px">元以上方可提现</span>
  213. </div>
  214. <span style="font-size: 14px;color: #777;">注: 最低提现为0.3元</span>
  215. </el-form-item>
  216. </el-form>
  217. <div slot="footer" class="dialog-footer">
  218. <el-button @click="setStatus = false">取消</el-button>
  219. <el-button
  220. type="primary"
  221. @click="submitForm"
  222. v-loading.fullscreen.lock="setLoading"
  223. element-loading-text="提交中..."
  224. element-loading-spinner="el-icon-loading"
  225. element-loading-background="rgba(0, 0, 0, 0.8)"
  226. >
  227. <span v-if="loading">提交中...</span>
  228. <span v-else>保存</span>
  229. </el-button>
  230. </div>
  231. </el-dialog>
  232. </div>
  233. </template>
  234. <script>
  235. import { pageList, deleteById, updateStatus, configUpdate, getSetInfo, getRetailQrcode } from '@/api/distribution/personnelMr'
  236. import addAndEdit from "./dialog/addAndEdit.vue";
  237. import promotionCode from "./dialog/promotionCode.vue";
  238. import { Message } from 'element-ui'
  239. import * as url from 'url'
  240. import html2canvas from 'html2canvas'
  241. export default {
  242. name: "agreement",
  243. computed: {
  244. url() {
  245. return url
  246. }
  247. },
  248. dicts: ['distribution_type','user_allow_withdraw'],
  249. components: { addAndEdit, promotionCode },
  250. data() {
  251. let validateNumber = (rule, value, callback) => {
  252. let regNumber=/^(([1-9]\d*)|([0][.]{1}[0-9]{0,2}[1-9]+)|([1-9]\d*[.]{1}[0-9]+))$/g;
  253. if (value === '') {
  254. callback(new Error('请输入数值!!!'));
  255. }else if (!regNumber.test(value)) {
  256. callback(new Error('只能输入大于0.3的数值!!!'));
  257. } else if(value < 0.3){
  258. callback(new Error('只能输入大于0.3的数值!!!'));
  259. }else {
  260. callback();
  261. }
  262. };
  263. let validateNumber1 = (rule, value, callback) => {
  264. let regNumber=/^(([1-9]\d*)|([0][.]{1}[0-9]{0,2}[1-9]+)|([1-9]\d*[.]{1}[0-9]+))$/g;
  265. if (value === '') {
  266. callback(new Error('请输入数值!!!'));
  267. } else if (value === 0) {
  268. callback();
  269. } else if (!regNumber.test(value)) {
  270. callback(new Error('只能输入>=0的数值!!!'));
  271. }else {
  272. callback();
  273. }
  274. };
  275. return {
  276. // 遮罩层
  277. loading: true,
  278. // 选中数组
  279. ids: [],
  280. // 非单个禁用
  281. single: true,
  282. // 非多个禁用
  283. multiple: true,
  284. // 显示搜索条件
  285. showSearch: true,
  286. // 总条数
  287. total: 0,
  288. // 用户表格数据
  289. dataList: null,
  290. // 弹出层标题
  291. title: "",
  292. // 是否显示弹出层
  293. open: false,
  294. // 日期范围
  295. dateRange: [],
  296. // 查询参数
  297. queryParams: {
  298. pageNum: 1,
  299. pageSize: 10,
  300. type: undefined
  301. },
  302. statusList: [
  303. {id: 1, name: '未发布', value: 0},
  304. {id: 2, name: '发布', value: 1},
  305. {id: 3, name: '下架', value: 2},
  306. ],
  307. visibleStatus: false,
  308. newObj: {},
  309. visibleType: '',
  310. setStatus: false,
  311. setForm: {},
  312. setFormRules: {
  313. type: [
  314. { required: true, message: '请选择类型', trigger: ['change','blur'] },
  315. ],
  316. serviceCharge: [
  317. { required: true, message: '请输入提现手续费', trigger: ['change','blur'] },
  318. { validator: validateNumber1, trigger: ["blur","change"]},
  319. ],
  320. withdrawMinMoney: [
  321. { required: true, message: '请输入提现门槛,最低0.3元', trigger: ['change','blur'] },
  322. { validator: validateNumber, trigger: ["blur","change"]},
  323. ],
  324. },
  325. setRules: [],
  326. setLoading: false,
  327. getShareImgBase64Loading: false,
  328. };
  329. },
  330. created() {
  331. this.getList();
  332. },
  333. methods: {
  334. /** 查询列表 */
  335. getList() {
  336. this.loading = true;
  337. pageList(this.queryParams)
  338. .then(response => {
  339. this.dataList = response.data.rows;
  340. this.dataList.forEach(item =>{
  341. item.switchValue = item.status;
  342. })
  343. this.total = response.data.total;
  344. this.loading = false;
  345. }
  346. );
  347. },
  348. // 取消按钮
  349. cancel() {
  350. this.open = false;
  351. },
  352. /** 搜索按钮操作 */
  353. handleQuery() {
  354. this.queryParams.pageNum = 1;
  355. this.getList();
  356. },
  357. /** 重置按钮操作 */
  358. resetQuery() {
  359. this.dateRange = [];
  360. this.$set(this.queryParams, 'name', '');
  361. this.$set(this.queryParams, 'type', '');
  362. this.queryParams.pageNum = 1;
  363. this.handleQuery();
  364. },
  365. /** 价格输入事件 */
  366. changePriceAmount(key) {
  367. if(this.setForm[key] * 1 < 0){
  368. this.$message.error("输入需大于或等于0!");
  369. this.$set(this.setForm, key, '');
  370. return false
  371. }
  372. },
  373. /** 新增按钮操作 */
  374. handleAdd() {
  375. this.$refs["addAndEdit"].openDialog("新增数据", null);
  376. },
  377. /** 提现设置按钮操作 */
  378. openSet() {
  379. this.setStatus = true
  380. this.getSetApi();
  381. },
  382. /** 海报设置按钮操作 */
  383. codeSet() {
  384. this.$refs["promotionCode"].openDialog("海报设置", null);
  385. },
  386. /** 修改按钮操作 */
  387. handleUpdate(row) {
  388. this.$refs["addAndEdit"].openDialog("修改数据", row);
  389. },
  390. /** 获取提现设置 */
  391. getSetApi(row) {
  392. getSetInfo().then(response => {
  393. const obj = response.data;
  394. this.$nextTick(() => {
  395. this.$set(this.setForm, 'id', obj.id ? obj.id : '');
  396. this.$set(this.setForm, 'withdrawMinMoney', obj.withdrawMinMoney);
  397. this.$set(this.setForm, 'serviceCharge', obj.serviceCharge);
  398. this.$set(this.setForm, 'type', obj.type ? (obj.type + '') : '1');
  399. });
  400. });
  401. },
  402. /** 获取推广码 */
  403. getRetailQrcodeApi(row) {
  404. getRetailQrcode({personsId: row.id}).then(response => {
  405. const obj = response.data;
  406. this.newObj = obj;
  407. this.newObj.name = row.name;
  408. });
  409. },
  410. /**
  411. * 分析提现
  412. * @date 2023-11-22
  413. * @returns {any}
  414. */
  415. submitForm() {
  416. this.$refs["setForm"].validate(async (valid) => {
  417. if (valid) {
  418. try {
  419. this.setLoading = true;
  420. const { code } = await configUpdate({ ...this.setForm });
  421. if (code === 200) {
  422. this.setLoading = false;
  423. this.$message.success("操作成功!");
  424. this.getList();
  425. this.setStatus = false;
  426. }
  427. } catch (error) {
  428. } finally {
  429. this.setLoading = false;
  430. }
  431. }
  432. });
  433. },
  434. /** 禁用或者启用发布按钮操作 */
  435. ionlineApi(row) {
  436. this.$confirm("是否对分销商名称为" + row.name + "的数据进行" + (row.status == 1 ? '禁用?' : '启用?'), '提示', {
  437. confirmButtonText: '确定',
  438. cancelButtonText: '取消',
  439. type: 'warning'
  440. }).then(() => {
  441. updateStatus({ id: row.id, status: row.status == 1 ? 0 : 1 }).then((res) => {
  442. if (res.code == 200) {
  443. this.$message({
  444. type: 'success',
  445. message: '操作成功!'
  446. });
  447. this.getList();
  448. }
  449. });
  450. }).catch(() => {});
  451. },
  452. /** 置顶或者取消置顶按钮操作 */
  453. resettingApi(row) {
  454. this.$confirm("是否对分销商名称为" + row.name + "的数据进行密码重置?重置后的密码为123456!", '提示', {
  455. confirmButtonText: '确定',
  456. cancelButtonText: '取消',
  457. type: 'warning'
  458. }).then(() => {
  459. updateStatus({ id: row.id, password: '123456' }).then((res) => {
  460. if (res.code == 200) {
  461. this.$message({
  462. type: 'success',
  463. message: '操作成功!'
  464. });
  465. this.getList();
  466. }
  467. });
  468. }).catch(() => {});
  469. },
  470. /** 删除按钮操作 */
  471. handleDelete(row) {
  472. this.$modal.confirm('是否确认删除数据分销商名称为"' + row.name + '"的数据项?').then(function() {
  473. return deleteById(row.id);
  474. }).then(() => {
  475. this.getList();
  476. this.$modal.msgSuccess("删除成功");
  477. }).catch(() => {});
  478. },
  479. /** 推广码按钮操作 */
  480. handleCode(obj, type) {
  481. this.getRetailQrcodeApi(obj);
  482. this.visibleStatus = true
  483. },
  484. // 推广码下载
  485. codeDownload(row) {
  486. let name = this.newObj.name + '的推广码' || ''
  487. if(row){
  488. let a = document.createElement("a");
  489. a.href = row;
  490. if(name.indexOf(".") > -1){
  491. a.download = name;
  492. } else {
  493. a.download = name + ".jpg";
  494. }
  495. a.style.display = "none";
  496. document.body.appendChild(a);
  497. a.click();
  498. a.remove();
  499. }
  500. },
  501. // 推广码 base64
  502. getShareImgBase64() {
  503. return new Promise((resolve) => {
  504. this.getShareImgBase64Loading = true
  505. setTimeout(() => {
  506. // #capture 就是我们要获取截图对应的 DOM 元素选择器
  507. html2canvas(document.querySelector('#capture'), {
  508. useCORS: true, // 【重要】开启跨域配置
  509. scale: window.devicePixelRatio < 3 ? window.devicePixelRatio : 2,
  510. allowTaint: true, // 允许跨域图片
  511. }).then((canvas) => {
  512. const imgData = canvas.toDataURL('image/jpeg', 1.0);
  513. this.codeDownload(imgData);
  514. resolve(imgData);
  515. this.getShareImgBase64Loading = false
  516. }).catch(()=>{
  517. this.getShareImgBase64Loading = false
  518. })
  519. }, 300); // 这里加上 300ms 的延迟是为了让 DOM 元素完全渲染完成后再进行图片的生成
  520. });
  521. },
  522. }
  523. };
  524. </script>