index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div>
  3. <basic-container v-if="show">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="data"
  8. :page.sync="page"
  9. @search-change="searchChange"
  10. :search.sync="search"
  11. :table-loading="loading"
  12. @on-load="onLoad"
  13. @row-update="rowUpdate">
  14. <template slot-scope="scope" slot="lockingQuantity">
  15. <span v-if="Number(scope.row.lockingQuantity) > 0" style="color: #409EFF;cursor: pointer" @click.stop="viewCell(scope.row,scope.index)">{{ scope.row.lockingQuantity }}</span>
  16. <span v-else>{{ scope.row.lockingQuantity }}</span>
  17. </template>
  18. <template slot-scope="{row,index}" slot="menu">
  19. <el-button
  20. type="text"
  21. size="small"
  22. @click="rowCell(row,index)"
  23. >{{ row.$cellEdit ? '保存' : '修改' }}
  24. </el-button>
  25. <el-button
  26. type="text"
  27. size="small"
  28. @click="deletePrice(row,index)"
  29. >删除
  30. </el-button>
  31. </template>
  32. <template slot="menuLeft">
  33. <el-button
  34. type="primary"
  35. size="small"
  36. icon="el-icon-plus"
  37. @click="excelBox = !excelBox"
  38. >导入
  39. </el-button>
  40. <el-button
  41. type="success"
  42. icon="el-icon-download"
  43. size="small"
  44. @click="derivation()"
  45. >下载模板
  46. </el-button>
  47. <el-button
  48. type="info"
  49. icon="el-icon-printer"
  50. size="small"
  51. :loading="exportLoading"
  52. @click.stop="statement"
  53. >报 表
  54. </el-button>
  55. </template>
  56. </avue-crud>
  57. <el-dialog title="导入价格"
  58. append-to-body
  59. :visible.sync="excelBox"
  60. width="555px">
  61. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"/>
  62. </el-dialog>
  63. </basic-container>
  64. <report-dialog
  65. :switchDialog="switchDialog"
  66. :searchValue="statementData"
  67. :reportName="'国内贸易-库存账'"
  68. @onClose="onClose()"
  69. ></report-dialog>
  70. </div>
  71. </template>
  72. <script>
  73. import option from "./configuration/mainList.json"
  74. import {deleteTemplate,customerList,typeSave} from "@/api/basicData/inventoryAccount"
  75. import {getToken} from "@/util/auth";
  76. import { defaultDate } from "@/util/date";
  77. import reportDialog from "@/components/report-dialog/main";
  78. export default {
  79. components:{
  80. reportDialog
  81. },
  82. data() {
  83. return {
  84. data: [],
  85. search:{},
  86. loading: false,
  87. exportLoading:false,
  88. switchDialog:false,
  89. statementData: {},
  90. excelForm: {},
  91. excelOption: {
  92. submitBtn: false,
  93. emptyBtn: false,
  94. column: [
  95. {
  96. label: '导入数据',
  97. prop: 'excelFile',
  98. type: 'upload',
  99. drag: true,
  100. loadText: '导入数据中,请稍等',
  101. span: 24,
  102. propsHttp: {
  103. res: 'data'
  104. },
  105. tip: '请上传 .xls,.xlsx 标准格式文件',
  106. action: "/api/blade-stock/stockgoods/import-price"
  107. }
  108. ]
  109. },
  110. excelBox: false,
  111. option: option,
  112. page: {
  113. pageSize: 10,
  114. pagerCount: 5,
  115. total: 0,
  116. pageSizes: [10,50,100,200,300]
  117. },
  118. show: true,
  119. params: {
  120. corpId: null,
  121. itemId: null
  122. },
  123. }
  124. },
  125. created() {
  126. this.search.createTime = defaultDate(1)
  127. let i = 0;
  128. this.option.column.forEach(item => {
  129. if (item.search) i++
  130. })
  131. if (i % 3 !== 0){
  132. const num = 3 - Number(i % 3)
  133. this.option.searchMenuSpan = num * 8;
  134. this.option.searchMenuPosition = "right";
  135. }
  136. },
  137. methods: {
  138. derivation() {
  139. this.$confirm("是否下载模板?", "提示", {
  140. confirmButtonText: "确定",
  141. cancelButtonText: "取消",
  142. type: "warning"
  143. }).then(() => {
  144. window.open(`/api/blade-stock/stockgoods/export-template?${this.website.tokenHeader}=${getToken()}`);
  145. });
  146. },
  147. uploadAfter(res, done, loading, column) {
  148. console.log(res)
  149. window.console.log(column);
  150. this.excelBox = false;
  151. this.page.currentPage = 1;
  152. if (res) {
  153. this.$message.warning(res)
  154. } else {
  155. this.$message.success('导入成功')
  156. }
  157. this.onLoad(this.page);
  158. loading()
  159. done();
  160. },
  161. rowCell(row, index) {
  162. this.$refs.crud.rowCell(row, index)
  163. },
  164. deletePrice(row,index){
  165. if (row.id){
  166. this.$confirm("确定将选择数据删除?", {
  167. confirmButtonText: "确定",
  168. cancelButtonText: "取消",
  169. type: "warning"
  170. }).then(() => {
  171. return deleteTemplate(row.id);
  172. }).then(() => {
  173. this.$message({
  174. type: "success",
  175. message: "操作成功!"
  176. });
  177. this.page.currentPage = 1;
  178. this.onLoad(this.page);
  179. })
  180. }
  181. },
  182. //点击搜索按钮触发
  183. searchChange(params, done) {
  184. if (params.createTime) {
  185. params.createStartTime = params.createTime[0]+ " " + "00:00:00"
  186. params.createEndTime = params.createTime[1]+ " " + "23:59:59"
  187. delete params.createTime;
  188. }
  189. this.page.currentPage = 1;
  190. this.onLoad(this.page, params);
  191. done()
  192. },
  193. onLoad(page, params = {}) {
  194. if (this.search.createTime && this.search.createTime.length > 0) {
  195. params = {
  196. ...params,
  197. createStartTime: this.search.createTime[0]+ " " + "00:00:00",
  198. createEndTime: this.search.createTime[1]+ " " + "23:59:59",
  199. }
  200. delete params.createTime;
  201. }
  202. let queryParams = Object.assign({}, params, {
  203. size: page.pageSize,
  204. current: page.currentPage,
  205. })
  206. this.loading = true;
  207. customerList(queryParams).then(res => {
  208. this.data = res.data.data.records
  209. this.page.total = res.data.data.total
  210. }).finally(() => {
  211. this.loading = false;
  212. })
  213. },
  214. rowUpdate(form, index, done) {
  215. typeSave(form).then(res => {
  216. this.$message({type: "success", message: form.id ? "修改成功!" : "新增成功!"});
  217. // this.page.currentPage = 1;
  218. // this.onLoad(this.page);
  219. //成功关闭此页面回到列表页
  220. // this.backToList()
  221. })
  222. done()
  223. },
  224. // 查看
  225. viewCell(row, index) {
  226. if (this.$store.getters.domStockDetail) {
  227. this.$alert("明细已存在,请保存关闭明细再进行操作", "温馨提示", {
  228. confirmButtonText: "确定",
  229. type: "warning",
  230. callback: action => {
  231. console.log(action);
  232. }
  233. });
  234. } else {
  235. this.params.corpId = row.corpId
  236. this.params.itemId = row.goodsId
  237. this.$router.$avueRouter.closeTag("/businessManagement/inventoryAccount/detail");
  238. this.$router.push({
  239. path: "/businessManagement/inventoryAccount/detail",
  240. query: {
  241. corpId: row.corpId,
  242. itemId: row.goodsId
  243. },
  244. });
  245. }
  246. // this.show = false;
  247. },
  248. statement() {
  249. this.statementData = {...this.search}
  250. this.statementData.createStartTime = this.statementData.createTime[0]+ " " + "00:00:00"
  251. this.statementData.createEndTime = this.statementData.createTime[1]+ " " + "23:59:59"
  252. delete this.statementData.createTime
  253. this.switchDialog = !this.switchDialog;
  254. },
  255. onClose(val) {
  256. this.switchDialog = val;
  257. },
  258. }
  259. }
  260. </script>