saleOrderSteel.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  1. <template>
  2. <!-- 销售订单页面 -->
  3. <div class="salePlan">
  4. <div class="top">
  5. <el-form :inline="true">
  6. <el-form-item v-if="activeName != 'first'">
  7. <el-date-picker
  8. v-model="startTime"
  9. type="datetime"
  10. placeholder="选择日期"
  11. style="width:220px"
  12. >
  13. </el-date-picker>
  14. <span>至</span>
  15. <el-date-picker
  16. v-model="endTime"
  17. type="datetime"
  18. placeholder="选择日期"
  19. style="width:220px"
  20. >
  21. </el-date-picker>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-input
  25. placeholder="请输入内容"
  26. v-model="input"
  27. clearable
  28. style="width:250px"
  29. >
  30. </el-input>
  31. <el-button type="primary" @click="onclick">
  32. <i class="el-icon-search"></i>
  33. </el-button>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button
  37. type="primary"
  38. @click="btnclick(0)"
  39. v-if="activeName == 'first'"
  40. >
  41. <i class="el-icon-plus"></i>新增
  42. </el-button>
  43. <el-button type="primary" @click="refresh">
  44. <i class="el-icon-refresh"></i>
  45. </el-button>
  46. <el-button
  47. type="primary"
  48. @click="batchReport"
  49. v-if="activeName == 'first'"
  50. >
  51. <i class="upload2"></i>批量上传
  52. </el-button>
  53. <el-button
  54. type="primary"
  55. @click="batchDeleteFirst"
  56. v-if="activeName == 'first'"
  57. >
  58. <i class="upload2"></i>批量删除
  59. </el-button>
  60. <el-button
  61. type="primary"
  62. @click="batchDeleteSecond"
  63. v-if="activeName == 'second'"
  64. >
  65. <i class="upload2"></i>批量删除
  66. </el-button>
  67. <el-button
  68. type="primary"
  69. @click="exportData()"
  70. v-if="activeName == 'first'"
  71. ><i class="el-icon-download"></i>导出Excel</el-button
  72. >
  73. <el-form-item v-if="activeName == 'first'">
  74. <el-upload
  75. class="upload-excel"
  76. action=""
  77. :on-change="importExcel"
  78. :show-file-list="false"
  79. accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
  80. :auto-upload="false"
  81. >
  82. <el-button type="primary" icon="el-icon-upload"
  83. >导入Excel</el-button
  84. >
  85. </el-upload>
  86. </el-form-item>
  87. <el-button disabled v-if="activeName != 'five'">物资总件数</el-button>
  88. <el-input
  89. placeholder=""
  90. v-model="matSum"
  91. clearable
  92. style="width:100px"
  93. disabled
  94. v-show="activeName == 'first'"
  95. >
  96. </el-input>
  97. <el-input
  98. placeholder=""
  99. v-model="matSum1"
  100. clearable
  101. style="width:100px"
  102. disabled
  103. v-show="activeName == 'four'"
  104. >
  105. </el-input>
  106. <el-input
  107. placeholder=""
  108. v-model="matSum2"
  109. clearable
  110. style="width:100px"
  111. disabled
  112. v-show="activeName == 'second'"
  113. >
  114. </el-input>
  115. </el-form-item>
  116. </el-form>
  117. </div>
  118. <div class="table">
  119. <el-tabs v-model="activeName" @tab-click="handleClick">
  120. <!-- 未上报 -->
  121. <el-tab-pane label="未上报" name="first">
  122. <mergeRowTable
  123. v-bind.sync="option"
  124. ref="excelDom"
  125. @selection-change="selectionChange"
  126. :pageSize="200"
  127. @func="func"
  128. >
  129. <el-table-column
  130. fixed="right"
  131. label="操作"
  132. align="center"
  133. width="200"
  134. >
  135. <template slot-scope="scope">
  136. <el-button
  137. @click="uploadclick(scope.row.saleOrderId)"
  138. type="text"
  139. size="small"
  140. >上传</el-button
  141. >
  142. <el-button
  143. @click="click(scope.row.saleOrderId)"
  144. type="text"
  145. size="small"
  146. >修改</el-button
  147. >
  148. <el-button
  149. type="text"
  150. size="small"
  151. @click="deleteclick(scope.row)"
  152. >删除</el-button
  153. >
  154. <el-button
  155. type="text"
  156. size="small"
  157. @click="copyClick(scope.row.saleOrderId)"
  158. >复制</el-button
  159. >
  160. </template>
  161. </el-table-column>
  162. </mergeRowTable>
  163. </el-tab-pane>
  164. <!-- 已审批 -->
  165. <el-tab-pane label="已审批" name="four">
  166. <mergeRowTable
  167. v-bind.sync="option4"
  168. ref="table"
  169. :pageSize="200"
  170. @func="func1"
  171. >
  172. <el-table-column
  173. fixed="right"
  174. label="操作"
  175. align="center"
  176. width="280"
  177. >
  178. <template slot-scope="scope">
  179. <el-button
  180. @click="deleteSaleOrder(scope.row)"
  181. type="text"
  182. size="small"
  183. >关闭订单</el-button
  184. >
  185. <el-button
  186. @click="adverseCloseSaleOrder(scope.row)"
  187. type="text"
  188. size="small"
  189. >反关闭订单</el-button
  190. >
  191. <el-button
  192. @click="updateSaleOrder(scope.row)"
  193. type="text"
  194. size="small"
  195. >异常处理</el-button
  196. >
  197. <el-button
  198. type="text"
  199. size="small"
  200. @click="copyClick(scope.row.saleOrderId)"
  201. >复制</el-button
  202. >
  203. </template>
  204. </el-table-column>
  205. </mergeRowTable>
  206. </el-tab-pane>
  207. <el-tab-pane label="反审批" name="five">
  208. <mergeRowTable v-bind.sync="option5" ref="table2" :pageSize="200">
  209. <el-table-column
  210. fixed="right"
  211. label="操作"
  212. align="center"
  213. width="200"
  214. >
  215. <template slot-scope="scope">
  216. <el-button
  217. @click="updateSaleOrder(scope.row)"
  218. type="text"
  219. size="small"
  220. >异常处理</el-button
  221. >
  222. </template>
  223. </el-table-column></mergeRowTable
  224. >
  225. </el-tab-pane>
  226. <!-- 已上报 -->
  227. <el-tab-pane label="已上报" name="second">
  228. <mergeRowTable
  229. v-bind.sync="option2"
  230. ref="table2"
  231. @selection-change="selectionChange2"
  232. :pageSize="200"
  233. @func="func2"
  234. >
  235. <el-table-column
  236. fixed="right"
  237. label="操作"
  238. align="center"
  239. width="200"
  240. >
  241. <template slot-scope="scope">
  242. <el-button
  243. @click="closeSteelOrderAndEas(scope.row)"
  244. type="text"
  245. size="small"
  246. >关闭订单</el-button
  247. >
  248. <el-button
  249. @click="updateReportedSaleOrder(scope)"
  250. type="text"
  251. size="small"
  252. >修改</el-button
  253. >
  254. </template>
  255. </el-table-column>
  256. </mergeRowTable>
  257. </el-tab-pane>
  258. </el-tabs>
  259. </div>
  260. </div>
  261. </template>
  262. <script>
  263. import { getCookie } from '@/utils/util.js'
  264. import { sjTime } from '@/utils/sharedJsFile'
  265. import { isNumber } from '../../../ADMINISTRATORS/app'
  266. import ExcelSaleOrder from '../saleContract/importExcelSaleOrder.vue'
  267. export default {
  268. name: 'saleOrder',
  269. components: {
  270. ExcelSaleOrder
  271. },
  272. data() {
  273. return {
  274. dialogTableVisible: false,
  275. startTime: null,
  276. endTime: null,
  277. batchReportList: [],
  278. activeName: 'first',
  279. tableTitle: '未上传销售订单报表',
  280. drawer: false,
  281. input: '',
  282. index: '',
  283. carrierId: null,
  284. carrierName: null,
  285. shipperName: '四川省达州钢铁集团有限责任公司',
  286. shipperId: 1,
  287. receivingCompany: [
  288. '四川省达州钢铁集团有限责任公司',
  289. '四川达钢商贸有限公司',
  290. '江西久隆贸易有限公司',
  291. '海南瀚途贸易有限公司',
  292. '成都兴城道成物流有限公司'
  293. ],
  294. option: {
  295. // 表格请求数据的地址
  296. requestUrl: '',
  297. selectionType: 'select',
  298. comparison: 'saleNumber',
  299. columnIndexs: [0, 1, 2, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
  300. },
  301. option2: {
  302. // 表格请求数据的地址
  303. requestUrl: '',
  304. selectionType: 'select',
  305. comparison: 'saleNumber',
  306. columnIndexs: [0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
  307. },
  308. option4: {
  309. // 表格请求数据的地址
  310. requestUrl: '',
  311. comparison: 'saleNumber',
  312. columnIndexs: [
  313. 0,
  314. 1,
  315. 6,
  316. 7,
  317. 8,
  318. 9,
  319. 10,
  320. 11,
  321. 12,
  322. 13,
  323. 14,
  324. 15,
  325. 16,
  326. 17,
  327. 18,
  328. 20,
  329. 21,
  330. 22
  331. ]
  332. },
  333. option5: {
  334. // 表格请求数据的地址
  335. requestUrl: '',
  336. comparison: 'saleNumber',
  337. columnIndexs: [
  338. 0,
  339. 6,
  340. 7,
  341. 8,
  342. 9,
  343. 10,
  344. 11,
  345. 12,
  346. 13,
  347. 14,
  348. 15,
  349. 16,
  350. 17,
  351. 18,
  352. 20,
  353. 21
  354. ]
  355. },
  356. mapList: [],
  357. mapItemList: [],
  358. matSum: null,
  359. matSum1: null,
  360. matSum2: null,
  361. tableData: [],
  362. secondList: [],
  363. saleDateOfReceipt: null,
  364. //销售订单主表数据
  365. saleOrderList: [
  366. 'receiveName',
  367. 'isSelfMention',
  368. 'saleRemark',
  369. 'saleOrderReceiveCustomer',
  370. 'salerName',
  371. 'saleOrderNo',
  372. 'saleArea'
  373. ],
  374. saleOrderMapList: [
  375. 'truckNo',
  376. 'province',
  377. 'district',
  378. 'town',
  379. 'truckRemark',
  380. 'place',
  381. 'saleOrderConsigneeTel',
  382. 'saleDateOfReceipt',
  383. 'materialName',
  384. 'materialSpecification',
  385. 'materialModel',
  386. 'materialNumber',
  387. 'steelMeters',
  388. 'isPoundSale'
  389. ]
  390. }
  391. },
  392. created() {
  393. this.getRmsReceivingCompany()
  394. if (getCookie('orgCode') == 'shouhuokehu') {
  395. this.option.requestUrl =
  396. '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
  397. getCookie('userId') +
  398. '&i=' +
  399. new Date()
  400. this.option2.requestUrl =
  401. '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
  402. getCookie('userId') +
  403. '&i=' +
  404. new Date()
  405. this.option4.requestUrl =
  406. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
  407. getCookie('userId')
  408. this.option5.requestUrl =
  409. '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
  410. getCookie('userId') +
  411. '&i=' +
  412. new Date()
  413. } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
  414. this.option.requestUrl =
  415. '/api/v1/ams/getSaleOrderInfoes?apiId=408&saler=' +
  416. getCookie('loginName') +
  417. '&i=' +
  418. new Date()
  419. this.option2.requestUrl =
  420. '/api/v1/ams/getSaleOrderReportedes?apiId=408&saler=' +
  421. getCookie('loginName') +
  422. '&i=' +
  423. new Date()
  424. this.option4.requestUrl =
  425. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&saler=' +
  426. getCookie('loginName') +
  427. '&i=' +
  428. new Date()
  429. this.option5.requestUrl =
  430. '/api/v1/ams/getSteelOrderDeletedList?apiId=409&saler=' +
  431. getCookie('loginName')
  432. } else {
  433. this.option.requestUrl =
  434. '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
  435. null +
  436. '&i=' +
  437. new Date()
  438. this.option2.requestUrl =
  439. '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
  440. null +
  441. '&i=' +
  442. new Date()
  443. this.option4.requestUrl =
  444. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
  445. null +
  446. '&i=' +
  447. new Date()
  448. this.option5.requestUrl =
  449. '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
  450. null +
  451. '&i=' +
  452. new Date()
  453. }
  454. let loadTime1 = new Date(
  455. new Date(new Date().toLocaleDateString()).getTime() +
  456. (3600 * 1000 * 8 - 1)
  457. ) // 当天8点前
  458. let loadTime2 = new Date(
  459. new Date(new Date().toLocaleDateString()).getTime() +
  460. (3600 * 1000 * 32 - 1)
  461. ) // 次天8点前
  462. if (new Date().getTime() - loadTime1 > 0) {
  463. this.saleDateOfReceipt = loadTime2
  464. } else {
  465. this.saleDateOfReceipt = loadTime1
  466. }
  467. },
  468. mounted() {
  469. console.log('我在mouted被执行了')
  470. },
  471. activated() {
  472. console.log('我在activated被执行了')
  473. if (getCookie('orgCode') == 'shouhuokehu') {
  474. this.option.requestUrl =
  475. '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
  476. getCookie('userId') +
  477. '&i=' +
  478. new Date()
  479. this.option2.requestUrl =
  480. '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
  481. getCookie('userId') +
  482. '&i=' +
  483. new Date()
  484. } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
  485. this.option.requestUrl =
  486. '/api/v1/ams/getSaleOrderInfoes?apiId=408&saler=' +
  487. getCookie('loginName') +
  488. '&i=' +
  489. new Date()
  490. this.option2.requestUrl =
  491. '/api/v1/ams/getSaleOrderReportedes?apiId=408&saler=' +
  492. getCookie('loginName') +
  493. '&i=' +
  494. new Date()
  495. } else {
  496. this.option.requestUrl =
  497. '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
  498. null +
  499. '&i=' +
  500. new Date()
  501. this.option2.requestUrl =
  502. '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
  503. null +
  504. '&i=' +
  505. new Date()
  506. }
  507. let loadTime1 = new Date(
  508. new Date(new Date().toLocaleDateString()).getTime() +
  509. (3600 * 1000 * 8 - 1)
  510. ) // 当天8点前
  511. let loadTime2 = new Date(
  512. new Date(new Date().toLocaleDateString()).getTime() +
  513. (3600 * 1000 * 32 - 1)
  514. ) // 次天8点前
  515. if (new Date().getTime() - loadTime1 > 0) {
  516. this.saleDateOfReceipt = loadTime2
  517. } else {
  518. this.saleDateOfReceipt = loadTime1
  519. }
  520. },
  521. methods: {
  522. //获取收款客户名称
  523. getRmsReceivingCompany() {
  524. this.axios.post('/api/v1/rmsReceivingCompany/name').then(res => {
  525. this.receivingCompany = res.data
  526. // console.log(res.data)
  527. })
  528. },
  529. //导入Excel格式
  530. //导入excel
  531. importExcel(file) {
  532. let that = this
  533. if (!file) {
  534. that.$message({
  535. message: '文件错误!',
  536. type: 'warning'
  537. })
  538. return
  539. }
  540. this.tableData = []
  541. var reader = new FileReader()
  542. var data = null
  543. var workbook = null
  544. //设置读取操作
  545. reader.onload = function(e) {
  546. data = e.target.result
  547. workbook = XLSX.read(data, {
  548. type: 'binary'
  549. })
  550. let rows = XLSX.utils.sheet_to_json(
  551. workbook.Sheets[workbook.SheetNames[0]]
  552. ) //只取第一页
  553. let uuid = Math.floor(Math.random() * 60 * 24)
  554. Array.from(rows).forEach((e, index) => {
  555. let map = {}
  556. try {
  557. Object.keys(e).forEach(e1 => {
  558. if (e1.includes('销售订单编号')) {
  559. map.saleOrderNo = e[e1]
  560. }
  561. if (e1.includes('物资名称')) {
  562. map.materialName = e[e1]
  563. if (
  564. e[e1].includes('盘螺') ||
  565. e[e1].includes('乱尺') ||
  566. e[e1].includes('盘元') ||
  567. e[e1].includes('盘圆')
  568. ) {
  569. map.isPoundSale = 0
  570. } else {
  571. map.isPoundSale = 1
  572. }
  573. //确定更改的物资有无米数
  574. if (e[e1].includes('米')) {
  575. map.steelMeters = Number(e[e1].replace(/[^0.0-9.0]/gi, ''))
  576. } else {
  577. map.steelMeters = null
  578. }
  579. }
  580. if (e1.includes('规格型号')) {
  581. // console.log(e[e1])
  582. let str = e[e1]
  583. let regex = /\((.+?)\)/g
  584. if (str.match(regex) != null) {
  585. let spa = str.replace(str.match(regex)[0], '')
  586. let model = str
  587. .match(regex)[0]
  588. .replace('(', '')
  589. .replace(')', '')
  590. map.materialModel = model
  591. if ((spa + '').includes('Φ')) {
  592. map.materialSpecification = spa
  593. } else {
  594. map.materialSpecification = 'Φ' + spa
  595. }
  596. } else {
  597. map.materialSpecification = e[e1]
  598. map.model = null
  599. }
  600. }
  601. if (e1.includes('下单客户')) {
  602. map.receiveName = e[e1]
  603. }
  604. if (
  605. e1.includes('米数') &&
  606. (map.steelMeters == null || map.steelMeters != '')
  607. ) {
  608. map.steelMeters = e[e1]
  609. }
  610. if (e1.includes('物资规格') && !e1.includes('规格型号')) {
  611. if ((e[e1] + '').includes('Φ')) {
  612. map.materialSpecification = e[e1]
  613. } else {
  614. map.materialSpecification = 'Φ' + e[e1]
  615. }
  616. }
  617. if (e1.includes('物资型号') && !e1.includes('规格型号')) {
  618. map.materialModel = e[e1]
  619. }
  620. if (e1.includes('物资件数')) {
  621. if (isNumber(e[e1])) {
  622. map.materialNumber = e[e1]
  623. } else {
  624. throw new Error(
  625. `该Excel第--${index +
  626. 2}--行-“物资件数”错误,请核实后再输入(件数输入整数)`
  627. )
  628. }
  629. }
  630. if (e1.includes('车序号')) {
  631. if (typeof e[e1] != 'undefined' && isNumber(e[e1])) {
  632. map.truckNo = e[e1]
  633. } else {
  634. throw new Error(
  635. `该Excel第--${index +
  636. 2}--行-“车序号”错误,请核实后再输入(车序号输入正整数)`
  637. )
  638. }
  639. }
  640. if (e1.includes('收款公司')) {
  641. if (that.receivingCompany.indexOf(e[e1]) === -1) {
  642. throw new Error(
  643. `该Excel第--${index + 2}--行-“收款公司”错误,请核实后再输入`
  644. )
  645. } else {
  646. map.saleOrderReceiveCustomer = e[e1]
  647. }
  648. }
  649. if (e1.includes('业务员')) {
  650. map.salerName = e[e1]
  651. }
  652. if (e1.includes('摘要')) {
  653. if (e[e1]) {
  654. let regex = /,定尺范围.*米|,范围定尺.*米/g
  655. // console.log(e[e1])
  656. map.saleRemark = e[e1].replace(/,|,/g, ',').split(regex)[0]
  657. }
  658. console.log(e[e1])
  659. let regex = /钢材.*组/g
  660. if (e[e1].match(regex)) {
  661. map.saleArea = e[e1].match(regex)[0]
  662. }
  663. let regex1 = /范围.*米/g
  664. if (e[e1].match(regex1)) {
  665. map.steelMeters = Number(
  666. e[e1].match(regex1)[0].match(/(\d+(\.\d+)?)/g)
  667. )
  668. }
  669. }
  670. if (e1.includes('省')) {
  671. map.province = e[e1]
  672. }
  673. if (e1.includes('市')) {
  674. map.district = e[e1]
  675. }
  676. if (e1.includes('县/区')) {
  677. map.town = e[e1]
  678. }
  679. if (e1.includes('具体收货地址')) {
  680. map.place = e[e1]
  681. }
  682. if (e1.includes('收货客户电话')) {
  683. map.saleOrderConsigneeTel = e[e1]
  684. }
  685. if (e1.includes('备注')) {
  686. map.truckRemark = e[e1]
  687. }
  688. if (e1.includes('是否自提')) {
  689. if (e[e1] === '是' || e[e1] === '否') {
  690. map.isSelfMention = e[e1]
  691. } else {
  692. map.isSelfMention = '否'
  693. }
  694. }
  695. })
  696. map.shipperName = that.shipperName
  697. if (typeof map.isSelfMention === 'undefined') {
  698. map.isSelfMention = '否'
  699. }
  700. if (typeof map.truckNo === 'undefined') {
  701. map.truckNo = Number(
  702. `${Math.floor(
  703. Math.random() *
  704. Math.random() *
  705. Math.random() *
  706. Math.random() *
  707. Math.random() *
  708. new Date().getTime() *
  709. 10000000
  710. )}${uuid}`
  711. )
  712. }
  713. if (map.saleRemark && map.receiveName && map.materialName) {
  714. that.tableData.push(map)
  715. }
  716. } catch (es) {
  717. that.$message.error(es.message)
  718. }
  719. })
  720. that.addExcelInport()
  721. // that.dialogTableVisible = true;
  722. return
  723. }
  724. reader.readAsBinaryString(file.raw) //以二进制方式读取
  725. },
  726. //自己写一个比较函数排序
  727. // 排序
  728. compare(property) {
  729. return function(a, b) {
  730. var value1 = a[property]
  731. var value2 = b[property]
  732. return value2 - value1
  733. }
  734. },
  735. addExcelInport() {
  736. //加载虚拟
  737. const loading = this.$loading({
  738. lock: true,
  739. text: '正在快马加鞭为您生成销售订单,请稍候',
  740. spinner: 'el-icon-loading',
  741. background: 'rgba(0, 0, 0, 0.7)'
  742. })
  743. //遍历数组,根据摘要和下单客户自动给出销售订单编号
  744. for (let i = 0; i < this.tableData.length; i++) {
  745. if (i === 0) {
  746. this.tableData[i].saleOrderNo = 1
  747. } else {
  748. let sortArr = this.tableData
  749. .filter(e => {
  750. return (
  751. typeof e.saleOrderNo != 'undefined' &&
  752. e.saleOrderNo != 'undefined' &&
  753. isNumber(e.saleOrderNo)
  754. )
  755. })
  756. .map(e => {
  757. if (
  758. typeof e.saleOrderNo != 'undefined' &&
  759. e.saleOrderNo != 'undefined' &&
  760. isNumber(e.saleOrderNo)
  761. ) {
  762. return e.saleOrderNo
  763. }
  764. })
  765. .sort((a, b) => {
  766. return a - b
  767. })
  768. //当大于0的时候,需要遍历整个数组,与之相等的有哪些
  769. for (let j = 0; j < i; j++) {
  770. if (
  771. this.tableData[i].saleRemark === this.tableData[j].saleRemark &&
  772. this.tableData[i].receiveName === this.tableData[j].receiveName &&
  773. this.tableData[i].saleOrderReceiveCustomer ===
  774. this.tableData[j].saleOrderReceiveCustomer
  775. ) {
  776. this.tableData[i].saleOrderNo = this.tableData[j].saleOrderNo
  777. break
  778. } else {
  779. if (j == i - 1) {
  780. this.tableData[i].saleOrderNo = sortArr[sortArr.length - 1] + 1
  781. }
  782. }
  783. }
  784. }
  785. }
  786. // this.tableData = this.tableData.sort(this.compare("saleOrderNo"));
  787. // debugger;
  788. //需要遍历数组,以销售订单编号为分类
  789. const map1 = this.tableData.reduce((result, item) => {
  790. result[item.saleOrderNo] = result[item.saleOrderNo] || []
  791. result[item.saleOrderNo].push(item)
  792. return result
  793. }, {})
  794. // result即为所求
  795. let result = Object.values(map1)
  796. //遍历数组
  797. let saleOrderListMap = []
  798. result.forEach((saleOrderList, index) => {
  799. let map = {}
  800. let arr = []
  801. saleOrderList.forEach(e => {
  802. let mapMaterial = {}
  803. Object.keys(e).forEach(e1 => {
  804. if (this.saleOrderList.includes(e1)) {
  805. map[e1] = e[e1]
  806. }
  807. if (this.saleOrderMapList.includes(e1)) {
  808. mapMaterial[e1] = e[e1]
  809. }
  810. })
  811. mapMaterial.saleDateOfReceipt = sjTime(this.saleDateOfReceipt)
  812. arr.push(mapMaterial)
  813. })
  814. map.shipperId = 1
  815. map.mapList = arr
  816. saleOrderListMap.push(map)
  817. })
  818. this.axios
  819. .post('/api/v1/ams/addSteelSaleOrderList', saleOrderListMap)
  820. .then(res => {
  821. if (res.data.code == '200') {
  822. this.getRequestUrl()
  823. this.tableData = []
  824. loading.close()
  825. this.$message.success('新增销售订单成功!')
  826. } else {
  827. console.log(res.data.data)
  828. this.$message.error(res.data.data)
  829. this.getRequestUrl()
  830. loading.close()
  831. this.tableData = []
  832. }
  833. })
  834. .catch(e => {
  835. loading.close()
  836. this.$message.error('请检查excel格式')
  837. this.tableData = []
  838. })
  839. },
  840. adverseCloseSaleOrder(row) {
  841. console.log(row)
  842. this.$confirm('确定反关闭整条订单吗?', '继续?', {
  843. cancelButtonText: '取消',
  844. confirmButtonText: '确定',
  845. center: true
  846. }).then(() => {
  847. this.axios
  848. .post(
  849. '/api/v1/ams/adverseCloseSaleOrder?saleOrderId=' + row.saleOrderId
  850. )
  851. .then(res => {
  852. if (res.data.code == '200') {
  853. this.$message.success('反关闭成功')
  854. this.getRequestUrl()
  855. } else {
  856. this.$message.error('反关闭失败')
  857. this.getRequestUrl()
  858. }
  859. })
  860. .catch(() => {
  861. this.$message.error('反关闭失败')
  862. })
  863. })
  864. },
  865. updateReportedSaleOrder(scope) {
  866. this.$router.push('/editSaleOrder/' + scope.row.saleOrderId)
  867. },
  868. updateSaleOrderStatusById(scope) {
  869. console.log(scope.row.saleOrderId)
  870. this.$confirm('是否撤销', '警告', {
  871. confirmButtonText: '确定撤销',
  872. cancelButtonText: '取消撤销',
  873. type: 'warning',
  874. center: true
  875. })
  876. .then(() => {
  877. this.axios
  878. .post(
  879. '/api/v1/uc/updateSaleOrderStatusById?saleOrderId=' +
  880. scope.row.saleOrderId
  881. )
  882. .then(res => {
  883. if (res.data.code == '200') {
  884. this.$message.success('撤销成功')
  885. this.activeName = 'first'
  886. this.getRequestUrl()
  887. } else {
  888. this.$message.error('撤销失败')
  889. }
  890. })
  891. .catch(() => {
  892. this.$message.error('撤销失败')
  893. })
  894. })
  895. .catch(() => {
  896. console.log('取消撤销')
  897. })
  898. },
  899. func(res) {
  900. // console.log('func', res)
  901. this.matSum = res.list.reduce(function(prev, item) {
  902. return prev + item.materialNumber
  903. }, 0)
  904. },
  905. func1(res) {
  906. // console.log('func1', res)
  907. this.matSum1 = res.list.reduce(function(prev, item) {
  908. return prev + item.materialNumber
  909. }, 0)
  910. // console.log(this.matSum, 'matsum')
  911. },
  912. func2(res) {
  913. this.matSum2 = res.list.reduce(function(prev, item) {
  914. return prev + item.materialNumber
  915. }, 0)
  916. },
  917. closeSteelOrderAndEas(row) {
  918. this.$prompt('此操作将同步关闭金蝶和物流的销售订单,是否继续?', '提示', {
  919. confirmButtonText: '确定',
  920. cancelButtonText: '取消',
  921. inputPlaceholder: '请输入关闭原因-必填!!!',
  922. center: true,
  923. type: 'warning'
  924. })
  925. .then(({ value }) => {
  926. if (value != null) {
  927. let mapValue = {
  928. number: row.saleNumber,
  929. saleOrderId: row.saleOrderId,
  930. reason: value
  931. }
  932. console.log(mapValue)
  933. this.axios
  934. .post('/api/v1/ams/deleteSaleOrderSame', mapValue)
  935. .then(res => {
  936. if (res.data.code == 200) {
  937. this.$message.success('关闭成功')
  938. this.getRequestUrl()
  939. } else {
  940. this.$message.error('关闭失败,请联系管理员')
  941. }
  942. })
  943. .catch(() => {
  944. this.$message.error('关闭失败,请联系管理员')
  945. this.getRequestUrl()
  946. })
  947. } else {
  948. this.$message.error('请输入理由')
  949. }
  950. })
  951. .catch(() => {
  952. this.$message({
  953. type: 'info',
  954. message: '取消输入'
  955. })
  956. })
  957. },
  958. deleteSaleOrder(row) {
  959. console.log(row)
  960. this.$prompt('此操作将关闭订单且下面的待运输订单,是否继续?', '提示', {
  961. confirmButtonText: '确定',
  962. cancelButtonText: '取消',
  963. inputPlaceholder: '请输入关闭原因-必填!!!',
  964. center: true,
  965. type: 'warning'
  966. })
  967. .then(({ value }) => {
  968. if (value != null) {
  969. let mapValue = {
  970. number: row.saleNumber,
  971. saleOrderId: row.saleOrderId,
  972. reason: value
  973. }
  974. this.axios
  975. .post(
  976. '/api/v1/ams/deleteSaleOrderById?saleOrderId=' + row.saleOrderId
  977. )
  978. .then(res => {
  979. if (res.data.code == 200) {
  980. this.$message.success('关闭成功')
  981. this.getRequestUrl()
  982. }
  983. })
  984. } else {
  985. this.$message.error('请输入理由')
  986. }
  987. })
  988. .catch(() => {
  989. this.$message({
  990. type: 'info',
  991. message: '取消输入'
  992. })
  993. })
  994. },
  995. updateSaleOrder(row) {
  996. console.log(row)
  997. this.$router.push(
  998. 'updateSaleOrderSteel/' + row.saleOrderId + '/' + row.deleted
  999. )
  1000. },
  1001. getOrderDetails(saleOrderId) {
  1002. console.log(saleOrderId)
  1003. this.$router.push('saleOrderOODetails/' + saleOrderId)
  1004. },
  1005. getRequestUrl() {
  1006. if (getCookie('orgCode') == 'shouhuokehu') {
  1007. this.option.requestUrl =
  1008. '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
  1009. getCookie('userId') +
  1010. '&i=' +
  1011. new Date()
  1012. this.option2.requestUrl =
  1013. '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
  1014. getCookie('userId') +
  1015. '&i=' +
  1016. new Date()
  1017. this.option4.requestUrl =
  1018. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
  1019. getCookie('userId') +
  1020. '&i=' +
  1021. new Date()
  1022. this.option5.requestUrl =
  1023. '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
  1024. getCookie('userId') +
  1025. '&i=' +
  1026. new Date()
  1027. } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
  1028. this.option.requestUrl =
  1029. '/api/v1/ams/getSaleOrderInfoes?apiId=408&saler=' +
  1030. getCookie('loginName') +
  1031. '&i=' +
  1032. new Date()
  1033. this.option2.requestUrl =
  1034. '/api/v1/ams/getSaleOrderReportedes?apiId=408&saler=' +
  1035. getCookie('loginName') +
  1036. '&i=' +
  1037. new Date()
  1038. this.option4.requestUrl =
  1039. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&saler=' +
  1040. getCookie('loginName') +
  1041. '&i=' +
  1042. new Date()
  1043. this.option5.requestUrl =
  1044. '/api/v1/ams/getSteelOrderDeletedList?apiId=409&saler=' +
  1045. getCookie('loginName')
  1046. } else {
  1047. this.option.requestUrl =
  1048. '/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=' +
  1049. null +
  1050. '&i=' +
  1051. new Date()
  1052. this.option2.requestUrl =
  1053. '/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=' +
  1054. null +
  1055. '&i=' +
  1056. new Date()
  1057. this.option4.requestUrl =
  1058. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=' +
  1059. null +
  1060. '&i=' +
  1061. new Date()
  1062. this.option5.requestUrl =
  1063. '/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=' +
  1064. null +
  1065. '&i=' +
  1066. new Date()
  1067. }
  1068. },
  1069. batchReport() {
  1070. if (this.batchReportList.length === 0) {
  1071. this.$message.error('请先选择需要批量上传的销售订单')
  1072. return
  1073. }
  1074. let arr = Array.from(
  1075. new Set(
  1076. this.batchReportList.map(e => {
  1077. return e.saleOrderId
  1078. })
  1079. )
  1080. ).map(e => {
  1081. let map = {}
  1082. map.saleOrderId = e
  1083. return map
  1084. })
  1085. console.log(arr)
  1086. const loading = this.$loading({
  1087. lock: true,
  1088. text: '正在努力上传',
  1089. spinner: 'el-icon-loading',
  1090. background: 'rgba(0, 0, 0, 0.7)'
  1091. })
  1092. this.axios
  1093. .post('/api/v1/ams/uploadSaleOrderList', arr)
  1094. .then(res => {
  1095. if (res.data.code == '200') {
  1096. this.$message.success('上传成功')
  1097. this.getRequestUrl()
  1098. loading.close()
  1099. } else {
  1100. this.$message.error('上传失败')
  1101. loading.close()
  1102. }
  1103. })
  1104. .catch(() => {
  1105. this.$message.error('上传失败')
  1106. loading.close()
  1107. })
  1108. },
  1109. selectionChange(selection) {
  1110. console.log(selection)
  1111. this.batchReportList = []
  1112. this.batchReportList = selection
  1113. console.log('firstList:', this.batchReportList)
  1114. },
  1115. selectionChange2(selection) {
  1116. console.log(selection)
  1117. this.secondList = []
  1118. this.secondList = selection
  1119. console.log('secondList:', this.secondList)
  1120. },
  1121. refresh() {
  1122. this.getRequestUrl()
  1123. },
  1124. handleClick(tab, event) {
  1125. console.log(tab, event)
  1126. },
  1127. onclick() {
  1128. var startTime = null
  1129. var endTime = null
  1130. if (this.startTime && this.endTime) {
  1131. startTime = sjTime(this.startTime)
  1132. endTime = sjTime(this.endTime)
  1133. }
  1134. if (getCookie('orgCode') == 'shouhuokehu') {
  1135. if (this.activeName == 'first') {
  1136. this.option.requestUrl =
  1137. '/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=' +
  1138. this.input +
  1139. '&consigneeSsoId=' +
  1140. getCookie('userId') +
  1141. '&startTime=' +
  1142. startTime +
  1143. '&endTime=' +
  1144. endTime +
  1145. '&i=' +
  1146. new Date()
  1147. } else if (this.activeName == 'second') {
  1148. this.option2.requestUrl =
  1149. '/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=' +
  1150. this.input +
  1151. '&consigneeSsoId=' +
  1152. getCookie('userId') +
  1153. '&startTime=' +
  1154. startTime +
  1155. '&endTime=' +
  1156. endTime +
  1157. '&i=' +
  1158. new Date()
  1159. } else if (this.activeName == 'four') {
  1160. this.option4.requestUrl =
  1161. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=' +
  1162. this.input +
  1163. '&consigneeSsoId=' +
  1164. getCookie('userId') +
  1165. '&startTime=' +
  1166. startTime +
  1167. '&endTime=' +
  1168. endTime +
  1169. '&i=' +
  1170. new Date()
  1171. }
  1172. } else if (getCookie('orgCode') == 'xiaoshouyewuyuan') {
  1173. if (this.activeName == 'first') {
  1174. this.option.requestUrl =
  1175. '/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=' +
  1176. this.input +
  1177. '&startTime=' +
  1178. startTime +
  1179. '&endTime=' +
  1180. endTime +
  1181. '&i=' +
  1182. new Date() +
  1183. 'saler=' +
  1184. getCookie('loginName')
  1185. } else if (this.activeName == 'second') {
  1186. this.option2.requestUrl =
  1187. '/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=' +
  1188. this.input +
  1189. '&startTime=' +
  1190. startTime +
  1191. '&endTime=' +
  1192. endTime +
  1193. '&i=' +
  1194. new Date() +
  1195. 'saler=' +
  1196. getCookie('loginName')
  1197. } else if (this.activeName == 'four') {
  1198. this.option4.requestUrl =
  1199. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=' +
  1200. this.input +
  1201. '&startTime=' +
  1202. startTime +
  1203. '&endTime=' +
  1204. endTime +
  1205. '&i=' +
  1206. new Date() +
  1207. 'saler=' +
  1208. getCookie('loginName')
  1209. }
  1210. } else {
  1211. if (this.activeName == 'first') {
  1212. this.option.requestUrl =
  1213. '/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=' +
  1214. this.input +
  1215. '&startTime=' +
  1216. startTime +
  1217. '&endTime=' +
  1218. endTime +
  1219. '&i=' +
  1220. new Date()
  1221. } else if (this.activeName == 'second') {
  1222. this.option2.requestUrl =
  1223. '/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=' +
  1224. this.input +
  1225. '&startTime=' +
  1226. startTime +
  1227. '&endTime=' +
  1228. endTime +
  1229. '&i=' +
  1230. new Date()
  1231. } else if (this.activeName == 'four') {
  1232. this.option4.requestUrl =
  1233. '/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=' +
  1234. this.input +
  1235. '&startTime=' +
  1236. startTime +
  1237. '&endTime=' +
  1238. endTime +
  1239. '&i=' +
  1240. new Date()
  1241. }
  1242. }
  1243. },
  1244. handleClose() {},
  1245. seeclick(saleOrderId) {
  1246. this.$router.push('/saleOrderDetail/' + saleOrderId)
  1247. },
  1248. btnclick() {
  1249. this.$router.push('/addSaleOrder')
  1250. },
  1251. click(saleOrderId) {
  1252. this.$router.push('/editSaleOrder/' + saleOrderId)
  1253. },
  1254. copyClick(saleOrderId) {
  1255. this.$router.push('/copySteelOrder/' + saleOrderId)
  1256. },
  1257. // 上传
  1258. uploadclick(saleOrderId) {
  1259. this.$confirm('是否上传', '提示', {
  1260. confirmButtonText: '确定',
  1261. cancelButtonText: '取消',
  1262. type: 'warning',
  1263. center: true
  1264. })
  1265. .then(() => {
  1266. const loading = this.$loading({
  1267. lock: true,
  1268. text: '正在努力上传',
  1269. spinner: 'el-icon-loading',
  1270. background: 'rgba(0, 0, 0, 0.7)'
  1271. })
  1272. this.axios
  1273. .post('/api/v1/ams/uploadSaleOrder?saleOrderId=' + saleOrderId)
  1274. .then(res => {
  1275. if (res.data.code == '200') {
  1276. this.$message.success('上传成功!')
  1277. this.getRequestUrl()
  1278. loading.close()
  1279. } else {
  1280. this.$message.success('上传失败!')
  1281. this.getRequestUrl()
  1282. loading.close()
  1283. }
  1284. })
  1285. .catch(() => {
  1286. loading.close()
  1287. })
  1288. })
  1289. .catch(() => {
  1290. this.$message({
  1291. type: 'info',
  1292. message: '取消上传!'
  1293. })
  1294. })
  1295. },
  1296. //删除
  1297. deleteclick(scope) {
  1298. this.$confirm('是否删除', '提示', {
  1299. confirmButtonText: '确定',
  1300. cancelButtonText: '取消',
  1301. type: 'warning',
  1302. center: true
  1303. })
  1304. .then(() => {
  1305. let rows = []
  1306. rows.push(scope)
  1307. this.batchDelete(rows)
  1308. })
  1309. .catch(() => {
  1310. this.$message({
  1311. type: 'info',
  1312. message: '取消删除!'
  1313. })
  1314. })
  1315. },
  1316. batchDeleteFirst() {
  1317. let rows = this.batchReportList
  1318. console.log('rows:', rows)
  1319. if (!rows || rows.length <= 0) {
  1320. this.$message.warning('请选中订单!')
  1321. return
  1322. }
  1323. this.$confirm('是否删除', '提示', {
  1324. confirmButtonText: '确定',
  1325. cancelButtonText: '取消',
  1326. type: 'warning',
  1327. center: true
  1328. })
  1329. .then(() => {
  1330. this.batchDelete(rows)
  1331. })
  1332. .catch(() => {
  1333. this.$message({
  1334. type: 'info',
  1335. message: '取消删除!'
  1336. })
  1337. })
  1338. },
  1339. batchDeleteSecond() {
  1340. let rows = this.secondList
  1341. console.log('rows:', rows)
  1342. if (!rows || rows.length <= 0) {
  1343. this.$message.warning('请选中订单!')
  1344. return
  1345. }
  1346. this.$confirm('是否删除', '提示', {
  1347. confirmButtonText: '确定',
  1348. cancelButtonText: '取消',
  1349. type: 'warning',
  1350. center: true
  1351. })
  1352. .then(() => {
  1353. this.batchDelete(rows)
  1354. })
  1355. .catch(() => {
  1356. this.$message({
  1357. type: 'info',
  1358. message: '取消删除!'
  1359. })
  1360. })
  1361. },
  1362. batchDelete(rows) {
  1363. this.axios
  1364. .post('/api/v1/ams/deleteAmsSaleOrderBySaleOrderId', rows)
  1365. .then(res => {
  1366. if (res.data.code == '200') {
  1367. this.$message.success('删除成功')
  1368. this.getRequestUrl()
  1369. } else {
  1370. this.$message.success('删除失败')
  1371. this.getRequestUrl()
  1372. }
  1373. })
  1374. }
  1375. }
  1376. }
  1377. </script>
  1378. <style lang="scss" scoped>
  1379. .salePlan {
  1380. .top {
  1381. margin-left: 20px;
  1382. margin-top: 20px;
  1383. }
  1384. .table {
  1385. margin-left: 20px;
  1386. margin-top: 20px;
  1387. }
  1388. .btn {
  1389. display: flex;
  1390. justify-content: center;
  1391. align-items: center;
  1392. }
  1393. }
  1394. </style>