index.vue 8.1 KB

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