新版交易所前段管理后台
1
PC-20250623MANY\Administrator
2025-07-06 0363875eb333c67529c8b27221a6da45d1a50bfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<template>
  <el-dialog :title="'调整'+title"
             :close-on-click-modal="false"
             :visible.sync="visible"
             @close = 'handClose'
             width="700px"
             class="transport-dialog"
  >
    <el-form :model="dataForm"
             ref="dataForm"
             @keyup.enter.native="dataFormSubmit()"
             label-width="0px">
      <el-form-item label=""
                    prop="transName">
                    <span>请输入正负调整值</span>
        <el-input v-model="dataForm.transName" type="number" @change="checkNumber()"
                  placeholder="请输入正负调整值"></el-input>
      </el-form-item>
      <el-form-item>
      <el-button v-if="isAuth('shop:transfee:update')"
                        type="primary"
                       size="middle"
                       class="el-icon-circle-plus-outline"
                       @click="addOrUpdateHandle()">{{pips}}</el-button>
            <el-button v-if="isAuth('shop:transfee:delete')"
                      type="primary"
                       size="middle"
                       class="el-icon-remove-outline"
                       @click="deleteHandle()">{{pips}}</el-button>
      </el-form-item>
      <el-form-item label=""
                    prop="second"
                    >
                    <span>生效趋势(秒,0秒为即时生效)</span>
        <el-input oninput="value=value.replace('-','')" v-model="second" type="number"
                  placeholder="0秒为即时生效"></el-input>
      </el-form-item>
      <div>调整值</div>
      <el-table :data="dataForm.transfees"
                border
                style="width: 100%;"
                class="table-con"
      >
        <el-table-column header-align="center"
                         align="center"
                         width="200"
                         label="原值">
          <template slot-scope="scope">
            <!-- <el-input type="number"
                        v-model="newPrice"
                        disabled></el-input> -->
     <div>{{newPrice}}</div>
          </template>
        </el-table-column>
        <el-table-column header-align="center"
                         align="center"
                         style="color:red;"
                         width="180"
                         label="调整后">
          <template slot-scope="scope">
            <el-form-item
                          label-width="0px"
                          >
                          <div class="spainput">{{afterValue}}</div>
              <!-- <el-input type="number" style="color:red !important;"
                        v-model="afterValue" class="spainput"
                        disabled></el-input> -->
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column header-align="center"
                         align="center"
                         label="累计修正值">
          <template slot-scope="scope">
            <el-form-item
                          label-width="0px"
                          >
              <!-- <el-input type="number"
                        v-model="adjustValue"
                        disabled></el-input> -->
                        <div>{{adjustValue}}</div>
            </el-form-item>
          </template>
        </el-table-column>
      </el-table>
      <div style="margin-top: 30px;">生效趋势</div>
      <el-table :data="dataForm.transfeeFrees"
                border
                style="width: 100%;"
                class="table-con"
      >
        <el-table-column header-align="center"
                         align="center"
                         width="338"
                         label="待生效值">
          <template slot-scope="scope">
            <!-- <el-input type="number"
                        v-model="delayValue"
                        disabled></el-input> -->
                        <div>{{delayValue}}</div>
          </template>
        </el-table-column>
        <el-table-column header-align="center"
                         align="center"
                         width="320"
                         label="时间(秒)">
          <template slot-scope="scope">
            <el-form-item
                          label-width="0px"
                          >
              <!-- <el-input type="number"
                        v-model="delaySecond"
                        disabled></el-input> -->
                        <div>{{ delaySecond }}</div>
            </el-form-item>
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <span slot="footer"
          class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary"
                 @click="dataFormSubmit()">确定</el-button>
    </span>
    <!-- 弹窗, 新增 / 修改 -->
    <!-- <add-or-update v-if="addOrUpdateVisible"
                   ref="addOrUpdate"
                   @refreshDataList="getDataList"></add-or-update> -->
  </el-dialog>
</template>
 
<script>
import { Debounce } from '@/utils/debounce'
// import AddOrUpdate from './transcity-add-or-update'
export default {
  data () {
    return {
      // hasFreeCondition: 0,
      visible: false,
      title:'',
      pips:'',
      adjustValue:'',//累计修正的值
      afterValue:'',//调整后值
      delaySecond:'',//生效趋势
      delayValue:'',// 待生效的值
      newPrice:'',//原值
      second:0,
      mafterValue:0,
      addOrUpdateVisible: false,
      dataForm: {
        // hasFreeCondition: false,
        transName: 0,
       
        // createTime: '',
        // chargeType: 0,
        // transportId: 0,
        // isFreeFee: 0,
        transfees: [{ cityList: [], status: 1 }],
        transfeeFrees: [{ freeCityList: [], freeType: 0 }]
      },
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      editVisible: false
    }
  },
  created(){
   // this.init(id)
  },
  components: {
    // AddOrUpdate
  },
  watch: {
    
    // 如果当前对话框不可见,则关闭选择城市的对话框
    visible: function (val) {
      if (!val) {
        this.addOrUpdateVisible = false
      }
    }
  },
  computed: {
    tableTitle () {
      var titles = [['调整后', '累计修正值', '续件(个)', '续费(元)'], ['首重(kg)', '运费(元)', '续重(kg)', '续费(元)'], ['首体积(m³)', '运费(元)', '续体积(m³)', '续费(元)']]
      if (this.dataForm.chargeType) {
        return titles[this.dataForm.chargeType]
      }
      return titles[0]
    }
  },
  methods: {
    init (id) {
      this.getDataList (id)
      this.title = id
      this.visible = true
      this.dataForm.transportId = id || 0
      this.$nextTick(() => {
        this.$refs.dataForm.resetFields()
        this.dataForm = {
          // hasFreeCondition: false,
          transName: 0,
          createTime: '',
          chargeType: 0,
          transportId: 0,
          isFreeFee: 0,
          transfees: [{ cityList: [], status: 1 }],
          transfeeFrees: [{ freeCityList: [], freeType: 0 }]
        }
      })
      // if (this.dataForm.transportId) {
      //   this.$http({
      //     // 获取运费模板数据
      //     url: this.$http.adornUrl(`/shop/transport/info/${this.dataForm.transportId}`),
      //     method: 'get'
      //   }).then(({ data }) => {
      //     if (data.isFreeFee) {
      //       data.transfees[0].status = 0
      //     } else {
      //       data.transfees[0].status = 1
      //     }
      //     this.dataForm = data
      //     this.dataForm.hasFreeCondition = !!data.hasFreeCondition
      //   })
      // }
    },
    handClose(){
        this.$data.dataForm=JSON.parse(JSON.stringify(this.$options.data().dataForm))
        this.second = 0
        this.$nextTick(() => {
            this.$refs['dataForm'].clearValidate() // 清除表单验证
          })
      },
    getDataList (id) {
      this.$http({
              url: this.$http.adornUrl(
                "/normal/adminMarketQuotationsManageAction!/showModal.action"
              ),
              method: "get",
              params: this.$http.adornParams({
                symbol:id
              }),
            }).then(({ data }) => {
              if(data){    
                if(data.data.afterValue){
                  this.afterValue = data.data.afterValue
                }else{
                  this.afterValue = data.data.newPrice
                }
                if(data.data.pips*1 == 0){
                  this.pips = 0.01
                }else{
                  this.pips = data.data.pips
                }
                this.mafterValue =  this.afterValue        
                this.adjustValue = data.data.adjustValue
                this.delaySecond = data.data.delaySecond
                this.delayValue = data.data.delayValue
                this.newPrice = data.data.newPrice
              }
              // if(data.records){
              //     this.option = data.records.map((item,index) =>{
              //       return Object.assign({},{'symbol':item.symbol,'name':item.name})
              //     })
              // }
            });
    },
    // 添加运费项
    addTransfee () {
      this.editVisible = true
      this.dataForm.transfees.push({ cityList: [], status: 1 })
    },
 
    // 添加指定包邮条件
    // addTransfeeFree () {
    //   if (this.dataForm.hasFreeCondition) {
    //     this.dataForm.transfeeFrees.push({ freeCityList: [], freeType: 0 })
    //   }
    // },
    // 删除指定包邮条件
    deleteTransfeeFree (rowIndex) {
      this.dataForm.transfeeFrees.splice(rowIndex, 1)
    },
    
    checkNumber () { //正负值计算
      // if(!this.dataForm.transName){
      //     this.afterValue = this.mafterValue
      //   }
        let m = this.adjustValue
        let n = this.afterValue
        //this.afterValue = this.mafterValue
        //this.afterValue = this.dataForm.transName
        this.afterValue = (n*1000000000 + this.dataForm.transName*1000000000)/1000000000
        this.adjustValue = (m*1000000000 + this.dataForm.transName*1000000000)/1000000000
    },
      
    addOrUpdateHandle (rowIndex) {//正值添加按钮
      let m = this.adjustValue
      let n = this.afterValue
      let p = this.dataForm.transName
      this.dataForm.transName = (p*1000000000 + this.pips*1000000000)/1000000000
      this.afterValue = (n*1000000000 + this.pips*1000000000)/1000000000
      this.adjustValue = (m*1000000000 + this.pips*1000000000)/1000000000
      //this.afterValue = (this.afterValue*1000000000 + this.pips*1000000000)/1000000000
    },
        // 删除运费项
    deleteHandle (rowIndex) {//负值添加按钮
      let m = this.adjustValue
      let n = this.afterValue
      let p = this.dataForm.transName
      this.dataForm.transName = (p*1000000000 - this.pips*1000000000)/1000000000
      this.afterValue = (n*1000000000 - this.pips*1000000000)/1000000000
      this.adjustValue = (m*1000000000 - this.pips*1000000000)/1000000000
      //this.afterValue = (this.afterValue*1000000000 - this.pips*1000000000)/1000000000
    },
    /**
     * 保留整数并小于零的数设为0
     */
    getNumber (num) {
      num = Math.round(num)
      return num < 0 ? 0 : num
    },
    // 表单提交
    dataFormSubmit: Debounce(function () {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.dataForm.transfees[0].cityList = []
          this.$http({
            url: this.$http.adornUrl(`/normal/adminMarketQuotationsManageAction!/adjust.action`),
            method: 'post',
            data: this.$http.adornData({
              'second': this.second,
              'symbol': this.title,
              'value': this.dataForm.transName,
            })
          }).then(({ data }) => {
            if(data.code == 0){
              this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1000,
              onClose: () => {
                this.visible = false
                this.$emit('refreshDataList', this.page)
              }
            })
            }else{
              this.$message({
              message: data.msg,
              type: 'error',
              duration: 1000,
              onClose: () => {
                this.visible = false
              }
            })
            }
 
          })
        }
      })
    })
  }
}
</script>
 
<style lang="scss" scoped>
.transport-dialog .table-con .el-form-item {
  margin-top: 16px;
  margin-bottom: 16px!important;
}
::v-deep.spainput{
  color: red;
}
::v-deep th {
  background: rgb(38,50,56);
  color: #fff;
}
</style>