dealer_deposit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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="160"
  149. show-overflow-tooltip
  150. >
  151. <template slot-scope="scope">
  152. <el-button
  153. type="text"
  154. class="textColor"
  155. @click="editFn(scope.row.id)"
  156. >编辑</el-button
  157. >
  158. <el-popconfirm
  159. @onConfirm="deleFn(scope.row.id)"
  160. title="这是一段内容确定删除吗?"
  161. >
  162. <el-button type="text" class="textColor" slot="reference"
  163. >删除</el-button
  164. >
  165. </el-popconfirm>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. </div>
  170. <!-- 分页 -->
  171. <div class="fr">
  172. <el-pagination
  173. @size-change="handleSizeChange"
  174. @current-change="handleCurrentChange"
  175. :current-page="currentPage"
  176. :page-sizes="[10, 20, 30, 50]"
  177. :page-size="10"
  178. layout="total, sizes, prev, pager, next, jumper"
  179. :total="listTotal"
  180. >
  181. </el-pagination>
  182. </div>
  183. </div>
  184. <!-- 弹窗 -->
  185. <el-dialog
  186. :title="title"
  187. :visible.sync="showDialog"
  188. width="30%"
  189. :show-close="false"
  190. :close-on-click-modal="false"
  191. >
  192. <el-form
  193. ref="dialogForm"
  194. :model="dialogForm"
  195. :rules="rules"
  196. label-width="110px"
  197. label-position="right"
  198. >
  199. <el-form-item label="经销商名称" prop="customerId">
  200. <el-select
  201. class="inputStyle"
  202. v-model="dialogForm.customerId"
  203. placeholder="请选择"
  204. filterable
  205. >
  206. <el-option
  207. v-for="item in dealerList"
  208. :key="item.id"
  209. :label="item.name"
  210. :value="item.id"
  211. >
  212. </el-option>
  213. </el-select>
  214. </el-form-item>
  215. <el-form-item label="押金比例" prop="rate">
  216. <el-input
  217. placeholder="请输入押金比例"
  218. v-model.number="dialogForm.rate"
  219. class="inputStyle"
  220. >
  221. <i class="el-input__icon" slot="suffix">% </i>
  222. </el-input>
  223. </el-form-item>
  224. <el-form-item label="" prop="">
  225. <el-slider
  226. class="inputStyle"
  227. v-model="dialogForm.rate"
  228. :marks="marks"
  229. >
  230. </el-slider>
  231. </el-form-item>
  232. <el-form-item label="押金定额金额" prop="amount">
  233. <el-input
  234. placeholder="请输入押金定额"
  235. v-model.number="dialogForm.amount"
  236. class="inputStyle"
  237. ></el-input>
  238. </el-form-item>
  239. <el-form-item label="开始时间" prop="startTime">
  240. <el-date-picker
  241. class="inputStyle"
  242. v-model="dialogForm.startTime"
  243. type="datetime"
  244. placeholder="选择日期时间"
  245. default-time="00:00:00"
  246. value-format="yyyy-MM-dd HH:mm:ss"
  247. >
  248. </el-date-picker>
  249. </el-form-item>
  250. <el-form-item label="结束时间" prop="endTime">
  251. <el-date-picker
  252. class="inputStyle"
  253. v-model="dialogForm.endTime"
  254. type="datetime"
  255. placeholder="选择日期时间"
  256. default-time="23:59:59"
  257. value-format="yyyy-MM-dd HH:mm:ss"
  258. >
  259. </el-date-picker>
  260. </el-form-item>
  261. <el-form-item label="备注" prop="remark">
  262. <el-input
  263. type="textarea"
  264. v-model="dialogForm.remark"
  265. placeholder="请输入备注信息"
  266. class="inputStyle"
  267. ></el-input>
  268. </el-form-item>
  269. </el-form>
  270. <div slot="footer" class="dialog-footer">
  271. <el-button @click="cancelFn">取 消</el-button>
  272. <el-button type="primary" @click="addDataListFn">确 定</el-button>
  273. </div>
  274. </el-dialog>
  275. </div>
  276. </template>
  277. <script>
  278. import {
  279. getDealerDepositList,
  280. getDealerDepositAdd,
  281. getDealerList,
  282. deleDealerDeposit,
  283. editDealerDeposit,
  284. infoDealerDeposit,
  285. } from "@/api/basic_data/dealer";
  286. import { number } from "echarts";
  287. export default {
  288. data() {
  289. return {
  290. marks: {
  291. 0: "0%",
  292. 20: "20%",
  293. 40: "40%",
  294. 60: "60%",
  295. 80: "80%",
  296. 100: {
  297. style: {
  298. width: "36px",
  299. },
  300. label: this.$createElement("div", "100%"),
  301. },
  302. },
  303. title: "",
  304. currentPage: 1, // 当前页码
  305. pageSize: 10, // 每页数量
  306. listTotal: 0, // 列表
  307. listLoading: false, // 列表加载loading
  308. searchForm: {
  309. customerName: "",
  310. },
  311. dialogForm: {
  312. amount: 0,
  313. customerId: "",
  314. customerName: "",
  315. customerNumber: "",
  316. endTime: "",
  317. rate: 0,
  318. remark: "",
  319. startTime: "",
  320. },
  321. rules: {
  322. rate: [
  323. {
  324. pattern: /^(?:[1-9]?\d|100)$/,
  325. message: "请输入0-100的数字",
  326. trigger: "blur",
  327. type: "number",
  328. required: false,
  329. },
  330. // {
  331. // validator: rate,
  332. // trigger: "blur",
  333. // },
  334. ],
  335. amount: [
  336. {
  337. trigger: "blur",
  338. message: "请输入定额押金",
  339. type: "number",
  340. required: false,
  341. },
  342. // {
  343. // validator: amount,
  344. // trigger: "blur",
  345. // },
  346. ],
  347. customerId: [
  348. {
  349. message: "请选择经销商名称",
  350. trigger: "blur",
  351. required: true,
  352. },
  353. ],
  354. startTime: [
  355. {
  356. message: "请选择开始时间",
  357. trigger: "blur",
  358. required: true,
  359. },
  360. ],
  361. endTime: [
  362. {
  363. message: "请选择结束时间",
  364. trigger: "blur",
  365. required: true,
  366. },
  367. ],
  368. },
  369. showDialog: false,
  370. dataList: [],
  371. dealerList: [],
  372. };
  373. },
  374. async created() {
  375. await this.getList({ pageNum: 1, pageSize: 10 });
  376. await this.getDealerDataList({ pageNum: 1, pageSize: -1 });
  377. },
  378. watch: {
  379. "dialogForm.amount": function (newValue, oldValue) {
  380. if (this.dialogForm.amount !== 0) {
  381. this.dialogForm.rate = 0;
  382. }
  383. },
  384. "dialogForm.rate": function (newValue, oldValue) {
  385. if (this.dialogForm.rate !== 0) {
  386. this.dialogForm.amount = 0;
  387. }
  388. },
  389. },
  390. methods: {
  391. // //押金
  392. // amountFn(e) {
  393. // if (this.dialogForm.rate != 0 || this.dialogForm.rate != "") {
  394. // this.$message.warning("已选押金比例,如需选择定额押金,请把押金比例归零");
  395. // }
  396. // },
  397. // rateFn(e) {
  398. // if (this.dialogForm.amount != 0 || this.dialogForm.amount != "") {
  399. // this.$message.warning("已选定额押金,如需选择押金比例,请把定额押金归零");
  400. // }
  401. // },
  402. //取消
  403. async cancelFn() {
  404. this.dialogForm = {
  405. amount: "",
  406. customerId: "",
  407. customerName: "",
  408. customerNumber: "",
  409. endTime: "",
  410. rate: "",
  411. remark: "",
  412. startTime: "",
  413. };
  414. await this.$refs.dialogForm.resetFields();
  415. this.showDialog = false;
  416. },
  417. //编辑
  418. async editFn(id) {
  419. console.log(id);
  420. this.title = "经销商工程机押金比例设置";
  421. const res = await infoDealerDeposit({ id });
  422. this.dialogForm = res.data;
  423. this.dialogForm.rate = parseInt(res.data.rate * 100);
  424. this.showDialog = true;
  425. },
  426. //删除
  427. async deleFn(id) {
  428. await deleDealerDeposit({ id });
  429. this.$message.success("删除成功");
  430. this.getList({ pageNum: 1, pageSize: 10 });
  431. },
  432. //获取经销商数据
  433. async getDealerDataList(data) {
  434. const res = await getDealerList(data);
  435. this.dealerList = res.data.records;
  436. },
  437. // 更改每页数量
  438. handleSizeChange(val) {
  439. this.pageSize = val;
  440. this.currentPage = 1;
  441. this.getList({ pageNum: 1, pageSize: this.pageSize });
  442. },
  443. // 更改当前页
  444. handleCurrentChange(val) {
  445. this.currentPage = val;
  446. this.getList({ pageNum: val, pageSize: 10 });
  447. },
  448. //搜索功能
  449. async searchFn() {
  450. console.log(this.searchForm);
  451. await this.getList({
  452. keyword: this.searchForm.customerName,
  453. pageNum: 1,
  454. pageSize: 10,
  455. });
  456. },
  457. //重置
  458. clearFn() {
  459. console.log(this.$refs.searchForm);
  460. this.$refs.searchForm.resetFields();
  461. },
  462. //获取列表数据
  463. async getList(data) {
  464. const res = await getDealerDepositList(data);
  465. console.log(res);
  466. this.dataList = res.data.records;
  467. this.listTotal = res.data.total;
  468. },
  469. async addDataListFn() {
  470. await this.$refs.dialogForm.validate();
  471. // if (this.dialogForm.rate !== 0) {
  472. // this.dialogForm.amount = 0;
  473. // }
  474. // if (this.dialogForm.amount !== 0) {
  475. // this.dialogForm.rate = 0;
  476. // }
  477. let res = this.dealerList.filter(
  478. (v) => v.id === this.dialogForm.customerId
  479. )[0];
  480. this.dialogForm.customerName = res.name;
  481. this.dialogForm.customerNumber = res.number;
  482. if (this.dialogForm.id) {
  483. await editDealerDeposit({
  484. ...this.dialogForm,
  485. rate: this.dialogForm.rate / 100,
  486. });
  487. this.$message.success("编辑成功");
  488. } else {
  489. await getDealerDepositAdd({
  490. ...this.dialogForm,
  491. rate: Number(this.dialogForm.rate / 100),
  492. amount: Number(this.dialogForm.amount),
  493. });
  494. this.$message.success("添加成功");
  495. }
  496. this.dialogForm = {
  497. amount: 0,
  498. customerId: "",
  499. customerName: "",
  500. customerNumber: "",
  501. endTime: "",
  502. rate: 0,
  503. remark: "",
  504. startTime: "",
  505. };
  506. this.getList({ pageNum: 1, pageSize: 10 });
  507. this.showDialog = false;
  508. },
  509. addFn() {
  510. this.title = "经销商工程机押金比例设置";
  511. this.showDialog = true;
  512. },
  513. },
  514. };
  515. </script>
  516. <style lang="scss" scoped>
  517. ::v-deep .el-textarea__inner {
  518. resize: none;
  519. }
  520. ::v-deep .el-form {
  521. .inputStyle {
  522. width: 80%;
  523. }
  524. }
  525. ::v-deep .dialog-footer {
  526. display: flex;
  527. justify-content: center;
  528. }
  529. ::v-deep .el-dialog__header {
  530. background-color: #dddddd;
  531. }
  532. .inp {
  533. margin: 0 12px;
  534. }
  535. .right {
  536. margin-top: 12px;
  537. float: right;
  538. }
  539. .table {
  540. margin-top: 12px;
  541. }
  542. .search {
  543. display: flex;
  544. margin-top: 12px;
  545. ::v-deep .el-input {
  546. width: 50%;
  547. margin-right: 12px;
  548. }
  549. }
  550. // .main {
  551. // padding: 12px;
  552. // }
  553. </style>
  554. >