index.vue 9.9 KB

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