index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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: "stockDate",
  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. prop: "deliveryDate",
  213. type: "date",
  214. value: dateFormat(new Date(),'yyyy-MM-dd'),
  215. format: "yyyy-MM-dd",
  216. valueFormat: "yyyy-MM-dd",
  217. width: 100
  218. }, {
  219. label: '状态',
  220. index: 19,
  221. prop: 'status',
  222. dataType: "number",
  223. type: 'select',
  224. dicUrl: "/api/blade-system/dict-biz/dictionary?code=inventory_account",
  225. props: {
  226. label: "dictValue",
  227. value: "dictKey"
  228. }
  229. }, {
  230. label: '状态',
  231. prop: 'isIssue',
  232. type: 'select',
  233. index: 19,
  234. hide: true,
  235. showColumn: false,
  236. dicData: [{
  237. label: "在库",
  238. value: 3
  239. }, {
  240. label: "计划",
  241. value: 4
  242. }, {
  243. label: "待出库",
  244. value: 5
  245. }, {
  246. label: "已出库",
  247. value: 7
  248. }],
  249. search: true
  250. }, {
  251. label: '可用片数',
  252. prop: 'sliceNumber',
  253. index: 7
  254. }, {
  255. label: '可用库存',
  256. prop: 'balanceNumber',
  257. index: 8
  258. }, {
  259. label: '库存单价',
  260. prop: 'price',
  261. index: 9
  262. }, {
  263. label: '库存金额',
  264. prop: 'balanceMoney',
  265. index: 10
  266. }, {
  267. label: '库位',
  268. prop: 'storageName',
  269. index: 12
  270. }]
  271. },
  272. commodityLabel: [],
  273. commodityData: []
  274. }
  275. },
  276. async created() {
  277. generalLedgerListByGoods().then(res => {
  278. for (let item in res.data.data) {
  279. this.commodityLabel.push({label: res.data.data[item].cname, prop: item, id: res.data.data[item].id})
  280. this.commodityData[0] = {
  281. ...this.commodityData[0],
  282. [item]: `${res.data.data[item].sliceNumber?res.data.data[item].sliceNumber:0}片,${res.data.data[item].balanceNumber?res.data.data[item].balanceNumber:0}立方`
  283. }
  284. }
  285. })
  286. this.option = await this.getColumnData(this.getColumnName(200), this.optionList);
  287. this.key++
  288. let i = 0;
  289. this.option.column.forEach(item => {
  290. if (item.search) i++
  291. })
  292. if (i % 3 !== 0) {
  293. const num = 3 - Number(i % 3)
  294. this.option.searchMenuSpan = num * 8;
  295. this.option.searchMenuPosition = "right";
  296. }
  297. },
  298. methods: {
  299. summaryMethod({ columns, data }){
  300. const sums = [];
  301. if (columns.length > 0) {
  302. columns.forEach((column, index) => {
  303. let prop=column.property
  304. if (['sliceNumber','balanceNumber','balanceMoney'].includes(prop) ) {
  305. if(prop=='sliceNumber'){
  306. sums[index]=this.total.sliceNumber
  307. }else if(prop=='balanceNumber'){
  308. sums[index]=this.total.balanceNumber
  309. }else if(prop=='balanceMoney'){
  310. sums[index]=this.total.balanceMoney
  311. }
  312. } else {
  313. sums[0] = '合计'
  314. }
  315. });
  316. }
  317. return sums;
  318. },
  319. cellClick(row, column, cell, event) {
  320. for (let item of this.commodityLabel) {
  321. if (row.label == item.label) {
  322. this.search.itemId = item.id
  323. this.onLoad(this.page, this.search)
  324. }
  325. }
  326. },
  327. onLoad(page, params = {}) {
  328. let queryParams = {
  329. size: page.pageSize,
  330. current: page.currentPage,
  331. ...Object.assign(params, this.search)
  332. }
  333. getList(queryParams).then(res => {
  334. this.data = res.data.data.records
  335. this.page.total = res.data.data.total
  336. this.option.height = window.innerHeight - 230;
  337. generalLedgerTotal(queryParams).then(res=>{
  338. this.total = res.data.data
  339. })
  340. })
  341. },
  342. //搜索
  343. searchChange(params, done) {
  344. let data = params
  345. if (params.arrivalTime) {
  346. data.beginArrivalTime = params.arrivalTime[0]
  347. data.endArrivalTime = params.arrivalTime[1]
  348. }
  349. if (params.createTime) {
  350. data.beginCrateTime = params.createTime[0]
  351. data.endCrateTime = params.createTime[1]
  352. }
  353. delete data.arrivalTime
  354. delete data.createTime
  355. this.query = data;
  356. this.onLoad(this.page, data)
  357. done();
  358. },
  359. // 获得高度
  360. searchCriteriaSwitch(type) {
  361. if (type) {
  362. this.option.height = this.option.height - 55
  363. } else {
  364. this.option.height = this.option.height + 55
  365. }
  366. this.$refs.crud.getTableHeight()
  367. },
  368. //自定义列保存
  369. async saveColumn() {
  370. /**
  371. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  372. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  373. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  374. */
  375. const inSave = await this.saveColumnData(this.getColumnName(200), this.option);
  376. if (inSave) {
  377. this.$message.success("保存成功");
  378. //关闭窗口
  379. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  380. }
  381. },
  382. //自定义列重置
  383. async resetColumn() {
  384. this.option = this.optionList;
  385. const inSave = await this.delColumnData(this.getColumnName(200), this.optionList);
  386. if (inSave) {
  387. this.$message.success("重置成功");
  388. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  389. }
  390. },
  391. refreshChange() {
  392. this.onLoad(this.page, this.search);
  393. },
  394. //导出
  395. outExport() {
  396. this.$confirm('是否导出数据明细?', '提示', {
  397. confirmButtonText: '确定',
  398. cancelButtonText: '取消',
  399. type: 'warning'
  400. }).then(() => {
  401. let queryParams = this.query
  402. const routeData = this.$router.resolve({
  403. path: '/api/trade-purchase/woodHarvestingCloud/generalLedgerExport', //跳转目标窗口的地址
  404. query: {
  405. 'Blade-Auth': getToken(),
  406. ...queryParams //括号内是要传递给新窗口的参数
  407. }
  408. })
  409. window.open(routeData.href.slice(1, routeData.href.length));
  410. }).catch(() => {
  411. this.$message({
  412. type: 'info',
  413. message: '已取消' //
  414. });
  415. })
  416. },
  417. }
  418. }
  419. </script>
  420. <style scoped>
  421. </style>