saleOrderSteel.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. <template>
  2. <!-- 销售订单页面 -->
  3. <div class="salePlan">
  4. <div class="top">
  5. <el-form :inline="true">
  6. <el-form-item>
  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 type="primary" @click="btnclick(0)">
  37. <i class="el-icon-plus"></i>新增
  38. </el-button>
  39. <el-button type="primary" @click="refresh">
  40. <i class="el-icon-refresh"></i>
  41. </el-button>
  42. <el-button type="primary" @click="batchReport">
  43. <i class="upload2"></i>批量上传
  44. </el-button>
  45. <el-button
  46. type="primary"
  47. @click="exportData()"
  48. v-if="activeName == 'first'"
  49. ><i class="el-icon-download"></i>导出Excel</el-button
  50. >
  51. <el-form-item v-if="activeName == 'first'">
  52. <el-upload
  53. class="upload-excel"
  54. action=""
  55. :on-change="importExcel"
  56. :show-file-list="false"
  57. accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
  58. :auto-upload="false"
  59. >
  60. <el-button type="primary" icon="el-icon-upload"
  61. >导入Excel</el-button
  62. >
  63. </el-upload>
  64. </el-form-item>
  65. <el-button disabled>物资总件数</el-button>
  66. <el-input
  67. placeholder=""
  68. v-model="matSum"
  69. clearable
  70. style="width:100px"
  71. disabled
  72. >
  73. </el-input>
  74. </el-form-item>
  75. </el-form>
  76. </div>
  77. <div class="table">
  78. <el-tabs v-model="activeName" @tab-click="handleClick">
  79. <!-- 未上报 -->
  80. <el-tab-pane label="未上报" name="first">
  81. <mergeRowTable
  82. v-bind.sync="option"
  83. ref="excelDom"
  84. @selection-change="selectionChange"
  85. :pageSize="200"
  86. @func="func"
  87. >
  88. <el-table-column
  89. fixed="right"
  90. label="操作"
  91. align="center"
  92. width="200"
  93. >
  94. <template slot-scope="scope">
  95. <el-button
  96. @click="uploadclick(scope.row.saleOrderId)"
  97. type="text"
  98. size="small"
  99. >上传</el-button
  100. >
  101. <el-button
  102. @click="click(scope.row.saleOrderId)"
  103. type="text"
  104. size="small"
  105. >修改</el-button
  106. >
  107. <el-button
  108. type="text"
  109. size="small"
  110. @click="deleteclick(scope.row.saleOrderId)"
  111. >删除</el-button
  112. >
  113. <el-button
  114. type="text"
  115. size="small"
  116. @click="copyClick(scope.row.saleOrderId)"
  117. >复制</el-button
  118. >
  119. </template>
  120. </el-table-column>
  121. </mergeRowTable>
  122. </el-tab-pane>
  123. <!-- 已审批 -->
  124. <el-tab-pane label="已审批" name="four">
  125. <mergeRowTable
  126. v-bind.sync="option4"
  127. ref="table"
  128. :pageSize="200"
  129. @func="func1"
  130. >
  131. <el-table-column
  132. fixed="right"
  133. label="操作"
  134. align="center"
  135. width="280"
  136. >
  137. <template slot-scope="scope">
  138. <el-button
  139. @click="getOrderDetails(scope.row.saleOrderId)"
  140. type="text"
  141. size="small"
  142. >运单</el-button
  143. >
  144. <el-button
  145. @click="deleteSaleOrder(scope.row)"
  146. type="text"
  147. size="small"
  148. >关闭订单</el-button
  149. >
  150. <el-button
  151. @click="adverseCloseSaleOrder(scope.row)"
  152. type="text"
  153. size="small"
  154. >反关闭订单</el-button
  155. >
  156. <el-button
  157. @click="updateSaleOrder(scope.row)"
  158. type="text"
  159. size="small"
  160. >异常处理</el-button
  161. >
  162. <el-button
  163. type="text"
  164. size="small"
  165. @click="copyClick(scope.row.saleOrderId)"
  166. >复制</el-button
  167. >
  168. </template>
  169. </el-table-column>
  170. </mergeRowTable>
  171. </el-tab-pane>
  172. <el-tab-pane label="反审批" name="five">
  173. <mergeRowTable
  174. v-bind.sync="option5"
  175. ref="table2"
  176. :pageSize="200"
  177. @func="func3"
  178. >
  179. <el-table-column
  180. fixed="right"
  181. label="操作"
  182. align="center"
  183. width="200"
  184. >
  185. <template slot-scope="scope">
  186. <el-button
  187. @click="updateSaleOrder(scope.row)"
  188. type="text"
  189. size="small"
  190. >异常处理</el-button
  191. >
  192. </template>
  193. </el-table-column></mergeRowTable
  194. >
  195. </el-tab-pane>
  196. <!-- 已上报 -->
  197. <el-tab-pane label="已上报" name="second">
  198. <mergeRowTable
  199. v-bind.sync="option2"
  200. ref="table2"
  201. :pageSize="200"
  202. @func="func2"
  203. >
  204. <el-table-column
  205. fixed="right"
  206. label="操作"
  207. align="center"
  208. width="200"
  209. >
  210. <template slot-scope="scope">
  211. <el-button
  212. @click="closeSteelOrderAndEas(scope.row)"
  213. type="text"
  214. size="small"
  215. >关闭订单</el-button
  216. >
  217. <el-button
  218. @click="updateReportedSaleOrder(scope)"
  219. type="text"
  220. size="small"
  221. >修改</el-button
  222. >
  223. </template>
  224. </el-table-column>
  225. </mergeRowTable>
  226. </el-tab-pane>
  227. </el-tabs>
  228. </div>
  229. <div>
  230. <el-dialog
  231. title="销售订单预览"
  232. :visible.sync="dialogTableVisible"
  233. :center="true"
  234. width="100%"
  235. >
  236. <ExcelSaleOrder :tableData="tableData"></ExcelSaleOrder>
  237. <div class="btn">
  238. <el-button
  239. type="primary"
  240. @click="addExcelInport"
  241. @keyup.native.enter="addExcelInport"
  242. >确认</el-button
  243. >
  244. <el-button type="primary" @click="cancelExcelInport">取消</el-button>
  245. </div>
  246. </el-dialog>
  247. </div>
  248. </div>
  249. </template>
  250. <script>
  251. import { getCookie } from "@/utils/util.js";
  252. import { sjTime } from "@/utils/sharedJsFile";
  253. import { isNumber } from "../../../ADMINISTRATORS/app";
  254. import ExcelSaleOrder from "../saleContract/importExcelSaleOrder.vue";
  255. export default {
  256. name: "saleOrder",
  257. components: {
  258. ExcelSaleOrder
  259. },
  260. data() {
  261. return {
  262. dialogTableVisible: false,
  263. startTime: null,
  264. endTime: null,
  265. batchReportList: [],
  266. activeName: "first",
  267. tableTitle: "未上传销售订单报表",
  268. drawer: false,
  269. input: "",
  270. index: "",
  271. carrierId: null,
  272. carrierName: null,
  273. shipperName: "四川省达州钢铁集团有限责任公司",
  274. shipperId: 1,
  275. receivingCompany: [
  276. "四川省达州钢铁集团有限责任公司",
  277. "四川达钢商贸有限公司"
  278. ],
  279. option: {
  280. // 表格请求数据的地址
  281. requestUrl: "",
  282. selectionType: "select",
  283. comparison: "saleNumber",
  284. columnIndexs: [0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17]
  285. },
  286. option2: {
  287. // 表格请求数据的地址
  288. requestUrl: "",
  289. comparison: "saleNumber",
  290. columnIndexs: [0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15, 16]
  291. },
  292. option4: {
  293. // 表格请求数据的地址
  294. requestUrl: "",
  295. comparison: "saleNumber",
  296. columnIndexs: [
  297. 0,
  298. 1,
  299. 2,
  300. 3,
  301. 8,
  302. 9,
  303. 10,
  304. 11,
  305. 12,
  306. 13,
  307. 14,
  308. 15,
  309. 16,
  310. 17,
  311. 18,
  312. 20,
  313. 21,
  314. 22
  315. ]
  316. },
  317. option5: {
  318. // 表格请求数据的地址
  319. requestUrl: "",
  320. comparison: "saleNumber",
  321. columnIndexs: [
  322. 0,
  323. 1,
  324. 2,
  325. 3,
  326. 7,
  327. 8,
  328. 9,
  329. 10,
  330. 11,
  331. 12,
  332. 13,
  333. 14,
  334. 15,
  335. 16,
  336. 17,
  337. 18,
  338. 20,
  339. 21
  340. ]
  341. },
  342. mapList: [],
  343. mapItemList: [],
  344. matSum: null,
  345. tableData: [],
  346. saleDateOfReceipt: null,
  347. //销售订单主表数据
  348. saleOrderList: [
  349. "receiveName",
  350. "isSelfMention",
  351. "saleRemark",
  352. "saleOrderReceiveCustomer",
  353. "salerName"
  354. ],
  355. saleOrderMapList: [
  356. "truckNo",
  357. "province",
  358. "district",
  359. "town",
  360. "truckRemark",
  361. "place",
  362. "saleOrderConsigneeTel",
  363. "saleDateOfReceipt",
  364. "materialName",
  365. "materialSpecification",
  366. "materialModel",
  367. "materialNumber",
  368. "steelMeters",
  369. "isPoundSale"
  370. ]
  371. };
  372. },
  373. created() {
  374. if (getCookie("orgCode") == "shouhuokehu") {
  375. this.option.requestUrl =
  376. "/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=" +
  377. getCookie("userId") +
  378. "&i=" +
  379. new Date();
  380. this.option2.requestUrl =
  381. "/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=" +
  382. getCookie("userId") +
  383. "&i=" +
  384. new Date();
  385. this.option4.requestUrl =
  386. "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=" +
  387. getCookie("userId");
  388. this.option5.requestUrl =
  389. "/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=" +
  390. getCookie("userId") +
  391. "&i=" +
  392. new Date();
  393. } else if (getCookie("orgCode") == "xiaoshouyewuyuan") {
  394. this.option.requestUrl =
  395. "/api/v1/ams/getSaleOrderInfoes?apiId=408&saler=" +
  396. getCookie("loginName") +
  397. "&i=" +
  398. new Date();
  399. this.option2.requestUrl =
  400. "/api/v1/ams/getSaleOrderReportedes?apiId=408&saler=" +
  401. getCookie("loginName") +
  402. "&i=" +
  403. new Date();
  404. this.option4.requestUrl =
  405. "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&saler=" +
  406. getCookie("loginName") +
  407. "&i=" +
  408. new Date();
  409. this.option5.requestUrl =
  410. "/api/v1/ams/getSteelOrderDeletedList?apiId=409&saler=" +
  411. getCookie("loginName");
  412. } else {
  413. this.option.requestUrl =
  414. "/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=" +
  415. null +
  416. "&i=" +
  417. new Date();
  418. this.option2.requestUrl =
  419. "/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=" +
  420. null +
  421. "&i=" +
  422. new Date();
  423. this.option4.requestUrl =
  424. "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=" +
  425. null +
  426. "&i=" +
  427. new Date();
  428. this.option5.requestUrl =
  429. "/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=" +
  430. null +
  431. "&i=" +
  432. new Date();
  433. }
  434. let loadTime1 = new Date(
  435. new Date(new Date().toLocaleDateString()).getTime() +
  436. (3600 * 1000 * 8 - 1)
  437. ); // 当天8点前
  438. let loadTime2 = new Date(
  439. new Date(new Date().toLocaleDateString()).getTime() +
  440. (3600 * 1000 * 32 - 1)
  441. ); // 次天8点前
  442. if (new Date().getTime() - loadTime1 > 0) {
  443. this.saleDateOfReceipt = loadTime2;
  444. } else {
  445. this.saleDateOfReceipt = loadTime1;
  446. }
  447. // document.addEventListener("keydown", e => {
  448. // let key = window.event.keyCode;
  449. // if (key == 13) {
  450. // // 13是enter键的键盘码 如果等于13 就调用click的登录方法
  451. // this.addExcelInport();
  452. // }
  453. // });
  454. },
  455. // beforeDestroy() {
  456. // //这里的 this.login('loginForm') 指的是键盘事件的方法名
  457. // document.removeEventListener("keydown", this.addExcelInport());
  458. // },
  459. methods: {
  460. //导入Excel格式
  461. //导入excel
  462. importExcel(file) {
  463. let that = this;
  464. if (!file) {
  465. that.$message({
  466. message: "文件错误!",
  467. type: "warning"
  468. });
  469. return;
  470. }
  471. this.tableData = [];
  472. var reader = new FileReader();
  473. var data = null;
  474. var workbook = null;
  475. //设置读取操作
  476. reader.onload = function(e) {
  477. console.log(e);
  478. data = e.target.result;
  479. workbook = XLSX.read(data, {
  480. type: "binary"
  481. });
  482. let rows = XLSX.utils.sheet_to_json(
  483. workbook.Sheets[workbook.SheetNames[0]]
  484. ); //只取第一页
  485. console.log("rows", rows);
  486. Array.from(rows).forEach((e, index) => {
  487. let map = {};
  488. try {
  489. Object.keys(e).forEach(e1 => {
  490. if (e1.includes("物资名称")) {
  491. map.materialName = e[e1];
  492. }
  493. if (e1.includes("下单客户")) {
  494. map.receiveName = e[e1];
  495. }
  496. if (e1.includes("米数")) {
  497. map.steelMeters = e[e1];
  498. }
  499. if (e1.includes("物资规格")) {
  500. if (e[e1].includes("Φ")) {
  501. map.materialSpecification = e[e1];
  502. } else {
  503. map.materialSpecification = "Φ" + e[e1];
  504. }
  505. }
  506. if (e1.includes("物资型号")) {
  507. map.materialModel = e[e1];
  508. }
  509. if (e1.includes("物资件数")) {
  510. if (isNumber(e[e1])) {
  511. map.materialNumber = e[e1];
  512. } else {
  513. throw new Error(
  514. `该Excel第--${index +
  515. 2}--行-“物资件数”错误,请核实后再输入(件数输入整数)`
  516. );
  517. }
  518. }
  519. if (e1.includes("车序号")) {
  520. if (isNumber(e[e1])) {
  521. map.truckNo = e[e1];
  522. } else {
  523. throw new Error(
  524. `该Excel第--${index +
  525. 2}--行-“车序号”错误,请核实后再输入(车序号输入正整数)`
  526. );
  527. }
  528. }
  529. if (e1.includes("收款公司")) {
  530. if (that.receivingCompany.indexOf(e[e1]) === -1) {
  531. throw new Error(
  532. `该Excel第--${index + 2}--行-“收款公司”错误,请核实后再输入`
  533. );
  534. } else {
  535. map.saleOrderReceiveCustomer = e[e1];
  536. }
  537. }
  538. if (e1.includes("业务员")) {
  539. map.salerName = e[e1];
  540. }
  541. if (e1.includes("摘要")) {
  542. map.saleRemark = e[e1];
  543. }
  544. if (e1.includes("省")) {
  545. map.province = e[e1];
  546. }
  547. if (e1.includes("市")) {
  548. map.district = e[e1];
  549. }
  550. if (e1.includes("县/区")) {
  551. map.town = e[e1];
  552. }
  553. if (e1.includes("具体收货地址")) {
  554. map.place = e[e1];
  555. }
  556. if (e1.includes("收货客户电话")) {
  557. map.saleOrderConsigneeTel = e[e1];
  558. }
  559. if (e1.includes("备注")) {
  560. map.truckRemark = e[e1];
  561. }
  562. if (e1.includes("是否磅重交货")) {
  563. if (e[e1] == "是") {
  564. map.isPoundSale = 1;
  565. } else if (e[e1] == "否") {
  566. map.isPoundSale = 0;
  567. } else {
  568. throw new Error(
  569. `该Excel第--${index +
  570. 2}--行-“是否磅重交货”-错误,请核实后再输入`
  571. );
  572. }
  573. }
  574. if (e1.includes("是否自提")) {
  575. if (e[e1] === "是" || e[e1] === "否") {
  576. map.isSelfMention = e[e1];
  577. } else {
  578. throw new Error(
  579. `该Excel第--${index + 2}--行-“是否自提”-错误,请核实后再输入`
  580. );
  581. }
  582. }
  583. });
  584. map.shipperName = that.shipperName;
  585. that.tableData.push(map);
  586. } catch (e) {
  587. that.$message.error(e.message);
  588. }
  589. });
  590. that.dialogTableVisible = true;
  591. return;
  592. };
  593. reader.readAsBinaryString(file.raw); //以二进制方式读取
  594. },
  595. addExcelInport() {
  596. this.$confirm("以上均核对正确,确定导入Excel", "提示", {
  597. cancelButtonText: "取消",
  598. confirmButtonText: "确认",
  599. center: true
  600. })
  601. .then(() => {
  602. let map = {};
  603. let arr = [];
  604. this.tableData.forEach(e => {
  605. let mapMaterial = {};
  606. Object.keys(e).forEach(e1 => {
  607. if (this.saleOrderList.includes(e1)) {
  608. map[e1] = e[e1];
  609. }
  610. if (this.saleOrderMapList.includes(e1)) {
  611. mapMaterial[e1] = e[e1];
  612. }
  613. });
  614. mapMaterial.saleDateOfReceipt = sjTime(this.saleDateOfReceipt);
  615. arr.push(mapMaterial);
  616. });
  617. map.shipperId = 1;
  618. map.mapList = arr;
  619. console.log(map);
  620. this.axios
  621. .post("/api/v1/ams/addSteelSaleOrder", map)
  622. .then(res => {
  623. if (res.data.code == "200") {
  624. this.$message.success("新增销售订单成功!");
  625. this.getRequestUrl();
  626. this.dialogTableVisible = false;
  627. } else {
  628. this.$message.error(res.data.data);
  629. this.getRequestUrl();
  630. this.dialogTableVisible = false;
  631. }
  632. })
  633. .catch(e => {
  634. this.$message.error("生成错误!");
  635. this.dialogTableVisible = false;
  636. });
  637. })
  638. .catch(() => {
  639. this.$message.info("取消导入");
  640. });
  641. },
  642. cancelExcelInport() {
  643. this.dialogTableVisible = false;
  644. },
  645. adverseCloseSaleOrder(row) {
  646. console.log(row);
  647. this.$confirm("确定反关闭整条订单吗?", "继续?", {
  648. cancelButtonText: "取消",
  649. confirmButtonText: "确定",
  650. center: true
  651. }).then(() => {
  652. this.axios
  653. .post(
  654. "/api/v1/ams/adverseCloseSaleOrder?saleOrderId=" + row.saleOrderId
  655. )
  656. .then(res => {
  657. if (res.data.code == "200") {
  658. this.$message.success("反关闭成功");
  659. this.getRequestUrl();
  660. } else {
  661. this.$message.error("反关闭失败");
  662. this.getRequestUrl();
  663. }
  664. })
  665. .catch(() => {
  666. this.$message.error("反关闭失败");
  667. });
  668. });
  669. },
  670. updateReportedSaleOrder(scope) {
  671. this.$router.push("/editSaleOrder/" + scope.row.saleOrderId);
  672. },
  673. updateSaleOrderStatusById(scope) {
  674. console.log(scope.row.saleOrderId);
  675. this.$confirm("是否撤销", "警告", {
  676. confirmButtonText: "确定撤销",
  677. cancelButtonText: "取消撤销",
  678. type: "warning",
  679. center: true
  680. })
  681. .then(() => {
  682. this.axios
  683. .post(
  684. "/api/v1/uc/updateSaleOrderStatusById?saleOrderId=" +
  685. scope.row.saleOrderId
  686. )
  687. .then(res => {
  688. if (res.data.code == "200") {
  689. this.$message.success("撤销成功");
  690. this.activeName = "first";
  691. this.getRequestUrl();
  692. } else {
  693. this.$message.error("撤销失败");
  694. }
  695. })
  696. .catch(() => {
  697. this.$message.error("撤销失败");
  698. });
  699. })
  700. .catch(() => {
  701. console.log("取消撤销");
  702. });
  703. },
  704. func(res) {
  705. this.matSum = res.list.reduce(function(prev, item) {
  706. return prev + item.materialNumber;
  707. }, 0);
  708. },
  709. func1(res) {
  710. this.matSum = res.list.reduce(function(prev, item) {
  711. return prev + item.materialNumber;
  712. }, 0);
  713. },
  714. func2(res) {
  715. this.matSum = res.list.reduce(function(prev, item) {
  716. return prev + item.materialNumber;
  717. }, 0);
  718. },
  719. func3(res) {
  720. this.matSum = res.list.reduce(function(prev, item) {
  721. return prev + item.materialNumber;
  722. }, 0);
  723. },
  724. closeSteelOrderAndEas(row) {
  725. this.$prompt("此操作将同步关闭金蝶和物流的销售订单,是否继续?", "提示", {
  726. confirmButtonText: "确定",
  727. cancelButtonText: "取消",
  728. inputPlaceholder: "请输入关闭原因-必填!!!",
  729. center: true,
  730. type: "warning"
  731. })
  732. .then(({ value }) => {
  733. if (value != null) {
  734. let mapValue = {
  735. number: row.saleNumber,
  736. saleOrderId: row.saleOrderId,
  737. reason: value
  738. };
  739. this.axios
  740. .post("/api/v1/ams/deleteSaleOrderById", mapValue)
  741. .then(res => {
  742. if (res.data.code == 200) {
  743. this.$message.success("关闭成功");
  744. this.getRequestUrl();
  745. } else {
  746. this.$message.error("关闭失败,请联系管理员");
  747. }
  748. })
  749. .catch(() => {
  750. this.$message.error("关闭失败,请联系管理员");
  751. this.getRequestUrl();
  752. });
  753. } else {
  754. this.$message.error("请输入理由");
  755. }
  756. })
  757. .catch(() => {
  758. this.$message({
  759. type: "info",
  760. message: "取消输入"
  761. });
  762. });
  763. },
  764. deleteSaleOrder(row) {
  765. this.$prompt("此操作将关闭订单且下面的待运输订单,是否继续?", "提示", {
  766. confirmButtonText: "确定",
  767. cancelButtonText: "取消",
  768. inputPlaceholder: "请输入关闭原因-必填!!!",
  769. center: true,
  770. type: "warning"
  771. })
  772. .then(({ value }) => {
  773. if (value != null) {
  774. let mapValue = {
  775. number: row.saleNumber,
  776. saleOrderId: row.saleOrderId,
  777. reason: value
  778. };
  779. this.axios
  780. .post("/api/v1/ams/deleteSaleOrderSame", mapValue)
  781. .then(res => {
  782. if (res.data.code == 200) {
  783. this.$message.success("关闭成功");
  784. this.getRequestUrl();
  785. }
  786. });
  787. } else {
  788. this.$message.error("请输入理由");
  789. }
  790. })
  791. .catch(() => {
  792. this.$message({
  793. type: "info",
  794. message: "取消输入"
  795. });
  796. });
  797. },
  798. updateSaleOrder(row) {
  799. console.log(row);
  800. this.$router.push(
  801. "updateSaleOrderSteel/" + row.saleOrderId + "/" + row.deleted
  802. );
  803. },
  804. getOrderDetails(saleOrderId) {
  805. console.log(saleOrderId);
  806. this.$router.push("saleOrderOODetails/" + saleOrderId);
  807. },
  808. getRequestUrl() {
  809. if (getCookie("orgCode") == "shouhuokehu") {
  810. this.option.requestUrl =
  811. "/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=" +
  812. getCookie("userId") +
  813. "&i=" +
  814. new Date();
  815. this.option2.requestUrl =
  816. "/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=" +
  817. getCookie("userId") +
  818. "&i=" +
  819. new Date();
  820. this.option4.requestUrl =
  821. "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=" +
  822. getCookie("userId") +
  823. "&i=" +
  824. new Date();
  825. this.option5.requestUrl =
  826. "/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=" +
  827. getCookie("userId") +
  828. "&i=" +
  829. new Date();
  830. } else {
  831. this.option.requestUrl =
  832. "/api/v1/ams/getSaleOrderInfoes?apiId=408&consigneeSsoId=" +
  833. null +
  834. "&i=" +
  835. new Date();
  836. this.option2.requestUrl =
  837. "/api/v1/ams/getSaleOrderReportedes?apiId=408&consigneeSsoId=" +
  838. null +
  839. "&i=" +
  840. new Date();
  841. this.option4.requestUrl =
  842. "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&shipperId=1&saleType=1&consigneeSsoId=" +
  843. null +
  844. "&i=" +
  845. new Date();
  846. this.option5.requestUrl =
  847. "/api/v1/ams/getSteelOrderDeletedList?apiId=409&consigneeSsoId=" +
  848. null +
  849. "&i=" +
  850. new Date();
  851. }
  852. },
  853. batchReport() {
  854. if (this.batchReportList.length === 0) {
  855. this.$message.error("请先选择需要批量上传的销售订单");
  856. return;
  857. }
  858. const loading = this.$loading({
  859. lock: true,
  860. text: "正在努力上传",
  861. spinner: "el-icon-loading",
  862. background: "rgba(0, 0, 0, 0.7)"
  863. });
  864. this.axios
  865. .post("/api/v1/ams/uploadSaleOrderList", this.batchReportList)
  866. .then(res => {
  867. if (res.data.code == "200") {
  868. this.$message.success("上传成功");
  869. this.getRequestUrl();
  870. loading.close();
  871. } else {
  872. this.$message.error("上传失败");
  873. loading.close();
  874. }
  875. })
  876. .catch(() => {
  877. this.$message.error("上传失败");
  878. loading.close();
  879. });
  880. },
  881. selectionChange(selection) {
  882. console.log(selection);
  883. this.batchReportList = [];
  884. this.batchReportList = selection;
  885. },
  886. refresh() {
  887. this.$router.go(0);
  888. },
  889. handleClick(tab, event) {
  890. console.log(tab, event);
  891. },
  892. onclick() {
  893. var startTime = null;
  894. var endTime = null;
  895. if (this.startTime && this.endTime) {
  896. startTime = sjTime(this.startTime);
  897. endTime = sjTime(this.endTime);
  898. }
  899. if (getCookie("orgCode") == "shouhuokehu") {
  900. if (this.activeName == "first") {
  901. this.option.requestUrl =
  902. "/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=" +
  903. this.input +
  904. "&consigneeSsoId=" +
  905. getCookie("userId") +
  906. "&startTime=" +
  907. startTime +
  908. "&endTime=" +
  909. endTime +
  910. "&i=" +
  911. new Date();
  912. } else if (this.activeName == "second") {
  913. this.option2.requestUrl =
  914. "/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=" +
  915. this.input +
  916. "&consigneeSsoId=" +
  917. getCookie("userId") +
  918. "&startTime=" +
  919. startTime +
  920. "&endTime=" +
  921. endTime +
  922. "&i=" +
  923. new Date();
  924. } else if (this.activeName == "four") {
  925. this.option4.requestUrl =
  926. "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=" +
  927. this.input +
  928. "&consigneeSsoId=" +
  929. getCookie("userId") +
  930. "&startTime=" +
  931. startTime +
  932. "&endTime=" +
  933. endTime +
  934. "&i=" +
  935. new Date();
  936. }
  937. } else {
  938. if (this.activeName == "first") {
  939. this.option.requestUrl =
  940. "/api/v1/ams/getSaleOrderInfoes?apiId=408&saleType=1&con=" +
  941. this.input +
  942. "&startTime=" +
  943. startTime +
  944. "&endTime=" +
  945. endTime +
  946. "&i=" +
  947. new Date();
  948. } else if (this.activeName == "second") {
  949. this.option2.requestUrl =
  950. "/api/v1/ams/getSaleOrderReportedes?apiId=408&saleType=1&con=" +
  951. this.input +
  952. "&startTime=" +
  953. startTime +
  954. "&endTime=" +
  955. endTime +
  956. "&i=" +
  957. new Date();
  958. } else if (this.activeName == "four") {
  959. this.option4.requestUrl =
  960. "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409&saleType=1&shipperId=1&con=" +
  961. this.input +
  962. "&startTime=" +
  963. startTime +
  964. "&endTime=" +
  965. endTime +
  966. "&i=" +
  967. new Date();
  968. }
  969. }
  970. },
  971. handleClose() {},
  972. seeclick(saleOrderId) {
  973. this.$router.push("/saleOrderDetail/" + saleOrderId);
  974. },
  975. btnclick() {
  976. this.$router.push("/addSaleOrder");
  977. },
  978. click(saleOrderId) {
  979. this.$router.push("/editSaleOrder/" + saleOrderId);
  980. },
  981. copyClick(saleOrderId) {
  982. this.$router.push("/copySteelOrder/" + saleOrderId);
  983. },
  984. // 上传
  985. uploadclick(saleOrderId) {
  986. this.$confirm("是否上传", "提示", {
  987. confirmButtonText: "确定",
  988. cancelButtonText: "取消",
  989. type: "warning",
  990. center: true
  991. })
  992. .then(() => {
  993. const loading = this.$loading({
  994. lock: true,
  995. text: "正在努力上传",
  996. spinner: "el-icon-loading",
  997. background: "rgba(0, 0, 0, 0.7)"
  998. });
  999. this.axios
  1000. .post("/api/v1/ams/uploadSaleOrder?saleOrderId=" + saleOrderId)
  1001. .then(res => {
  1002. if (res.data.code == "200") {
  1003. this.$message.success("上传成功!");
  1004. this.getRequestUrl();
  1005. loading.close();
  1006. } else {
  1007. this.$message.success("上传失败!");
  1008. this.getRequestUrl();
  1009. loading.close();
  1010. }
  1011. })
  1012. .catch(() => {
  1013. loading.close();
  1014. });
  1015. })
  1016. .catch(() => {
  1017. this.$message({
  1018. type: "info",
  1019. message: "取消上传!"
  1020. });
  1021. });
  1022. },
  1023. //删除
  1024. deleteclick(scope) {
  1025. let saleOrderId = scope;
  1026. this.$confirm("是否删除", "提示", {
  1027. confirmButtonText: "确定",
  1028. cancelButtonText: "取消",
  1029. type: "warning",
  1030. center: true
  1031. })
  1032. .then(() => {
  1033. this.axios
  1034. .post(
  1035. "/api/v1/ams/deleteAmsSaleOrderBySaleOrderId?saleOrderId=" +
  1036. saleOrderId
  1037. )
  1038. .then(res => {
  1039. if (res.data.code == "200") {
  1040. this.$message.success("删除成功");
  1041. this.getRequestUrl();
  1042. } else {
  1043. this.$message.success("删除失败");
  1044. this.getRequestUrl();
  1045. }
  1046. });
  1047. })
  1048. .catch(() => {
  1049. this.$message({
  1050. type: "info",
  1051. message: "取消删除!"
  1052. });
  1053. });
  1054. }
  1055. }
  1056. };
  1057. </script>
  1058. <style lang="scss" scoped>
  1059. .salePlan {
  1060. .top {
  1061. margin-left: 20px;
  1062. margin-top: 20px;
  1063. }
  1064. .table {
  1065. margin-left: 20px;
  1066. margin-top: 20px;
  1067. }
  1068. .btn {
  1069. display: flex;
  1070. justify-content: center;
  1071. align-items: center;
  1072. }
  1073. }
  1074. </style>