index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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">导出</el-button>
  10. </template>
  11. <template slot="corpNameSearch">
  12. <crop-select v-model="search.corpName" corpType="KH" :zhKey="true"></crop-select>
  13. </template>
  14. <template slot="careteTimeSearch">
  15. <el-date-picker v-model="search.careteTime" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
  16. format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']">
  17. </el-date-picker>
  18. </template>
  19. <template slot="brandSearch">
  20. <el-select v-model="search.brand" filterable clearable>
  21. <el-option v-for="(item, index) in brandOption" :key="index" :label="item.dictValue"
  22. :value="item.dictValue" />
  23. </el-select>
  24. </template>
  25. </avue-crud>
  26. </basic-container>
  27. </div>
  28. </template>
  29. <script>
  30. import { getToken } from "@/util/auth";
  31. import { getList } from "@/api/statisticAnalysis/salesProfitN"
  32. import _ from "lodash";
  33. export default {
  34. name: "index",
  35. data() {
  36. return {
  37. form: {},
  38. search: {},
  39. dataList: [],
  40. loading: false,
  41. detailData: {},
  42. page: {
  43. pageSize: 20,
  44. currentPage: 1,
  45. total: 0,
  46. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  47. },
  48. option: {
  49. searchShow: true,
  50. searchMenuSpan: 8,
  51. align: "center",
  52. searchSpan: 8,
  53. border: true,
  54. index: true,
  55. addBtn: false,
  56. viewBtn: false,
  57. editBtn: false,
  58. delBtn: false,
  59. showSummary: true,
  60. searchIcon: true,
  61. searchIndex: 2,
  62. menu: false,
  63. column: [
  64. {
  65. label: "客户名称",
  66. prop: "corpName",
  67. overHidden: true,
  68. width: 100,
  69. search: true
  70. },
  71. {
  72. label: "品牌",
  73. prop: "brand",
  74. type: "select",
  75. showColumn: false,
  76. search: true
  77. },
  78. {
  79. label: "省份",
  80. prop: "province",
  81. overHidden: true,
  82. width: 100,
  83. search: true
  84. },
  85. {
  86. label: "日期",
  87. prop: "careteTime",
  88. type: "date",
  89. format: "yyyy-MM-dd",
  90. overHidden: true,
  91. search: true,
  92. width: 100
  93. },
  94. {
  95. label: "业务员",
  96. prop: "salesName",
  97. overHidden: true,
  98. search: true,
  99. width: 100
  100. },
  101. {
  102. label: "发货数量",
  103. prop: "quantity",
  104. overHidden: true,
  105. width: 100
  106. },
  107. {
  108. label: "销售金额",
  109. prop: "amount",
  110. overHidden: true,
  111. width: 100
  112. },
  113. {
  114. label: "特价条数",
  115. prop: "specialOfferQuantity",
  116. overHidden: true,
  117. width: 100
  118. },
  119. {
  120. label: "特价总金额",
  121. prop: "specialOfferAmounts",
  122. overHidden: true,
  123. width: 100
  124. },
  125. {
  126. label: "非特价条数",
  127. prop: "nonSpecialOfferQuantity",
  128. overHidden: true,
  129. width: 100
  130. },
  131. {
  132. label: "非特价总金额",
  133. prop: "nonSpecialOfferAmount",
  134. overHidden: true,
  135. width: 100
  136. },
  137. {
  138. label: "17寸以上数量",
  139. prop: "seventeenQuantity",
  140. overHidden: true,
  141. width: 100
  142. },
  143. {
  144. label: "17寸以上金额",
  145. prop: "seventeenAmount",
  146. overHidden: true,
  147. width: 100
  148. },
  149. {
  150. label: "采购金额",
  151. prop: "purchaseAmount",
  152. overHidden: true,
  153. width: 100
  154. },
  155. {
  156. label: "返利使用额",
  157. prop: "thisUsedProfit",
  158. overHidden: true,
  159. width: 100
  160. },
  161. {
  162. label: "费用总金额",
  163. prop: "totalAmount",
  164. overHidden: true,
  165. width: 100
  166. },
  167. {
  168. label: "销售毛利",
  169. prop: "grossProfit",
  170. overHidden: true,
  171. width: 100
  172. },
  173. {
  174. label: "销售毛利率",
  175. prop: "grossProfitRate",
  176. overHidden: true,
  177. width: 100
  178. }
  179. ]
  180. },
  181. brandOption: []
  182. };
  183. },
  184. async created() {
  185. this.option = await this.getColumnData(this.getColumnName(185), this.option);
  186. this.getWorkDicts('brand').then(res => {
  187. this.brandOption = res.data.data;
  188. })
  189. },
  190. methods: {
  191. cellStyle() {
  192. return "padding:0;height:40px;";
  193. },
  194. searchCriteriaSwitch(type) {
  195. if (type) {
  196. this.option.height = this.option.height - 46;
  197. } else {
  198. this.option.height = this.option.height + 46;
  199. }
  200. this.$refs.crud.getTableHeight();
  201. },
  202. //点击搜索按钮触发
  203. searchChange(params, done) {
  204. this.page.currentPage = 1;
  205. this.onLoad(this.page, params);
  206. done();
  207. },
  208. refreshChange() {
  209. this.onLoad(this.page, this.search);
  210. },
  211. currentChange(val) {
  212. this.page.currentPage = val;
  213. },
  214. sizeChange(val) {
  215. this.page.currentPage = 1;
  216. this.page.pageSize = val;
  217. },
  218. onLoad(page, params = {}) {
  219. let data = this.deepClone(Object.assign({}, params, this.search));
  220. if (data.careteTime) {
  221. data.beginCreateTime = data.careteTime[0]
  222. data.endCreateTime = data.careteTime[1]
  223. delete data.careteTime
  224. }
  225. this.loading = true;
  226. getList(
  227. page.currentPage,
  228. page.pageSize,
  229. data
  230. )
  231. .then(res => {
  232. if (res.data.data.records) {
  233. res.data.data.records.forEach(e => {
  234. e.itemLoading = true;
  235. });
  236. }
  237. this.dataList = res.data.data.records ? res.data.data.records : [];
  238. this.page.total = res.data.data.total;
  239. if (this.page.total) {
  240. this.option.height = window.innerHeight - 210;
  241. }
  242. })
  243. .finally(() => {
  244. this.loading = false;
  245. });
  246. },
  247. //列保存触发
  248. async saveColumn() {
  249. const inSave = await this.saveColumnData(this.getColumnName(185), this.option);
  250. if (inSave) {
  251. this.$message.success("保存成功");
  252. //关闭窗口
  253. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  254. }
  255. },
  256. async resetColumn() {
  257. this.option = this.option;
  258. const inSave = await this.delColumnData(this.getColumnName(185), this.option);
  259. if (inSave) {
  260. this.$message.success("重置成功");
  261. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  262. }
  263. },
  264. outExport() {
  265. let params = { ...this.search }
  266. if (params.careteTime && params.careteTime.length > 0) {
  267. params = {
  268. ...params,
  269. beginCreateTime: params.careteTime[0] + ' 00:00:00',
  270. endCreateTime: params.careteTime[1] + ' 23:59:59',
  271. }
  272. } else {
  273. params = {
  274. ...params,
  275. beginCreateTime: '',
  276. endCreateTime: '',
  277. }
  278. }
  279. window.open(
  280. `/api/blade-purchase-sales/exportOrder/selSalesProfitExport?${this.website.tokenHeader
  281. }=${getToken()}&corpName=${this.search.corpName}&brand=${params.brand}&beginCreateTime=${params.beginCreateTime}&endCreateTime=${params.endCreateTime}&salesName=${params.salesName}&province=${params.province}`
  282. );
  283. },
  284. }
  285. };
  286. </script>
  287. <style scoped>
  288. .page-crad ::v-deep .basic-container__card {
  289. height: 94.2vh;
  290. }
  291. ::v-deep .el-table__expanded-cell[class*="cell"] {
  292. padding: 0px;
  293. }
  294. .itemTable ::v-deep .el-table {
  295. width: 100%;
  296. }
  297. </style>