index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <div>
  3. <basic-container class="page-crad" v-show="show">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. :page.sync="page"
  9. :search.sync="search"
  10. :cell-style="cellStyle"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. @resetColumn="resetColumn"
  19. @search-criteria-switch="searchCriteriaSwitch"
  20. @search-reset="searchReset"
  21. >
  22. <template slot="menuLeft">
  23. <el-button
  24. type="info"
  25. icon="el-icon-printer"
  26. size="small"
  27. :loading="exportLoading"
  28. @click.stop="statement"
  29. v-if="false"
  30. >报表打印
  31. </el-button>
  32. <el-button type="info" size="small" @click="outExport" icon="el-icon-download">导出</el-button>
  33. </template>
  34. <template slot="corpNameSearch">
  35. <crop-select
  36. v-model="search.corpId"
  37. corpType="KG"
  38. ></crop-select>
  39. </template>
  40. <template slot="sizeSearch">
  41. <el-select
  42. v-model="search.size"
  43. placeholder="请选择"
  44. >
  45. <el-option label="是" :value="1"></el-option>
  46. <el-option label="否" :value="0"></el-option>
  47. </el-select>
  48. </template>
  49. <template slot="corpName" slot-scope="scope">
  50. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.corpName }}</span>
  51. </template>
  52. </avue-crud>
  53. </basic-container>
  54. <report-dialog
  55. :switchDialog="switchDialog"
  56. :searchValue="statementData"
  57. :reportName="'经销商-可用库存表'"
  58. @onClose="onClose()"
  59. />
  60. <detail
  61. v-if="!show"
  62. :detail-data="detailData"
  63. :trade-type="tradeType"
  64. @goBack="goBack"
  65. ></detail>
  66. </div>
  67. </template>
  68. <script>
  69. import { getToken } from "@/util/auth";
  70. import { getList } from "@/api/statisticAnalysis/profitLedger";
  71. import { micrometerFormat } from "@/util/validate";
  72. import _ from "lodash";
  73. import reportDialog from "@/components/report-dialog/main";
  74. import { gainUser } from "@/api/basicData/customerInquiry";
  75. import detail from "./detail";
  76. export default {
  77. name: "index",
  78. components: {
  79. reportDialog,
  80. detail
  81. },
  82. data() {
  83. return {
  84. exportLoading:false,
  85. switchDialog:false,
  86. statementData: {},
  87. form: {},
  88. search: {},
  89. dataList: [],
  90. loading: false,
  91. detailData: {},
  92. page: {
  93. pageSize: 20,
  94. currentPage: 1,
  95. total: 0,
  96. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  97. },
  98. option: {},
  99. defaultOption: {
  100. searchShow: true,
  101. align: "center",
  102. searchSpan: 8,
  103. searchMenuSpan: 8,
  104. border: true,
  105. index: true,
  106. addBtn: false,
  107. viewBtn: false,
  108. editBtn: false,
  109. delBtn: false,
  110. showSummary: true,
  111. summaryText: '合计',
  112. sumColumnList: [
  113. {
  114. name: 'amount',
  115. type: 'sum'
  116. },
  117. {
  118. name: 'handleAmount',
  119. type: 'sum'
  120. },
  121. {
  122. name: 'profitAmount',
  123. type: 'sum'
  124. },
  125. ],
  126. searchIcon: true,
  127. searchIndex: 2,
  128. menu: false,
  129. column: [
  130. {
  131. label: "结算单位",
  132. prop: "corpName",
  133. search: true,
  134. overHidden: true,
  135. },
  136. {
  137. label: "年月",
  138. prop: "accDate",
  139. search: true,
  140. type: 'date',
  141. format: "yyyy-MM-dd",
  142. valueFormat: "yyyy-MM-dd",
  143. unlinkPanels: true,
  144. searchRange: true,
  145. overHidden: true,
  146. },
  147. {
  148. label: "应收金额",
  149. prop: "amount",
  150. search: false,
  151. overHidden: true,
  152. },
  153. {
  154. label: "成本金额",
  155. prop: "handleAmount",
  156. search: false,
  157. overHidden: true,
  158. },
  159. {
  160. label: "利润金额",
  161. prop: "profitAmount",
  162. search: false,
  163. overHidden: true,
  164. },
  165. ],
  166. },
  167. // 仓库配置
  168. configurationWarehouse: {
  169. multipleChoices: false,
  170. multiple: false,
  171. collapseTags: false,
  172. placeholder: "请点击右边按钮选择",
  173. dicData: [],
  174. },
  175. brandOption: [],
  176. userList: [],
  177. tradeType: '',
  178. sysitemType: null,
  179. show: true,
  180. };
  181. },
  182. filters: {
  183. decimalFormat(num) {
  184. return num ? Number(num).toFixed(2) : "0.00";
  185. }
  186. },
  187. async created() {
  188. this.option = await this.getColumnData(this.getColumnName(139), this.defaultOption);
  189. this.getWorkDicts('brand').then(res => {
  190. this.brandOption = res.data.data;
  191. })
  192. gainUser().then(res => {
  193. this.userList = res.data.data;
  194. });
  195. let i = 0;
  196. this.option.column.forEach(item => {
  197. if (item.search) i++
  198. })
  199. if (i % 3 !== 0){
  200. const num = 3 - Number(i % 3)
  201. this.option.searchMenuSpan = num * 8;
  202. this.option.searchMenuPosition = "right";
  203. }
  204. },
  205. methods: {
  206. cellStyle() {
  207. return "padding:0;height:40px;";
  208. },
  209. searchReset() {
  210. },
  211. searchCriteriaSwitch(type) {
  212. if (type) {
  213. this.option.height = this.option.height - 46;
  214. } else {
  215. this.option.height = this.option.height + 46;
  216. }
  217. this.$refs.crud.getTableHeight();
  218. },
  219. //点击搜索按钮触发
  220. searchChange(params, done) {
  221. this.page.currentPage = 1;
  222. this.onLoad(this.page, params);
  223. done();
  224. },
  225. refreshChange() {
  226. this.onLoad(this.page, this.search);
  227. },
  228. currentChange(val) {
  229. this.page.currentPage = val;
  230. },
  231. sizeChange(val) {
  232. this.page.currentPage = 1;
  233. this.page.pageSize = val;
  234. },
  235. onLoad(page, params) {
  236. this.sysitemType = localStorage.getItem('sysitemType');
  237. if (this.sysitemType == 999) {
  238. this.tradeType = ''
  239. } else if (this.sysitemType == 1) {
  240. this.tradeType = 'XX'
  241. } else if (this.sysitemType == 2) {
  242. this.tradeType = 'GN'
  243. } else if (this.sysitemType == 3) {
  244. this.tradeType = 'JK'
  245. } else if (this.sysitemType == 4) {
  246. this.tradeType = 'CK'
  247. } else if (this.sysitemType == 5) {
  248. this.tradeType = 'SW'
  249. } else if (this.sysitemType == 6) {
  250. this.tradeType = 'JXS'
  251. } else if (this.sysitemType == 7) {
  252. this.tradeType = 'LY'
  253. }
  254. this.loading = true;
  255. this.dataList.forEach(item => {
  256. this.$refs.crud.toggleRowExpansion(item, false);
  257. });
  258. let queryParams = Object.assign({tradeType: this.tradeType}, params);
  259. if (queryParams.accDate && queryParams.accDate.length > 0) {
  260. queryParams = {
  261. ...queryParams,
  262. accDateStart: queryParams.accDate[0] + ' 00:00:00',
  263. accDateEnd: queryParams.accDate[1] + ' 23:59:59',
  264. }
  265. delete queryParams.accDate;
  266. }
  267. getList(
  268. page.currentPage,
  269. page.pageSize,
  270. queryParams
  271. )
  272. .then(res => {
  273. if (res.data.data.records) {
  274. res.data.data.records.forEach(e => {
  275. e.itemLoading = true;
  276. });
  277. }
  278. this.dataList = res.data.data.records ? res.data.data.records : [];
  279. this.page.total = res.data.data.total;
  280. if (this.page.total) {
  281. this.option.height = window.innerHeight - 230;
  282. }
  283. })
  284. .finally(() => {
  285. this.loading = false;
  286. });
  287. },
  288. editOpen(row) {
  289. if (row.billType == "BJ") {
  290. this.$router.push({
  291. path: "/exportTrade/customerInquiry/index",
  292. query: {
  293. id: row.id
  294. }
  295. });
  296. } else {
  297. this.$router.push({
  298. path: "/exportTrade/salesContract/index",
  299. query: {
  300. id: row.id
  301. }
  302. });
  303. }
  304. },
  305. statement() {
  306. this.statementData = {...this.search};
  307. if (this.statementData.accDate && this.statementData.accDate.length > 0) {
  308. this.statementData.accDateStart = this.statementData.accDate[0]+ " " + "00:00:00"
  309. this.statementData.accDateEnd = this.statementData.accDate[1]+ " " + "23:59:59"
  310. delete this.statementData.accDate
  311. }
  312. this.switchDialog = !this.switchDialog;
  313. },
  314. onClose(val) {
  315. this.switchDialog = val;
  316. },
  317. //列保存触发
  318. async saveColumn() {
  319. const inSave = await this.saveColumnData(
  320. this.getColumnName(139),
  321. this.option
  322. );
  323. if (inSave) {
  324. this.$nextTick(() => {
  325. this.$refs.crud.doLayout();
  326. });
  327. this.$message.success("保存成功");
  328. //关闭窗口
  329. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  330. }
  331. },
  332. async resetColumn() {
  333. this.option = this.defaultOption;
  334. const inSave = await this.delColumnData(this.getColumnName(139), this.defaultOption);
  335. if (inSave) {
  336. this.$nextTick(() => {
  337. this.$refs.crud.doLayout()
  338. })
  339. this.$message.success("重置成功");
  340. //关闭窗口
  341. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  342. }
  343. },
  344. // 跳转到详情
  345. beforeOpenPage(row, index) {
  346. this.detailData = {
  347. id: row.corpId
  348. };
  349. this.show = false;
  350. },
  351. goBack() {
  352. this.detailData=this.$options.data().detailData
  353. if (JSON.stringify(this.$route.query) != "{}") {
  354. this.$router.$avueRouter.closeTag();
  355. this.$router.push({
  356. path: "/statisticAnalysis/collectLedger/index"
  357. });
  358. }
  359. this.dataList.forEach(item => {
  360. this.$refs.crud.toggleRowExpansion(item, false)
  361. })
  362. this.show = true;
  363. this.onLoad(this.page, this.search);
  364. },
  365. outExport() {
  366. if (!this.search.corpId) this.$set(this.search, 'corpId', '');
  367. if (this.search.accDate && this.search.accDate.length > 0) {
  368. this.search = {
  369. ...this.search,
  370. accDateStart: this.search.accDate[0] + ' 00:00:00',
  371. accDateEnd: this.search.accDate[1] + ' 23:59:59',
  372. }
  373. } else {
  374. this.search = {
  375. ...this.search,
  376. accDateStart: '',
  377. accDateEnd: '',
  378. }
  379. }
  380. this.$confirm('是否导出应付总账信息?', '提示', {
  381. confirmButtonText: '确定',
  382. cancelButtonText: '取消',
  383. type: 'warning'
  384. }).then(() => {
  385. window.open(
  386. `/api/trade-finance/profit/export?${
  387. this.website.tokenHeader
  388. }=${getToken()}&tradeType=${this.tradeType}&corpId=${this.search.corpId}&accDateStart=${this.search.accDateStart}&accDateEnd=${this.search.accDateEnd}`
  389. );
  390. }).catch(() => {
  391. this.$message({
  392. type: 'info',
  393. message: '已取消' //
  394. });
  395. })
  396. },
  397. }
  398. };
  399. </script>
  400. <style scoped>
  401. .page-crad ::v-deep .basic-container__card {
  402. height: 94.2vh;
  403. }
  404. ::v-deep .el-table__expanded-cell[class*="cell"] {
  405. padding: 0px;
  406. }
  407. .itemTable ::v-deep .el-table {
  408. width: 100%;
  409. }
  410. </style>