Browse Source

今日市场取数逻辑修改

master
juwei001 1 year ago
parent
commit
e4aed9b984
  1. 170
      src/views/next/screen-content-left/zdyf-left/index.vue

170
src/views/next/screen-content-left/zdyf-left/index.vue

@ -179,68 +179,68 @@
</template>
<script>
import { mapActions } from "vuex";
import { prcCollectionListForGov } from "@/api/zdyf";
import { mapActions } from 'vuex'
import { prcCollectionListForGov } from '@/api/zdyf'
export default {
data () {
return {
shichangList: [
{
name: "豌豆荚",
name: '豌豆荚',
num: 14,
jzr: 1,
jzr: 1
},
{
name: "白玉菇",
name: '白玉菇',
num: 14,
jzr: 1,
jzr: 1
},
{
name: "生菜球",
name: '生菜球',
num: 14,
jzr: -1,
jzr: -1
},
{
name: "秋葵",
name: '秋葵',
num: 14,
jzr: -1,
jzr: -1
},
{
name: "苦菊",
name: '苦菊',
num: 14,
jzr: 1,
jzr: 1
},
{
name: "白菜",
name: '白菜',
num: 14,
jzr: 1,
},
jzr: 1
}
],
yfclzList: [
{
name: "豌豆荚",
num: 460,
name: '豌豆荚',
num: 460
},
{
name: "白玉菇",
num: 389,
name: '白玉菇',
num: 389
},
{
name: "生菜球",
num: 322,
name: '生菜球',
num: 322
},
{
name: "秋葵",
num: 266,
name: '秋葵',
num: 266
},
{
name: "苦菊",
num: 198,
name: '苦菊',
num: 198
},
{
name: "白菜",
num: 890,
},
name: '白菜',
num: 890
}
],
optionHover1: {
step: 0.5, //
@ -250,84 +250,102 @@ export default {
openWatch: true, // dom
singleHeight: 0, // (0) direction => 0/1
singleWidth: 0, // (0) direction => 2/3
waitTime: 2000, // (1000ms)
waitTime: 2000 // (1000ms)
},
};
},
created() {
const params = {
params: {
Country: 0,
FEndDate: this.$moment().format("yyyy-MM-DD"),
FEndDate: this.$moment().format('yyyy-MM-DD'),
FParentPartyID: 1,
FPartyName: "青岛移风蔬菜批发市场有限公司",
FPartyName: '青岛移风蔬菜批发市场有限公司',
FPartyType: 1010,
FStartDate: this.$moment().format("yyyy-MM-DD"),
FStartDate: this.$moment().format('yyyy-MM-DD'),
FStoreId: 1,
Name: "全部",
Name: '全部',
page: 1,
pageSize: 10,
singletype: 0,
sort: "",
};
prcCollectionListForGov(params).then((res) => {
if (res.priceslist.length > 0) {
prcCollectionListForGov({
...params,
FEndDate: this.$moment().subtract(1, "days").format("yyyy-MM-DD"),
FStartDate: this.$moment().subtract(1, "days").format("yyyy-MM-DD"),
}).then((res1) => {
if (res1.priceslist.length > 0) {
this.shichangList = this.getScData(res.priceslist, res1.priceslist);
} else {
this.shichangList = [];
}
});
} else {
this.shichangList = [];
sort: ''
},
times: this.$moment().subtract(1, 'days').format('yyyy-MM-DD'),
dayList: [],
tDayList: []
}
});
},
created () {
this.getDayScData()
},
methods: {
...mapActions({
showGlobalDialog: "showGlobalDialog",
set_yfcj: "SET_YFCJ",
set_yfclz: "SET_YFCLZ",
set_ldhg: "SET_LDGH",
showGlobalDialog: 'showGlobalDialog',
set_yfcj: 'SET_YFCJ',
set_yfclz: 'SET_YFCLZ',
set_ldhg: 'SET_LDGH'
}),
openClz () {
this.set_yfclz(true);
this.set_yfclz(true)
},
deduplicationJs (arr) {
const data = [];
const data = []
arr.forEach((item, index) => {
if ((index + 1) % 2 === 0) {
const num = (arr[index - 1].AvgPrice + item.AvgPrice) / 2;
data.push({ ...item, price: num });
const num = (arr[index - 1].AvgPrice + item.AvgPrice) / 2
data.push({ ...item, price: num })
}
})
return data
},
getDayScData (data) {
prcCollectionListForGov({ ...this.params, ...data }).then((res) => {
if (res.priceslist.length > 0) {
this.dayList = res.priceslist
this.getDayScTData()
} else {
this.times = this.$moment(this.times).subtract(1, 'days').format('yyyy-MM-DD')
this.getDayScData({
FEndDate: this.$moment().subtract(1, 'days').format('yyyy-MM-DD'),
FStartDate: this.$moment().subtract(1, 'days').format('yyyy-MM-DD')
})
}
});
return data;
})
},
getDayScTData () {
prcCollectionListForGov({
...this.params,
FEndDate: this.times,
FStartDate: this.times
}).then((res1) => {
if (res1.priceslist.length > 0) {
this.shichangList = this.getScData(
this.dayList,
res1.priceslist
)
} else {
this.times = this.$moment(this.times).subtract(1, 'days').format('yyyy-MM-DD')
this.getDayScTData()
}
})
},
getScData (arr, arr1) {
const dataD = this.deduplicationJs(arr);
const dataTd = this.deduplicationJs(arr1);
const dataD = this.deduplicationJs(arr)
const dataTd = this.deduplicationJs(arr1)
return dataD.map((item, index) => {
const priceTd = dataTd.filter((item1) => item.Name === item1.Name)[0]
.price;
const jzrPrice = item.price - priceTd;
.price
const jzrPrice = item.price - priceTd
return {
...item,
jzrPrice,
};
});
jzrPrice
}
})
},
handelClickEmap () {
this.$EventBus.$emit("switcMapType", "Emap");
},
this.$EventBus.$emit('switcMapType', 'Emap')
}
},
components: {},
computed: {},
watch: {},
};
watch: {}
}
</script>
<style lang="scss" scoped>

Loading…
Cancel
Save