dealer_deposit.vue 15 KB

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