index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div>
  3. <basic-container class="page-crad">
  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">
  8. <template slot="menuLeft">
  9. <el-button type="info" size="small" @click="outExport">导出
  10. </el-button>
  11. </template>
  12. <template slot="corpNameSearch">
  13. <crop-select v-model="search.corpName" corpType="KH" :zhKey="true"></crop-select>
  14. </template>
  15. <template slot="businesDateSearch">
  16. <el-date-picker v-model="search.businesDate" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
  17. format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']">
  18. </el-date-picker>
  19. </template>
  20. <template slot="predictOceanFreight" slot-scope="{ row, index }">
  21. <span>{{ Number(row.predictOceanFreight ? row.predictOceanFreight : 0).toFixed(2) }}</span>
  22. </template>
  23. <template slot="netGrossProfit" slot-scope="{ row, index }">
  24. <span>{{ Number(row.netGrossProfit ? row.netGrossProfit : 0).toFixed(2) }}</span>
  25. </template>
  26. <template slot="grossProfitRate" slot-scope="{ row, index }">
  27. <span>{{ Number(row.grossProfitRate ? row.grossProfitRate : 0).toFixed(2) }}</span>
  28. </template>
  29. <template slot="purchaseAmount" slot-scope="{ row, index }">
  30. <span>{{ Number(row.purchaseAmount ? row.purchaseAmount : 0).toFixed(2) }}</span>
  31. </template>
  32. </avue-crud>
  33. </basic-container>
  34. </div>
  35. </template>
  36. <script>
  37. import { getToken } from "@/util/auth";
  38. import { getList } from "@/api/statisticAnalysis/customerProfit"
  39. import { defaultDate5 } from "@/util/date";
  40. import { gainUser } from "@/api/basicData/customerInquiry";
  41. export default {
  42. name: "index",
  43. data() {
  44. return {
  45. UConfiguration: {
  46. multipleChoices: false,
  47. multiple: false,
  48. disabled: false,
  49. searchShow: true,
  50. collapseTags: false,
  51. placeholder: '请点击右边按钮选择',
  52. dicData: []
  53. },
  54. form: {},
  55. search: {
  56. date: defaultDate5()
  57. },
  58. dataList: [],
  59. loading: false,
  60. detailData: {},
  61. page: {
  62. pageSize: 20,
  63. currentPage: 1,
  64. total: 0,
  65. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  66. },
  67. option: {},
  68. optionBack: {
  69. align: "center",
  70. searchShow: true,
  71. searchMenuPosition: "right",
  72. searchSpan: 8,
  73. searchMenuSpan: 24,
  74. border: true,
  75. index: true,
  76. addBtn: false,
  77. viewBtn: false,
  78. editBtn: false,
  79. delBtn: false,
  80. searchIcon: true,
  81. menu: false,
  82. summaryText: "合计",
  83. showSummary: true,
  84. sumColumnList: [
  85. {
  86. name: "quantity",
  87. type: "sum",
  88. decimals: 0
  89. },
  90. {
  91. name: "grossProfit",
  92. type: "sum",
  93. decimals: 2
  94. },
  95. {
  96. name: "amount",
  97. type: "sum",
  98. decimals: 2
  99. },
  100. {
  101. name: "thisUsedProfit",
  102. type: "sum",
  103. decimals: 2
  104. },
  105. {
  106. name: "grossProfit",
  107. type: "sum",
  108. decimals: 2
  109. },
  110. {
  111. name: "predictOceanFreight",
  112. type: "sum",
  113. decimals: 2
  114. },
  115. {
  116. name: "netGrossProfit",
  117. type: "sum",
  118. decimals: 2
  119. },
  120. {
  121. name: "purchaseAmount",
  122. type: "sum",
  123. decimals: 2
  124. }
  125. ],
  126. column: [
  127. {
  128. label: "业务日期",
  129. prop: "date",
  130. type: "date",
  131. format: 'yyyy-MM-dd',
  132. valueFormat: 'yyyy-MM-dd',
  133. searchValue:defaultDate5(),
  134. searchRange: true,
  135. overHidden: true,
  136. hide: true,
  137. showColumn: false,
  138. search: true,
  139. },
  140. {
  141. label: "品牌",
  142. prop: "brand",
  143. filterable: true,
  144. multiple: true,
  145. type: "select",
  146. props: {
  147. label: "dictValue",
  148. value: "dictValue"
  149. },
  150. dicData: [],
  151. dataType: "string",
  152. overHidden: true,
  153. hide: true,
  154. showColumn: false,
  155. search: true
  156. },
  157. {
  158. label: "客户",
  159. prop: "corpName",
  160. overHidden: true,
  161. search: true
  162. },
  163. {
  164. label: "销售收入",
  165. prop: "amount",
  166. overHidden: true,
  167. },
  168. {
  169. label: "数量",
  170. prop: "quantity",
  171. overHidden: true,
  172. },
  173. {
  174. label: "销售成本",
  175. prop: "purchaseAmount",
  176. overHidden: true,
  177. },
  178. {
  179. label: "返利",
  180. prop: "thisUsedProfit",
  181. overHidden: true,
  182. },
  183. {
  184. label: "毛利额",
  185. prop: "grossProfit",
  186. overHidden: true,
  187. },
  188. {
  189. label: "订单运费",
  190. prop: "predictOceanFreight",
  191. overHidden: true,
  192. },
  193. {
  194. label: "营业净利润",
  195. prop: "netGrossProfit",
  196. overHidden: true,
  197. },
  198. {
  199. label: "订单毛利率",
  200. prop: "grossProfitRate",
  201. overHidden: true,
  202. }
  203. ]
  204. }
  205. };
  206. },
  207. async created() {
  208. this.option = await this.getColumnData(this.getColumnName(231), this.optionBack);
  209. this.getAllWorkDicts()
  210. },
  211. activated() {
  212. this.$nextTick(() => {
  213. this.$refs.crud.refreshTable();
  214. });
  215. },
  216. methods: {
  217. getAllWorkDicts() {
  218. this.option.height = window.innerHeight - 210;
  219. this.getWorkDicts('brand').then(res => {
  220. this.findObject(this.option.column, "brand").dicData =
  221. res.data.data;
  222. })
  223. // gainUser().then(res => {
  224. // this.findObject(this.option.column, "chargeMember").dicData =
  225. // res.data.data;
  226. // })
  227. },
  228. cellStyle() {
  229. return "padding:0;height:40px;";
  230. },
  231. searchCriteriaSwitch(type) {
  232. if (type) {
  233. this.option.height = this.option.height - 46;
  234. } else {
  235. this.option.height = this.option.height + 46;
  236. }
  237. this.$refs.crud.getTableHeight();
  238. },
  239. //点击搜索按钮触发
  240. searchChange(params, done) {
  241. this.page.currentPage = 1;
  242. this.onLoad(this.page, params);
  243. done();
  244. },
  245. refreshChange() {
  246. this.onLoad(this.page, this.search);
  247. },
  248. currentChange(val) {
  249. this.page.currentPage = val;
  250. },
  251. sizeChange(val) {
  252. this.page.currentPage = 1;
  253. this.page.pageSize = val;
  254. },
  255. onLoad(page, params = {}) {
  256. let data = this.deepClone(Object.assign({}, params, this.search));
  257. if (data.date) {
  258. data.beginTime = data.date[0]
  259. data.endTime = data.date[1]
  260. delete data.date
  261. }
  262. this.loading = true;
  263. getList(
  264. page.currentPage,
  265. page.pageSize,
  266. data
  267. ).then(res => {
  268. this.dataList = res.data.data.records ? res.data.data.records : [];
  269. this.page.total = res.data.data.total;
  270. }).finally(() => {
  271. this.loading = false;
  272. });
  273. },
  274. //列保存触发
  275. async saveColumn() {
  276. const inSave = await this.saveColumnData(this.getColumnName(231), this.option);
  277. if (inSave) {
  278. this.$message.success("保存成功");
  279. //关闭窗口
  280. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  281. }
  282. },
  283. async resetColumn() {
  284. this.option = this.optionBack;
  285. const inSave = await this.delColumnData(this.getColumnName(231), this.optionBack);
  286. this.getAllWorkDicts()
  287. if (inSave) {
  288. this.$message.success("重置成功");
  289. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  290. }
  291. },
  292. editOpen(row) {
  293. },
  294. outExport() {
  295. let params = { ...this.search }
  296. if (params.date && params.date.length > 0) {
  297. params = {
  298. ...params,
  299. beginTime: params.date[0],
  300. endTime: params.date[1],
  301. }
  302. } else {
  303. params = {
  304. ...params,
  305. beginTime: '',
  306. endTime: '',
  307. }
  308. }
  309. window.open(
  310. `/api/blade-purchase-sales/exportOrder/customerProfitExport?${this.website.tokenHeader
  311. }=${getToken()}&beginTime=${params.beginTime}&endTime=${params.endTime}&brand=${params.brand ? params.brand : ''}`
  312. );
  313. }
  314. }
  315. };
  316. </script>
  317. <style scoped>
  318. .page-crad ::v-deep .basic-container__card {
  319. height: 94.2vh;
  320. }
  321. ::v-deep .el-table__expanded-cell[class*="cell"] {
  322. padding: 0px;
  323. }
  324. .itemTable ::v-deep .el-table {
  325. width: 100%;
  326. }
  327. </style>