Analysis.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. <template>
  2. <div class="analysis">
  3. <!-- 工作看板 -->
  4. <board :title="title[0]">
  5. <div>
  6. <work-infos :dataList="workInfos" @workInfoClick="handleWorkInfoClick">
  7. </work-infos>
  8. <div class="table-content">
  9. <table-content
  10. :tableItems="tableItems"
  11. :height="height"
  12. :shows="tableShows"
  13. :listData="tableData"
  14. >
  15. <template v-slot:handleState="slotProps">
  16. {{ slotProps.row.handleState ? "已处理" : "未处理" }}
  17. </template>
  18. </table-content>
  19. </div>
  20. </div>
  21. </board>
  22. <!-- 存栏情况 -->
  23. <board :title="title[1]">
  24. <div>
  25. <div>
  26. <!-- 存栏结构 -->
  27. <chart-inventory-pie :data="inventoryPieData"></chart-inventory-pie>
  28. <!-- 存栏变动 -->
  29. <chart-inventory-lines :data="inventoryLinesData">
  30. </chart-inventory-lines>
  31. </div>
  32. <div>
  33. <!-- 存栏计数 -->
  34. <inventory-items :data="inventoryItemsData"></inventory-items>
  35. </div>
  36. </div>
  37. </board>
  38. <!-- 生产情况 -->
  39. <board :title="title[2]">
  40. <!-- 环形图 -->
  41. <production-donuts :data="productionPercents"> </production-donuts>
  42. <!-- 8个格子 -->
  43. <production-items :data="productionItems"></production-items>
  44. </board>
  45. <!-- 经营分析 -->
  46. <board :title="title[3]">
  47. <!-- 成本分析 -->
  48. <div class="cost">
  49. <div class="cost-content">
  50. <div class="cost-left">
  51. <cost-pie :data="costPieData" :title="costTitles[costIndex]">
  52. </cost-pie>
  53. </div>
  54. <div class="cost-right">
  55. <cost-histogram
  56. :data="costHisData"
  57. :xAxisData="costTitles"
  58. @changeCostIndex="changeCostIndex"
  59. >
  60. </cost-histogram>
  61. </div>
  62. </div>
  63. <h3 class="label">成本分析</h3>
  64. </div>
  65. <!-- 重要指标 -->
  66. <div class="important">
  67. <div class="condition">
  68. <el-select
  69. size="small"
  70. v-model="importantValue"
  71. style="margin-right: 20px"
  72. @change="changeImportantValue"
  73. >
  74. <el-option
  75. v-for="item in importantOptions"
  76. :key="item.type"
  77. :label="item.label"
  78. :value="item.type"
  79. >
  80. </el-option>
  81. </el-select>
  82. <el-date-picker
  83. v-model="importantDates"
  84. size="small"
  85. type="daterange"
  86. range-separator="至"
  87. start-placeholder="开始日期"
  88. end-placeholder="结束日期"
  89. value-format="yyyy-MM-dd"
  90. @change="changeImportantDates"
  91. >
  92. </el-date-picker>
  93. </div>
  94. <div class="important-chart">
  95. <important-line :listData="importantData" v-bind="importantTitle">
  96. </important-line>
  97. </div>
  98. </div>
  99. <!-- 销售情况 -->
  100. <div class="sales">
  101. <div class="sales-condition">
  102. <el-date-picker
  103. v-model="getSalesDates"
  104. type="daterange"
  105. range-separator="至"
  106. start-placeholder="开始日期"
  107. end-placeholder="结束日期"
  108. align="right"
  109. size="small"
  110. value-format="yyyy-MM-dd"
  111. >
  112. </el-date-picker>
  113. </div>
  114. <div class="sales-content">
  115. <div class="sales-left">
  116. <div class="up">
  117. <label>上月销售额</label>
  118. <span>{{ weekSales }}元</span>
  119. <div class="sales-change">
  120. <div>
  121. <div
  122. class="triangle-change"
  123. :class="
  124. weekSalesChange > 0 ? 'triangle-up' : 'triangle-down'
  125. "
  126. ></div>
  127. <span :class="weekSalesChange > 0 ? 'color-up' : 'color-down'"
  128. >{{ weekSalesChange }}%</span
  129. >
  130. &nbsp;&nbsp;&nbsp;环比上月
  131. </div>
  132. </div>
  133. </div>
  134. <div class="down">
  135. <label>上月销售量</label>
  136. <span>{{ weekSalesVolume }}头</span>
  137. <div class="sales-change">
  138. <div>
  139. <div
  140. class="triangle-change"
  141. :class="
  142. weekSalesVolumeChange > 0
  143. ? 'triangle-up'
  144. : 'triangle-down'
  145. "
  146. ></div>
  147. <span
  148. :class="
  149. weekSalesVolumeChange > 0 ? 'color-up' : 'color-down'
  150. "
  151. >
  152. {{ weekSalesVolumeChange }}%
  153. </span>
  154. &nbsp;&nbsp;&nbsp;环比上月
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. <div class="sales-right">
  160. <sales-chart :data="salesChartData"></sales-chart>
  161. </div>
  162. </div>
  163. </div>
  164. </board>
  165. <!-- 应收排名 -->
  166. <!-- <board :title="title[4]">
  167. <table-content
  168. :tableItems="yingshouTableItems"
  169. :height="height"
  170. :shows="yingshouTableShows"
  171. :listData="yingshouTableData"
  172. >
  173. </table-content>
  174. </board> -->
  175. <!-- 应付排名 -->
  176. <board :title="title[5]">
  177. <table-content
  178. :tableItems="yingshouTableItems"
  179. :height="height"
  180. :shows="yingshouTableShows"
  181. :listData="yingfuTableData"
  182. >
  183. </table-content>
  184. </board>
  185. <!-- 安全库存报警 -->
  186. <board :title="title[6]">
  187. <table-content
  188. :tableItems="safetyTableItems"
  189. :height="height"
  190. :shows="safetyTableShows"
  191. :listData="safetyTableData"
  192. :empty-text="'暂无报警'"
  193. >
  194. <template #isWarning="slotProps">
  195. <el-tag
  196. :type="slotProps.row.isWarning ? 'success' : 'warning'"
  197. effect="dark"
  198. >
  199. {{ slotProps.row.isWarning ? "已报警" : "未报警" }}
  200. </el-tag>
  201. </template>
  202. </table-content>
  203. <table-footer
  204. :totals="total"
  205. :size="size"
  206. @sizeChange="sizeChange"
  207. @pageChange="pageChange"
  208. >
  209. </table-footer>
  210. </board>
  211. </div>
  212. </template>
  213. <script>
  214. import Board from "components/board/index.vue";
  215. import WorkInfos from "./analysis/WorkInfos.vue";
  216. import TableContent from "components/newTable/TableContent.vue";
  217. import ChartInventoryPie from "./analysis/ChartInventoryPie.vue";
  218. import ChartInventoryLines from "./analysis/ChartInventoryLines.vue";
  219. import InventoryItems from "./analysis/InventoryItems.vue";
  220. import ProductionDonuts from "./analysis/ProductionDonuts.vue";
  221. import ProductionItems from "./analysis/ProductionItems.vue";
  222. import CostPie from "./analysis/CostPie.vue";
  223. import CostHistogram from "./analysis/CostHistogram.vue";
  224. import ImportantLine from "./analysis/ImportantLine.vue";
  225. import SalesChart from "./analysis/SalesChart.vue";
  226. import TableFooter from "../../components/TableFooter";
  227. import { tableItems, tableShows } from "./analysis/table.config";
  228. import {
  229. yingshouTableItems,
  230. yingshouTableShows,
  231. } from "./analysis/yingshouTable.config";
  232. import {
  233. safetyTableItems,
  234. safetyTableShows,
  235. } from "./analysis/safetyTable.config";
  236. // import { formItems } from './analysis/salesXForm.config'
  237. import {
  238. getInventoryLines,
  239. getInventoryAndProduct,
  240. // getSalesChange,
  241. // getSalesChart,
  242. // getCosts,
  243. // getYingShou,
  244. getYingFu,
  245. } from "utils/api";
  246. import {
  247. getWorkTotal,
  248. getWorkInfos,
  249. getSafeInventory,
  250. getProductionCondition,
  251. getImportantData,
  252. getCostData,
  253. getTheSales,
  254. } from "utils/chenApi";
  255. export default {
  256. name: "Analysis",
  257. components: {
  258. Board,
  259. WorkInfos,
  260. TableContent,
  261. ChartInventoryPie,
  262. ChartInventoryLines,
  263. InventoryItems,
  264. ProductionDonuts,
  265. ProductionItems,
  266. CostPie,
  267. CostHistogram,
  268. ImportantLine,
  269. // XForm,
  270. SalesChart,
  271. TableFooter,
  272. },
  273. data() {
  274. return {
  275. title: [
  276. "工作看板",
  277. "存栏情况",
  278. "生产情况",
  279. "经营分析",
  280. "应收排名",
  281. "应付排名",
  282. "安全库存报警",
  283. ],
  284. workInfos: [],
  285. tableItems: [],
  286. tableShows: {},
  287. height: 300,
  288. tableData: [],
  289. // 存栏情况
  290. inventoryLinesData: {}, // 折线图数据
  291. inventoryPieData: [], // 环形图数据
  292. inventoryItemsData: [], // 下面块图的数据
  293. // 生产情况
  294. productionPercents: [], // 百分比
  295. productionItems: [], // 下面块图的数据
  296. // 经营分析
  297. costTitles: ["总成本", "基础猪群", "保育猪群", "育肥猪群", "后备猪群"], // 成本分析 - 被选中的名字
  298. costIndex: 0, // 成本分析 - 名字数组的 index
  299. costPieData: {}, // 经营分析 - 成本分析环形图
  300. costHisData: [], // 经营分析 - 柱状图
  301. // 重要指标
  302. importantOptions: [
  303. {
  304. type: 1,
  305. label: "配种指标",
  306. },
  307. {
  308. type: 2,
  309. label: "分娩指标",
  310. },
  311. {
  312. type: 3,
  313. label: "断奶指标",
  314. },
  315. {
  316. type: 4,
  317. label: "成活率指标",
  318. },
  319. ],
  320. importantValue: 1,
  321. importantDates: [],
  322. importantData: [], // 重要指标折线图数据
  323. importantTitle: {}, // 重要指标的名称
  324. // 销售额
  325. // salesFormItems: [],
  326. salesDay: 2, //默认选择本周
  327. weekSales: 1545252,
  328. weekSalesChange: 10,
  329. weekSalesVolume: 1000,
  330. weekSalesVolumeChange: -10,
  331. getSalesDates: [], // 销售图的时间选择
  332. pickerOptions: {
  333. // 快捷选项
  334. shortcuts: [
  335. {
  336. text: "最近一周",
  337. onClick(picker) {
  338. const end = new Date();
  339. const start = new Date();
  340. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  341. picker.$emit("pick", [start, end]);
  342. },
  343. },
  344. {
  345. text: "最近一个月",
  346. onClick(picker) {
  347. const end = new Date();
  348. const start = new Date();
  349. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  350. picker.$emit("pick", [start, end]);
  351. },
  352. },
  353. {
  354. text: "最近三个月",
  355. onClick(picker) {
  356. const end = new Date();
  357. const start = new Date();
  358. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  359. picker.$emit("pick", [start, end]);
  360. },
  361. },
  362. ],
  363. },
  364. salesChartData: {}, // 销售图的数据
  365. // 应收排名
  366. yingshouTableItems: [],
  367. yingshouTableShows: {},
  368. yingshouTableData: [],
  369. // 应付排名
  370. yingfuTableData: [],
  371. // 安全库存报警
  372. safetyTableItems: [],
  373. safetyTableShows: {},
  374. safetyTableData: [],
  375. total: 0,
  376. size: 20,
  377. pageNum: 1,
  378. };
  379. },
  380. mounted() {
  381. // this.salesFormItems = formItems
  382. this.tableItems = tableItems;
  383. this.tableShows = tableShows;
  384. this.yingshouTableItems = yingshouTableItems;
  385. this.yingshouTableShows = yingshouTableShows;
  386. this.safetyTableItems = safetyTableItems;
  387. this.safetyTableShows = safetyTableShows;
  388. /** 获取网络请求数据 */
  389. this.initInventoryLines();
  390. this.initInventoryAndProduct();
  391. // this.initSalesChange();
  392. // this.initSalesChart();
  393. // this.initYingShou();
  394. this.initYingFu();
  395. this.initWorkBoard(); // 工作看板
  396. this.initSafeInventory(); // 安全库存报警
  397. this.initProductionCondition(); // 生产情况
  398. this.initImportantData(); // 重要指标
  399. this.initCostData(); // 成本分析
  400. this.initTheSales(); // 销售情况
  401. },
  402. methods: {
  403. handleWorkInfoClick(item) {
  404. console.log(item);
  405. },
  406. // 修改size
  407. sizeChange(val) {
  408. this.size = val;
  409. this.init();
  410. },
  411. // 修改页数
  412. pageChange(val) {
  413. this.pageNum = val;
  414. this.init();
  415. },
  416. // 销售额选中日期
  417. salesSetDay(data) {
  418. this.salesDay = data;
  419. // console.log(this.salesDay);
  420. },
  421. // 销售额选中日周月
  422. salesOnClickType(data) {
  423. // console.log(data);
  424. },
  425. // 工作看板
  426. initWorkBoard() {
  427. getWorkTotal({}).then(async (res) => {
  428. this.workInfos = [
  429. {
  430. label: "报警信息",
  431. number: res.data.warning?.planTimes || 0,
  432. },
  433. {
  434. label: "日常计划",
  435. number: res.data.daily?.planTimes || 0,
  436. },
  437. {
  438. label: "转舍记录",
  439. number: res.data.transferHouse?.planTimes || 0,
  440. },
  441. {
  442. label: "普免计划",
  443. number: res.data.ordinary?.planTimes || 0,
  444. },
  445. {
  446. label: "免疫计划",
  447. number: res.data.immune?.planTimes || 0,
  448. },
  449. ];
  450. const result = await getWorkInfos({});
  451. this.tableData = result.data;
  452. });
  453. },
  454. // 存栏情况 - 存栏变动折线图数据请求
  455. initInventoryLines() {
  456. getInventoryLines({}).then((res) => {
  457. if (res.code === 10000) {
  458. this.inventoryLinesData = res.data;
  459. } else {
  460. this.inventoryLinesData = {
  461. boarStock: [],
  462. fatpigStock: [],
  463. griceStock: [],
  464. month: [],
  465. pigletStock: [],
  466. sowStock: [],
  467. };
  468. }
  469. });
  470. },
  471. // 存栏情况 + 生产情况
  472. initInventoryAndProduct() {
  473. getInventoryAndProduct({}).then((res) => {
  474. if (res.code === 10000) {
  475. // this.inventoryLinesData = res.data
  476. // console.log(res.data);
  477. const undefinedData = {
  478. stockQuantity: 0,
  479. };
  480. // this.inventoryPieData = res.data.slice(0, 6)
  481. this.inventoryPieData = [
  482. res.data["sow_stock"] || undefinedData,
  483. res.data["boar_stock"] || undefinedData,
  484. res.data["grice_stock"] || undefinedData,
  485. res.data["piglet_stock"] || undefinedData,
  486. res.data["fatpig_stock"] || undefinedData,
  487. ];
  488. // console.log("object", this.inventoryPieData);
  489. this.inventoryItemsData = [
  490. res.data["sow_stock"] ? res.data["sow_stock"].stockQuantity : 0,
  491. res.data["sow_stock_1"] ? res.data["sow_stock_1"].stockQuantity : 0,
  492. res.data["sow_stock_2"] ? res.data["sow_stock_2"].stockQuantity : 0,
  493. res.data["sow_stock_3"] ? res.data["sow_stock_3"].stockQuantity : 0,
  494. res.data["boar_stock"] ? res.data["boar_stock"].stockQuantity : 0,
  495. res.data["business_stock"]
  496. ? res.data["business_stock"].stockQuantity
  497. : 0,
  498. ];
  499. // this.productionPercents = [
  500. // res.data[12].rate * 100,
  501. // res.data[13].rate * 100,
  502. // res.data[14].rate * 100,
  503. // res.data[15].rate * 100,
  504. // res.data[16].rate * 100,
  505. // ];
  506. // this.productionPercents = [res.data[12].rate*100, res.data[13].rate*100, res.data[14].rate*100, res.data[15].rate*100, res.data[16].rate*100]
  507. // this.productionItems = [res.data[17].stockQuantity, res.data[18].stockQuantity, res.data[19].stockQuantity, res.data[20].stockQuantity, res.data[21].stockQuantity, res.data[22].stockQuantity, res.data[23].stockQuantity, res.data[24].stockQuantity]
  508. } else {
  509. // this.inventoryLinesData = {
  510. // boarStock: [],
  511. // fatpigStock: [],
  512. // griceStock: [],
  513. // month: [],
  514. // pigletStock: [],
  515. // sowStock: []
  516. // }
  517. }
  518. });
  519. },
  520. // // 经营分析 - 销售改变
  521. // initSalesChange() {
  522. // getSalesChange({}).then((res) => {
  523. // if (res.code === 10000) {
  524. // this.weekSales = res.data.quantityAll;
  525. // this.weekSalesChange = res.data.quantityType
  526. // ? res.data.quantityPercentage
  527. // : -res.data.quantityPercentage;
  528. // this.weekSalesVolume = res.data.saleAll;
  529. // this.weekSalesVolumeChange = res.data.saleType
  530. // ? res.data.salePercentage
  531. // : -res.data.salePercentage;
  532. // } else {
  533. // this.weekSales = 0;
  534. // this.weekSalesChange = 0;
  535. // this.weekSalesVolume = 0;
  536. // this.weekSalesVolumeChange = 0;
  537. // }
  538. // });
  539. // },
  540. // // 经营分析 - 销售情况图
  541. // initSalesChart() {
  542. // const params = {
  543. // beginDate: this.getSalesDates[0] || "",
  544. // endDate: this.getSalesDates[1] || "",
  545. // };
  546. // console.log("我要放参数了", params);
  547. // getSalesChart(params).then((res) => {
  548. // if (res.code === 10000) {
  549. // this.salesChartData = res.data;
  550. // console.log(this.salesChartData);
  551. // }
  552. // });
  553. // },
  554. // 经营分析 - 成本分析
  555. initCostData() {
  556. getCostData({}).then((res) => {
  557. // console.log(res);
  558. if (res.code === 10000) {
  559. this.costHisData = [
  560. res.data["total"],
  561. res.data["baseGroup"],
  562. res.data["pigletGroup"],
  563. res.data["fattenPig"],
  564. res.data["replaceGilt"],
  565. ];
  566. this.costPieData = this.costHisData[this.costIndex];
  567. }
  568. });
  569. },
  570. // // 应收排名
  571. // initYingShou() {
  572. // getYingShou({}).then((res) => {
  573. // console.log("应收", res);
  574. // if (res.code === 10000) {
  575. // this.yingshouTableData = res.data;
  576. // }
  577. // });
  578. // },
  579. // 应付排名
  580. initYingFu() {
  581. getYingFu({}).then((res) => {
  582. // console.log("应付", res);
  583. if (res.code === 10000) {
  584. this.yingfuTableData = res.data;
  585. }
  586. });
  587. },
  588. // 安全库存报警
  589. initSafeInventory() {
  590. getSafeInventory({
  591. current: this.pageNum,
  592. size: this.size,
  593. }).then((res) => {
  594. // console.log(res);
  595. if (res.code === 10000) {
  596. this.safetyTableData = res.data.records;
  597. this.total = res.data.total;
  598. }
  599. });
  600. },
  601. // 生产情况
  602. initProductionCondition() {
  603. getProductionCondition({}).then((res) => {
  604. // console.log(res.data);
  605. if (res.code === 10000) {
  606. this.productionPercents = [
  607. { ...res.data["grice_rate"], color: "rgb(112,249,250)" },
  608. { ...res.data["piglet_rate"], color: "rgb(51, 211, 137)" },
  609. { ...res.data["fatpig_rate"], color: "rgb(255, 125, 0)" },
  610. { ...res.data["break_rate"], color: "rgb(2, 167, 240)" },
  611. { ...res.data["breed_rate"], color: "rgb(112, 0, 217)" },
  612. ];
  613. this.productionItems = [
  614. res.data["avg_farrow_1"].stockQuantity,
  615. res.data["avg_farrow_2"].stockQuantity,
  616. res.data["avg_farrow_3"].stockQuantity,
  617. res.data["break_grice"].stockQuantity,
  618. res.data["avg_weight"].stockQuantity,
  619. res.data["avg_weight"].stockQuantity, // FIXME: 没有数据,随便放一个先
  620. res.data["nest_times"].stockQuantity,
  621. res.data["psy"].stockQuantity,
  622. ];
  623. }
  624. });
  625. },
  626. // 重要指标折线图
  627. initImportantData() {
  628. getImportantData({
  629. startDate: this.importantDates[0],
  630. endDate: this.importantDates[1],
  631. type: this.importantValue,
  632. }).then((res) => {
  633. const types = [
  634. [
  635. {
  636. type: "break_rate",
  637. name: "七日断配率",
  638. },
  639. ],
  640. [
  641. {
  642. type: "avg_farrow_1",
  643. name: "平均窝产仔猪数",
  644. },
  645. {
  646. type: "avg_farrow_2",
  647. name: "平均窝产活仔数",
  648. },
  649. {
  650. type: "avg_farrow_3",
  651. name: "平均窝产正常仔数",
  652. },
  653. ],
  654. [
  655. {
  656. type: "avg_weight",
  657. name: "平均断奶窝重",
  658. },
  659. {
  660. type: "break_grice",
  661. name: "窝断奶仔猪数",
  662. },
  663. ],
  664. [
  665. {
  666. type: "fatpig_rate",
  667. name: "肥猪成活率",
  668. },
  669. {
  670. type: "grice_rate",
  671. name: "产房成活率",
  672. },
  673. {
  674. type: "piglet_rate",
  675. name: "保育成活率",
  676. },
  677. ],
  678. ];
  679. this.importantData = [];
  680. types[this.importantValue - 1].forEach((item) => {
  681. this.importantData.push({
  682. ...res.data[item.type],
  683. name: item.name, // 各项名称
  684. });
  685. });
  686. this.importantTitle = {
  687. isPercentage: res.data["isPercentage"],
  688. isWeight: res.data["isWeight"],
  689. isHead: res.data["isHead"],
  690. };
  691. // console.log("重要指标数据----------------", this.importantTitle);
  692. });
  693. },
  694. // 重要指标的 type 改变
  695. changeImportantValue() {
  696. this.initImportantData();
  697. },
  698. // 重要指标的时间改变
  699. changeImportantDates() {
  700. this.initImportantData();
  701. },
  702. // 成本分析 - 数据改变
  703. changeCostIndex(value) {
  704. this.costIndex = value;
  705. this.costPieData = this.costHisData[value];
  706. },
  707. // 销售情况
  708. initTheSales() {
  709. getTheSales({
  710. type: this.getSalesDates[0] ? 3 : 2,
  711. startDate: this.getSalesDates[0] || undefined,
  712. endDate: this.getSalesDates[1] || undefined,
  713. }).then((res) => {
  714. if (res.code === 10000) {
  715. this.weekSales = res.data.money;
  716. this.weekSalesChange = res.data.moneyPercent;
  717. this.weekSalesVolume = res.data.quantity;
  718. this.weekSalesVolumeChange = res.data.quantityPercent;
  719. // console.log("救命");
  720. this.salesChartData = {
  721. moneyList: res.data.moneyList,
  722. moneyList1: res.data.moneyList1,
  723. quantityList: res.data.quantityList,
  724. timeList: res.data.timeList,
  725. };
  726. // console.log(this.salesChartData);
  727. }
  728. });
  729. },
  730. },
  731. watch: {
  732. getSalesDates(newValue) {
  733. this.getSalesDates = newValue;
  734. this.initTheSales();
  735. },
  736. },
  737. };
  738. </script>
  739. <style scoped>
  740. .analysis {
  741. width: 100%;
  742. height: 100%;
  743. box-sizing: border-box;
  744. padding: 20px;
  745. }
  746. .table-content {
  747. padding: 10px 15px 12px;
  748. }
  749. /* 成本分析echarts图排列 */
  750. .cost {
  751. border-bottom: 1px solid rgba(228, 228, 228, 1);
  752. position: relative;
  753. }
  754. .cost > .select {
  755. position: absolute;
  756. right: 0;
  757. margin: 20px;
  758. }
  759. .cost-content {
  760. padding-top: 20px;
  761. display: flex;
  762. }
  763. .cost-left {
  764. flex: 1;
  765. }
  766. .cost-right {
  767. flex: 1;
  768. }
  769. .cost > .label {
  770. text-align: center;
  771. font-weight: bold;
  772. font-size: 18px;
  773. }
  774. /* 重要指标 */
  775. .important {
  776. padding: 20px;
  777. position: relative;
  778. border-bottom: 1px solid rgba(228, 228, 228, 1);
  779. }
  780. .important > .condition {
  781. position: absolute;
  782. right: 0;
  783. margin-right: 20px;
  784. }
  785. .important-chart {
  786. margin-top: 20px;
  787. }
  788. /* 销售情况 */
  789. .sales {
  790. padding: 20px;
  791. padding-bottom: 0;
  792. }
  793. .sales-condition {
  794. margin-left: 250px;
  795. }
  796. .sales-content {
  797. padding-top: 20px;
  798. width: 100%;
  799. display: flex;
  800. flex-direction: row;
  801. justify-content: space-around;
  802. }
  803. .sales-left {
  804. width: 15%;
  805. line-height: 25px;
  806. padding-top: 30px;
  807. }
  808. .sales-left > .up {
  809. margin-bottom: 20px;
  810. }
  811. .sales-left > .up > label,
  812. .sales-left > .down > label {
  813. display: block;
  814. text-align: center;
  815. font-size: 13px;
  816. color: #999;
  817. }
  818. .sales-left > .up > span,
  819. .sales-left > .down > span {
  820. display: block;
  821. text-align: center;
  822. font-size: 16px;
  823. color: #333;
  824. }
  825. .sales-left > .up > .sales-change,
  826. .sales-left > .down > .sales-change {
  827. display: flex;
  828. justify-content: space-around;
  829. font-size: 13px;
  830. }
  831. /* 三角形 */
  832. .triangle-change {
  833. display: inline-block;
  834. width: 8px;
  835. height: 8px;
  836. border-style: solid;
  837. border-width: 8px;
  838. margin-right: 20px;
  839. }
  840. .triangle-up {
  841. border-color: transparent transparent rgb(238, 16, 16) transparent;
  842. }
  843. .triangle-down {
  844. border-color: rgb(2, 112, 2) transparent transparent transparent;
  845. position: relative;
  846. top: 7px;
  847. }
  848. .color-up {
  849. color: rgb(238, 16, 16);
  850. }
  851. .color-down {
  852. color: rgb(2, 112, 2);
  853. }
  854. /* 销售情况右侧 */
  855. .sales-right {
  856. width: 85%;
  857. border-left: 1px solid rgba(228, 228, 228, 1);
  858. height: 300px;
  859. }
  860. </style>