index.vue 11 KB

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