12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <template>
- <!-- saleCount -->
- <div class="SaleCount">
- <h2 style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd">销售统计</h2>
- <formList v-model="list" :title="['时间','值(万元)']" inputWidth="200px"></formList>
- <el-button style="margin-left:510px" type="primary" @click="onSubmit">更新信息</el-button>
- </div>
- </template>
- <script>
- import { reqSaleCount, reqSetSaleCount } from "@/api/butcher.js";
- export default {
- name: "SaleCount",
- data() {
- return {
- id: '-1',
- list: [{ keyList: "" , valueList: ""}]
- };
- },
- created() {
- this.getSaleCount();
- },
- methods: {
- onSubmit() {
- let keyList = [];
- let valueList = [];
- this.list.forEach(item => {
- keyList.push(item.keyList);
- valueList.push(item.valueList);
- });
- this.$confirm("确定更新信息?").then(() => {
- reqSetSaleCount({id: this.id, keyList: keyList.toString(), valueList: valueList.toString()})
- .then(res => {
- console.log(res);
- if (res.errCode) {
- this.$message.error(res.errMsg);
- } else {
- this.getSaleCount();
- this.$message.success("更新成功!");
- }
- })
- .catch(err => {
- console.log(err);
- this.$message.error("更新失败!");
- });
- });
- },
- getSaleCount() {
- reqSaleCount()
- .then(res => {
- this.id = res.id
- let arr2 = res.conf['valueList']
- this.list = [];
- res.conf['keyList'].forEach((item, i) => {
- this.list.push({ 'keyList': item , 'valueList': arr2[i]});
- });
- })
- .catch(err => {
- console.error(err);
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .SaleCount {
- .left {
- width: 400px;
- margin-left: 50px;
- }
- }
- </style>
|