credit_list.vue 10 KB

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