index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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:set']"
  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">
  88. <template slot-scope="scope">
  89. <el-switch
  90. @change="ionlineApi(scope.row)"
  91. v-model="scope.row.switchValue"
  92. :active-value="1"
  93. active-color="#13ce66"
  94. inactive-color="#ff4949">
  95. </el-switch>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="添加时间" align="center" prop="createTime" width="160">
  99. <template slot-scope="scope">
  100. <span>{{ parseTime(scope.row.createTime) }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
  104. <template slot-scope="scope">
  105. <el-button
  106. size="mini"
  107. type="text"
  108. @click="handleUpdate(scope.row)"
  109. v-hasPermi="['personnelMr:personnelMr:edit']"
  110. >修改</el-button>
  111. <el-button
  112. size="mini"
  113. type="text"
  114. @click="resettingApi(scope.row)"
  115. v-hasPermi="['personnelMr:personnelMr:resetting']"
  116. >重置密码</el-button>
  117. <el-button
  118. size="mini"
  119. type="text"
  120. @click="handleCode(scope.row, 'img')"
  121. v-hasPermi="['personnelMr:personnelMr:edit']"
  122. >推广码</el-button>
  123. <el-button
  124. size="mini"
  125. type="text"
  126. @click="handleDelete(scope.row,scope.index)"
  127. v-hasPermi="['personnelMr:personnelMr:delete']"
  128. >删除</el-button>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <pagination
  133. v-show="total>0"
  134. :total="total"
  135. :page.sync="queryParams.pageNum"
  136. :limit.sync="queryParams.pageSize"
  137. @pagination="getList"
  138. />
  139. <!-- 新增/编辑弹框 -->
  140. <add-and-edit
  141. ref="addAndEdit"
  142. :dict="dict"
  143. @getList="getList"
  144. />
  145. <!-- 海报设置 -->
  146. <promotion-code ref="promotionCode"></promotion-code>
  147. <el-dialog
  148. title="推广码"
  149. :visible.sync="visibleStatus"
  150. width="500px"
  151. :destroy-on-close="true"
  152. :close-on-click-modal="false"
  153. >
  154. <div id="capture" style="width: 400px; height: 500px; position: relative;background-size: cover;background-repeat: no-repeat" :style="{backgroundImage:'url('+newObj.posterImg+')'}">
  155. <el-image
  156. style="width: 180px; height: 180px; position: absolute; bottom: 0; right: 0;"
  157. :src="newObj.url"
  158. fit="cover"
  159. />
  160. </div>
  161. <div slot="footer" class="dialog-footer">
  162. <el-button @click="visibleStatus = false">取 消</el-button>
  163. <el-button type="primary" @click="getShareImgBase64(newObj)">下 载</el-button>
  164. </div>
  165. </el-dialog>
  166. <el-dialog
  167. title="提现设置"
  168. :visible.sync="setStatus"
  169. width="600px"
  170. :destroy-on-close="true"
  171. :close-on-click-modal="false"
  172. >
  173. <el-form :model="setForm" ref="setForm" label-width="120px">
  174. <el-form-item label="类型:">
  175. <el-radio v-model="setForm.type" label="1">按实值</el-radio>
  176. <el-radio v-model="setForm.type" label="2">按比例</el-radio>
  177. </el-form-item>
  178. <el-form-item label="提现手续费">
  179. <el-input
  180. type="number"
  181. v-model="setForm.serviceCharge"
  182. placeholder=""
  183. clearable
  184. @change="changePriceAmount('serviceCharge')"
  185. style="width: 260px;"
  186. >
  187. <template slot="append">{{ setForm.type == 2 ? '%' : '元' }}</template>
  188. </el-input>
  189. </el-form-item>
  190. <el-form-item label="提现门槛">
  191. <el-input
  192. type="number"
  193. v-model="setForm.withdrawMinMoney"
  194. placeholder=""
  195. clearable
  196. @change="changePriceAmount('withdrawMinMoney')"
  197. style="width: 260px;"
  198. >
  199. </el-input>
  200. <span style="margin-left: 5px">元以上方可提现</span>
  201. </el-form-item>
  202. </el-form>
  203. <div slot="footer" class="dialog-footer">
  204. <el-button @click="setStatus = false">取消</el-button>
  205. <el-button
  206. type="primary"
  207. @click="submitForm"
  208. v-loading.fullscreen.lock="setLoading"
  209. element-loading-text="提交中..."
  210. element-loading-spinner="el-icon-loading"
  211. element-loading-background="rgba(0, 0, 0, 0.8)"
  212. >
  213. <span v-if="loading">提交中...</span>
  214. <span v-else>保存</span>
  215. </el-button>
  216. </div>
  217. </el-dialog>
  218. </div>
  219. </template>
  220. <script>
  221. import { pageList, deleteById, updateStatus, configUpdate, getSetInfo, getRetailQrcode } from '@/api/distribution/personnelMr'
  222. import addAndEdit from "./dialog/addAndEdit.vue";
  223. import promotionCode from "./dialog/promotionCode.vue";
  224. import { Message } from 'element-ui'
  225. import * as url from 'url'
  226. import html2canvas from 'html2canvas'
  227. export default {
  228. name: "agreement",
  229. computed: {
  230. url() {
  231. return url
  232. }
  233. },
  234. dicts: ['distribution_type'],
  235. components: { addAndEdit, promotionCode },
  236. data() {
  237. return {
  238. // 遮罩层
  239. loading: true,
  240. // 选中数组
  241. ids: [],
  242. // 非单个禁用
  243. single: true,
  244. // 非多个禁用
  245. multiple: true,
  246. // 显示搜索条件
  247. showSearch: true,
  248. // 总条数
  249. total: 0,
  250. // 用户表格数据
  251. dataList: null,
  252. // 弹出层标题
  253. title: "",
  254. // 是否显示弹出层
  255. open: false,
  256. // 日期范围
  257. dateRange: [],
  258. // 查询参数
  259. queryParams: {
  260. pageNum: 1,
  261. pageSize: 10,
  262. type: undefined
  263. },
  264. statusList: [
  265. {id: 1, name: '未发布', value: 0},
  266. {id: 2, name: '发布', value: 1},
  267. {id: 3, name: '下架', value: 2},
  268. ],
  269. visibleStatus: false,
  270. newObj: {},
  271. visibleType: '',
  272. setStatus: false,
  273. setForm: {},
  274. setRules: [],
  275. setLoading: false,
  276. };
  277. },
  278. created() {
  279. this.getList();
  280. },
  281. methods: {
  282. /** 查询列表 */
  283. getList() {
  284. this.loading = true;
  285. pageList(this.queryParams)
  286. .then(response => {
  287. this.dataList = response.data.rows;
  288. this.dataList.forEach(item =>{
  289. item.switchValue = item.status;
  290. })
  291. this.total = response.data.total;
  292. this.loading = false;
  293. }
  294. );
  295. },
  296. // 取消按钮
  297. cancel() {
  298. this.open = false;
  299. },
  300. /** 搜索按钮操作 */
  301. handleQuery() {
  302. this.queryParams.pageNum = 1;
  303. this.getList();
  304. },
  305. /** 重置按钮操作 */
  306. resetQuery() {
  307. this.dateRange = [];
  308. this.$set(this.queryParams, 'name', '');
  309. this.$set(this.queryParams, 'type', '');
  310. this.queryParams.pageNum = 1;
  311. this.handleQuery();
  312. },
  313. /** 价格输入事件 */
  314. changePriceAmount(key) {
  315. if(this.setForm[key] * 1 < 0){
  316. this.$message.error("输入需大于或等于0!");
  317. this.$set(this.setForm, key, '');
  318. return false
  319. }
  320. },
  321. /** 新增按钮操作 */
  322. handleAdd() {
  323. this.$refs["addAndEdit"].openDialog("新增数据", null);
  324. },
  325. /** 提现设置按钮操作 */
  326. openSet() {
  327. this.setStatus = true
  328. this.getSetApi();
  329. },
  330. /** 海报设置按钮操作 */
  331. codeSet() {
  332. this.$refs["promotionCode"].openDialog("海报设置", null);
  333. },
  334. /** 修改按钮操作 */
  335. handleUpdate(row) {
  336. this.$refs["addAndEdit"].openDialog("修改数据", row);
  337. },
  338. /** 获取提现设置 */
  339. getSetApi(row) {
  340. getSetInfo().then(response => {
  341. const obj = response.data;
  342. this.$nextTick(() => {
  343. this.$set(this.setForm, 'id', obj.id ? obj.id : '');
  344. this.$set(this.setForm, 'withdrawMinMoney', obj.withdrawMinMoney);
  345. this.$set(this.setForm, 'serviceCharge', obj.serviceCharge);
  346. this.$set(this.setForm, 'type', obj.type ? (obj.type + '') : '1');
  347. });
  348. });
  349. },
  350. /** 获取推广码 */
  351. getRetailQrcodeApi(row) {
  352. getRetailQrcode({personsId: row.id}).then(response => {
  353. const obj = response.data;
  354. this.newObj = obj;
  355. this.newObj.name = row.name;
  356. });
  357. },
  358. /**
  359. * 分析提现
  360. * @date 2023-11-22
  361. * @returns {any}
  362. */
  363. submitForm() {
  364. this.$refs["setForm"].validate(async (valid) => {
  365. if (valid) {
  366. try {
  367. this.setLoading = true;
  368. const { code } = await configUpdate({ ...this.setForm });
  369. if (code === 200) {
  370. this.setLoading = false;
  371. this.$message.success("操作成功!");
  372. this.getList();
  373. this.setStatus = false;
  374. }
  375. } catch (error) {
  376. } finally {
  377. this.setLoading = false;
  378. }
  379. }
  380. });
  381. },
  382. /** 禁用或者启用发布按钮操作 */
  383. ionlineApi(row) {
  384. this.$confirm("是否对分销商名称为" + row.name + "的数据进行" + (row.status == 1 ? '禁用?' : '启用?'), '提示', {
  385. confirmButtonText: '确定',
  386. cancelButtonText: '取消',
  387. type: 'warning'
  388. }).then(() => {
  389. updateStatus({ id: row.id, status: row.status == 1 ? 0 : 1 }).then((res) => {
  390. if (res.code == 200) {
  391. this.$message({
  392. type: 'success',
  393. message: '操作成功!'
  394. });
  395. this.getList();
  396. }
  397. });
  398. }).catch(() => {});
  399. },
  400. /** 置顶或者取消置顶按钮操作 */
  401. resettingApi(row) {
  402. this.$confirm("是否对分销商名称为" + row.name + "的数据进行密码重置?重置后的密码为123456!", '提示', {
  403. confirmButtonText: '确定',
  404. cancelButtonText: '取消',
  405. type: 'warning'
  406. }).then(() => {
  407. updateStatus({ id: row.id, password: '123456' }).then((res) => {
  408. if (res.code == 200) {
  409. this.$message({
  410. type: 'success',
  411. message: '操作成功!'
  412. });
  413. this.getList();
  414. }
  415. });
  416. }).catch(() => {});
  417. },
  418. /** 删除按钮操作 */
  419. handleDelete(row) {
  420. this.$modal.confirm('是否确认删除数据分销商名称为"' + row.name + '"的数据项?').then(function() {
  421. return deleteById(row.id);
  422. }).then(() => {
  423. this.getList();
  424. this.$modal.msgSuccess("删除成功");
  425. }).catch(() => {});
  426. },
  427. /** 推广码按钮操作 */
  428. handleCode(obj, type) {
  429. this.getRetailQrcodeApi(obj);
  430. this.visibleStatus = true
  431. },
  432. // 推广码下载
  433. codeDownload(row) {
  434. let name = this.newObj.name + '的推广码' || ''
  435. if(row){
  436. let a = document.createElement("a");
  437. a.href = row;
  438. if(name.indexOf(".") > -1){
  439. a.download = name;
  440. } else {
  441. a.download = name + ".jpg";
  442. }
  443. a.style.display = "none";
  444. document.body.appendChild(a);
  445. a.click();
  446. a.remove();
  447. }
  448. },
  449. // 推广码 base64
  450. getShareImgBase64() {
  451. return new Promise((resolve) => {
  452. setTimeout(() => {
  453. // #capture 就是我们要获取截图对应的 DOM 元素选择器
  454. html2canvas(document.querySelector('#capture'), {
  455. useCORS: true, // 【重要】开启跨域配置
  456. scale: window.devicePixelRatio < 3 ? window.devicePixelRatio : 2,
  457. allowTaint: true, // 允许跨域图片
  458. }).then((canvas) => {
  459. const imgData = canvas.toDataURL('image/jpeg', 1.0);
  460. this.codeDownload(imgData);
  461. resolve(imgData);
  462. });
  463. }, 300); // 这里加上 300ms 的延迟是为了让 DOM 元素完全渲染完成后再进行图片的生成
  464. });
  465. },
  466. }
  467. };
  468. </script>