index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. ref="crud"
  5. :option="option"
  6. :data="data"
  7. :page.sync="page"
  8. @search-change="searchChange"
  9. @on-load="onLoad"
  10. @row-update="rowUpdate">
  11. <template slot-scope="{row,index}" slot="menu">
  12. <el-button
  13. type="text"
  14. size="small"
  15. @click="rowCell(row,index)"
  16. >{{ row.$cellEdit ? '保存' : '修改' }}
  17. </el-button>
  18. <el-button
  19. type="text"
  20. size="small"
  21. @click="deletePrice(row,index)"
  22. >删除
  23. </el-button>
  24. </template>
  25. <template slot="menuLeft">
  26. <el-button
  27. type="primary"
  28. size="small"
  29. icon="el-icon-plus"
  30. @click="excelBox = !excelBox"
  31. >导入
  32. </el-button>
  33. <el-button
  34. type="success"
  35. icon="el-icon-upload2"
  36. size="small"
  37. @click="derivation()"
  38. >下载模板
  39. </el-button>
  40. <el-button
  41. type="info"
  42. icon="el-icon-printer"
  43. size="small"
  44. >报 表
  45. </el-button>
  46. </template>
  47. </avue-crud>
  48. <el-dialog title="导入价格"
  49. append-to-body
  50. :visible.sync="excelBox"
  51. width="555px">
  52. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"/>
  53. </el-dialog>
  54. </basic-container>
  55. </template>
  56. <script>
  57. import option from "./configuration/mainList.json"
  58. import {deleteTemplate,customerList,typeSave} from "@/api/basicData/inventoryAccount"
  59. import {getToken} from "@/util/auth";
  60. export default {
  61. data() {
  62. return {
  63. data: [],
  64. excelForm: {},
  65. excelOption: {
  66. submitBtn: false,
  67. emptyBtn: false,
  68. column: [
  69. {
  70. label: '导入数据',
  71. prop: 'excelFile',
  72. type: 'upload',
  73. drag: true,
  74. loadText: '导入数据中,请稍等',
  75. span: 24,
  76. propsHttp: {
  77. res: 'data'
  78. },
  79. tip: '请上传 .xls,.xlsx 标准格式文件',
  80. action: "/api/blade-stock/stockgoods/import-price"
  81. }
  82. ]
  83. },
  84. excelBox: false,
  85. option: option,
  86. page: {
  87. pageSize: 10,
  88. pagerCount: 5,
  89. total: 0,
  90. }
  91. }
  92. },
  93. methods: {
  94. derivation() {
  95. this.$confirm("是否下载模板?", "提示", {
  96. confirmButtonText: "确定",
  97. cancelButtonText: "取消",
  98. type: "warning"
  99. }).then(() => {
  100. window.open(`/api/blade-stock/stockgoods/export-template?${this.website.tokenHeader}=${getToken()}`);
  101. });
  102. },
  103. uploadAfter(res, done, loading, column) {
  104. window.console.log(column);
  105. this.excelBox = false;
  106. this.page.currentPage = 1;
  107. this.onLoad(this.page);
  108. loading()
  109. done();
  110. },
  111. rowCell(row, index) {
  112. this.$refs.crud.rowCell(row, index)
  113. },
  114. deletePrice(row,index){
  115. if (row.id){
  116. this.$confirm("确定将选择数据删除?", {
  117. confirmButtonText: "确定",
  118. cancelButtonText: "取消",
  119. type: "warning"
  120. }).then(() => {
  121. return deleteTemplate(row.id);
  122. }).then(() => {
  123. this.$message({
  124. type: "success",
  125. message: "操作成功!"
  126. });
  127. this.page.currentPage = 1;
  128. this.onLoad(this.page);
  129. })
  130. }
  131. },
  132. //点击搜索按钮触发
  133. searchChange(params, done) {
  134. console.log(params)
  135. this.page.currentPage = 1;
  136. this.onLoad(this.page, params);
  137. done()
  138. },
  139. onLoad(page, params = {}) {
  140. let queryParams = Object.assign({}, params, {
  141. size: page.pageSize,
  142. current: page.currentPage,
  143. })
  144. customerList(queryParams).then(res => {
  145. this.data = res.data.data.records
  146. this.page.total = res.data.data.total
  147. })
  148. },
  149. rowUpdate(form, index, done) {
  150. console.log(form)
  151. typeSave(form).then(res => {
  152. this.$message({type: "success", message: form.id ? "修改成功!" : "新增成功!"});
  153. // this.page.currentPage = 1;
  154. // this.onLoad(this.page);
  155. //成功关闭此页面回到列表页
  156. // this.backToList()
  157. })
  158. done()
  159. }
  160. }
  161. }
  162. </script>