doum
16 小时以前 46124fe454f90d24171ebc5be0d9cfe2ab22cbc5
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
<template>
  <GlobalWindow
    :title="title"
    width="70%"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
    <p class="tip-warn"><i class="el-icon-warning"></i>优化说明:<br>
      1、当前优化任务最多支持<span class="orange">【 {{lineNum}} 】</span>条线路;<br>
      2、合理选择线路,选择线路的总客户数和总送货量需要满足当日订单累计值;<br>
      3、强制优化表示忽略该主线优化中的任务,重新开启优化任务(不建议);<br>
    </p>
<!--    <el-form :model="form" ref="form" :rules="rules">
      <el-form-item label="生成线路数量" prop="planLineNum">
        <el-input type="number" disabled  v-model="form.planLineNum" placeholder="请输入线路数" v-trim/>
      </el-form-item>
    </el-form>-->
    <div>
      <el-form :model="form" ref="form" :rules="rules">
        <el-form-item label="是否强制优化" prop="forceUpdate">
          <el-radio-group v-model="form.forceUpdate">
            <el-radio :label="0" :value="0">不强制</el-radio>
            <el-radio :label="1" :value="1">强制</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="选择生成线路" prop="lineIdList" >
          <el-table  :data="lineList" stripe    @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column prop="name" label="送货线路" min-width="130px" show-tooltip-when-overflow>  </el-table-column>
            <el-table-column prop="maxCustomer" label="客户数(户)" min-width="100px"  show-tooltip-when-overflow></el-table-column>
            <el-table-column prop="maxOrder" label="送货量(条)" min-width="100px"  show-tooltip-when-overflow></el-table-column>
            <el-table-column prop="carCode" label="车牌号" min-width="100px"></el-table-column>
            <el-table-column prop="memberName" label="送货司机" min-width="100px"></el-table-column>
          </el-table>
        </el-form-item>
      </el-form>
    </div>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { allList } from '@/api/business/jkLine'
export default {
  name: 'OperaJkSketchWindow',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      // 表单数据
      form: {
        id: null,
        planLineNum: '',
        forceUpdate: 0,
        lineIdList: []
      },
      categoryId: null,
      lineList: [],
      lineNum: null,
      // 验证规则
      rules: {
        lineIdList: [{ required: true, message: '请选择生成线路数量' }],
        forceUpdate: [{ required: true, message: '请选择是否强制优化' }]
      }
    }
  },
  created () {
    this.config({
      api: '/business/jkSketch',
      'field.id': 'id'
    })
  },
  methods: {
    handleSelectionChange (rows) {
      this.form.lineIdList = []
      if (rows || rows.length) {
        rows.forEach(item => {
          this.form.lineIdList.push(item.id)
        })
      }
    },
    open (title, target) {
      if (!target || !target.id) {
        return
      }
      this.lineList = []
      this.title = title
      this.visible = true
      this.categoryId = target.categoryId
      this.form.id = target.id
      this.form.planLineNum = target.planLineNum
      this.form.forceUpdate = 0
      this.form.lineIdList = []
      this.loadLines()
    },
    confirm () {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
      /*  if (this.form.planLineNum <= 0 || this.form.planLineNum > this.lineNum) {
          this.$message.error('优化线路数必须在[1-' + this.lineNum + ']范围内!')
          return
        }*/
        this.confirmDo()
      })
    },
    confirmDo () {
      // 调用新建接口
      this.isWorking = true
      this.api.updateById({
        id: this.form.id,
        lineIdList: this.form.lineIdList,
        forceUpdate: this.form.forceUpdate
      })
        .then(() => {
          this.visible = false
          this.$tip.apiSuccess('优化任务正在后台执行,请等待优化完成后查看优化结果!')
          this.$emit('success')
        })
        .catch(e => {
          // this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.isWorking = false
        })
    },
    loadLines () {
      allList({
        categoryId: this.categoryId
      }).then(res => {
        this.lineList = res || []
        this.lineNum = this.lineList.length
      })
    }
  }
}
</script>