doum
10 小时以前 82203a196fa700adfc379b2b453b2266266c940c
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
<template>
  <GlobalWindow
    v-loading="isUploading"
    :title="title"
    width="70%"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
    <el-form :model="form" ref="form" :rules="rules" label-width="120px" label-suffix=":"  inline>
      <el-form-item label="规则名称" prop="name">
        <el-input v-model="form.name" placeholder="请输入规则名称"  v-trim/>
      </el-form-item>
      <el-form-item label="选择省份" prop="name">
        <el-select v-model="form.areaIdList" placeholder="请选择省份" multiple filterable>
          <el-option
              v-for="item in province"
              :key="item.id"
              :value="item.id"
              :label="item.name"
          ></el-option>
        </el-select>
      </el-form-item>
      <div style="display: flex">
        <el-form-item label="首重" prop="weight0" style="display: inline-block;flex: 1;">
          <el-input  v-model="form.weight0"    style="width: 150px" placeholder="请输入首重"    type="number">    <template slot="append" >kg</template>  </el-input>
        </el-form-item>
        <el-form-item label="首重运费" prop="fee0" style="display: inline-block;flex: 1;">
          <el-input  v-model="form.fee0"  style="width: 150px"    placeholder="请输入金额"  > <template slot="append" >元</template> </el-input>
        </el-form-item>
      </div>
      <div style="display: flex">
      <el-form-item label="续重" prop="weight1" style="display: inline-block;flex:1">
        <el-input  v-model="form.weight1" style="width: 150px"    placeholder="请输入续重"    type="number">    <template slot="append" >kg</template>  </el-input>
      </el-form-item>
      <el-form-item label="续重运费增加" prop="fee1" style="display: inline-block;flex: 1;">
        <el-input  v-model="form.fee1" style="width: 150px"    placeholder="请输入金额"  > <template slot="append" >元</template> </el-input>
      </el-form-item>
    </div>
      <el-form-item label="排序码" prop="sortnum">
        <el-input v-model="form.sortnum" type="number"  placeholder="请输入排序码" v-trim/>
      </el-form-item>
    </el-form>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { listByParentId } from '@/api/business/areas'
 
export default {
  name: 'OperaLabelsFeeAreaWindow',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      isUploading: false,
      // 表单数据
      form: {
        id: null,
        name: '',
        info: '',
        type: 16,
        module: 0,
        sortnum: '',
        weight0: null,
        fee0: null,
        weight1: null,
        fee1: null,
        areaIdList: [],
        areaList: []
      },
      province: [],
      // 验证规则
      rules: {
        areaIdList: [
          { required: true, message: '请选择省份信息' }
        ],
        weight0: [
          { required: true, message: '请输入首重' }
        ],
        fee0: [
          { required: true, message: '请输入金额' }
        ],
        weight1: [
          { required: true, message: '请输入续重' }
        ],
        fee1: [
          { required: true, message: '请输入金额' }
        ],
        name: [
          { required: true, message: '请输入名称' }
        ]
      }
    }
  },
  created () {
    this.config({
      api: '/business/labels',
      'field.id': 'id'
    })
    listByParentId({ type: 0, parentId: '' })
      .then(data => {
        this.province = data
      })
  },
  methods: {
    confirm () {
      this.form.param = JSON.stringify({
        weight0: this.form.weight0,
        fee0: this.form.fee0,
        weight1: this.form.weight1,
        fee1: this.form.fee1
      })
      if (this.form.id == null || this.form.id === '') {
        this.__confirmCreate()
        return
      }
      this.__confirmEdit()
    },
    open (title, target) {
      var that = this
      this.title = title
      this.visible = true
      // this.isEdit = false
      this.form.areaList = []
      this.form.areaIdList = []
      this.form.paramObj = { weight0: null, fee0: null, weight1: null, fee1: null }
      // 新建
      if (target == null) {
        this.$nextTick(() => {
          this.$refs.form.resetFields()
          this.form[this.configData['field.id']] = null
        })
        return
      }
      // 编辑
      this.$nextTick(() => {
        this.isEdit = true
        for (const key in this.form) {
          this.form[key] = target[key]
        }
        that.form.areaIdList = []
        var t = JSON.parse(target.param)
        if (t) {
          that.form.weight0 = parseFloat(t.weight0 || 0)
          that.form.fee0 = parseFloat(t.fee0 || 0)
          that.form.weight1 = parseFloat(t.weight1 || 0)
          that.form.fee1 = parseFloat(t.fee1 || 0)
        }
        if (this.form.areaList && this.form.areaList.length) {
          this.form.areaList.forEach(item => {
            that.form.areaIdList.push(item.id)
          })
        }
      })
    }
  }
}
</script>
 
<style lang="scss" scoped>
@import "@/assets/style/alertstyle.scss";
$image-width: 100px;
 
::v-deep .el-select {
    width: 100%;
    .el-input__inner {
      width: 100%;
    }
  }
.avatar-uploader {
  width: $image-width;
  height: $image-width;
}
::v-deep .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  width: $image-width;
  height: $image-width;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: $image-width;
  height: $image-width;
  line-height: $image-width;
  text-align: center;
}
.avatar {
  width: $image-width;
  height: $image-width;
  display: block;
}
</style>