12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394 |
- <template>
- <!-- 销售订单页面 -->
- <div class="salePlan">
- <div class="top">
- <el-form :inline="true">
- <el-form-item v-if="activeName != 'first'">
- <el-date-picker
- v-model="startTime"
- type="datetime"
- placeholder="选择日期"
- style="width:220px"
- >
- </el-date-picker>
- <span>至</span>
- <el-date-picker
- v-model="endTime"
- type="datetime"
- placeholder="选择日期"
- style="width:220px"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-input
- placeholder="请输入内容"
- v-model="input"
- clearable
- style="width:250px"
- >
- </el-input>
- <el-button type="primary" @click="onclick">
- <i class="el-icon-search"></i>
- </el-button>
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- @click="btnclick(0)"
- v-if="activeName == 'first'"
- >
- <i class="el-icon-plus"></i>新增
- </el-button>
- <el-button type="primary" @click="refresh">
- <i class="el-icon-refresh"></i>
- </el-button>
- <el-button
- type="primary"
- @click="batchReport"
- v-if="activeName == 'first'"
- >
- <i class="upload2"></i>批量上传
- </el-button>
- <el-button
- type="primary"
- @click="batchDeleteFirst"
- v-if="activeName == 'first'"
- >
- <i class="upload2"></i>批量删除
- </el-button>
- <el-button
- type="primary"
- @click="batchDeleteSecond"
- v-if="activeName == 'second'"
- >
- <i class="upload2"></i>批量删除
- </el-button>
- <el-button
- type="primary"
- @click="exportData()"
- v-if="activeName == 'first'"
- ><i class="el-icon-download"></i>导出Excel</el-button
- >
- <el-form-item v-if="activeName == 'first'">
- <el-upload
- class="upload-excel"
- action=""
- :on-change="importExcel"
- :show-file-list="false"
- accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
- :auto-upload="false"
- >
- <el-button type="primary" icon="el-icon-upload"
- >导入Excel</el-button
- >
- </el-upload>
- </el-form-item>
- <el-button disabled v-if="activeName != 'five'">物资总件数</el-button>
- <el-input
- placeholder=""
- v-model="matSum"
- clearable
- style="width:100px"
- disabled
- v-show="activeName == 'first'"
- >
- </el-input>
- <el-input
- placeholder=""
- v-model="matSum1"
- clearable
- style="width:100px"
- disabled
- v-show="activeName == 'four'"
- >
- </el-input>
- <el-input
- placeholder=""
- v-model="matSum2"
- clearable
- style="width:100px"
- disabled
- v-show="activeName == 'second'"
- >
- </el-input>
- </el-form-item>
- </el-form>
- </div>
- <div class="table">
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <!-- 未上报 -->
- <el-tab-pane label="未上报" name="first">
- <mergeRowTable
- v-bind.sync="option"
- ref="excelDom"
- @selection-change="selectionChange"
- :pageSize="200"
- @func="func"
- >
- <el-table-column
- fixed="right"
- label="操作"
- align="center"
- width="200"
- >
- <template slot-scope="scope">
- <el-button
- @click="uploadclick(scope.row.saleOrderId)"
- type="text"
- size="small"
- >上传</el-button
- >
- <el-button
- @click="click(scope.row.saleOrderId)"
- type="text"
- size="small"
- >修改</el-button
- >
- <el-button
- type="text"
- size="small"
- @click="deleteclick(scope.row)"
- >删除</el-button
- >
- <el-button
- type="text"
- size="small"
- @click="copyClick(scope.row.saleOrderId)"
- >复制</el-button
- >
- </template>
- </el-table-column>
- </mergeRowTable>
- </el-tab-pane>
- <!-- 已审批 -->
- <el-tab-pane label="已审批" name="four">
- <mergeRowTable
- v-bind.sync="option4"
- ref="table"
- :pageSize="200"
- @func="func1"
- >
- <el-table-column
- fixed="right"
- label="操作"
- align="center"
- width="280"
- >
- <template slot-scope="scope">
- <el-button
- @click="deleteSaleOrder(scope.row)"
- type="text"
- size="small"
- >关闭订单</el-button
- >
- <el-button
- @click="adverseCloseSaleOrder(scope.row)"
- type="text"
- size="small"
- >反关闭订单</el-button
- >
- <el-button
- @click="updateSaleOrder(scope.row)"
- type="text"
- size="small"
- >异常处理</el-button
- >
- <el-button
- type="text"
- size="small"
- @click="copyClick(scope.row.saleOrderId)"
- >复制</el-button
- >
- </template>
- </el-table-column>
- </mergeRowTable>
- </el-tab-pane>
- <el-tab-pane label="反审批" name="five">
- <mergeRowTable v-bind.sync="option5" ref="table2" :pageSize="200">
- <el-table-column
- fixed="right"
- label="操作"
- align="center"
- width="200"
- >
- <template slot-scope="scope">
- <el-button
- @click="updateSaleOrder(scope.row)"
- type="text"
- size="small"
- >异常处理</el-button
- >
- </template>
- </el-table-column></mergeRowTable
- >
- </el-tab-pane>
- <!-- 已上报 -->
- <el-tab-pane label="已上报" name="second">
- <mergeRowTable
- v-bind.sync="option2"
- ref="table2"
- @selection-change="selectionChange2"
- :pageSize="200"
- @func="func2"
- >
- <el-table-column
- fixed="right"
- label="操作"
- align="center"
- width="200"
- >
- <template slot-scope="scope">
- <el-button
- @click="closeSteelOrderAndEas(scope.row)"
- type="text"
- size="small"
- >关闭订单</el-button
- >
- <el-button
- @click="updateReportedSaleOrder(scope)"
- type="text"
- size="small"
- >修改</el-button
- >
- </template>
- </el-table-column>
- </mergeRowTable>
- </el-tab-pane>
- </el-tabs>
- </div>
- </div>
- </template>
- <script>
- import { getCookie } from '@/utils/util.js'
- import { sjTime } from '@/utils/sharedJsFile'
- import { isNumber } from '../../../ADMINISTRATORS/app'
- import ExcelSaleOrder from '../saleContract/importExcelSaleOrder.vue'
- export default {
- name: 'saleOrder',
- components: {
- ExcelSaleOrder
- },
- data() {
- return {
- dialogTableVisible: false,
- startTime: null,
- endTime: null,
- batchReportList: [],
- activeName: 'first',
- tableTitle: '未上传销售订单报表',
- drawer: false,
- input: '',
- index: '',
- carrierId: null,
- carrierName: null,
- shipperName: '四川省达州钢铁集团有限责任公司',
- shipperId: 1,
- receivingCompany: [
- '四川省达州钢铁集团有限责任公司',
- '四川达钢商贸有限公司',
- '江西久隆贸易有限公司',
- '海南瀚途贸易有限公司',
- '成都兴城道成物流有限公司'
- ],
- option: {
- // 表格请求数据的地址
- requestUrl: '',
- selectionType: 'select',
- comparison: 'saleNumber',
- columnIndexs: [0, 1, 2, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
- },
- option2: {
- // 表格请求数据的地址
- requestUrl: '',
- selectionType: 'select',
- comparison: 'saleNumber',
- columnIndexs: [0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
- },
- option4: {
- // 表格请求数据的地址
- requestUrl: '',
- comparison: 'saleNumber',
- columnIndexs: [
- 0,
- 1,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 16,
- 17,
- 18,
- 20,
- 21,
- 22
- ]
- },
- option5: {
- // 表格请求数据的地址
- requestUrl: '',
- comparison: 'saleNumber',
- columnIndexs: [
- 0,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 16,
- 17,
- 18,
- 20,
- 21
- ]
- },
- mapList: [],
- mapItemList: [],
- matSum: null,
- matSum1: null,
- matSum2: null,
- tableData: [],
- secondList: [],
- saleDateOfReceipt: null,
- //销售订单主表数据
- saleOrderList: [
- 'receiveName',
- 'isSelfMention',
- 'saleRemark',
- 'saleOrderReceiveCustomer',
- 'salerName',
- 'saleOrderNo',
- 'saleArea'
- ],
- saleOrderMapList: [
- 'truckNo',
- 'province',
- 'district',
- 'town',
- 'truckRemark',
- 'place',
- 'saleOrderConsigneeTel',
- 'saleDateOfReceipt',
- 'materialName',
- 'materialSpecification',
- 'materialModel',
- 'materialNumber',
- 'steelMeters',
- 'isPoundSale'
- ]
- }
- },
- created() {
- this.getRmsReceivingCompany()
- if (getCookie('orgCode') == 'shouhuokehu') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
- getCookie('userId')
- this.option5.requestUrl =
- '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- this.option5.requestUrl =
- '/api/v1/ams/getSteelOrderDeletedList?apiId=409&saler=' +
- getCookie('loginName')
- } else {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- this.option5.requestUrl =
- '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- }
- let loadTime1 = new Date(
- new Date(new Date().toLocaleDateString()).getTime() +
- (3600 * 1000 * 8 - 1)
- ) // 当天8点前
- let loadTime2 = new Date(
- new Date(new Date().toLocaleDateString()).getTime() +
- (3600 * 1000 * 32 - 1)
- ) // 次天8点前
- if (new Date().getTime() - loadTime1 > 0) {
- this.saleDateOfReceipt = loadTime2
- } else {
- this.saleDateOfReceipt = loadTime1
- }
- },
- mounted() {
- console.log('我在mouted被执行了')
- },
- activated() {
- console.log('我在activated被执行了')
- if (getCookie('orgCode') == 'shouhuokehu') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- } else {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- }
- let loadTime1 = new Date(
- new Date(new Date().toLocaleDateString()).getTime() +
- (3600 * 1000 * 8 - 1)
- ) // 当天8点前
- let loadTime2 = new Date(
- new Date(new Date().toLocaleDateString()).getTime() +
- (3600 * 1000 * 32 - 1)
- ) // 次天8点前
- if (new Date().getTime() - loadTime1 > 0) {
- this.saleDateOfReceipt = loadTime2
- } else {
- this.saleDateOfReceipt = loadTime1
- }
- },
- methods: {
- //获取收款客户名称
- getRmsReceivingCompany() {
- this.axios.post('/api/v1/rmsReceivingCompany/name').then(res => {
- this.receivingCompany = res.data
- // console.log(res.data)
- })
- },
- //导入Excel格式
- //导入excel
- importExcel(file) {
- let that = this
- if (!file) {
- that.$message({
- message: '文件错误!',
- type: 'warning'
- })
- return
- }
- this.tableData = []
- var reader = new FileReader()
- var data = null
- var workbook = null
- //设置读取操作
- reader.onload = function(e) {
- data = e.target.result
- workbook = XLSX.read(data, {
- type: 'binary'
- })
- let rows = XLSX.utils.sheet_to_json(
- workbook.Sheets[workbook.SheetNames[0]]
- ) //只取第一页
- let uuid = Math.floor(Math.random() * 60 * 24)
- Array.from(rows).forEach((e, index) => {
- let map = {}
- try {
- Object.keys(e).forEach(e1 => {
- if (e1.includes('销售订单编号')) {
- map.saleOrderNo = e[e1]
- }
- if (e1.includes('物资名称')) {
- map.materialName = e[e1]
- if (
- e[e1].includes('盘螺') ||
- e[e1].includes('乱尺') ||
- e[e1].includes('盘元') ||
- e[e1].includes('盘圆')
- ) {
- map.isPoundSale = 0
- } else {
- map.isPoundSale = 1
- }
- //确定更改的物资有无米数
- if (e[e1].includes('米')) {
- map.steelMeters = Number(e[e1].replace(/[^0.0-9.0]/gi, ''))
- } else {
- map.steelMeters = null
- }
- }
- if (e1.includes('规格型号')) {
- // console.log(e[e1])
- let str = e[e1]
- let regex = /\((.+?)\)/g
- if (str.match(regex) != null) {
- let spa = str.replace(str.match(regex)[0], '')
- let model = str
- .match(regex)[0]
- .replace('(', '')
- .replace(')', '')
- map.materialModel = model
- if ((spa + '').includes('Φ')) {
- map.materialSpecification = spa
- } else {
- map.materialSpecification = 'Φ' + spa
- }
- } else {
- map.materialSpecification = e[e1]
- map.model = null
- }
- }
- if (e1.includes('下单客户')) {
- map.receiveName = e[e1]
- }
- if (
- e1.includes('米数') &&
- (map.steelMeters == null || map.steelMeters != '')
- ) {
- map.steelMeters = e[e1]
- }
- if (e1.includes('物资规格') && !e1.includes('规格型号')) {
- if ((e[e1] + '').includes('Φ')) {
- map.materialSpecification = e[e1]
- } else {
- map.materialSpecification = 'Φ' + e[e1]
- }
- }
- if (e1.includes('物资型号') && !e1.includes('规格型号')) {
- map.materialModel = e[e1]
- }
- if (e1.includes('物资件数')) {
- if (isNumber(e[e1])) {
- map.materialNumber = e[e1]
- } else {
- throw new Error(
- `该Excel第--${index +
- 2}--行-“物资件数”错误,请核实后再输入(件数输入整数)`
- )
- }
- }
- if (e1.includes('车序号')) {
- if (typeof e[e1] != 'undefined' && isNumber(e[e1])) {
- map.truckNo = e[e1]
- } else {
- throw new Error(
- `该Excel第--${index +
- 2}--行-“车序号”错误,请核实后再输入(车序号输入正整数)`
- )
- }
- }
- if (e1.includes('收款公司')) {
- if (that.receivingCompany.indexOf(e[e1]) === -1) {
- throw new Error(
- `该Excel第--${index + 2}--行-“收款公司”错误,请核实后再输入`
- )
- } else {
- map.saleOrderReceiveCustomer = e[e1]
- }
- }
- if (e1.includes('业务员')) {
- map.salerName = e[e1]
- }
- if (e1.includes('摘要')) {
- if (e[e1]) {
- let regex = /,定尺范围.*米|,范围定尺.*米/g
- // console.log(e[e1])
- map.saleRemark = e[e1].replace(/,|,/g, ',').split(regex)[0]
- }
- console.log(e[e1])
- let regex = /钢材.*组/g
- if (e[e1].match(regex)) {
- map.saleArea = e[e1].match(regex)[0]
- }
- let regex1 = /范围.*米/g
- if (e[e1].match(regex1)) {
- map.steelMeters = Number(
- e[e1].match(regex1)[0].match(/(\d+(\.\d+)?)/g)
- )
- }
- }
- if (e1.includes('省')) {
- map.province = e[e1]
- }
- if (e1.includes('市')) {
- map.district = e[e1]
- }
- if (e1.includes('县/区')) {
- map.town = e[e1]
- }
- if (e1.includes('具体收货地址')) {
- map.place = e[e1]
- }
- if (e1.includes('收货客户电话')) {
- map.saleOrderConsigneeTel = e[e1]
- }
- if (e1.includes('备注')) {
- map.truckRemark = e[e1]
- }
- if (e1.includes('是否自提')) {
- if (e[e1] === '是' || e[e1] === '否') {
- map.isSelfMention = e[e1]
- } else {
- map.isSelfMention = '否'
- }
- }
- })
- map.shipperName = that.shipperName
- if (typeof map.isSelfMention === 'undefined') {
- map.isSelfMention = '否'
- }
- if (typeof map.truckNo === 'undefined') {
- map.truckNo = Number(
- `${Math.floor(
- Math.random() *
- Math.random() *
- Math.random() *
- Math.random() *
- Math.random() *
- new Date().getTime() *
- 10000000
- )}${uuid}`
- )
- }
- if (map.saleRemark && map.receiveName && map.materialName) {
- that.tableData.push(map)
- }
- } catch (es) {
- that.$message.error(es.message)
- }
- })
- that.addExcelInport()
- // that.dialogTableVisible = true;
- return
- }
- reader.readAsBinaryString(file.raw) //以二进制方式读取
- },
- //自己写一个比较函数排序
- // 排序
- compare(property) {
- return function(a, b) {
- var value1 = a[property]
- var value2 = b[property]
- return value2 - value1
- }
- },
- addExcelInport() {
- //加载虚拟
- const loading = this.$loading({
- lock: true,
- text: '正在快马加鞭为您生成销售订单,请稍候',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- })
- //遍历数组,根据摘要和下单客户自动给出销售订单编号
- for (let i = 0; i < this.tableData.length; i++) {
- if (i === 0) {
- this.tableData[i].saleOrderNo = 1
- } else {
- let sortArr = this.tableData
- .filter(e => {
- return (
- typeof e.saleOrderNo != 'undefined' &&
- e.saleOrderNo != 'undefined' &&
- isNumber(e.saleOrderNo)
- )
- })
- .map(e => {
- if (
- typeof e.saleOrderNo != 'undefined' &&
- e.saleOrderNo != 'undefined' &&
- isNumber(e.saleOrderNo)
- ) {
- return e.saleOrderNo
- }
- })
- .sort((a, b) => {
- return a - b
- })
- //当大于0的时候,需要遍历整个数组,与之相等的有哪些
- for (let j = 0; j < i; j++) {
- if (
- this.tableData[i].saleRemark === this.tableData[j].saleRemark &&
- this.tableData[i].receiveName === this.tableData[j].receiveName &&
- this.tableData[i].saleOrderReceiveCustomer ===
- this.tableData[j].saleOrderReceiveCustomer
- ) {
- this.tableData[i].saleOrderNo = this.tableData[j].saleOrderNo
- break
- } else {
- if (j == i - 1) {
- this.tableData[i].saleOrderNo = sortArr[sortArr.length - 1] + 1
- }
- }
- }
- }
- }
- // this.tableData = this.tableData.sort(this.compare("saleOrderNo"));
- // debugger;
- //需要遍历数组,以销售订单编号为分类
- const map1 = this.tableData.reduce((result, item) => {
- result[item.saleOrderNo] = result[item.saleOrderNo] || []
- result[item.saleOrderNo].push(item)
- return result
- }, {})
- // result即为所求
- let result = Object.values(map1)
- //遍历数组
- let saleOrderListMap = []
- result.forEach((saleOrderList, index) => {
- let map = {}
- let arr = []
- saleOrderList.forEach(e => {
- let mapMaterial = {}
- Object.keys(e).forEach(e1 => {
- if (this.saleOrderList.includes(e1)) {
- map[e1] = e[e1]
- }
- if (this.saleOrderMapList.includes(e1)) {
- mapMaterial[e1] = e[e1]
- }
- })
- mapMaterial.saleDateOfReceipt = sjTime(this.saleDateOfReceipt)
- arr.push(mapMaterial)
- })
- map.shipperId = 1
- map.mapList = arr
- saleOrderListMap.push(map)
- })
- this.axios
- .post('/api/v1/ams/addSteelSaleOrderList', saleOrderListMap)
- .then(res => {
- if (res.data.code == '200') {
- this.getRequestUrl()
- this.tableData = []
- loading.close()
- this.$message.success('新增销售订单成功!')
- } else {
- console.log(res.data.data)
- this.$message.error(res.data.data)
- this.getRequestUrl()
- loading.close()
- this.tableData = []
- }
- })
- .catch(e => {
- loading.close()
- this.$message.error('请检查excel格式')
- this.tableData = []
- })
- },
- adverseCloseSaleOrder(row) {
- console.log(row)
- this.$confirm('确定反关闭整条订单吗?', '继续?', {
- cancelButtonText: '取消',
- confirmButtonText: '确定',
- center: true
- }).then(() => {
- this.axios
- .post(
- '/api/v1/ams/adverseCloseSaleOrder?saleOrderId=' + row.saleOrderId
- )
- .then(res => {
- if (res.data.code == '200') {
- this.$message.success('反关闭成功')
- this.getRequestUrl()
- } else {
- this.$message.error('反关闭失败')
- this.getRequestUrl()
- }
- })
- .catch(() => {
- this.$message.error('反关闭失败')
- })
- })
- },
- updateReportedSaleOrder(scope) {
- this.$router.push('/editSaleOrder/' + scope.row.saleOrderId)
- },
- updateSaleOrderStatusById(scope) {
- console.log(scope.row.saleOrderId)
- this.$confirm('是否撤销', '警告', {
- confirmButtonText: '确定撤销',
- cancelButtonText: '取消撤销',
- type: 'warning',
- center: true
- })
- .then(() => {
- this.axios
- .post(
- '/api/v1/uc/updateSaleOrderStatusById?saleOrderId=' +
- scope.row.saleOrderId
- )
- .then(res => {
- if (res.data.code == '200') {
- this.$message.success('撤销成功')
- this.activeName = 'first'
- this.getRequestUrl()
- } else {
- this.$message.error('撤销失败')
- }
- })
- .catch(() => {
- this.$message.error('撤销失败')
- })
- })
- .catch(() => {
- console.log('取消撤销')
- })
- },
- func(res) {
- // console.log('func', res)
- this.matSum = res.list.reduce(function(prev, item) {
- return prev + item.materialNumber
- }, 0)
- },
- func1(res) {
- // console.log('func1', res)
- this.matSum1 = res.list.reduce(function(prev, item) {
- return prev + item.materialNumber
- }, 0)
- // console.log(this.matSum, 'matsum')
- },
- func2(res) {
- this.matSum2 = res.list.reduce(function(prev, item) {
- return prev + item.materialNumber
- }, 0)
- },
- closeSteelOrderAndEas(row) {
- this.$prompt('此操作将同步关闭金蝶和物流的销售订单,是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputPlaceholder: '请输入关闭原因-必填!!!',
- center: true,
- type: 'warning'
- })
- .then(({ value }) => {
- if (value != null) {
- let mapValue = {
- number: row.saleNumber,
- saleOrderId: row.saleOrderId,
- reason: value
- }
- console.log(mapValue)
- this.axios
- .post('/api/v1/ams/deleteSaleOrderSame', mapValue)
- .then(res => {
- if (res.data.code == 200) {
- this.$message.success('关闭成功')
- this.getRequestUrl()
- } else {
- this.$message.error('关闭失败,请联系管理员')
- }
- })
- .catch(() => {
- this.$message.error('关闭失败,请联系管理员')
- this.getRequestUrl()
- })
- } else {
- this.$message.error('请输入理由')
- }
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '取消输入'
- })
- })
- },
- deleteSaleOrder(row) {
- console.log(row)
- this.$prompt('此操作将关闭订单且下面的待运输订单,是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputPlaceholder: '请输入关闭原因-必填!!!',
- center: true,
- type: 'warning'
- })
- .then(({ value }) => {
- if (value != null) {
- let mapValue = {
- number: row.saleNumber,
- saleOrderId: row.saleOrderId,
- reason: value
- }
- this.axios
- .post(
- '/api/v1/ams/deleteSaleOrderById?saleOrderId=' + row.saleOrderId
- )
- .then(res => {
- if (res.data.code == 200) {
- this.$message.success('关闭成功')
- this.getRequestUrl()
- }
- })
- } else {
- this.$message.error('请输入理由')
- }
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '取消输入'
- })
- })
- },
- updateSaleOrder(row) {
- console.log(row)
- this.$router.push(
- 'updateSaleOrderSteel/' + row.saleOrderId + '/' + row.deleted
- )
- },
- getOrderDetails(saleOrderId) {
- console.log(saleOrderId)
- this.$router.push('saleOrderOODetails/' + saleOrderId)
- },
- getRequestUrl() {
- if (getCookie('orgCode') == 'shouhuokehu') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- this.option5.requestUrl =
- '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
- getCookie('userId') +
- '&i=' +
- new Date()
- } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&saler=' +
- getCookie('loginName') +
- '&i=' +
- new Date()
- this.option5.requestUrl =
- '/api/v1/ams/getSteelOrderDeletedList?apiId=409&saler=' +
- getCookie('loginName')
- } else {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- this.option5.requestUrl =
- '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
- null +
- '&i=' +
- new Date()
- }
- },
- batchReport() {
- if (this.batchReportList.length === 0) {
- this.$message.error('请先选择需要批量上传的销售订单')
- return
- }
- let arr = Array.from(
- new Set(
- this.batchReportList.map(e => {
- return e.saleOrderId
- })
- )
- ).map(e => {
- let map = {}
- map.saleOrderId = e
- return map
- })
- console.log(arr)
- const loading = this.$loading({
- lock: true,
- text: '正在努力上传',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- })
- this.axios
- .post('/api/v1/ams/uploadSaleOrderList', arr)
- .then(res => {
- if (res.data.code == '200') {
- this.$message.success('上传成功')
- this.getRequestUrl()
- loading.close()
- } else {
- this.$message.error('上传失败')
- loading.close()
- }
- })
- .catch(() => {
- this.$message.error('上传失败')
- loading.close()
- })
- },
- selectionChange(selection) {
- console.log(selection)
- this.batchReportList = []
- this.batchReportList = selection
- console.log('firstList:', this.batchReportList)
- },
- selectionChange2(selection) {
- console.log(selection)
- this.secondList = []
- this.secondList = selection
- console.log('secondList:', this.secondList)
- },
- refresh() {
- this.getRequestUrl()
- },
- handleClick(tab, event) {
- console.log(tab, event)
- },
- onclick() {
- var startTime = null
- var endTime = null
- if (this.startTime && this.endTime) {
- startTime = sjTime(this.startTime)
- endTime = sjTime(this.endTime)
- }
- if (getCookie('orgCode') == 'shouhuokehu') {
- if (this.activeName == 'first') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=' +
- this.input +
- '&consigneeSsoId=' +
- getCookie('userId') +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date()
- } else if (this.activeName == 'second') {
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=' +
- this.input +
- '&consigneeSsoId=' +
- getCookie('userId') +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date()
- } else if (this.activeName == 'four') {
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=' +
- this.input +
- '&consigneeSsoId=' +
- getCookie('userId') +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date()
- }
- } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
- if (this.activeName == 'first') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=' +
- this.input +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date() +
- 'saler=' +
- getCookie('loginName')
- } else if (this.activeName == 'second') {
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=' +
- this.input +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date() +
- 'saler=' +
- getCookie('loginName')
- } else if (this.activeName == 'four') {
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=' +
- this.input +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date() +
- 'saler=' +
- getCookie('loginName')
- }
- } else {
- if (this.activeName == 'first') {
- this.option.requestUrl =
- '/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=' +
- this.input +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date()
- } else if (this.activeName == 'second') {
- this.option2.requestUrl =
- '/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=' +
- this.input +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date()
- } else if (this.activeName == 'four') {
- this.option4.requestUrl =
- '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=' +
- this.input +
- '&startTime=' +
- startTime +
- '&endTime=' +
- endTime +
- '&i=' +
- new Date()
- }
- }
- },
- handleClose() {},
- seeclick(saleOrderId) {
- this.$router.push('/saleOrderDetail/' + saleOrderId)
- },
- btnclick() {
- this.$router.push('/addSaleOrder')
- },
- click(saleOrderId) {
- this.$router.push('/editSaleOrder/' + saleOrderId)
- },
- copyClick(saleOrderId) {
- this.$router.push('/copySteelOrder/' + saleOrderId)
- },
- // 上传
- uploadclick(saleOrderId) {
- this.$confirm('是否上传', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- })
- .then(() => {
- const loading = this.$loading({
- lock: true,
- text: '正在努力上传',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- })
- this.axios
- .post('/api/v1/ams/uploadSaleOrder?saleOrderId=' + saleOrderId)
- .then(res => {
- if (res.data.code == '200') {
- this.$message.success('上传成功!')
- this.getRequestUrl()
- loading.close()
- } else {
- this.$message.success('上传失败!')
- this.getRequestUrl()
- loading.close()
- }
- })
- .catch(() => {
- loading.close()
- })
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '取消上传!'
- })
- })
- },
- //删除
- deleteclick(scope) {
- this.$confirm('是否删除', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- })
- .then(() => {
- let rows = []
- rows.push(scope)
- this.batchDelete(rows)
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '取消删除!'
- })
- })
- },
- batchDeleteFirst() {
- let rows = this.batchReportList
- console.log('rows:', rows)
- if (!rows || rows.length <= 0) {
- this.$message.warning('请选中订单!')
- return
- }
- this.$confirm('是否删除', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- })
- .then(() => {
- this.batchDelete(rows)
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '取消删除!'
- })
- })
- },
- batchDeleteSecond() {
- let rows = this.secondList
- console.log('rows:', rows)
- if (!rows || rows.length <= 0) {
- this.$message.warning('请选中订单!')
- return
- }
- this.$confirm('是否删除', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- })
- .then(() => {
- this.batchDelete(rows)
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '取消删除!'
- })
- })
- },
- batchDelete(rows) {
- this.axios
- .post('/api/v1/ams/deleteAmsSaleOrderBySaleOrderId', rows)
- .then(res => {
- if (res.data.code == '200') {
- this.$message.success('删除成功')
- this.getRequestUrl()
- } else {
- this.$message.success('删除失败')
- this.getRequestUrl()
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .salePlan {
- .top {
- margin-left: 20px;
- margin-top: 20px;
- }
- .table {
- margin-left: 20px;
- margin-top: 20px;
- }
- .btn {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- }
- </style>
|