warehouse_cost.vue 14 KB

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