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

Loading…
Cancel
Save