saleCount.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <!-- saleCount -->
  3. <div class="SaleCount">
  4. <h2 style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd">销售统计</h2>
  5. <formList v-model="list" :title="['时间','值(万元)']" inputWidth="200px"></formList>
  6. <el-button style="margin-left:510px" type="primary" @click="onSubmit">更新信息</el-button>
  7. </div>
  8. </template>
  9. <script>
  10. import { reqSaleCount, reqSetSaleCount } from "@/api/butcher.js";
  11. export default {
  12. name: "SaleCount",
  13. data() {
  14. return {
  15. id: '-1',
  16. list: [{ keyList: "" , valueList: ""}]
  17. };
  18. },
  19. created() {
  20. this.getSaleCount();
  21. },
  22. methods: {
  23. onSubmit() {
  24. let keyList = [];
  25. let valueList = [];
  26. this.list.forEach(item => {
  27. keyList.push(item.keyList);
  28. valueList.push(item.valueList);
  29. });
  30. this.$confirm("确定更新信息?").then(() => {
  31. reqSetSaleCount({id: this.id, keyList: keyList.toString(), valueList: valueList.toString()})
  32. .then(res => {
  33. console.log(res);
  34. if (res.errCode) {
  35. this.$message.error(res.errMsg);
  36. } else {
  37. this.getSaleCount();
  38. this.$message.success("更新成功!");
  39. }
  40. })
  41. .catch(err => {
  42. console.log(err);
  43. this.$message.error("更新失败!");
  44. });
  45. });
  46. },
  47. getSaleCount() {
  48. reqSaleCount()
  49. .then(res => {
  50. this.id = res.id
  51. let arr2 = res.conf['valueList']
  52. this.list = [];
  53. res.conf['keyList'].forEach((item, i) => {
  54. this.list.push({ 'keyList': item , 'valueList': arr2[i]});
  55. });
  56. })
  57. .catch(err => {
  58. console.error(err);
  59. });
  60. }
  61. }
  62. };
  63. </script>
  64. <style lang="scss" scoped>
  65. .SaleCount {
  66. .left {
  67. width: 400px;
  68. margin-left: 50px;
  69. }
  70. }
  71. </style>