index.vue 8.1 KB

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