<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> 
 |