index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. :key="key"
  5. ref="crud"
  6. :option="option"
  7. :data="data"
  8. :search.sync="search"
  9. @on-load="onLoad"
  10. @search-reset="query={}"
  11. :page.sync="page"
  12. @search-change="searchChange"
  13. @search-criteria-switch="searchCriteriaSwitch"
  14. @resetColumn="resetColumn"
  15. @saveColumn="saveColumn"
  16. :summary-method="summaryMethod"
  17. @refresh-change="refreshChange">
  18. <template slot="itemId" slot-scope="{row,index}">
  19. {{ row.goodsName }}
  20. </template>
  21. <template slot="warehouseId" slot-scope="{row,index}">
  22. {{ row.warehouse }}
  23. </template>
  24. <template slot="corpNameSearch">
  25. <crop-select v-model="search.corpId" corpType="GYS" :refresh="false"></crop-select>
  26. </template>
  27. <template slot="purchaserSearch">
  28. <crop-select v-model="search.purchaserId" corpType="KH" :refresh="false"></crop-select>
  29. </template>
  30. <template slot="menuLeft">
  31. <el-button type="warning"
  32. icon="el-icon-plus"
  33. size="small"
  34. @click="outExport()">导出
  35. </el-button>
  36. </template>
  37. <template slot="header">
  38. <el-table
  39. :data="commodityData"
  40. border
  41. size="small"
  42. @header-click="cellClick"
  43. style="width: 100%">
  44. <el-table-column
  45. v-for="(item,index) in commodityLabel"
  46. :key="index"
  47. :prop="item.prop"
  48. width="200"
  49. show-overflow-tooltip
  50. :label="item.label">
  51. </el-table-column>
  52. </el-table>
  53. </template>
  54. </avue-crud>
  55. </basic-container>
  56. </template>
  57. <script>
  58. import {generalLedgerListByGoods, getList,generalLedgerTotal} from "@/api/purchasingManagement/inventoryAccount";
  59. import {getToken} from "@/util/auth";
  60. export default {
  61. data() {
  62. return {
  63. key: 0,
  64. search: {
  65. isIssue:3,
  66. },
  67. data: [],
  68. total: [],
  69. query: {},
  70. page: {
  71. pageSize: 10,
  72. currentPage: 1,
  73. total: 0,
  74. pageSizes: [10, 50, 100, 200, 300]
  75. },
  76. option: {},
  77. optionList: {
  78. align: 'center',
  79. stripe: true,
  80. index: true,
  81. menu: false,
  82. height: "auto",
  83. searchSpan: 8,
  84. searchIcon: true,
  85. searchIndex: 2,
  86. // highlightCurrentRow: true,
  87. addBtn: false,
  88. showSummary: true,
  89. summaryText: "合计",
  90. sumColumnList: [
  91. {
  92. name: 'sliceNumber',
  93. type: 'sum',
  94. decimals: 2
  95. },{
  96. name: 'balanceNumber',
  97. type: 'sum',
  98. decimals: 2
  99. },{
  100. name: 'balanceMoney',
  101. type: 'sum',
  102. decimals: 2
  103. }],
  104. column: [{
  105. label: '货权人',
  106. prop: 'purchaser',
  107. index: 18,
  108. width: 140,
  109. overHidden: true,
  110. search: true
  111. },{
  112. label: '品名',
  113. // searchProp: 'goodsName',
  114. prop: 'itemId',
  115. dicUrl: '/api/blade-client/goodsdesc/descListAll',
  116. props: {
  117. label: "cname",
  118. value: "id",
  119. },
  120. filterable: true,
  121. type: "select",
  122. overHidden: true,
  123. index: 1,
  124. search: true
  125. }, {
  126. label: '提单号',
  127. prop: 'morderNo',
  128. index: 19,
  129. search: true
  130. }, {
  131. label: '箱号',
  132. prop: 'containerNo',
  133. index: 6,
  134. width: 100,
  135. search: true
  136. }, {
  137. label: '仓库',
  138. prop: 'warehouseId',
  139. type: "tree",
  140. dicUrl: "/api/blade-client/storagetype/tree",
  141. index: 11,
  142. props: {
  143. "label": "title",
  144. "value": "value"
  145. },
  146. "checkStrictly": true,
  147. "showAllLevels": false,
  148. "emitPath": false,
  149. "width": 120,
  150. "searchSpan": 8,
  151. "overHidden": true,
  152. search: true
  153. }, {
  154. label: '捆包号',
  155. prop: 'billNo',
  156. index: 6,
  157. width: 100,
  158. search: true
  159. }, {
  160. label: '长',
  161. prop: 'length',
  162. index: 2,
  163. search: true
  164. }, {
  165. label: '厚',
  166. prop: 'thickness',
  167. index: 5,
  168. search: true
  169. }, {
  170. label: '等级',
  171. prop: 'grade',
  172. dicUrl: "/api/blade-system/dict-biz/dictionary?code=goods_grade",
  173. type: "select",
  174. props: {
  175. label: "dictValue",
  176. value: "dictKey"
  177. },
  178. dataType: "string",
  179. index: 14,
  180. search: true
  181. }, {
  182. label: '品牌',
  183. prop: 'itemType',
  184. index: 13,
  185. search: true
  186. }, {
  187. label: '车船号',
  188. prop: 'vehicleShipNumber',
  189. index: 17,
  190. search: true
  191. }, {
  192. label: '产地',
  193. prop: 'itemProp',
  194. index: 15,
  195. search: true
  196. }, {
  197. label: '供应商',
  198. prop: 'corpName',
  199. index: 16,
  200. width: 100,
  201. overHidden: true,
  202. search: true
  203. }, {
  204. label: '状态',
  205. index: 19,
  206. prop: 'status',
  207. dataType: "number",
  208. type: 'select',
  209. dicUrl: "/api/blade-system/dict-biz/dictionary?code=inventory_account",
  210. props: {
  211. label: "dictValue",
  212. value: "dictKey"
  213. }
  214. }, {
  215. label: '状态',
  216. prop: 'isIssue',
  217. type: 'select',
  218. index: 19,
  219. hide: true,
  220. showColumn: false,
  221. searchValue: 3,
  222. dicData: [{
  223. label: "在库",
  224. value: 3
  225. }, {
  226. label: "计划",
  227. value: 4
  228. }, {
  229. label: "待出库",
  230. value: 5
  231. }, {
  232. label: "已出库",
  233. value: 7
  234. }],
  235. search: true
  236. }, {
  237. label: '可用片数',
  238. prop: 'sliceNumber',
  239. index: 7
  240. }, {
  241. label: '可用库存',
  242. prop: 'balanceNumber',
  243. index: 8
  244. }, {
  245. label: '库存单价',
  246. prop: 'price',
  247. index: 9
  248. }, {
  249. label: '库存金额',
  250. prop: 'balanceMoney',
  251. index: 10
  252. }, {
  253. label: '库位',
  254. prop: 'storageName',
  255. index: 12
  256. }]
  257. },
  258. commodityLabel: [],
  259. commodityData: []
  260. }
  261. },
  262. async created() {
  263. generalLedgerListByGoods().then(res => {
  264. for (let item in res.data.data) {
  265. this.commodityLabel.push({label: res.data.data[item].cname, prop: item, id: res.data.data[item].id})
  266. this.commodityData[0] = {
  267. ...this.commodityData[0],
  268. [item]: `${res.data.data[item].sliceNumber?res.data.data[item].sliceNumber:0}片,${res.data.data[item].balanceNumber?res.data.data[item].balanceNumber:0}立方`
  269. }
  270. }
  271. })
  272. this.option = await this.getColumnData(this.getColumnName(200), this.optionList);
  273. this.key++
  274. let i = 0;
  275. this.option.column.forEach(item => {
  276. if (item.search) i++
  277. })
  278. if (i % 3 !== 0) {
  279. const num = 3 - Number(i % 3)
  280. this.option.searchMenuSpan = num * 8;
  281. this.option.searchMenuPosition = "right";
  282. }
  283. },
  284. methods: {
  285. summaryMethod({ columns, data }){
  286. const sums = [];
  287. if (columns.length > 0) {
  288. columns.forEach((column, index) => {
  289. let prop=column.property
  290. if (['sliceNumber','balanceNumber','balanceMoney'].includes(prop) ) {
  291. if(prop=='sliceNumber'){
  292. sums[index]=this.total.sliceNumber
  293. }else if(prop=='balanceNumber'){
  294. sums[index]=this.total.balanceNumber
  295. }else if(prop=='balanceMoney'){
  296. sums[index]=this.total.balanceMoney
  297. }
  298. } else {
  299. sums[0] = '合计'
  300. }
  301. });
  302. }
  303. return sums;
  304. },
  305. cellClick(row, column, cell, event) {
  306. for (let item of this.commodityLabel) {
  307. if (row.label == item.label) {
  308. this.search.itemId = item.id
  309. this.onLoad(this.page, this.search)
  310. }
  311. }
  312. },
  313. onLoad(page, params = {}) {
  314. let queryParams = {
  315. size: page.pageSize,
  316. current: page.currentPage,
  317. ...Object.assign(params, this.search)
  318. }
  319. getList(queryParams).then(res => {
  320. this.data = res.data.data.records
  321. this.page.total = res.data.data.total
  322. this.option.height = window.innerHeight - 230;
  323. generalLedgerTotal(queryParams).then(res=>{
  324. this.total = res.data.data
  325. })
  326. })
  327. },
  328. //搜索
  329. searchChange(params, done) {
  330. let data = params
  331. if (params.arrivalTime) {
  332. data.beginArrivalTime = params.arrivalTime[0]
  333. data.endArrivalTime = params.arrivalTime[1]
  334. }
  335. if (params.createTime) {
  336. data.beginCrateTime = params.createTime[0]
  337. data.endCrateTime = params.createTime[1]
  338. }
  339. delete data.arrivalTime
  340. delete data.createTime
  341. this.query = data;
  342. this.onLoad(this.page, data)
  343. done();
  344. },
  345. // 获得高度
  346. searchCriteriaSwitch(type) {
  347. if (type) {
  348. this.option.height = this.option.height - 55
  349. } else {
  350. this.option.height = this.option.height + 55
  351. }
  352. this.$refs.crud.getTableHeight()
  353. },
  354. //自定义列保存
  355. async saveColumn() {
  356. /**
  357. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  358. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  359. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  360. */
  361. const inSave = await this.saveColumnData(this.getColumnName(200), this.option);
  362. if (inSave) {
  363. this.$message.success("保存成功");
  364. //关闭窗口
  365. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  366. }
  367. },
  368. //自定义列重置
  369. async resetColumn() {
  370. this.option = this.optionList;
  371. const inSave = await this.delColumnData(this.getColumnName(200), this.optionList);
  372. if (inSave) {
  373. this.$message.success("重置成功");
  374. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  375. }
  376. },
  377. refreshChange() {
  378. this.onLoad(this.page, this.search);
  379. },
  380. //导出
  381. outExport() {
  382. this.$confirm('是否导出数据明细?', '提示', {
  383. confirmButtonText: '确定',
  384. cancelButtonText: '取消',
  385. type: 'warning'
  386. }).then(() => {
  387. let queryParams = this.query
  388. const routeData = this.$router.resolve({
  389. path: '/api/trade-purchase/woodHarvestingCloud/generalLedgerExport', //跳转目标窗口的地址
  390. query: {
  391. 'Blade-Auth': getToken(),
  392. ...queryParams //括号内是要传递给新窗口的参数
  393. }
  394. })
  395. window.open(routeData.href.slice(1, routeData.href.length));
  396. }).catch(() => {
  397. this.$message({
  398. type: 'info',
  399. message: '已取消' //
  400. });
  401. })
  402. },
  403. }
  404. }
  405. </script>
  406. <style scoped>
  407. </style>