index.vue 8.0 KB

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