index.vue 11 KB

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