index.vue 9.6 KB

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