agentrecord.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <basic-container>
  3. <el-dialog @close="dialogShow=false" append-to-body :close-on-click-modal="false" :visible.sync="dialogShow" :destroy-on-close="true"
  4. :title="dialogTitle" width="80%">
  5. <agent-shop v-if="dialogTitle=='代理商户'" ref="refName" :operateId="operateId"></agent-shop>
  6. </el-dialog>
  7. <avue-crud :option="option"
  8. :table-loading="loading"
  9. :data="data"
  10. :page.sync="page"
  11. :permission="permissionList"
  12. :before-open="beforeOpen"
  13. v-model="form"
  14. ref="crud"
  15. @row-update="rowUpdate"
  16. @row-save="rowSave"
  17. @row-del="rowDel"
  18. @search-change="searchChange"
  19. @search-reset="searchReset"
  20. @selection-change="selectionChange"
  21. @current-change="currentChange"
  22. @size-change="sizeChange"
  23. @refresh-change="refreshChange"
  24. @on-load="onLoad">
  25. <template slot-scope="scope" slot="dataInfo">
  26. <div>
  27. 账户余额:
  28. <div
  29. style="background-color: #0baaee;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  30. {{parseFloat(scope.row.balance|0).toFixed(2)}}
  31. </div>
  32. </div>
  33. <div>
  34. 推广数量:
  35. <div
  36. style="background-color: #e15c14;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  37. {{(scope.row.promoteCount|0)}}
  38. </div>
  39. </div>
  40. <!-- <div>-->
  41. <!-- 城市分红:-->
  42. <!-- <div-->
  43. <!-- style="background-color: #ee0e2f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">-->
  44. <!-- {{-->
  45. <!-- (scope.row.agentType==="渠道代理商"?-->
  46. <!-- parseFloat(platformSetting.agentCitySetting.value.promoteRate)-->
  47. <!-- :parseFloat(platformSetting.agentCitySetting.value.cityRate)).toFixed(2)+"%"-->
  48. <!-- }}-->
  49. <!-- </div>-->
  50. <!-- </div>-->
  51. <!-- <div>-->
  52. <!-- 渠道分红:-->
  53. <!-- <div-->
  54. <!-- style="background-color: #ee0e2f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">-->
  55. <!-- {{-->
  56. <!-- (scope.row.agentType==="渠道代理商"?-->
  57. <!-- parseFloat(platformSetting.agentChannelSetting.value.promoteRate)-->
  58. <!-- :parseFloat(platformSetting.agentChannelSetting.value.cityRate)).toFixed(2)+"%"-->
  59. <!-- }}-->
  60. <!-- </div>-->
  61. <!-- </div>-->
  62. </template>
  63. <template slot-scope="scope" slot="menu">
  64. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  65. @click.stop="openDialog(scope.row.accountId,'代理商户')">代理商户
  66. </el-button>
  67. </template>
  68. </avue-crud>
  69. </basic-container>
  70. </template>
  71. <script>
  72. import {getList, getDetail, add, update, remove} from "@/api/ldt_agent/agentrecord";
  73. // import {getList as platformList} from "@/api/ldt_platform/platformsetting";
  74. import {mapGetters} from "vuex";
  75. import agentShop from "./comps/agent-shop"
  76. export default {
  77. components:{agentShop},
  78. data() {
  79. return {
  80. //弹框
  81. dialogShow:false,
  82. operateId: '',
  83. dialogTitle:'',
  84. form: {},
  85. query: {},
  86. loading: true,
  87. platformSetting:{
  88. agentChannelSetting:{
  89. key:"agent_channel_setting",
  90. value:{},
  91. },
  92. agentCitySetting:{
  93. key:"agent_city_setting",
  94. value:{}
  95. }
  96. },
  97. page: {
  98. pageSize: 10,
  99. currentPage: 1,
  100. total: 0
  101. },
  102. selectionList: [],
  103. option: {
  104. height:'auto',
  105. calcHeight: 30,
  106. tip: false,
  107. searchShow: true,
  108. searchMenuSpan: 6,
  109. border: true,
  110. index: true,
  111. viewBtn: true,
  112. delBtn: false,
  113. selection: true,
  114. dialogClickModal: false,
  115. column: [
  116. {
  117. label: "用户ID",
  118. prop: "accountId",
  119. hide: true,
  120. rules: [{
  121. required: true,
  122. message: "请输入用户ID",
  123. trigger: "blur"
  124. }]
  125. },
  126. {
  127. label: "用户",
  128. prop: "accountName",
  129. disabled: true,
  130. rules: [{
  131. required: true,
  132. message: "请输入用户",
  133. trigger: "blur"
  134. }]
  135. },
  136. {
  137. prop: "dataInfo",
  138. slot: true,
  139. width: 250,
  140. display: false,
  141. label: "数据统计"
  142. },
  143. {
  144. label: "代理类型",
  145. prop: "agentType",
  146. rules: [{
  147. required: true,
  148. message: "请输入代理类型",
  149. trigger: "blur"
  150. }]
  151. },
  152. {
  153. label: "代理城市",
  154. prop: "agentArea",
  155. rules: [{
  156. required: false,
  157. message: "请输入代理城市",
  158. trigger: "blur"
  159. }]
  160. },
  161. {
  162. label: "代理商邀请码",
  163. prop: "agentCode",
  164. rules: [{
  165. required: false,
  166. message: "请输入代理商邀请码",
  167. trigger: "blur"
  168. }]
  169. },
  170. {
  171. label: "城市编码",
  172. prop: "areaCode",
  173. rules: [{
  174. required: false,
  175. message: "请输入城市编码",
  176. trigger: "blur"
  177. }]
  178. },
  179. {
  180. label: "是否启用",
  181. prop: "enable",
  182. type: "radio",
  183. search: true,
  184. dicData:[{
  185. label:"是",
  186. value:1
  187. },{
  188. label:"否",
  189. value:0
  190. }],
  191. rules: [{
  192. required: true,
  193. message: "请输入是否启用",
  194. trigger: "blur"
  195. }]
  196. },
  197. {
  198. label: "后台账号",
  199. prop: "userId",
  200. type: "select",
  201. dicUrl: "",
  202. disabled: true,
  203. props: {
  204. label: "account",
  205. value: "id",
  206. desc: "name",
  207. res:"data.records"
  208. },
  209. rules: [{
  210. required: false,
  211. message: "请选择租户",
  212. trigger: "blur"
  213. }]
  214. },
  215. ]
  216. },
  217. data: []
  218. };
  219. },
  220. computed: {
  221. ...mapGetters(["userInfo","permission"]),
  222. permissionList() {
  223. return {
  224. addBtn: this.vaildData(this.permission.agentrecord_add, false),
  225. viewBtn: this.vaildData(this.permission.agentrecord_view, false),
  226. delBtn: this.vaildData(this.permission.agentrecord_delete, false),
  227. editBtn: this.vaildData(this.permission.agentrecord_edit, false)
  228. };
  229. },
  230. ids() {
  231. let ids = [];
  232. this.selectionList.forEach(ele => {
  233. ids.push(ele.id);
  234. });
  235. return ids.join(",");
  236. }
  237. },
  238. created() {
  239. //判断是否是管理员,禁用
  240. const user = this.option.column.find(ele => {
  241. return ele.prop === "userId";
  242. });
  243. user.disabled = this.userInfo.detail.tenantType !== 'ADMIN' && this.userInfo.role_name!=='administrator';
  244. user.dicUrl = this.userInfo.detail.tenantType === 'ADMIN' && this.userInfo.role_name==='administrator'?"/api/blade-user/page?current=1&size=999&deptId=":"";
  245. },
  246. methods: {
  247. openDialog(id,name) {
  248. this.dialogTitle=name
  249. this.operateId = id
  250. this.dialogShow = true
  251. if (this.canReset) {
  252. this.$refs.refName.refreshChange()
  253. }
  254. this.canReset = true
  255. },
  256. rowSave(row, done, loading) {
  257. add(row).then(() => {
  258. this.onLoad(this.page);
  259. this.$message({
  260. type: "success",
  261. message: "操作成功!"
  262. });
  263. done();
  264. }, error => {
  265. loading();
  266. window.console.log(error);
  267. });
  268. },
  269. rowUpdate(row, index, done, loading) {
  270. update(row).then(() => {
  271. this.onLoad(this.page);
  272. this.$message({
  273. type: "success",
  274. message: "操作成功!"
  275. });
  276. done();
  277. }, error => {
  278. loading();
  279. console.log(error);
  280. });
  281. },
  282. rowDel(row) {
  283. this.$confirm("确定将选择数据删除?", {
  284. confirmButtonText: "确定",
  285. cancelButtonText: "取消",
  286. type: "warning"
  287. })
  288. .then(() => {
  289. return remove(row.id);
  290. })
  291. .then(() => {
  292. this.onLoad(this.page);
  293. this.$message({
  294. type: "success",
  295. message: "操作成功!"
  296. });
  297. });
  298. },
  299. handleDelete() {
  300. if (this.selectionList.length === 0) {
  301. this.$message.warning("请选择至少一条数据");
  302. return;
  303. }
  304. this.$confirm("确定将选择数据删除?", {
  305. confirmButtonText: "确定",
  306. cancelButtonText: "取消",
  307. type: "warning"
  308. })
  309. .then(() => {
  310. return remove(this.ids);
  311. })
  312. .then(() => {
  313. this.onLoad(this.page);
  314. this.$message({
  315. type: "success",
  316. message: "操作成功!"
  317. });
  318. this.$refs.crud.toggleSelection();
  319. });
  320. },
  321. beforeOpen(done, type) {
  322. if (["edit", "view"].includes(type)) {
  323. getDetail(this.form.id).then(res => {
  324. this.form = res.data.data;
  325. });
  326. }
  327. done();
  328. },
  329. searchReset() {
  330. this.query = {};
  331. this.onLoad(this.page);
  332. },
  333. searchChange(params, done) {
  334. this.query = params;
  335. this.page.currentPage = 1;
  336. this.onLoad(this.page, params);
  337. done();
  338. },
  339. selectionChange(list) {
  340. this.selectionList = list;
  341. },
  342. selectionClear() {
  343. this.selectionList = [];
  344. this.$refs.crud.toggleSelection();
  345. },
  346. currentChange(currentPage){
  347. this.page.currentPage = currentPage;
  348. },
  349. sizeChange(pageSize){
  350. this.page.pageSize = pageSize;
  351. },
  352. refreshChange() {
  353. this.onLoad(this.page, this.query);
  354. },
  355. onLoad(page, params = {}) {
  356. this.query.accountId = this.operateId;
  357. this.loading = true;
  358. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  359. const data = res.data.data;
  360. this.page.total = data.total;
  361. this.data = data.records;
  362. this.loading = false;
  363. this.selectionClear();
  364. });
  365. },
  366. }
  367. };
  368. </script>
  369. <style>
  370. </style>