dealer_deposit.vue 13 KB

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