dealer_deposit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. ></el-popconfirm
  141. >
  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 v-model.number="dialogForm.rate" class="inputStyle">
  192. <i class="el-input__icon" slot="suffix">% </i>
  193. </el-input>
  194. </el-form-item>
  195. <el-form-item label="押金定额金额" prop="amount">
  196. <el-input
  197. v-model.number="dialogForm.amount"
  198. class="inputStyle"
  199. ></el-input>
  200. </el-form-item>
  201. <el-form-item label="开始时间" prop="startTime">
  202. <el-date-picker
  203. class="inputStyle"
  204. v-model="dialogForm.startTime"
  205. type="datetime"
  206. placeholder="选择日期时间"
  207. default-time="00:00:00"
  208. value-format="yyyy-MM-dd HH:mm:ss"
  209. >
  210. </el-date-picker>
  211. </el-form-item>
  212. <el-form-item label="结束时间" prop="endTime">
  213. <el-date-picker
  214. class="inputStyle"
  215. v-model="dialogForm.endTime"
  216. type="datetime"
  217. placeholder="选择日期时间"
  218. default-time="23:59:59"
  219. value-format="yyyy-MM-dd HH:mm:ss"
  220. >
  221. </el-date-picker>
  222. </el-form-item>
  223. <el-form-item label="备注" prop="remark">
  224. <el-input
  225. type="textarea"
  226. v-model="dialogForm.remark"
  227. placeholder="请输入备注信息"
  228. class="inputStyle"
  229. ></el-input>
  230. </el-form-item>
  231. </el-form>
  232. <div slot="footer" class="dialog-footer">
  233. <el-button @click="cancelFn">取 消</el-button>
  234. <el-button type="primary" @click="addDataListFn">确 定</el-button>
  235. </div>
  236. </el-dialog>
  237. </div>
  238. </template>
  239. <script>
  240. import {
  241. getDealerDepositList,
  242. getDealerDepositAdd,
  243. getDealerList,
  244. deleDealerDeposit,
  245. editDealerDeposit,
  246. infoDealerDeposit,
  247. } from "@/api/basic_data/dealer";
  248. import { number } from "echarts";
  249. export default {
  250. data() {
  251. // var amount = (rule, value, callback) => {
  252. // console.log(rule, value);
  253. // console.log(this.dialogForm);
  254. // if (this.dialogForm.rate !== 0) {
  255. // this.$message.warning("已选押金比例,如需选择定额押金,请把押金比例归零");
  256. // // callback(new Error("已选押金比例,如需选择定额押金,请把押金比例归零"));
  257. // } else {
  258. // callback();
  259. // }
  260. // };
  261. // var rate = (rule, value, callback) => {
  262. // console.log(rule, value);
  263. // console.log(this.dialogForm);
  264. // if (this.dialogForm.amount !== 0) {
  265. // this.$message.warning("已选定额押金,如需选择押金比例,请把定额押金归零");
  266. // // callback(new Error("已选定额押金,如需选择押金比例,请把定额押金归零"));
  267. // } else {
  268. // callback();
  269. // }
  270. // };
  271. return {
  272. title: "",
  273. currentPage: 1, // 当前页码
  274. pageSize: 10, // 每页数量
  275. listTotal: 0, // 列表
  276. listLoading: false, // 列表加载loading
  277. searchForm: {
  278. customerName: "",
  279. },
  280. dialogForm: {
  281. amount: "",
  282. customerId: "",
  283. customerName: "",
  284. customerNumber: "",
  285. endTime: "",
  286. rate: "",
  287. remark: "",
  288. startTime: "",
  289. },
  290. rules: {
  291. rate: [
  292. {
  293. pattern: /^(?:[1-9]?\d|100)$/,
  294. message: "请输入0-100的数字",
  295. trigger: "blur",
  296. type: "number",
  297. required: true,
  298. },
  299. // {
  300. // validator: rate,
  301. // trigger: "blur",
  302. // },
  303. ],
  304. amount: [
  305. {
  306. trigger: "blur",
  307. message: "请输入定额押金",
  308. type: "number",
  309. required: true,
  310. },
  311. // {
  312. // validator: amount,
  313. // trigger: "blur",
  314. // },
  315. ],
  316. customerId: [
  317. {
  318. message: "请选择经销商名称",
  319. trigger: "blur",
  320. required: true,
  321. },
  322. ],
  323. startTime: [
  324. {
  325. message: "请选择开始时间",
  326. trigger: "blur",
  327. required: true,
  328. },
  329. ],
  330. endTime: [
  331. {
  332. message: "请选择结束时间",
  333. trigger: "blur",
  334. required: true,
  335. },
  336. ],
  337. },
  338. showDialog: false,
  339. dataList: [],
  340. dealerList: [],
  341. };
  342. },
  343. async created() {
  344. await this.getList({ pageNum: 1, pageSize: 10 });
  345. await this.getDealerDataList({ pageNum: 1, pageSize: 10 });
  346. },
  347. methods: {
  348. //取消
  349. async cancelFn() {
  350. await this.$refs.dialogForm.resetFields();
  351. this.showDialog = false;
  352. },
  353. //编辑
  354. async editFn(id) {
  355. console.log(id);
  356. this.title = "编辑经销商工程机配置";
  357. const res = await infoDealerDeposit({ id });
  358. this.dialogForm = res.data;
  359. this.dialogForm.rate = parseInt(res.data.rate * 100);
  360. this.showDialog = true;
  361. },
  362. //删除
  363. async deleFn(id) {
  364. await deleDealerDeposit({ id });
  365. this.$message.success("删除成功");
  366. this.getList({ pageNum: 1, pageSize: 10 });
  367. },
  368. //获取经销商数据
  369. async getDealerDataList(data) {
  370. const res = await getDealerList(data);
  371. this.dealerList = res.data.records;
  372. },
  373. // 更改每页数量
  374. handleSizeChange(val) {
  375. this.pageSize = val;
  376. this.currentPage = 1;
  377. this.getList({ pageNum: 1, pageSize: this.pageSize });
  378. },
  379. // 更改当前页
  380. handleCurrentChange(val) {
  381. this.currentPage = val;
  382. this.getList({ pageNum: val, pageSize: 10 });
  383. },
  384. //搜索功能
  385. async searchFn() {
  386. console.log(this.searchForm);
  387. await this.getList({
  388. keyword: this.searchForm.customerName,
  389. pageNum: 1,
  390. pageSize: 10,
  391. });
  392. },
  393. //重置
  394. clearFn() {
  395. console.log(this.$refs.searchForm);
  396. this.$refs.searchForm.resetFields();
  397. },
  398. //获取列表数据
  399. async getList(data) {
  400. const res = await getDealerDepositList(data);
  401. console.log(res);
  402. this.dataList = res.data.records;
  403. this.listTotal = res.data.total;
  404. },
  405. async addDataListFn() {
  406. await this.$refs.dialogForm.validate();
  407. // if (this.dialogForm.rate !== 0) {
  408. // this.dialogForm.amount = 0;
  409. // }
  410. // if (this.dialogForm.amount !== 0) {
  411. // this.dialogForm.rate = 0;
  412. // }
  413. let res = this.dealerList.filter(
  414. (v) => v.id === this.dialogForm.customerId
  415. )[0];
  416. this.dialogForm.customerName = res.name;
  417. this.dialogForm.customerNumber = res.number;
  418. if (this.dialogForm.id) {
  419. await editDealerDeposit({
  420. ...this.dialogForm,
  421. rate: this.dialogForm.rate / 100,
  422. });
  423. this.$message.success("编辑成功");
  424. } else {
  425. await getDealerDepositAdd({
  426. ...this.dialogForm,
  427. rate: Number(this.dialogForm.rate / 100),
  428. amount: Number(this.dialogForm.amount),
  429. });
  430. this.$message.success("添加成功");
  431. }
  432. this.dialogForm = {
  433. amount: 0,
  434. customerId: "",
  435. customerName: "",
  436. customerNumber: "",
  437. endTime: "",
  438. rate: 0,
  439. remark: "",
  440. startTime: "",
  441. };
  442. this.getList({ pageNum: 1, pageSize: 10 });
  443. this.showDialog = false;
  444. },
  445. addFn() {
  446. this.title = "新增经销商工程机配置";
  447. this.showDialog = true;
  448. },
  449. },
  450. };
  451. </script>
  452. <style lang="scss" scoped>
  453. ::v-deep .el-textarea__inner {
  454. resize: none;
  455. }
  456. ::v-deep .el-form {
  457. .inputStyle {
  458. width: 80%;
  459. }
  460. }
  461. ::v-deep .dialog-footer {
  462. display: flex;
  463. justify-content: center;
  464. }
  465. ::v-deep .el-dialog__header {
  466. background-color: #dddddd;
  467. }
  468. .inp {
  469. margin: 0 12px;
  470. }
  471. .right {
  472. margin-top: 12px;
  473. float: right;
  474. }
  475. .table {
  476. margin-top: 12px;
  477. }
  478. .search {
  479. display: flex;
  480. margin-top: 12px;
  481. ::v-deep .el-input {
  482. width: 50%;
  483. margin-right: 12px;
  484. }
  485. }
  486. // .main {
  487. // padding: 12px;
  488. // }
  489. </style>>