credit_list.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="app-container">
  3. <div v-if="showRecord">
  4. <!-- 筛选条件 -->
  5. <div>
  6. <el-form ref="searchForm" :model="searchForm" label-width="100px" size="mini" label-position="left">
  7. <el-row :gutter="20">
  8. <el-col :xs="24" :sm="12" :lg="6">
  9. <el-form-item label="经销商名称" prop="customerId">
  10. <el-select class="selectStyle" v-model="searchForm.customerId" placeholder="请选择" filterable>
  11. <el-option v-for="v in customerList" :key="v.id" :label="v.name" :value="v.id">
  12. </el-option>
  13. </el-select>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :xs="24" :sm="12" :lg="18">
  17. <el-form-item label="" class="fr">
  18. <el-button size="mini" @click="clearFn">清空</el-button>
  19. <el-button size="mini" type="primary" @click="searchFn">搜索</el-button>
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. </el-form>
  24. </div>
  25. <!-- 按钮 -->
  26. <div class="btn-group clearfix">
  27. <div class="fr">
  28. <ExportButton :exUrl="'/wallet/customer/list/export'" :exParams="exParams" class="exportClass" />
  29. <el-button type="primary" size="mini">打印</el-button>
  30. </div>
  31. </div>
  32. <!-- 列表 -->
  33. <div class="mymain-container">
  34. <div class="table">
  35. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe show-summary :summary-method="getSummaries">
  36. <el-table-column label="序号" align="left" type="index" width="100" show-overflow-tooltip></el-table-column>
  37. <el-table-column align="left" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip>
  38. <template slot-scope="scope">
  39. <CopyButton :copyText="scope.row.customerNumber" />
  40. <span>{{scope.row.customerNumber}}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip>
  44. <template slot-scope="scope">
  45. <CopyButton :copyText="scope.row.customerName" />
  46. <span>{{scope.row.customerName}}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="left" label="关联钱包" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  50. <el-table-column align="right" label="总信用额度" prop="amount" min-width="160" show-overflow-tooltip>
  51. <template slot-scope="scope">
  52. {{
  53. (scope.row.usedCreditAmount + scope.row.freeCreditAmount)
  54. | numToFixed
  55. }}
  56. </template>
  57. </el-table-column>
  58. <el-table-column align="center" label="操作" min-width="160" show-overflow-tooltip>
  59. <template slot-scope="scope">
  60. <el-button type="text" class="textColor" v-if="$checkBtnRole('edit', $route.meta.roles)" @click="editFn(scope.row)">设置额度</el-button>
  61. <el-button type="text" class="textColor" @click="recordFn(scope.row.customerWalletId)">记录</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. </div>
  66. <!-- 分页 -->
  67. <div class="fr">
  68. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 50]" :page-size="10" layout="total, sizes, prev, pager, next, jumper" :total="listTotal">
  69. </el-pagination>
  70. </div>
  71. </div>
  72. </div>
  73. <CreditListDetail :recordsListId="recordsListId" v-else />
  74. <!-- 新增弹窗 -->
  75. <el-dialog title="经销商信用额度管理" :visible.sync="dialogForm" width="30%" :show-close="false" :close-on-click-modal="false">
  76. <el-form ref="addForm" :rules="rules" :model="addForm" label-width="120px">
  77. <el-form-item label="信用变更额度" prop="amount">
  78. <el-input v-model.number="addForm.amount"></el-input>
  79. </el-form-item>
  80. <el-form-item label="开始时间" prop="startTime">
  81. <el-date-picker class="selectStyle" v-model="addForm.startTime" type="date" placeholder="选择日期时间" value-format="yyyy-MM-dd">
  82. </el-date-picker>
  83. </el-form-item>
  84. <el-form-item label="结束时间" prop="endTime">
  85. <el-date-picker class="selectStyle" v-model="addForm.endTime" type="date" placeholder="选择日期时间" value-format="yyyy-MM-dd">
  86. </el-date-picker>
  87. </el-form-item>
  88. </el-form>
  89. <div slot="footer" class="dialog-footer">
  90. <el-button @click="cancelFn">取 消</el-button>
  91. <el-button type="primary" @click="addDataFn">确 定</el-button>
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. import {
  98. getCreditListEdit,
  99. getWalletCustomerList,
  100. getCustomerList,
  101. } from "@/api/finance/credit_list";
  102. import CreditListDetail from "./components/credit_list-detail";
  103. import { downloadFiles } from "@/utils/util";
  104. export default {
  105. components: {
  106. CreditListDetail,
  107. },
  108. data() {
  109. return {
  110. currentPage: 1, // 当前页码
  111. pageSize: 10, // 每页数量
  112. listTotal: 0, // 列表总数
  113. dataList: [], // 列表数据
  114. searchForm: {
  115. customerId: "",
  116. }, //搜索表单
  117. listLoading: false, // 列表加载loading
  118. showRecord: true,
  119. dialogForm: false, //弹窗表单
  120. addForm: {
  121. startTime: "",
  122. endTime: "",
  123. amount: null,
  124. },
  125. data: null,
  126. recordsListId: {}, //记录
  127. customerList: null,
  128. rules: {
  129. startTime: [
  130. { required: true, message: "请选择开始时间", trigger: "blur" },
  131. ],
  132. endTime: [
  133. { required: true, message: "请选择结束时间", trigger: "blur" },
  134. ],
  135. amount: [
  136. {
  137. required: true,
  138. message: "请输入数字",
  139. type: "number",
  140. trigger: "blur",
  141. },
  142. ],
  143. customerId: [
  144. { required: true, message: "请选择经销商", trigger: "blur" },
  145. ],
  146. customerWalletId: [
  147. { required: true, message: "请选择钱包", trigger: "blur" },
  148. ],
  149. },
  150. };
  151. },
  152. computed: {
  153. exParams() {
  154. return {
  155. customerId: this.searchForm.customerId,
  156. type: "COMMONLY",
  157. };
  158. },
  159. },
  160. created() {
  161. this.getDataList({
  162. type: "COMMONLY",
  163. pageSize: this.pageSize,
  164. pageNum: this.currentPage,
  165. });
  166. this.getCustomerData({ pageSize: -1, pageNum: 1 });
  167. },
  168. methods: {
  169. //列表合计
  170. getSummaries(param) {
  171. const { columns, data } = param;
  172. const sums = [];
  173. columns.forEach((column, index) => {
  174. if (index === 0) {
  175. sums[index] = "合计";
  176. }
  177. if (index === 4) {
  178. let map1 = data.map((v) => {
  179. return v.usedCreditAmount + v.freeCreditAmount;
  180. });
  181. sums[index] = map1
  182. .reduce((prev, curr) => {
  183. const value = Number(curr);
  184. if (!isNaN(value)) {
  185. return prev + curr;
  186. } else {
  187. return prev;
  188. }
  189. }, 0)
  190. .toFixed(2);
  191. }
  192. });
  193. return sums;
  194. },
  195. //获取经销商列表
  196. async getCustomerData(data) {
  197. const res = await getCustomerList(data);
  198. console.log(res);
  199. this.customerList = res.data.records;
  200. },
  201. //设置额度
  202. editFn(value) {
  203. this.data = {
  204. customerId: value.customerId,
  205. customerWalletId: value.customerWalletId,
  206. };
  207. this.dialogForm = true;
  208. },
  209. //清空
  210. clearFn() {
  211. this.$refs.searchForm.resetFields();
  212. },
  213. //搜索
  214. searchFn() {
  215. this.getDataList({
  216. ...this.searchForm,
  217. pageSize: this.pageSize,
  218. pageNum: this.currentPage,
  219. type: "COMMONLY",
  220. });
  221. },
  222. // 更改每页数量
  223. handleSizeChange(val) {
  224. this.pageSize = val;
  225. this.currentPage = 1;
  226. this.getDataList({ pageNum: 1, pageSize: this.pageSize });
  227. },
  228. // 更改当前页
  229. handleCurrentChange(val) {
  230. this.currentPage = val;
  231. this.getDataList({ pageNum: val, pageSize: 10 });
  232. },
  233. //列表数据
  234. async getDataList(data) {
  235. const res = await getWalletCustomerList(data);
  236. // console.log(res);
  237. this.dataList = res.data.records;
  238. this.listTotal = res.data.total;
  239. },
  240. //确定
  241. async addDataFn() {
  242. await this.$refs.addForm.validate();
  243. await getCreditListEdit({ ...this.addForm, ...this.data });
  244. this.getDataList({
  245. type: "COMMONLY",
  246. pageSize: this.pageSize,
  247. pageNum: this.currentPage,
  248. });
  249. this.$message.success("设置成功");
  250. this.dialogForm = false;
  251. },
  252. //取消
  253. async cancelFn() {
  254. await this.$refs.addForm.resetFields();
  255. this.dialogForm = false;
  256. },
  257. //记录
  258. recordFn(id) {
  259. console.log(id);
  260. this.recordsListId = id;
  261. this.showRecord = false;
  262. },
  263. },
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. .selectStyle {
  268. width: 100%;
  269. }
  270. .exportClass {
  271. display: inline-block;
  272. margin-right: 10px;
  273. }
  274. </style>