index.vue 9.5 KB

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