index.vue 9.3 KB

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