dealer_deposit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div class="app-container">
  3. <div v-if="showHistory">
  4. <!-- <el-card class="box-card">
  5. <el-row>
  6. <h4>通用经销商工程机押金比例配置</h4>
  7. <h4>
  8. 工程机押金比例配置
  9. <input
  10. type="text"
  11. class="inp"
  12. />%通用工程押金比例配置适用于,没有单独配置工程机押金比例的经销商.
  13. </h4>
  14. </el-row>
  15. </el-card> -->
  16. <!-- 筛选条件 -->
  17. <div>
  18. <el-form ref="searchForm" :model="searchForm" label-width="100px" size="mini" label-position="left">
  19. <el-row :gutter="20">
  20. <el-col :xs="24" :sm="12" :lg="6">
  21. <el-form-item label="经销商名称" prop="customerName">
  22. <el-input v-model="searchForm.customerName" placeholder="请输入经销商名称"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :xs="24" :sm="12" :lg="6">
  26. <el-form-item label="状态" prop="currentStatus">
  27. <el-select class="selectStyle" v-model="searchForm.currentStatus" placeholder="请选择">
  28. <el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="12">
  34. <el-form-item label="" class="fr">
  35. <el-button size="mini" @click="clearFn">清空</el-button>
  36. <el-button size="mini" type="primary" @click="searchFn">搜索</el-button>
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. </el-form>
  41. </div>
  42. <!-- 按钮 -->
  43. <div class="btn-group clearfix">
  44. <div class="fl">
  45. <el-button v-if="$checkBtnRole('add', $route.meta.roles)" type="primary" size="mini" @click="addFn">新增</el-button>
  46. </div>
  47. <div class="fr">
  48. <el-button type="primary" size="mini" @click="downLoadFn">模板</el-button>
  49. <el-upload class="import-btn" action="" :http-request="handleImport" :file-list="importFileList" :show-file-list="false">
  50. <el-button type="primary" size="mini">批量导入</el-button>
  51. </el-upload>
  52. </div>
  53. </div>
  54. <div class="mymain-container">
  55. <!-- 列表 -->
  56. <div class="table">
  57. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  58. <el-table-column align="left" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip>
  59. <template slot-scope="scope">
  60. <CopyButton :copyText="scope.row.customerNumber" />
  61. <span>{{scope.row.customerNumber}}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="260" show-overflow-tooltip>
  65. <template slot-scope="scope">
  66. <CopyButton :copyText="scope.row.customerName" />
  67. <span>{{scope.row.customerName}}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column align="left" label="押金比例" prop="rate" min-width="100" show-overflow-tooltip />
  71. <el-table-column align="left" label="押金" prop="amount" min-width="100" show-overflow-tooltip />
  72. <el-table-column align="left" label="状态" prop="currentStatus" min-width="100" show-overflow-tooltip>
  73. <template slot-scope="scope">
  74. <el-tag type="info" v-if="scope.row.currentStatus == '未开始'">未开始</el-tag>
  75. <el-tag type="success" v-if="scope.row.currentStatus == '生效中'">生效中</el-tag>
  76. <el-tag type="danger" v-if="scope.row.currentStatus == '已结束'">已结束</el-tag>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="left" label="开始时间" prop="startTime" min-width="160" show-overflow-tooltip />
  80. <el-table-column align="left" label="结束时间" prop="endTime" min-width="160" show-overflow-tooltip />
  81. <el-table-column align="left" label="备注" prop="remark" min-width="160" show-overflow-tooltip />
  82. <el-table-column align="left" label="创建人" prop="createBy" min-width="160" show-overflow-tooltip />
  83. <el-table-column align="left" label="创建时间" prop="createTime" min-width="160" show-overflow-tooltip />
  84. <el-table-column align="left" label="更新人" prop="updateBy" min-width="160" show-overflow-tooltip />
  85. <el-table-column align="left" label="更新时间" prop="updateTime" min-width="160" show-overflow-tooltip />
  86. <el-table-column align="center" label="操作" min-width="200" show-overflow-tooltip fixed="right">
  87. <template slot-scope="scope">
  88. <el-button type="text" class="textColor" v-if="$checkBtnRole('edit', $route.meta.roles)" @click="editFn(scope.row.id)">编辑</el-button>
  89. <el-button type="text" class="textColor" @click="logFn(scope.row.id)">记录</el-button>
  90. <el-popconfirm @onConfirm="deleFn(scope.row.id)" v-if="$checkBtnRole('del', $route.meta.roles)" title="这是一段内容确定删除吗?">
  91. <el-button type="text" class="textColor" slot="reference">删除</el-button>
  92. </el-popconfirm>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. </div>
  97. <!-- 分页 -->
  98. <div class="fr">
  99. <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">
  100. </el-pagination>
  101. </div>
  102. </div>
  103. <!-- 弹窗 -->
  104. <el-dialog :title="title" :visible.sync="showDialog" width="30%" :show-close="false" :close-on-click-modal="false">
  105. <el-form ref="dialogForm" :model="dialogForm" :rules="rules" label-width="110px" label-position="right">
  106. <el-form-item label="经销商名称" prop="customerId">
  107. <el-select class="inputStyle" v-model="dialogForm.customerId" placeholder="请选择" filterable>
  108. <el-option v-for="item in dealerList" :key="item.id" :label="item.name" :value="item.id">
  109. </el-option>
  110. </el-select>
  111. </el-form-item>
  112. <el-form-item label="押金比例" prop="rate">
  113. <el-input placeholder="请输入押金比例" v-model.number="dialogForm.rate" class="inputStyle">
  114. <i class="el-input__icon" slot="suffix">% </i>
  115. </el-input>
  116. </el-form-item>
  117. <el-form-item label="" prop="">
  118. <el-slider class="inputStyle" v-model="dialogForm.rate" :marks="marks">
  119. </el-slider>
  120. </el-form-item>
  121. <el-form-item label="押金定额金额" prop="amount">
  122. <el-input placeholder="请输入押金定额" v-model.number="dialogForm.amount" class="inputStyle"></el-input>
  123. </el-form-item>
  124. <el-form-item label="开始时间" prop="startTime">
  125. <el-date-picker class="inputStyle" v-model="dialogForm.startTime" type="datetime" placeholder="选择日期时间" default-time="00:00:00" value-format="yyyy-MM-dd HH:mm:ss">
  126. </el-date-picker>
  127. </el-form-item>
  128. <el-form-item label="结束时间" prop="">
  129. <el-date-picker class="inputStyle" v-model="dialogForm.endTime" type="datetime" placeholder="选择日期时间" default-time="23:59:59" value-format="yyyy-MM-dd HH:mm:ss">
  130. </el-date-picker>
  131. </el-form-item>
  132. <el-form-item label="备注" prop="remark">
  133. <el-input type="textarea" v-model="dialogForm.remark" placeholder="请输入备注信息" class="inputStyle"></el-input>
  134. </el-form-item>
  135. </el-form>
  136. <div slot="footer" class="dialog-footer">
  137. <el-button @click="cancelFn">取 消</el-button>
  138. <el-button type="primary" @click="addDataListFn">确 定</el-button>
  139. </div>
  140. </el-dialog>
  141. </div>
  142. <!-- 记录页面 -->
  143. <DealerDepositHistory :historyId="historyId" v-else />
  144. </div>
  145. </template>
  146. <script>
  147. import {
  148. getDealerDepositList,
  149. getDealerDepositAdd,
  150. getDealerList,
  151. deleDealerDeposit,
  152. editDealerDeposit,
  153. infoDealerDeposit,
  154. } from "@/api/basic_data/dealer";
  155. // import { number } from "echarts";
  156. import DealerDepositHistory from "./components/dealer_deposit_history";
  157. import { downloadFiles, handleImport } from "@/utils/util";
  158. export default {
  159. components: {
  160. DealerDepositHistory,
  161. },
  162. data() {
  163. return {
  164. importFileList: [],
  165. historyId: "",
  166. showHistory: true,
  167. marks: {
  168. 0: "0%",
  169. 20: "20%",
  170. 40: "40%",
  171. 60: "60%",
  172. 80: "80%",
  173. 100: {
  174. style: {
  175. width: "36px",
  176. },
  177. label: this.$createElement("div", "100%"),
  178. },
  179. },
  180. title: "",
  181. currentPage: 1, // 当前页码
  182. pageSize: 10, // 每页数量
  183. listTotal: 0, // 列表
  184. listLoading: false, // 列表加载loading
  185. searchForm: {
  186. customerName: "",
  187. },
  188. dialogForm: {
  189. amount: 0,
  190. customerId: "",
  191. customerName: "",
  192. customerNumber: "",
  193. endTime: "",
  194. rate: 0,
  195. remark: "",
  196. startTime: "",
  197. },
  198. rules: {
  199. rate: [
  200. {
  201. pattern: /^(?:[1-9]?\d|100)$/,
  202. message: "请输入0-100的数字",
  203. trigger: "blur",
  204. type: "number",
  205. required: false,
  206. },
  207. // {
  208. // validator: rate,
  209. // trigger: "blur",
  210. // },
  211. ],
  212. amount: [
  213. {
  214. trigger: "blur",
  215. message: "请输入定额押金",
  216. type: "number",
  217. required: false,
  218. },
  219. // {
  220. // validator: amount,
  221. // trigger: "blur",
  222. // },
  223. ],
  224. customerId: [
  225. {
  226. message: "请选择经销商名称",
  227. trigger: "blur",
  228. required: true,
  229. },
  230. ],
  231. startTime: [
  232. {
  233. message: "请选择开始时间",
  234. trigger: "blur",
  235. required: true,
  236. },
  237. ],
  238. // endTime: [
  239. // {
  240. // message: "请选择结束时间",
  241. // trigger: "blur",
  242. // required: true,
  243. // },
  244. // ],
  245. },
  246. showDialog: false,
  247. dataList: [],
  248. dealerList: [],
  249. statusList: [
  250. {
  251. value: "1",
  252. label: "未开始",
  253. },
  254. {
  255. value: "2",
  256. label: "生效中",
  257. },
  258. {
  259. value: "3",
  260. label: "已结束",
  261. },
  262. ],
  263. currentStatus: "",
  264. };
  265. },
  266. async created() {
  267. await this.getList({ pageNum: 1, pageSize: 10 });
  268. await this.getDealerDataList({ pageNum: 1, pageSize: -1 });
  269. },
  270. watch: {
  271. "dialogForm.amount": function (newValue, oldValue) {
  272. if (this.dialogForm.amount !== 0) {
  273. this.dialogForm.rate = 0;
  274. }
  275. },
  276. "dialogForm.rate": function (newValue, oldValue) {
  277. if (this.dialogForm.rate !== 0) {
  278. this.dialogForm.amount = 0;
  279. }
  280. },
  281. },
  282. methods: {
  283. // //押金
  284. // amountFn(e) {
  285. // if (this.dialogForm.rate != 0 || this.dialogForm.rate != "") {
  286. // this.$message.warning("已选押金比例,如需选择定额押金,请把押金比例归零");
  287. // }
  288. // },
  289. // rateFn(e) {
  290. // if (this.dialogForm.amount != 0 || this.dialogForm.amount != "") {
  291. // this.$message.warning("已选定额押金,如需选择押金比例,请把定额押金归零");
  292. // }
  293. // },
  294. // 导入
  295. async handleImport(param) {
  296. const file = param.file;
  297. const formData = new FormData();
  298. formData.append("file", file);
  299. let result = await handleImport("/customer/deposit/import", formData);
  300. console.log(result);
  301. this.importFileList = [];
  302. if (result.code == 200) {
  303. this.$message.success("导入成功");
  304. } else {
  305. this.$message.error(result.message);
  306. }
  307. },
  308. //下载模板
  309. async downLoadFn() {
  310. downloadFiles("/customer/deposit/downModel");
  311. },
  312. //记录
  313. logFn(id) {
  314. this.historyId = id;
  315. this.showHistory = false;
  316. },
  317. //取消
  318. async cancelFn() {
  319. this.dialogForm = {
  320. amount: 0,
  321. customerId: "",
  322. customerName: "",
  323. customerNumber: "",
  324. endTime: "",
  325. rate: 0,
  326. remark: "",
  327. startTime: "",
  328. };
  329. await this.$refs.dialogForm.resetFields();
  330. this.showDialog = false;
  331. },
  332. //编辑
  333. async editFn(id) {
  334. console.log(id);
  335. this.title = "经销商工程机押金比例设置";
  336. const res = await infoDealerDeposit({ id });
  337. this.dialogForm = res.data;
  338. this.dialogForm.rate = parseInt(res.data.rate * 100);
  339. this.showDialog = true;
  340. },
  341. //删除
  342. async deleFn(id) {
  343. await deleDealerDeposit({ id });
  344. this.$message.success("删除成功");
  345. this.getList({ pageNum: 1, pageSize: 10 });
  346. },
  347. //获取经销商数据
  348. async getDealerDataList(data) {
  349. const res = await getDealerList(data);
  350. this.dealerList = res.data.records;
  351. },
  352. // 更改每页数量
  353. handleSizeChange(val) {
  354. this.pageSize = val;
  355. this.currentPage = 1;
  356. this.getList({
  357. pageNum: 1,
  358. pageSize: this.pageSize,
  359. keyword: this.searchForm.customerName,
  360. currentStatus: this.searchForm.currentStatus,
  361. });
  362. },
  363. // 更改当前页
  364. handleCurrentChange(val) {
  365. this.currentPage = val;
  366. this.getList({
  367. pageNum: val,
  368. pageSize: 10,
  369. keyword: this.searchForm.customerName,
  370. currentStatus: this.searchForm.currentStatus,
  371. });
  372. },
  373. //搜索功能
  374. async searchFn() {
  375. console.log(this.searchForm);
  376. await this.getList({
  377. keyword: this.searchForm.customerName,
  378. currentStatus: this.searchForm.currentStatus,
  379. pageNum: 1,
  380. pageSize: 10,
  381. });
  382. },
  383. //重置
  384. clearFn() {
  385. console.log(this.$refs.searchForm);
  386. this.$refs.searchForm.resetFields();
  387. },
  388. //获取列表数据
  389. async getList(data) {
  390. const res = await getDealerDepositList(data);
  391. console.log(res);
  392. this.dataList = res.data.records;
  393. this.listTotal = res.data.total;
  394. },
  395. async addDataListFn() {
  396. await this.$refs.dialogForm.validate();
  397. // if (this.dialogForm.rate !== 0) {
  398. // this.dialogForm.amount = 0;
  399. // }
  400. // if (this.dialogForm.amount !== 0) {
  401. // this.dialogForm.rate = 0;
  402. // }
  403. let res = this.dealerList.filter(
  404. (v) => v.id === this.dialogForm.customerId
  405. )[0];
  406. this.dialogForm.customerName = res.name;
  407. this.dialogForm.customerNumber = res.number;
  408. if (this.dialogForm.id) {
  409. await editDealerDeposit({
  410. ...this.dialogForm,
  411. rate: this.dialogForm.rate / 100,
  412. });
  413. this.$message.success("编辑成功");
  414. } else {
  415. if (this.dialogForm.endTime === "") {
  416. this.dialogForm.endTime = "2100-01-01 00:00:00";
  417. }
  418. await getDealerDepositAdd({
  419. ...this.dialogForm,
  420. rate: Number(this.dialogForm.rate / 100),
  421. amount: Number(this.dialogForm.amount),
  422. });
  423. this.$message.success("添加成功");
  424. }
  425. this.dialogForm = {
  426. amount: 0,
  427. customerId: "",
  428. customerName: "",
  429. customerNumber: "",
  430. endTime: "",
  431. rate: 0,
  432. remark: "",
  433. startTime: "",
  434. };
  435. this.getList({ pageNum: 1, pageSize: 10 });
  436. this.showDialog = false;
  437. },
  438. addFn() {
  439. this.title = "经销商工程机押金比例设置";
  440. this.showDialog = true;
  441. },
  442. },
  443. };
  444. </script>
  445. <style lang="scss" scoped>
  446. .selectStyle {
  447. width: 100%;
  448. }
  449. ::v-deep .el-textarea__inner {
  450. resize: none;
  451. }
  452. ::v-deep .el-form {
  453. .inputStyle {
  454. width: 80%;
  455. }
  456. }
  457. ::v-deep .dialog-footer {
  458. display: flex;
  459. justify-content: center;
  460. }
  461. ::v-deep .el-dialog__header {
  462. background-color: #dddddd;
  463. }
  464. .inp {
  465. margin: 0 12px;
  466. }
  467. .right {
  468. margin-top: 12px;
  469. float: right;
  470. }
  471. .table {
  472. margin-top: 12px;
  473. }
  474. .search {
  475. display: flex;
  476. margin-top: 12px;
  477. ::v-deep .el-input {
  478. width: 50%;
  479. margin-right: 12px;
  480. }
  481. }
  482. .import-btn {
  483. display: inline-block;
  484. margin-left: 10px;
  485. }
  486. // .main {
  487. // padding: 12px;
  488. // }
  489. </style>
  490. >