|  |  |  | 
|---|
|  |  |  | <el-table-column prop="dateInfo" label="送货日期" min-width="130px"></el-table-column> | 
|---|
|  |  |  | <el-table-column prop="lineName" label="送货线路" min-width="130px">  </el-table-column> | 
|---|
|  |  |  | <el-table-column prop="orderNum" label="客户数(户)" min-width="130px"> </el-table-column> | 
|---|
|  |  |  | <el-table-column prop="totalNum" label="送货量(条)" min-width="130px"></el-table-column> | 
|---|
|  |  |  | <el-table-column prop="totalNum" label="送货量/最大量(条)" min-width="130px"> | 
|---|
|  |  |  | <template slot-scope="{row}"> | 
|---|
|  |  |  | {{row.totalNum ||0}} / {{row.maxOrder || 0}} | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </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-column prop="distance" label="总路程(公里)" min-width="100px"> | 
|---|
|  |  |  | <template slot-scope="{row}"> | 
|---|
|  |  |  | {{((row.distance ||0)/1000).toFixed(2)}} | 
|---|
|  |  |  | {{((row.distance ||0)/1000).toFixed(2)}}(调整前) | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </el-table-column> | 
|---|
|  |  |  | <el-table-column | 
|---|
|  |  |  | 
|---|
|  |  |  | align="left" | 
|---|
|  |  |  | fixed="right" | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <template slot-scope="{row}"> | 
|---|
|  |  |  | <template slot-scope="{row}" v-if="dataList.length>1"> | 
|---|
|  |  |  | <el-button type="text" @click="updateDo(row)" icon="el-icon-edit"   style="color: #0d68ff" v-if="!updating" >微调</el-button> | 
|---|
|  |  |  | <template v-else-if="updating &&  currentRow.id ===row.id" > | 
|---|
|  |  |  | <el-button type="text" style="color: #13ce66"  >本车</el-button> | 
|---|
|  |  |  | <el-button type="text" @click="cancelDo(row)"  icon="el-icon-delete"  style="color: red" >取消</el-button> | 
|---|
|  |  |  | <el-button type="text" @click="cancelDo(row)"  icon="el-icon-circle-close"  style="color: red" >取消</el-button> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | <el-button type="text" @click="addDo(row)" icon="el-icon-plus"  style="color: red" v-else-if="updating &&  currentRow.id !==row.id" >加入</el-button> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | 
|---|
|  |  |  | <div> | 
|---|
|  |  |  | <p class="tip-warn"><i class="el-icon-warning"></i>操作说明:<br> | 
|---|
|  |  |  | 1.请选择若干客户信息,点击上述其他线路后的<span class="red">【加入】</span>按钮,将选中的客户移加到对应线路中;<br> | 
|---|
|  |  |  | 2.点击本车线路后的<span class="red">【取消】</span>按钮,可撤销本车微调操作;<br> | 
|---|
|  |  |  | 2.点击本车线路后的<span class="red">【取消】</span>按钮,可撤销本车微调操作;<br> | 
|---|
|  |  |  | 3.经过调整后的线路路程数请等待提交后查看;<br> | 
|---|
|  |  |  | </p> | 
|---|
|  |  |  | <el-table  :data="paginatedData" stripe  @selection-change="handleSelectionChange">> | 
|---|
|  |  |  | <el-table-column type="selection" width="55"></el-table-column> | 
|---|
|  |  |  | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <template   v-slot:footer> | 
|---|
|  |  |  | <el-button @click="confirmDo" type="primary" v-if="buttonName!==''">{{ buttonName||'确认' }}</el-button> | 
|---|
|  |  |  | <el-button @click="resetData" type="danger" v-if="buttonName!==''">撤销所有调整</el-button> | 
|---|
|  |  |  | <el-button @click="visible=false">返回</el-button> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </GlobalWindow> | 
|---|
|  |  |  | 
|---|
|  |  |  | import BaseOpera from '@/components/base/BaseOpera' | 
|---|
|  |  |  | import GlobalWindow from '@/components/common/GlobalWindow' | 
|---|
|  |  |  | import { allList as customerList } from '@/api/business/jkSketchCustomer' | 
|---|
|  |  |  | import { updateSketchLine } from '@/api/business/jkSketch' | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: 'OperaJkSketchLineWindow', | 
|---|
|  |  |  | extends: BaseOpera, | 
|---|
|  |  |  | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | // 表单数据 | 
|---|
|  |  |  | updating: false, | 
|---|
|  |  |  | edited: false, | 
|---|
|  |  |  | currentRow: null, | 
|---|
|  |  |  | model: { | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | buttonName: '', | 
|---|
|  |  |  | dataList: [], | 
|---|
|  |  |  | originDataList: [], | 
|---|
|  |  |  | currentPage: 1, | 
|---|
|  |  |  | pageSize: 10, | 
|---|
|  |  |  | totalItems: 0, // 总数据条目数 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | resetData () { | 
|---|
|  |  |  | this.buttonName = '' | 
|---|
|  |  |  | this.cancelDo() | 
|---|
|  |  |  | this.loadList() | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | confirmDo () { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.isWorking = true | 
|---|
|  |  |  | updateSketchLine({ | 
|---|
|  |  |  | id: this.model.id, | 
|---|
|  |  |  | sketchLineList: this.dataList | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .then(() => { | 
|---|
|  |  |  | this.visible = false | 
|---|
|  |  |  | this.$tip.apiSuccess('线路调整已完成!') | 
|---|
|  |  |  | this.$emit('success') | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch(e => { | 
|---|
|  |  |  | // this.$tip.apiFailed(e) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .finally(() => { | 
|---|
|  |  |  | this.isWorking = false | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | open (title, target) { | 
|---|
|  |  |  | this.title = title + target.categoryName | 
|---|
|  |  |  | 
|---|
|  |  |  | this.selectRows = [] | 
|---|
|  |  |  | this.updating = true | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | cancelDo (row) { | 
|---|
|  |  |  | cancelDo () { | 
|---|
|  |  |  | this.selectRows = [] | 
|---|
|  |  |  | this.currentRow = null | 
|---|
|  |  |  | this.updating = false | 
|---|
|  |  |  | 
|---|
|  |  |  | tarray.push(item) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | if(tarray.length === 0){ | 
|---|
|  |  |  | if (tarray.length === 0) { | 
|---|
|  |  |  | this.$message.error('对不起,本车线路至少留存一个客户信息,无法全部清空!') | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var rArray =  row.customerList || [] | 
|---|
|  |  |  | rArray = rArray.push(...this.selectRows) | 
|---|
|  |  |  | var rArray = [...row.customerList || []] | 
|---|
|  |  |  | rArray.push(...this.selectRows) | 
|---|
|  |  |  | let ttNum = 0 | 
|---|
|  |  |  | rArray.forEach(item => { | 
|---|
|  |  |  | ttNum += (item.totalNum || 0) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | if(tarray.length >= (row.maxCustomer||0)){ | 
|---|
|  |  |  | this.$message.error('对不起,加入的线路最大支持'+ (row.maxOrderNum||0) + '客户!') | 
|---|
|  |  |  | if (tarray.length >= (row.maxCustomer || 0)) { | 
|---|
|  |  |  | this.$message.error('对不起,加入的线路最大支持' + (row.maxCustomer || 0) + '客户!') | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(ttNum >= (row.maxOrder||0)){ | 
|---|
|  |  |  | this.$message.error('对不起,加入的线路最大支持'+ (row.maxOrder||0) + '送货量!') | 
|---|
|  |  |  | if (ttNum >= (row.maxOrder || 0)) { | 
|---|
|  |  |  | this.$message.error('对不起,加入的线路最大支持' + (row.maxOrder || 0) + '送货量,当前方案:' + ttNum) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.currentRow.customerList = tarray | 
|---|
|  |  |  | 
|---|
|  |  |  | this.currentRow = null | 
|---|
|  |  |  | this.updating = false | 
|---|
|  |  |  | this.buttonName = '保存调整开始优化' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | console.log(this.dataList) | 
|---|
|  |  |  | console.log(this.originDataList) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | handleSelectionChange (rows) { | 
|---|
|  |  |  | this.selectRows = rows | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | loadList () { | 
|---|
|  |  |  | this.api.allList({ | 
|---|
|  |  |  | sketchId: this.model.id | 
|---|
|  |  |  | sketchId: this.model.id, | 
|---|
|  |  |  | type: 1 | 
|---|
|  |  |  | }).then(res => { | 
|---|
|  |  |  | this.dataList = res | 
|---|
|  |  |  | this.dataList = [...(res || [])] | 
|---|
|  |  |  | this.originDataList = JSON.parse(JSON.stringify(res||[])); | 
|---|
|  |  |  | this.loadCustomerList() | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|