index.vue 12 KB

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