sales-trend.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div class="home-container">
  3. <el-card class="home-container__card" v-if="tenantId == 577435">
  4. <div style="display:flex;">
  5. <el-date-picker
  6. v-model="search.dateList"
  7. type="daterange"
  8. range-separator="-"
  9. size="mini"
  10. style="margin-right: 5px"
  11. :default-time="['00:00:00', '23:59:59']"
  12. value-format="yyyy-MM-dd HH:mm:ss"
  13. @change="query(0)"
  14. start-placeholder="开始日期"
  15. end-placeholder="结束日期">
  16. </el-date-picker>
  17. <el-button size="mini" @click="query(1)">当日</el-button>
  18. <el-button size="mini" @click="query(2)">当月</el-button>
  19. </div>
  20. <el-table
  21. :data="tableData"
  22. size="mini"
  23. height="300"
  24. style="width: 100%">
  25. <el-table-column
  26. prop="orderNo"
  27. align="center"
  28. show-overflow-tooltip
  29. label="订单号">
  30. </el-table-column>
  31. <el-table-column
  32. prop="corpsName"
  33. align="center"
  34. show-overflow-tooltip
  35. label="客户名称">
  36. </el-table-column>
  37. <el-table-column
  38. prop="businesDate"
  39. align="center"
  40. show-overflow-tooltip
  41. label="订单日期">
  42. </el-table-column>
  43. <el-table-column
  44. prop="orderStatus"
  45. align="center"
  46. show-overflow-tooltip
  47. label="订单状态">
  48. <template slot-scope="{row}">
  49. <span v-for="item in orderStatusList" :style="{color: item.colour}" v-if="item.dictValue == row.orderStatus">{{row.orderStatus}}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column
  53. prop="createUserName"
  54. align="center"
  55. show-overflow-tooltip
  56. label="制单人">
  57. </el-table-column>
  58. <el-table-column
  59. prop="documenterName"
  60. align="center"
  61. show-overflow-tooltip
  62. label="跟单人">
  63. </el-table-column>
  64. <el-table-column
  65. prop="buyerName"
  66. align="center"
  67. show-overflow-tooltip
  68. label="采购员">
  69. </el-table-column>
  70. </el-table>
  71. </el-card>
  72. <el-card class="home-container__card" v-else>
  73. <div v-if="sysType !== 5">
  74. <!--<div class="title">-->
  75. <!-- <span>-->
  76. <!-- 销售趋势-->
  77. <!-- </span>-->
  78. <!-- <span>-->
  79. <!-- <i-->
  80. <!-- class="el-icon-refresh-right"-->
  81. <!-- style="cursor: pointer;font-size:20px"-->
  82. <!-- @click="refresh"-->
  83. <!-- ></i>-->
  84. <!-- </span>-->
  85. <!--</div>-->
  86. <index-card
  87. title="销售趋势"
  88. iconName="el-icon-s-fold"
  89. style="height:400px;margin-bottom: 30px"
  90. >
  91. <div slot="select">
  92. <el-date-picker
  93. v-model="annual3"
  94. type="year"
  95. size="mini"
  96. placeholder="选择年"
  97. value-format="yyyy"
  98. style="margin-right:10px;margin-bottom: -20px"
  99. @change="commoDity2Datafun"
  100. >
  101. </el-date-picker>
  102. </div>
  103. <div slot="content" style="height:350px" id="commoDity2"></div>
  104. </index-card>
  105. <!--<div class="content" v-loading="loading">-->
  106. <!-- <div class="content-year">-->
  107. <!-- <el-date-picker-->
  108. <!-- v-model="annual"-->
  109. <!-- type="year"-->
  110. <!-- size="mini"-->
  111. <!-- placeholder="选择年"-->
  112. <!-- value-format="yyyy"-->
  113. <!-- style="margin-right:10px"-->
  114. <!-- @change="getsalesTrend"-->
  115. <!-- />-->
  116. <!-- </div>-->
  117. <!-- <div-->
  118. <!-- id="polylineData"-->
  119. <!-- ref="polylineData"-->
  120. <!-- style="width:55vw;height:33vh"-->
  121. <!-- />-->
  122. <!--</div>-->
  123. </div>
  124. <div v-if="sysType === 5">
  125. <div class="title">
  126. <span>
  127. 业绩趋势
  128. </span>
  129. <span>
  130. <i
  131. class="el-icon-refresh-right"
  132. style="cursor: pointer;font-size:20px"
  133. @click="refresh"
  134. ></i>
  135. </span>
  136. </div>
  137. <div class="content" v-loading="loading">
  138. <div
  139. id="polylineDatas"
  140. ref="polylineData"
  141. style="width:60vw;height:33vh"
  142. />
  143. </div>
  144. </div>
  145. </el-card>
  146. </div>
  147. </template>
  148. <script>
  149. import {dateFormat, getYearDate} from "@/util/date";
  150. import {salesList, salesTrend, xinsalaryDataChain} from "@/api/wel";
  151. import indexCard from "../components/card.vue";
  152. import butCard from "../components/butCard.vue";
  153. export default {
  154. name: "basicContainer",
  155. components: {
  156. indexCard,
  157. butCard
  158. },
  159. props: {
  160. sysType: Number
  161. },
  162. data() {
  163. return {
  164. loading: false,
  165. annual: "",
  166. search:{},
  167. tradeType: null,
  168. tenantId: this.$store.getters.userInfo.tenant_id,
  169. moneyList: [],
  170. tableData:[],
  171. orderStatusList:[],
  172. annual3:'',
  173. amountList2:[],
  174. numberList2:[],
  175. };
  176. },
  177. created() {
  178. this.annual = getYearDate().toString();
  179. this.getSysType();
  180. this.getWorkDicts("order_status").then(res => {
  181. this.orderStatusList = res.data.data
  182. });
  183. this.annual3 = getYearDate().toString();
  184. },
  185. mounted() {
  186. this.init();
  187. this.commoDity2Datafun()
  188. },
  189. methods: {
  190. query(type){
  191. const date = new Date();
  192. if (type == 1){
  193. this.$set(this.search,"dateList",[`${dateFormat(new Date(),"yyyy-MM-dd")} 00:00:00`,`${dateFormat(new Date(),"yyyy-MM-dd")} 23:59:59`])
  194. }
  195. if (type == 2){
  196. this.$set(this.search,"dateList",[
  197. `${dateFormat(new Date(date.getFullYear(), date.getMonth(), 1),"yyyy-MM-dd")} 00:00:00`,
  198. `${dateFormat(new Date(date.getFullYear(), date.getMonth() + 1, 0),"yyyy-MM-dd")} 23:59:59`
  199. ])
  200. }
  201. salesList({...this.search}).then(res=>{
  202. this.tableData = res.data.data
  203. })
  204. },
  205. init() {
  206. if (this.tradeType == null) {
  207. return
  208. }else {
  209. this.getsalesTrend();
  210. }
  211. },
  212. getSysType() {
  213. const sysType = localStorage.getItem("sysitemType");
  214. if (sysType == 6) {
  215. this.tradeType = "JXS";
  216. } else if (sysType == 5) {
  217. this.tradeType = "SW";
  218. } else if (sysType == 4) {
  219. this.tradeType = "CK";
  220. } else if (sysType == 3) {
  221. this.tradeType = "JK";
  222. } else if (sysType == 2) {
  223. this.tradeType = "GN";
  224. } else if (sysType == 1) {
  225. this.tradeType = "XX";
  226. } else if (sysType == 999) {
  227. this.tradeType = "ADMIN";
  228. }
  229. },
  230. getsalesTrend() {
  231. this.loading = true;
  232. this.moneyList = [];
  233. salesTrend({
  234. tradeType: this.tradeType,
  235. billType: "XS",
  236. annual: this.annual
  237. })
  238. .then(res => {
  239. res.data.data.forEach(e => {
  240. this.moneyList.push(Number(e.money));
  241. });
  242. })
  243. .finally(() => {
  244. this.loading = false;
  245. this.polylineData();
  246. });
  247. },
  248. refresh() {
  249. this.init();
  250. },
  251. polylineData() {
  252. let polylineData = this.$echarts.init(
  253. document.getElementById("polylineData")
  254. );
  255. polylineData.setOption({
  256. tooltip: {
  257. trigger: "axis",
  258. axisPointer: {
  259. type: "line"
  260. }
  261. },
  262. xAxis: {
  263. type: "category",
  264. data: [
  265. "一月",
  266. "二月",
  267. "三月",
  268. "四月",
  269. "五月",
  270. "六月",
  271. "七月",
  272. "八月",
  273. "九月",
  274. "十月",
  275. "十一月",
  276. "十二月"
  277. ]
  278. },
  279. yAxis: {
  280. type: "value"
  281. },
  282. series: [
  283. {
  284. data: this.moneyList,
  285. type: "line",
  286. smooth: true
  287. }
  288. ]
  289. });
  290. },
  291. // 获取echarts 表的数据
  292. commoDity2Datafun() {
  293. xinsalaryDataChain({
  294. year:Number(this.annual3)
  295. }).then(res=>{
  296. this.amountList2 = res.data.data.amount
  297. this.numberList2 = res.data.data.number
  298. this.commoDity2()
  299. })
  300. },
  301. commoDity2() {
  302. // 基于准备好的dom,初始化echarts实例,所以只能在mounted中调用
  303. let myChart = this.$echarts.init(document.getElementById("commoDity2"));
  304. // 绘制图表
  305. myChart.setOption({
  306. tooltip: {
  307. trigger: 'axis',
  308. axisPointer: {
  309. type: 'cross',
  310. crossStyle: {
  311. color: '#999'
  312. }
  313. }
  314. },
  315. toolbox: {
  316. },
  317. legend: {
  318. data: ['数量', '金额']
  319. },
  320. xAxis: [
  321. {
  322. type: 'category',
  323. data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月','十二月'],
  324. axisPointer: {
  325. type: 'shadow'
  326. }
  327. }
  328. ],
  329. grid: {
  330. left: "10%",
  331. right: "10%",
  332. bottom: "3%",
  333. containLabel: true
  334. },
  335. yAxis: [
  336. {
  337. type: 'value',
  338. name: '数量(条)',
  339. min: 0,
  340. axisLine:{
  341. show:true,
  342. lineStyle: {
  343. color: "#5266bc",//y轴线的颜色(若只设置了y轴线的颜色,未设置y轴文字的颜色,则y轴文字会默认跟设置的y轴线颜色一致)
  344. },
  345. },
  346. axisLabel: {
  347. formatter: '{value}'
  348. }
  349. },
  350. {
  351. type: 'value',
  352. name: '金额(元)',
  353. min: 0,
  354. axisLine:{
  355. show:true,
  356. lineStyle: {
  357. color: "#98c46d",//y轴线的颜色(若只设置了y轴线的颜色,未设置y轴文字的颜色,则y轴文字会默认跟设置的y轴线颜色一致)
  358. },
  359. },
  360. axisLabel: {
  361. formatter: '{value}',
  362. // textStyle: {
  363. // color: "#000",//Y轴内容文字颜色
  364. // },
  365. }
  366. }
  367. ],
  368. series: [
  369. {
  370. name: '数量',
  371. type: 'bar',
  372. yAxisIndex: 0,
  373. tooltip: {
  374. valueFormatter: function (value) {
  375. return value + ' 条';
  376. }
  377. },
  378. data: this.numberList2
  379. },
  380. {
  381. name: '金额',
  382. type: 'bar',
  383. yAxisIndex: 1,
  384. tooltip: {
  385. valueFormatter: function (value) {
  386. return value + ' 元';
  387. }
  388. },
  389. data: this.amountList2
  390. },
  391. ]
  392. });
  393. },
  394. }
  395. };
  396. </script>
  397. <style lang="scss" scoped>
  398. .home-container {
  399. padding: 0px 5px 5px 0px;
  400. box-sizing: border-box;
  401. height: 100%;
  402. ::v-deep .el-card__body {
  403. padding: 10px 15px;
  404. font-size: 14px;
  405. }
  406. &__card {
  407. width: 100%;
  408. height: 100%;
  409. }
  410. .title {
  411. display: flex;
  412. justify-content: space-between;
  413. }
  414. }
  415. .content {
  416. display: flex;
  417. flex-direction: column;
  418. &-year {
  419. display: flex;
  420. justify-content: right;
  421. }
  422. }
  423. </style>