123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
-
- <div id="PriceChangeDiv">
- <form action="" method="post" class="config-form">
- <div class="config-form-group">
- <label class="price-form-label">{{$t('Product')}}</label>
- <label class="price-form-label">{{$t('CurrentPrice')}}</label>
- <label class="price-form-label">{{$t('NewPrice')}}</label>
- </div>
- <div v-for="r in rows" class="config-form-group">
- <label class="price-form-label">{{ r.FuelName }}</label>
- <label class="price-form-label">{{ r.CurrentPrice }}</label>
- <input class="price-form-input" oninput="value=value.match(/[0-9]{1,10}\.?[0-9]{0,6}/)" v-model="r.NewPrice" />
- </div>
- <div class="config-form-submit-group">
- <label :class="showResult ? (result ? 'config-form-result' : 'config-form-result-fail') : 'color-transparent'">{{ result ? '提交完成' : '提交失败' }}</label>
- </div>
- <div class="config-form-submit-group" v-if="receiveData">
- <label class="config-form-label"></label>
- <button class="config-form-submit" type="button" @@click="submit(event)" id="FuelChange" />
- </div>
- </form>
- </div>
- <script type="text/javascript">
- var vm = new Vue({
- el: '#PriceChangeDiv',
- i18n,
- data: {
- //rows: { "1": { "FuelName": "0#", "CurrentPrice": 0.0, "NewPrice": null }, "2": { "FuelName": "98#", "CurrentPrice": 0.0, "NewPrice": null } },
- rows: [],
- receiveData: false,
- showResult: false,
- result: false,
- currentIndex:0
- },
- methods: {
- receive(resdata) {
- resdata = JSON.parse(resdata)
- this.rows = resdata
- },
- submit(e) {
- if (!confirm("确定要继续吗?")) {
- return
- }
- this.currentIndex = 0;
- this.ChangeFuelPrice();
- //let url = '/api/fuelprice'
- //InvokeHttpPost(url, JSON.stringify(this.rows), function (res) {
- // vm.showResult = true
- // vm.result = res.value
- //})
- return false
- },
- GetData() {
- var temp = {
- "parameters": [
- { "name": "pumpId", "value": "-1" }
- ]
- };
- GetDataByAPIS("GetPumpsLayout", temp, "post", function (response) {
- console.log(response);
- if (response === null || response.length === 0) return;
- vm.rows.splice(0, vm.rows.length);
- var tempMap = new Map();
- response.forEach(function (p) {
- p.Nozzles.forEach(function (n) {
- if (n.ProductBarcode !== null && !tempMap.has(n.ProductBarcode)) {
- tempMap.set(n.ProductBarcode, {
- "FuelName": n.ProductName,
- "CurrentPrice": n.RealPriceOnPhysicalPump === null ? 0 : n.RealPriceOnPhysicalPump / Math.pow(10, p.AmountDecimalDigits), "NewPrice": null, "ProductBarcode": n.ProductBarcode
- });
- }
- });
- });
- tempMap.forEach(function (value, key) {
- vm.rows.push(value);
- });
- vm.receiveData = true;
- tempMap.clear();
- });
- },
- ChangeFuelPrice() {
- if (vm.rows.length === 0) return;
- var resultMap = new Map();
- //var succeed = false;
- if (vm.currentIndex > vm.rows.length - 1 ||
- vm.rows[vm.currentIndex].NewPrice === null || vm.rows[vm.currentIndex].NewPrice === "") {
- vm.currentIndex++;
- if (vm.currentIndex < vm.rows.length) vm.ChangeFuelPrice();
- else {
- vm.showResult = true;
- vm.GetData();
- }
- return;
- }
- var tempPara = new Array();
- tempPara.push(vm.rows[vm.currentIndex].ProductBarcode);
- tempPara.push(vm.rows[vm.currentIndex].NewPrice * 1);
- GetDataByAPIS("ChangeFuelPriceAsync", tempPara, "post", function (response) {
- if (response === null || response.length === 0) {
- resultMap.set(vm.rows[vm.currentIndex].ProductBarcode, false);
- } else {
- vm.result = true;
- resultMap.set(vm.rows[vm.currentIndex].ProductBarcode, true);
- }
- vm.currentIndex++;
- if (vm.currentIndex < vm.rows.length) {
- vm.ChangeFuelPrice();
- }
- else{
- vm.showResult = true;
- //vm.result = succeed;
- vm.GetData();
- }
- })
- //vm.rows.forEach(function (value) {
- // if (value.NewPrice === null || value.NewPrice === "") {
- // resultMap.set(value.ProductBarcode, false);
- // return;
- // }
- // var tempPara = new Array();
- // tempPara.push(value.ProductBarcode);
- // tempPara.push(value.NewPrice*1);
- // GetDataByAPIS("ChangeFuelPriceAsync", tempPara, "post", function (response) {
- // if (response === null || response.length === 0) {
- // resultMap.set(value.ProductBarcode, false);
- // } else {
- // succeed = true;
- // resultMap.set(value.ProductBarcode, true);
- // }
- // if (resultMap.size === vm.rows.length) {
- // vm.showResult = true;
- // vm.result = succeed;
- // vm.GetData();
- // }
- // })
- //});
-
- }
- },
- mounted: function () {
- console.log("test");
- this.GetData();
- //let url = '/api/fuelprice'
- //InvokeHttpGet(url, function (res) {
- // vm.receive(res)
- // vm.receiveData = true
- //})
- }
- })
- </script>
|