dealer_deposit.vue 17 KB

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