warehouse_cost.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div>
  5. <el-form
  6. ref="screenForm"
  7. :model="screenForm"
  8. label-width="70px"
  9. size="small"
  10. label-position="left"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="经销商名称" prop="customerName">
  15. <el-input
  16. placeholder="请输入经销商名称"
  17. v-model="screenForm.customerName"
  18. ></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="18" class="tr">
  22. <el-form-item label="">
  23. <el-button size="small" @click="resetScreenForm">清空</el-button>
  24. <el-button size="small" type="primary" @click="submitScreenForm"
  25. >搜索</el-button
  26. >
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. </el-form>
  31. </div>
  32. <!-- 按钮 -->
  33. <div class="btn-group clearfix">
  34. <div class="fl">
  35. <el-button
  36. type="primary"
  37. size="small"
  38. v-if="$checkBtnRole('add', $route.meta.roles)"
  39. icon="el-icon-plus"
  40. @click="(showDialog = true), (type = 1)"
  41. >新增</el-button
  42. >
  43. <el-popconfirm
  44. v-if="$checkBtnRole('del', $route.meta.roles)"
  45. confirm-button-text="好的"
  46. cancel-button-text="不用了"
  47. icon="el-icon-info"
  48. icon-color="red"
  49. title="内容确定删除吗?"
  50. @onConfirm="hanleDelete"
  51. >
  52. <el-button
  53. type="primary"
  54. size="small"
  55. icon="el-icon-delete"
  56. slot="reference"
  57. class="el-popover-left"
  58. >批量删除</el-button
  59. >
  60. </el-popconfirm>
  61. </div>
  62. <div class="fr">
  63. <el-upload
  64. class="import-btn"
  65. :action="baseURL + 'student/import'"
  66. :http-request="handleImport"
  67. :file-list="importFileList"
  68. >
  69. <el-button type="primary" size="small">导入</el-button>
  70. </el-upload>
  71. <el-button type="primary" size="small" @click="handleExport"
  72. >导出</el-button
  73. >
  74. <!-- <el-button type="primary" size="small" @click="hanlePrint"
  75. >打印</el-button
  76. > -->
  77. </div>
  78. </div>
  79. <div class="mymain-container">
  80. <!-- 列表 -->
  81. <div class="table">
  82. <!-- startprint -->
  83. <el-table
  84. v-loading="listLoading"
  85. :data="dataList"
  86. element-loading-text="Loading"
  87. border
  88. fit
  89. highlight-current-row
  90. stripe
  91. @select-all="hanleSelectAll"
  92. @select="hanleSelectAll"
  93. >
  94. <el-table-column type="selection" align="center" min-width="100" />
  95. <el-table-column
  96. align="center"
  97. label="经销商编码"
  98. prop="customerNumber"
  99. min-width="160"
  100. show-overflow-tooltip
  101. />
  102. <el-table-column
  103. align="center"
  104. label="经销商名称"
  105. prop="customerName"
  106. min-width="160"
  107. show-overflow-tooltip
  108. />
  109. <el-table-column
  110. align="center"
  111. label="存放免费天数"
  112. prop="freeDay"
  113. min-width="160"
  114. show-overflow-tooltip
  115. />
  116. <el-table-column
  117. align="center"
  118. label="收费规则(每立方米)"
  119. prop="toll"
  120. min-width="160"
  121. show-overflow-tooltip
  122. />
  123. <el-table-column
  124. align="center"
  125. label="创建人"
  126. prop="createBy"
  127. min-width="160"
  128. show-overflow-tooltip
  129. />
  130. <el-table-column
  131. align="center"
  132. label="创建时间"
  133. prop="createTime"
  134. min-width="160"
  135. show-overflow-tooltip
  136. />
  137. <el-table-column
  138. align="center"
  139. label="更新人"
  140. prop="updateBy"
  141. min-width="160"
  142. show-overflow-tooltip
  143. />
  144. <el-table-column
  145. align="center"
  146. label="更新时间"
  147. prop="updateTime"
  148. min-width="160"
  149. show-overflow-tooltip
  150. />
  151. <el-table-column
  152. align="center"
  153. label="操作"
  154. min-width="160"
  155. show-overflow-tooltip
  156. >
  157. <template slot-scope="scope">
  158. <el-button
  159. type="text"
  160. v-if="$checkBtnRole('edit', $route.meta.roles)"
  161. class="textColor"
  162. @click="editFn(scope.row.id, scope.row)"
  163. >编辑</el-button
  164. >
  165. <el-popconfirm
  166. v-if="$checkBtnRole('del', $route.meta.roles)"
  167. confirm-button-text="好的"
  168. cancel-button-text="不用了"
  169. icon="el-icon-info"
  170. icon-color="red"
  171. title="内容确定删除吗?"
  172. @onConfirm="hanleDelete(scope.row.id)"
  173. >
  174. <el-button
  175. slot="reference"
  176. type="text"
  177. class="textColor el-popover-left"
  178. >删除</el-button
  179. >
  180. </el-popconfirm>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. <!-- endprint -->
  185. </div>
  186. <!-- 分页 -->
  187. <div class="fr">
  188. <el-pagination
  189. @size-change="handleSizeChange"
  190. @current-change="handleCurrentChange"
  191. :current-page="currentPage"
  192. :page-sizes="[10, 20, 30, 50]"
  193. :page-size="10"
  194. layout="total, sizes, prev, pager, next, jumper"
  195. :total="listTotal"
  196. >
  197. </el-pagination>
  198. </div>
  199. </div>
  200. <!-- 弹窗 -->
  201. <el-dialog
  202. title="仓库费规则配置"
  203. :visible.sync="showDialog"
  204. width="50%"
  205. :show-close="false"
  206. :close-on-click-modal="false"
  207. >
  208. <el-form :model="dialogForm" label-width="100px" label-position="right">
  209. <el-form-item label="经销商编码" prop="customerNumber">
  210. <el-select
  211. v-model="dialogForm.customerNumber"
  212. placeholder="请选择活动区域"
  213. filterable
  214. class="inputStyle"
  215. v-el-select-loadmore="loadmore"
  216. >
  217. <!-- v-el-select-loadmore="loadMore" -->
  218. <el-option
  219. v-for="(item, index) in customerList"
  220. :key="index"
  221. :label="item.number"
  222. :value="item.id"
  223. ></el-option>
  224. </el-select>
  225. </el-form-item>
  226. <el-form-item label="经销商名称" prop="customerName">
  227. <el-input
  228. v-model="dialogForm.customerName"
  229. class="inputStyle"
  230. ></el-input>
  231. </el-form-item>
  232. <el-form-item label="仓库存放" class="sty" prop="freeDay">
  233. <el-input
  234. type="number"
  235. v-model="dialogForm.freeDay"
  236. class="inputStyle"
  237. />天内可免费受存储管理费用.
  238. <br/>
  239. 当超过
  240. <el-input
  241. type="number"
  242. v-model="dialogForm.freeDay"
  243. class="inputStyle"
  244. />天后,按每立方米
  245. <el-input
  246. v-model="dialogForm.toll"
  247. type="number"
  248. class="inputStyle"
  249. />
  250. 元/天计算
  251. </el-form-item>
  252. </el-form>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button @click="(showDialog = false), kong()">取 消</el-button>
  255. <el-button type="primary" @click="hanleInfo(dialogForm)"
  256. >确 定</el-button
  257. >
  258. </div>
  259. </el-dialog>
  260. </div>
  261. </template>
  262. <script>
  263. import Mixin from "@/mixin/index";
  264. import { downloadFiles, handleImport } from "@/utils/util";
  265. import {
  266. getListToll,
  267. getDetail,
  268. updateToll,
  269. addToll,
  270. deleteToll,
  271. getCustomerList,
  272. } from "@/api/basic_data/warehouse";
  273. export default {
  274. mixins: [Mixin],
  275. data() {
  276. return {
  277. dialogForm: {
  278. id: null,
  279. customerName: "",
  280. customerNumber: "",
  281. freeDay: 0,
  282. toll: 0,
  283. },
  284. sleectBox: {
  285. currentPage: 1, // 当前页码
  286. pageSize: 10, // 每页数量
  287. listTotal: 0, // 列表总数
  288. },
  289. baseURL: "",
  290. currentPage: 1, // 当前页码
  291. pageSize: 10, // 每页数量
  292. listTotal: 0, // 列表总数
  293. importLoading: false, // 导入加载loading
  294. importFileList: [], // 导入列表
  295. customerList: [],
  296. showDialog: false,
  297. dataList: [],
  298. screenForm: {
  299. customerName: "",
  300. freeDay: "",
  301. toll: "",
  302. },
  303. type: null, // 1 新增 2 修改 null 详情
  304. };
  305. },
  306. created() {
  307. this.getList();
  308. this.getCustomerList();
  309. },
  310. directives: {
  311. "el-select-loadmore": {
  312. bind(el, binding) {
  313. // 获取element-ui定义好的scroll盒⼦
  314. const SELECTWRAP_DOM = el.querySelector(
  315. ".el-select-dropdown .el-select-dropdown__wrap"
  316. );
  317. SELECTWRAP_DOM.addEventListener("scroll", function () {
  318. /**
  319. * scrollHeight 获取元素内容⾼度(只读)
  320. * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
  321. * clientHeight 读取元素的可见⾼度(只读)
  322. * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
  323. * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
  324. */
  325. const condition =
  326. this.scrollHeight - this.scrollTop <= this.clientHeight;
  327. if (condition) {
  328. binding.value();
  329. }
  330. });
  331. },
  332. },
  333. },
  334. methods: {
  335. editFn(id, row) {
  336. (this.dialogForm = {
  337. id: id,
  338. customerName: row.customerName,
  339. customerNumber: row.customerNumber,
  340. freeDay: row.freeDay,
  341. toll: row.toll,
  342. }),
  343. (this.type = 2);
  344. this.showDialog = true;
  345. },
  346. hanleInfo(dialogForm) {
  347. if (this.type === 1) {
  348. const params = {
  349. ...dialogForm,
  350. };
  351. console.log(params, 78798);
  352. addToll(params).then((res) => {
  353. this.getList();
  354. this.$successMsg("保存成功");
  355. this.kong();
  356. });
  357. } else if (this.type === 2) {
  358. const paramss = {
  359. ...this.dialogForm,
  360. };
  361. updateToll(paramss).then((res) => {
  362. this.$successMsg("编辑成功");
  363. this.getList();
  364. this.kong();
  365. this.diaLogForm.id = null;
  366. });
  367. }
  368. this.showDialog = false;
  369. },
  370. getList() {
  371. this.listLoading = true;
  372. let params = {
  373. pageNum: this.currentPage,
  374. pageSize: this.pageSize,
  375. customerName: this.screenForm.customerName,
  376. freeDay: this.screenForm.freeDay,
  377. toll: this.screenForm.toll,
  378. };
  379. getListToll(params).then((res) => {
  380. this.dataList = res.data.records;
  381. this.listTotal = res.data.total;
  382. this.listLoading = false;
  383. });
  384. },
  385. loadmore() {
  386. this.sleectBox.currentPage++;
  387. this.getCustomerList();
  388. },
  389. getCustomerList() {
  390. let params = {
  391. pageNum:1,
  392. pageSize: -1,
  393. keyword: "",
  394. };
  395. getCustomerList(params).then((res) => {
  396. if (res.data.records.length) {
  397. this.customerList = [...this.customerList, ...res.data.records];
  398. }
  399. // this.listTotal = res.data.total;
  400. });
  401. },
  402. // hanleDetail(detail) {
  403. // this.type = null;
  404. // this.showDialog = true;
  405. // this.diaLogForm = detail;
  406. // },
  407. handleExport() {
  408. let screenData = {
  409. customerName: this.screenForm.customerName,
  410. freeDay: this.screenForm.freeDay,
  411. toll: this.screenForm.toll,
  412. };
  413. downloadFiles("/stock/exportToll", screenData);
  414. },
  415. // 删除数据
  416. hanleDelete(id) {
  417. deleteToll({ id }).then((res) => {
  418. this.$successMsg("删除成功");
  419. this.getList();
  420. });
  421. },
  422. // 导入
  423. async handleImport(param) {
  424. this.importLoading = true;
  425. const file = param.file;
  426. console.log(file, 123);
  427. const formData = new FormData();
  428. formData.append("file", file);
  429. let result = await handleImport("/stock/importToll", formData);
  430. this.importLoading = false;
  431. this.importFileList = [];
  432. if (result.code == 200) {
  433. this.$alert(result.message, "导入成功", {
  434. confirmButtonText: "确定",
  435. });
  436. this.getList();
  437. } else {
  438. this.$alert(result.message, "导入失败", {
  439. confirmButtonText: "确定",
  440. });
  441. }
  442. },
  443. kong() {
  444. this.dialogForm = {
  445. customerName: "",
  446. customerNumber: "",
  447. freeDay: 0,
  448. toll: 0,
  449. };
  450. },
  451. },
  452. };
  453. </script>
  454. <style lang="scss" scoped>
  455. ::v-deep .sty {
  456. width: 85%;
  457. .el-form-item__content .el-input {
  458. width: 22%;
  459. margin: 0px 10px 16px 0;
  460. }
  461. }
  462. .zhu {
  463. padding-top: 18px;
  464. }
  465. .import-btn {
  466. display: inline-block;
  467. margin-right: 10px;
  468. }
  469. .set {
  470. margin-bottom: 30px;
  471. }
  472. .inputs {
  473. margin: 0 18px;
  474. }
  475. ::v-deep .el-form {
  476. .inputStyle {
  477. width: 80%;
  478. }
  479. }
  480. ::v-deep .dialog-footer {
  481. display: flex;
  482. justify-content: center;
  483. }
  484. ::v-deep .el-dialog__header {
  485. background-color: #dddddd;
  486. }
  487. .inp {
  488. margin: 0 12px;
  489. }
  490. .right {
  491. margin-top: 12px;
  492. float: right;
  493. }
  494. .table {
  495. margin-top: 12px;
  496. }
  497. .search {
  498. display: flex;
  499. margin-top: 12px;
  500. ::v-deep .el-input {
  501. width: 50%;
  502. margin-right: 12px;
  503. }
  504. }
  505. .main {
  506. padding: 12px;
  507. }
  508. </style>
  509. >