index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  55. </el-row>
  56. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  57. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  58. <el-table-column label="分销商名称" align="center" prop="name" />
  59. <el-table-column label="分销商类型" align="center" prop="type">
  60. <template slot-scope="scope">
  61. <dict-tag :options="dict.type.distribution_type" :value="scope.row.type"/>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="负责人" align="center" prop="contact" />
  65. <el-table-column label="手机号" align="center" prop="mobile" />
  66. <el-table-column label="佣金总额" align="center" prop="brokerageTotal">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.brokerageTotal">¥{{ scope.row.brokerageTotal }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="待提现" align="center" prop="withdrawTotal">
  72. <template slot-scope="scope">
  73. <span v-if="scope.row.withdrawTotal">¥{{ scope.row.withdrawTotal }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="状态" align="center">
  77. <template slot-scope="scope">
  78. <el-switch
  79. @change="ionlineApi(scope.row)"
  80. v-model="scope.row.switchValue"
  81. :active-value="1"
  82. active-color="#13ce66"
  83. inactive-color="#ff4949">
  84. </el-switch>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="添加时间" align="center" prop="createTime" width="160">
  88. <template slot-scope="scope">
  89. <span>{{ parseTime(scope.row.createTime) }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
  93. <template slot-scope="scope">
  94. <el-button
  95. size="mini"
  96. type="text"
  97. @click="handleUpdate(scope.row)"
  98. v-hasPermi="['personnelMr:personnelMr:edit']"
  99. >修改</el-button>
  100. <el-button
  101. size="mini"
  102. type="text"
  103. @click="resettingApi(scope.row)"
  104. v-hasPermi="['personnelMr:personnelMr:resetting']"
  105. >重置密码</el-button>
  106. <el-button
  107. size="mini"
  108. type="text"
  109. @click="handleDelete(scope.row,scope.index)"
  110. v-hasPermi="['personnelMr:personnelMr:delete']"
  111. >删除</el-button>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. v-show="total>0"
  117. :total="total"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. <!-- 新增/编辑弹框 -->
  123. <add-and-edit
  124. ref="addAndEdit"
  125. :dict="dict"
  126. @getList="getList"
  127. />
  128. <el-dialog
  129. title="查看"
  130. :visible.sync="visibleStatus"
  131. width="600px"
  132. :destroy-on-close="true"
  133. :close-on-click-modal="false"
  134. >
  135. <div v-if="visibleType == 'img'">
  136. <el-image
  137. style="width: 400px; height: 100%"
  138. :src="newObj.mainImg"
  139. fit="cover"
  140. />
  141. </div>
  142. <div v-if="visibleType == 'html'">
  143. <div v-html="newObj.centent"></div>
  144. </div>
  145. <div slot="footer" class="dialog-footer">
  146. <el-button type="primary" @click="visibleStatus = false">确 定</el-button>
  147. </div>
  148. </el-dialog>
  149. <el-dialog
  150. title="提现设置"
  151. :visible.sync="setStatus"
  152. width="600px"
  153. :destroy-on-close="true"
  154. :close-on-click-modal="false"
  155. >
  156. <el-form :model="setForm" ref="setForm" label-width="120px">
  157. <el-form-item label="类型:">
  158. <el-radio v-model="setForm.type" label="1">按实值</el-radio>
  159. <el-radio v-model="setForm.type" label="2">按比例</el-radio>
  160. </el-form-item>
  161. <el-form-item label="提现手续费">
  162. <el-input
  163. type="number"
  164. v-model="setForm.serviceCharge"
  165. placeholder=""
  166. clearable
  167. @change="changePriceAmount('serviceCharge')"
  168. style="width: 260px;"
  169. >
  170. <template slot="append">{{ setForm.type == 2 ? '%' : '元' }}</template>
  171. </el-input>
  172. </el-form-item>
  173. <el-form-item label="提现门槛">
  174. <el-input
  175. type="number"
  176. v-model="setForm.withdrawMinMoney"
  177. placeholder=""
  178. clearable
  179. @change="changePriceAmount('withdrawMinMoney')"
  180. style="width: 260px;"
  181. >
  182. </el-input>
  183. <span style="margin-left: 5px">元以上方可提现</span>
  184. </el-form-item>
  185. </el-form>
  186. <div slot="footer" class="dialog-footer">
  187. <el-button @click="setStatus = false">取消</el-button>
  188. <el-button
  189. type="primary"
  190. @click="submitForm"
  191. v-loading.fullscreen.lock="setLoading"
  192. element-loading-text="提交中..."
  193. element-loading-spinner="el-icon-loading"
  194. element-loading-background="rgba(0, 0, 0, 0.8)"
  195. >
  196. <span v-if="loading">提交中...</span>
  197. <span v-else>保存</span>
  198. </el-button>
  199. </div>
  200. </el-dialog>
  201. </div>
  202. </template>
  203. <script>
  204. import { pageList, deleteById, updateStatus, configUpdate, getSetInfo } from '@/api/distribution/personnelMr'
  205. import addAndEdit from "./dialog/addAndEdit.vue";
  206. export default {
  207. name: "agreement",
  208. dicts: ['distribution_type'],
  209. components: { addAndEdit },
  210. data() {
  211. return {
  212. // 遮罩层
  213. loading: true,
  214. // 选中数组
  215. ids: [],
  216. // 非单个禁用
  217. single: true,
  218. // 非多个禁用
  219. multiple: true,
  220. // 显示搜索条件
  221. showSearch: true,
  222. // 总条数
  223. total: 0,
  224. // 用户表格数据
  225. dataList: null,
  226. // 弹出层标题
  227. title: "",
  228. // 是否显示弹出层
  229. open: false,
  230. // 日期范围
  231. dateRange: [],
  232. // 查询参数
  233. queryParams: {
  234. pageNum: 1,
  235. pageSize: 10,
  236. type: undefined
  237. },
  238. statusList: [
  239. {id: 1, name: '未发布', value: 0},
  240. {id: 2, name: '发布', value: 1},
  241. {id: 3, name: '下架', value: 2},
  242. ],
  243. visibleStatus: false,
  244. newObj: {},
  245. visibleType: '',
  246. setStatus: false,
  247. setForm: {},
  248. setRules: [],
  249. setLoading: false,
  250. };
  251. },
  252. created() {
  253. this.getList();
  254. },
  255. methods: {
  256. /** 查询列表 */
  257. getList() {
  258. this.loading = true;
  259. pageList(this.queryParams)
  260. .then(response => {
  261. this.dataList = response.data.rows;
  262. this.dataList.forEach(item =>{
  263. item.switchValue = item.status;
  264. })
  265. this.total = response.data.total;
  266. this.loading = false;
  267. }
  268. );
  269. },
  270. // 取消按钮
  271. cancel() {
  272. this.open = false;
  273. },
  274. /** 搜索按钮操作 */
  275. handleQuery() {
  276. this.queryParams.pageNum = 1;
  277. this.getList();
  278. },
  279. /** 重置按钮操作 */
  280. resetQuery() {
  281. this.dateRange = [];
  282. this.$set(this.queryParams, 'name', '');
  283. this.$set(this.queryParams, 'type', '');
  284. this.queryParams.pageNum = 1;
  285. this.handleQuery();
  286. },
  287. /** 价格输入事件 */
  288. changePriceAmount(key) {
  289. if(this.setForm[key] * 1 < 0){
  290. this.$message.error("输入需大于或等于0!");
  291. this.$set(this.setForm, key, '');
  292. return false
  293. }
  294. },
  295. /** 新增按钮操作 */
  296. handleAdd() {
  297. this.$refs["addAndEdit"].openDialog("新增数据", null);
  298. },
  299. /** 提现设置按钮操作 */
  300. openSet() {
  301. this.setStatus = true
  302. this.getSetApi();
  303. },
  304. /** 修改按钮操作 */
  305. handleUpdate(row) {
  306. this.$refs["addAndEdit"].openDialog("修改数据", row);
  307. },
  308. /** 获取提现设置 */
  309. getSetApi(row) {
  310. getSetInfo().then(response => {
  311. const obj = response.data;
  312. this.$nextTick(() => {
  313. this.$set(this.setForm, 'id', obj.id ? obj.id : '');
  314. this.$set(this.setForm, 'withdrawMinMoney', obj.withdrawMinMoney);
  315. this.$set(this.setForm, 'serviceCharge', obj.serviceCharge);
  316. this.$set(this.setForm, 'type', obj.type ? (obj.type + '') : '1');
  317. });
  318. });
  319. },
  320. /**
  321. * 分析提现
  322. * @date 2023-11-22
  323. * @returns {any}
  324. */
  325. submitForm() {
  326. this.$refs["setForm"].validate(async (valid) => {
  327. if (valid) {
  328. try {
  329. this.setLoading = true;
  330. const { code } = await configUpdate({ ...this.setForm });
  331. if (code === 200) {
  332. this.setLoading = false;
  333. this.$message.success("操作成功!");
  334. this.getList();
  335. this.setStatus = false;
  336. }
  337. } catch (error) {
  338. } finally {
  339. this.setLoading = false;
  340. }
  341. }
  342. });
  343. },
  344. /** 禁用或者启用发布按钮操作 */
  345. ionlineApi(row) {
  346. this.$confirm("是否对分销商名称为" + row.name + "的数据进行" + (row.status == 1 ? '禁用?' : '启用?'), '提示', {
  347. confirmButtonText: '确定',
  348. cancelButtonText: '取消',
  349. type: 'warning'
  350. }).then(() => {
  351. updateStatus({ id: row.id, status: row.status == 1 ? 0 : 1 }).then((res) => {
  352. if (res.code == 200) {
  353. this.$message({
  354. type: 'success',
  355. message: '操作成功!'
  356. });
  357. this.getList();
  358. }
  359. });
  360. }).catch(() => {});
  361. },
  362. /** 置顶或者取消置顶按钮操作 */
  363. resettingApi(row) {
  364. this.$confirm("是否对分销商名称为" + row.name + "的数据进行密码重置,重置后的密码为123456?", '提示', {
  365. confirmButtonText: '确定',
  366. cancelButtonText: '取消',
  367. type: 'warning'
  368. }).then(() => {
  369. updateStatus({ id: row.id, password: '123456' }).then((res) => {
  370. if (res.code == 200) {
  371. this.$message({
  372. type: 'success',
  373. message: '操作成功!'
  374. });
  375. this.getList();
  376. }
  377. });
  378. }).catch(() => {});
  379. },
  380. /** 删除按钮操作 */
  381. handleDelete(row) {
  382. this.$modal.confirm('是否确认删除数据分销商名称为"' + row.name + '"的数据项?').then(function() {
  383. return deleteById(row.id);
  384. }).then(() => {
  385. this.getList();
  386. this.$modal.msgSuccess("删除成功");
  387. }).catch(() => {});
  388. },
  389. /** 查看按钮操作 */
  390. seeCenter(obj, type) {
  391. this.visibleStatus = true
  392. this.visibleType = type;
  393. this.newObj = obj;
  394. }
  395. }
  396. };
  397. </script>