| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="100%" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <div style="display: block;margin-bottom: 30px;"> |
| | | <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 20px;">主线路信æ¯</div> |
| | | <div style="display: flex;"> |
| | | <div style="flex: 1">éè´§æ¥æï¼{{model.dateInfo ||''}}</div> |
| | | <div style="flex: 1">主线路ï¼{{model.categoryName ||''}}</div> |
| | | <div style="flex: 1">å®¢æ·æ°ï¼{{model.orderNum ||'-'}}</div> |
| | | <div style="flex: 1">éè´§é(æ¡)ï¼{{model.totalNum ||'-'}}</div> |
| | | </div> |
| | | <div style="display: flex;margin-top: 30px"> |
| | | <div style="flex: 1">ä¼åæ¶é´ï¼{{model.planLineDate ||''}} - {{model.planLineEndDate ||''}}</div> |
| | | </div> |
| | | <div style="display: flex;margin-top: 20px" class="orange"> |
| | | <div style="flex: 1">ä¼åç»æï¼ä¼ååæ»è·¯ç¨ <span class="red" style="font-weight: bold"> {{((model.originDistance ||0)/1000).toFixed(2)}}</span> å
¬éï¼ä¼ååæ»è·¯ç¨<span class="green" style="font-weight: bold"> {{((model.distance ||0)/1000).toFixed(2)}} </span> å
Ž</div> |
| | | </div> |
| | | </div> |
| | | <div style="display: block"> |
| | | <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 10px;">线路æç»</div> |
| | | <div> |
| | | <el-table :data="dataList" stripe :row-class-name="tableRowClassName"> |
| | | <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"> |
| | | <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)}}(è°æ´å) |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="æä½" |
| | | min-width="120" |
| | | align="left" |
| | | fixed="right" |
| | | > |
| | | <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-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> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </div> |
| | | |
| | | <div style="display: block;margin-top: 30px;border: 1px solid #f2f2f2;padding: 10px" v-if="updating"> |
| | | <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 10px;">{{currentRow.lineName}} - å®¢æ·æç»</div> |
| | | <div> |
| | | <p class="tip-warn"><i class="el-icon-warning"></i>æä½è¯´æï¼<br> |
| | | 1.è¯·éæ©è¥å¹²å®¢æ·ä¿¡æ¯ï¼ç¹å»ä¸è¿°å
¶ä»çº¿è·¯åç<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> |
| | | <el-table-column prop="code" label="客æ·ç®ç " min-width="130px"></el-table-column> |
| | | <el-table-column prop="name" label="客æ·åç§°" min-width="130px"> </el-table-column> |
| | | <el-table-column prop="totalNum" label="éè´§é(æ¡)" min-width="130px"></el-table-column> |
| | | <el-table-column prop="location" label="客æ·å°å" min-width="200px" show-tooltip-when-overflow></el-table-column> |
| | | <el-table-column prop="latitude" label="ç»çº¬åº¦" min-width="200px"> |
| | | <template slot-scope="{row}"> |
| | | {{(row.longitude || 0).toFixed(6)}},{{(row.latitude || 0).toFixed(6)}} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div class="table-pagination"> |
| | | <el-pagination |
| | | @current-change="handleCurrentChange" |
| | | :current-page="currentPage" |
| | | :page-size="pageSize" |
| | | layout="total, prev, pager, next, jumper" |
| | | :total="totalItems"> |
| | | </el-pagination> |
| | | </div> |
| | | </div> |
| | | </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> |
| | | </template> |
| | | |
| | | <script> |
| | | 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, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | // è¡¨åæ°æ® |
| | | updating: false, |
| | | edited: false, |
| | | currentRow: null, |
| | | model: { |
| | | }, |
| | | buttonName: '', |
| | | dataList: [], |
| | | originDataList: [], |
| | | currentPage: 1, |
| | | pageSize: 10, |
| | | totalItems: 0, // æ»æ°æ®æ¡ç®æ° |
| | | allCustomerList: [], |
| | | tableData: [], // æææ°æ® |
| | | selectRows: [] |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/jkSketchLine', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | computed: { |
| | | paginatedData () { |
| | | const start = (this.currentPage - 1) * this.pageSize |
| | | const end = start + this.pageSize |
| | | return this.tableData.slice(start, end) |
| | | } |
| | | }, |
| | | 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.visible = true |
| | | this.model = target |
| | | this.updating = false |
| | | this.selectRows = [] |
| | | this.tableData = [] |
| | | this.allCustomerList = [] |
| | | this.currentRow = null |
| | | this.loadList() |
| | | }, |
| | | updateDo (row) { |
| | | this.currentRow = row |
| | | this.tableData = row.customerList || [] |
| | | this.totalItems = this.tableData.length |
| | | this.currentPage = 1 |
| | | this.selectRows = [] |
| | | this.updating = true |
| | | }, |
| | | cancelDo () { |
| | | this.selectRows = [] |
| | | this.currentRow = null |
| | | this.updating = false |
| | | }, |
| | | addDo (row) { |
| | | if (!this.selectRows || !this.selectRows.length) { |
| | | this.$message.error('对ä¸èµ·ï¼è¯·è³å°éæ©æä¸æ¡å®¢æ·è®°å½å å
¥è¯¥è·¯çº¿ï¼') |
| | | return |
| | | } |
| | | const tarray = [] |
| | | let tNum = 0 |
| | | this.currentRow.customerList.forEach(item => { |
| | | let flag = false |
| | | this.selectRows.forEach(item1 => { |
| | | if (item.id === item1.id) { |
| | | flag = true |
| | | } |
| | | }) |
| | | if (!flag) { |
| | | tNum += (item.totalNum || 0) |
| | | tarray.push(item) |
| | | } |
| | | }) |
| | | if (tarray.length === 0) { |
| | | this.$message.error('对ä¸èµ·ï¼æ¬è½¦çº¿è·¯è³å°çåä¸ä¸ªå®¢æ·ä¿¡æ¯ï¼æ æ³å
¨é¨æ¸
空ï¼') |
| | | return |
| | | } |
| | | 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.maxCustomer || 0) + '客æ·ï¼') |
| | | return |
| | | } |
| | | if (ttNum >= (row.maxOrder || 0)) { |
| | | this.$message.error('对ä¸èµ·ï¼å å
¥ç线路æå¤§æ¯æ' + (row.maxOrder || 0) + 'éè´§éï¼å½åæ¹æ¡ï¼' + ttNum) |
| | | return |
| | | } |
| | | this.currentRow.customerList = tarray |
| | | this.currentRow.orderNum = this.currentRow.customerList.length |
| | | this.currentRow.totalNum = tNum |
| | | row.customerList = rArray |
| | | row.orderNum = row.customerList.length |
| | | row.totalNum = ttNum |
| | | this.currentRow = null |
| | | this.updating = false |
| | | this.buttonName = 'ä¿åè°æ´å¼å§ä¼å' |
| | | |
| | | console.log(this.dataList) |
| | | console.log(this.originDataList) |
| | | }, |
| | | handleSelectionChange (rows) { |
| | | this.selectRows = rows |
| | | }, |
| | | loadCustomerList () { |
| | | customerList({ sketchId: this.model.id }) |
| | | .then(res => { |
| | | this.allCustomerList = res |
| | | if (this.allCustomerList && this.allCustomerList.length) { |
| | | this.dataList.forEach(item => { |
| | | var tarray = [] |
| | | this.allCustomerList.forEach(item1 => { |
| | | if (item.id === item1.sketchLineId) { |
| | | tarray.push(item1) |
| | | } |
| | | }) |
| | | item.customerList = tarray |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | loadList () { |
| | | this.api.allList({ |
| | | sketchId: this.model.id, |
| | | type: 1 |
| | | }).then(res => { |
| | | this.dataList = [...(res || [])] |
| | | this.originDataList = JSON.parse(JSON.stringify(res||[])); |
| | | this.loadCustomerList() |
| | | }) |
| | | }, |
| | | tableRowClassName ({ row, rowIndex }) { |
| | | if (this.currentRow && row.id === this.currentRow.id) { |
| | | return 'warning-row' |
| | | } else { |
| | | return 'success-row' |
| | | } |
| | | }, |
| | | handleCurrentChange (newPage) { |
| | | this.currentPage = newPage |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style lang="scss"> |
| | | .el-table .warning-row { |
| | | background: rgba(161, 231, 20, 0.2) !important; |
| | | td{ |
| | | background: rgba(161, 231, 20, 0.2) !important; |
| | | } |
| | | } |
| | | .el-table .success-row { |
| | | background: #f0f9eb !important; |
| | | td{ |
| | | background: #f0f9eb !important; |
| | | } |
| | | } |
| | | </style> |