saleTruckPreview.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. <!-- 内转钢材到异地库派单界面 -->
  2. <template>
  3. <div class="purchasFuelNewMonitor">
  4. <div class="tableTop">
  5. <el-form :inline="true" style="margin-top: 5px">
  6. <el-form-item>
  7. <el-select
  8. v-model="screen"
  9. placeholder="请选择需筛选的内容"
  10. clearable
  11. @change="changeScreen"
  12. style="width: 150px"
  13. >
  14. <el-option
  15. v-for="item in options"
  16. :key="item.value"
  17. :label="item.label"
  18. :value="item.value"
  19. >
  20. </el-option>
  21. </el-select>
  22. <el-input
  23. style="width: 200px"
  24. v-model="input"
  25. placeholder="请输入查询条件"
  26. clearable
  27. ></el-input>
  28. </el-form-item>
  29. <el-form-item>
  30. <label class="el-form-item__label" style="width: auto"
  31. >订单时间:</label
  32. >
  33. <el-date-picker
  34. v-model="startTime"
  35. type="datetime"
  36. placeholder="选择日期时间"
  37. style="width: 200px"
  38. >
  39. </el-date-picker>
  40. <span>至</span>
  41. <el-date-picker
  42. v-model="endTime"
  43. type="datetime"
  44. placeholder="选择日期时间"
  45. style="width: 200px"
  46. >
  47. </el-date-picker>
  48. <el-button type="primary" class="btn" @click="onclick">
  49. <i class="el-icon-search"></i>
  50. </el-button>
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="primary" @click="refresh">
  54. <i class="el-icon-refresh"></i>
  55. </el-button>
  56. </el-form-item>
  57. <el-form-item>
  58. <el-button type="primary" @click="showDialog">多拼派车</el-button>
  59. </el-form-item>
  60. </el-form>
  61. </div>
  62. <div class="table">
  63. <el-table
  64. :data="tableData"
  65. :span-method="objectSpanMethod"
  66. ref="tableRef"
  67. border
  68. stripe
  69. style="width: 100%; margin-top: 20px"
  70. max-height="800px"
  71. @cell-click="cellClik"
  72. :row-style="{ height: '30px' }"
  73. :cell-style="{ fontWeight: '700' }"
  74. >
  75. <el-table-column type="selection" width="40" :selectable="selectInit">
  76. </el-table-column>
  77. <el-table-column
  78. prop="index"
  79. width="40"
  80. label="序号"
  81. align="center"
  82. :resizable="false"
  83. >
  84. <template slot-scope="scope">{{ scope.row.group + 1 }}</template>
  85. </el-table-column>
  86. <el-table-column
  87. prop="consigneeName"
  88. label="收货单位"
  89. width="200px"
  90. align="center"
  91. >
  92. </el-table-column>
  93. <el-table-column
  94. prop="sendStationName"
  95. column-key="sendStationName"
  96. label="车皮装车地点"
  97. align="center"
  98. width="100px"
  99. :filters="[
  100. { text: '专用线', value: '专用线' },
  101. { text: '达州站', value: '达州站' }
  102. ]"
  103. :filter-method="filterSend"
  104. >
  105. <!-- 选择发站 -->
  106. <template slot-scope="scope">
  107. <el-select
  108. filterable
  109. v-model="scope.row.sendStationId"
  110. @change="updateSendStation($event, scope.row)"
  111. >
  112. <el-option
  113. v-for="item in sendStations"
  114. :value="item.sendStationId"
  115. :key="item.sendStationId"
  116. :label="item.sendStation"
  117. ></el-option>
  118. </el-select>
  119. </template>
  120. </el-table-column>
  121. <el-table-column
  122. prop="capacityNo"
  123. column-key="capacityNo"
  124. label="车牌号"
  125. align="center"
  126. width="200px"
  127. >
  128. <template slot-scope="scope">
  129. <el-autocomplete
  130. style="width: 120px"
  131. v-model="scope.row.capacityNo"
  132. :fetch-suggestions="querySearch"
  133. placeholder="请输入车牌号"
  134. @select="handleSelect(scope.row, scope.$index)"
  135. :disabled="scope.row.isCapacityShow != 1"
  136. ></el-autocomplete>
  137. <el-button
  138. @click="updateCapacity(scope.row)"
  139. type="primary"
  140. v-if="scope.row.isCapacityShow == 1"
  141. >提交</el-button
  142. >
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. prop="toTheStation"
  147. label="到站"
  148. align="center"
  149. width="100px"
  150. >
  151. </el-table-column>
  152. <el-table-column
  153. prop="materialName"
  154. label="物资名称"
  155. align="center"
  156. width="100px"
  157. >
  158. </el-table-column>
  159. <el-table-column prop="materialSpe" label="物资规格" align="center">
  160. </el-table-column>
  161. <el-table-column
  162. prop="materialNum"
  163. label="物资件数"
  164. align="center"
  165. width="100px"
  166. >
  167. <!-- <template slot-scope="scope">
  168. <button
  169. type="primary"
  170. @click="scope.row.materialNum--"
  171. v-if="scope.row.isNumShow == 1"
  172. style="height: 40px"
  173. >
  174. -
  175. </button>
  176. <input
  177. v-model="scope.row.materialNum"
  178. disabled
  179. style="
  180. width: 40px;
  181. height: 40px;
  182. font-size: 16px;
  183. line-height: 40px;
  184. text-align: center;
  185. "
  186. />
  187. <el-button
  188. type="primary"
  189. @click="updateBillOrder(scope.row)"
  190. v-if="scope.row.isNumShow == 1"
  191. >提交</el-button
  192. >
  193. </template> -->
  194. </el-table-column>
  195. <el-table-column
  196. prop="transInDep"
  197. label="调入部门"
  198. width="120px"
  199. align="center"
  200. column-key="transInDep"
  201. >
  202. </el-table-column>
  203. <el-table-column
  204. prop="transInWarehouse"
  205. label="调入仓库"
  206. width="120px"
  207. align="center"
  208. column-key="transInWarehouse"
  209. >
  210. </el-table-column>
  211. <el-table-column prop="netWeight" label="净重" align="center"></el-table-column>
  212. </el-table-column>
  213. <el-table-column
  214. prop="carrierName"
  215. label="承运商"
  216. align="center"
  217. width="250px"
  218. >
  219. <template slot-scope="scope">
  220. <el-autocomplete
  221. style="width: 120px"
  222. v-model="scope.row.carrierName"
  223. :fetch-suggestions="querySearchCarrier"
  224. placeholder="请输入承运商"
  225. @select="handleSelectCarrier(scope.row, scope.$index)"
  226. :disabled="scope.row.isCarrierShow != 1"
  227. >
  228. </el-autocomplete>
  229. <el-button
  230. @click="updateTruckCarrier(scope.row)"
  231. type="primary"
  232. v-if="scope.row.isCarrierShow == 1"
  233. >提交</el-button
  234. >
  235. </template>
  236. </el-table-column>
  237. <el-table-column
  238. prop="orderNumber"
  239. label="运输订单号"
  240. width="180px"
  241. align="center"
  242. >
  243. </el-table-column>
  244. <el-table-column
  245. prop="transOutDep"
  246. label="调出部门"
  247. width="120px"
  248. align="center"
  249. column-key="transOutDep"
  250. >
  251. </el-table-column>
  252. <el-table-column
  253. prop="capacityTel"
  254. label="司机电话"
  255. width="250px"
  256. align="center"
  257. >
  258. <template slot-scope="scope">
  259. <el-input
  260. style="width: 120px"
  261. v-model="scope.row.capacityTel"
  262. placeholder="请输入电话号码"
  263. :disabled="scope.row.isTelShow != 1"
  264. ></el-input>
  265. <el-button
  266. @click="updateDriverTel(scope.row)"
  267. type="primary"
  268. v-if="scope.row.isTelShow == 1"
  269. >提交</el-button
  270. >
  271. </template>
  272. </el-table-column>
  273. <el-table-column
  274. prop="shipperName"
  275. label="发货单位"
  276. width="170px"
  277. align="center"
  278. >
  279. </el-table-column>
  280. </el-table>
  281. </div>
  282. <!-- 多拼弹出层-->
  283. <el-dialog
  284. title="生成多拼"
  285. :visible.sync="dialogTableVisible"
  286. style="width: 500px"
  287. >
  288. <el-form :inline="true">
  289. <el-form-item>
  290. <el-autocomplete
  291. style="width: 120px"
  292. v-model="capacityNo"
  293. :fetch-suggestions="querySearch"
  294. placeholder="请输入车牌号"
  295. @select="handleMulSelect"
  296. ></el-autocomplete>
  297. <el-button
  298. @click="updateMulCapacity"
  299. type="primary"
  300. :disabled="disabledDispatch"
  301. >提交</el-button
  302. >
  303. </el-form-item>
  304. </el-form>
  305. </el-dialog>
  306. </div>
  307. </template>
  308. <script>
  309. import { sjTime, isVehicleNumber } from "@/utils/sharedJsFile";
  310. import { getCookie } from "@/utils/util.js";
  311. export default {
  312. data() {
  313. return {
  314. // 线路名称
  315. lineName: "",
  316. //线路id
  317. lineId: null,
  318. drawer: false,
  319. clickIndex: null,
  320. input: null,
  321. screen: "",
  322. dialogTableVisible: false,
  323. newsCapacityId: null,
  324. capacityNo: null,
  325. selection: [],
  326. options: [
  327. {
  328. value: "收货单位",
  329. lable: "收货单位"
  330. },
  331. {
  332. value: "车牌号",
  333. lable: "车牌号"
  334. }
  335. ],
  336. startTime: null,
  337. endTime: null,
  338. //合计净重
  339. totalNumber: 0,
  340. //合计车数
  341. totalCapacity: 0,
  342. tableTitle: "销售统计报表",
  343. capacityList: [],
  344. carrierList: [],
  345. // 线路
  346. LineList: [],
  347. tableData: [],
  348. spanArr: [],
  349. pos: 0,
  350. a: 1,
  351. isCellClick: 0,
  352. //需要合并的行
  353. mergeList: [
  354. "shipperName",
  355. "capacityTel",
  356. "orderNo",
  357. "carrierName",
  358. "transInWarehouse",
  359. "transOutDep",
  360. "transInDep",
  361. "capacityNo",
  362. "sendStationName",
  363. "consigneeName",
  364. "index"
  365. ],
  366. //钢材多拼车辆线路ID
  367. //索引从1-10为1-10拼路线ID
  368. // lineSpelling: [
  369. // 0,
  370. // 110001,
  371. // 110002,
  372. // 110003,
  373. // 110004,
  374. // 110005,
  375. // 110006,
  376. // 110007,
  377. // 110008,
  378. // 110009,
  379. // 110010
  380. // ],
  381. //达州站内转多拼车辆线路ID,从1-5为1-5拼线路id
  382. lineDazhou: [0, 189982, 189983, 189984, 189985, 189986],
  383. //专用线内转多拼车辆线路ID,从1-5为1-5拼线路id
  384. lineZhuanxian: [0, 189987, 189988, 189989, 189990, 189991],
  385. sendStationId: null,
  386. sendStations: [],
  387. direction: "rtl"
  388. };
  389. },
  390. mounted() {
  391. this.getSteelReport();
  392. this.getSendStations();
  393. },
  394. methods: {
  395. // dispatchSome() {
  396. // console.log(this.tableData);
  397. // //首先过滤掉已派车的数据
  398. // let arr = this.tableData.filter(item => {
  399. // return item.capacityIds == 0;
  400. // });
  401. // if (arr.length == 0) {
  402. // ths.$message.error("没有符合条件的分录可供拼装");
  403. // return;
  404. // }
  405. // console.log(arr);
  406. // this.selection = arr;
  407. // this.updateMulCapacity();
  408. // },
  409. //禁用已派车
  410. selectInit(row) {
  411. console.log(row);
  412. if (row.capacityIds != 0) {
  413. return false;
  414. } else {
  415. return true;
  416. }
  417. },
  418. filterSend(value, row, column) {
  419. return row.sendStation === value;
  420. },
  421. //反关闭整条分录
  422. adverseCloseSaleMaterial(row) {
  423. console.log(row.saleMaterialId);
  424. this.$confirm("确定反关闭该条分录?", "提示", {
  425. cancelButtonText: "确定",
  426. confirmButtonText: "取消",
  427. center: true
  428. }).then(() => {
  429. this.axios
  430. .post(
  431. "/api/v1/ams/adverseCloseSaleMaterial?saleMaterialId=" +
  432. row.saleMaterialId
  433. )
  434. .then(res => {
  435. if (res.data.code == "200") {
  436. this.$message.success("反关闭成功");
  437. this.getSteelReport();
  438. } else {
  439. this.$message.error("反关闭失败");
  440. this.getSteelReport();
  441. }
  442. })
  443. .catch(() => {
  444. this.$message.error("反关闭失败");
  445. this.getSteelReport();
  446. });
  447. });
  448. },
  449. //销售钢材报表导出excel
  450. exportAllReportToExcel() {
  451. const loading = this.$loading({
  452. lock: true,
  453. text: "正在导出Excel",
  454. spinner: "el-icon-loading",
  455. background: "rgba(0, 0, 0, 0.7)"
  456. });
  457. var title = this.tableTitle;
  458. let tHeader = [];
  459. let filterVal = [];
  460. console.log(this.$refs.tableRef);
  461. this.$refs.tableRef.$children.forEach(item => {
  462. if (item.label != undefined && item.prop != undefined) {
  463. if (tHeader.indexOf(item.label) === -1) {
  464. tHeader.push(item.label);
  465. }
  466. if (filterVal.indexOf(item.prop) === -1) {
  467. filterVal.push(item.prop);
  468. }
  469. }
  470. });
  471. this.downloadLoading = true;
  472. require.ensure([], () => {
  473. const {
  474. export_json_to_excel
  475. } = require("@/assets/excel/Export2Excel.js"); //这里必须使用绝对路径,使用@/+存放export2Excel的路径
  476. let data = this.tableData.map(v => filterVal.map(j => v[j])); //3.formatJson格式转换
  477. export_json_to_excel(tHeader, data, title); // (title)导出的表格名称
  478. });
  479. loading.close();
  480. },
  481. cellClik(row, column, cell, event) {
  482. if (row.group != this.clickIndex) {
  483. // this.getSteelReport();
  484. this.tableData.forEach(item => {
  485. if (item.group == this.clickIndex) {
  486. this.$set(item, "isCapacityShow", 0);
  487. this.$set(item, "isCarrierShow", 0);
  488. this.$set(item, "isTelShow", 0);
  489. this.$set(item, "isSendStationName", 0);
  490. }
  491. });
  492. }
  493. if (column.property == "capacityNo") {
  494. this.$set(row, "isCapacityShow", 1);
  495. this.clickIndex = row.group;
  496. }
  497. if (column.property == "sendStationName") {
  498. this.$set(row, "isSendStationName", 1);
  499. this.clickIndex = row.group;
  500. }
  501. if (column.property == "carrierName") {
  502. this.$set(row, "isCarrierShow", 1);
  503. this.clickIndex = row.group;
  504. }
  505. if (column.property == "capacityTel") {
  506. this.$set(row, "isTelShow", 1);
  507. this.clickIndex = row.group;
  508. }
  509. },
  510. //承运商弹出层
  511. handleSelectCarrier(row, index, item) {
  512. this.carrierList.forEach(item => {
  513. if (item.carrierName == row.carrierName) {
  514. row.newCarrierId = item.carrierId;
  515. row.carrierId = item.carrierId;
  516. row.carrierIds = item.carrierId;
  517. }
  518. });
  519. },
  520. //承运商边输边查
  521. querySearchCarrier(queryString, cb) {
  522. if (queryString.length > 1) {
  523. this.axios
  524. .post("/api/v1/uc/getCarrierMesByLike?index=" + queryString)
  525. .then(res => {
  526. if (res.data.code == "200") {
  527. this.carrierList = [];
  528. if (res.data.data.length == 0) {
  529. this.$message.info("承运商不存在,请前往注册");
  530. return;
  531. }
  532. var restaurants = res.data.data;
  533. this.carrierList = res.data.data;
  534. var results = queryString
  535. ? restaurants.filter(this.createFilterCarrier(queryString))
  536. : restaurants;
  537. cb(results);
  538. }
  539. });
  540. }
  541. },
  542. //获取发站
  543. getSendStations() {
  544. this.axios.get("/api/v1/uc/getInwardSendStation").then(res => {
  545. console.log(res.data.data);
  546. if (res.data.code == "200") {
  547. this.sendStations = res.data.data;
  548. }
  549. });
  550. },
  551. createFilterCarrier(queryString) {
  552. return restaurants => {
  553. return (
  554. restaurants.value1.toLowerCase().indexOf(queryString.toLowerCase()) >
  555. -1
  556. );
  557. };
  558. },
  559. //以下是车牌号边输边查搜索
  560. querySearch(queryString, cb) {
  561. if (queryString.length > 3) {
  562. this.axios
  563. .post("/api/v1/uc/getCapacityByLike?index=" + queryString)
  564. .then(res => {
  565. this.capacityList = [];
  566. if (res.data.code == "200") {
  567. if (res.data.data.length == 0) {
  568. this.$message.info("车牌号不存在,请前往注册");
  569. return;
  570. }
  571. var restaurants = res.data.data;
  572. this.capacityList = res.data.data;
  573. var results = queryString
  574. ? restaurants.filter(this.createFilter(queryString))
  575. : restaurants;
  576. // console.log("res",+results);
  577. // 调用 callback 返回建议列表的数据
  578. cb(results);
  579. }
  580. });
  581. }
  582. },
  583. createFilter(queryString) {
  584. return restaurants => {
  585. return (
  586. restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >
  587. -1
  588. );
  589. };
  590. },
  591. //车牌号弹出层
  592. handleSelect(row, index) {
  593. this.capacityList.forEach(item => {
  594. if (item.capacityNumber === row.capacityNo) {
  595. row.newsCapacityId = item.capacityId;
  596. }
  597. });
  598. },
  599. //多拼弹出层绑定车牌号
  600. handleMulSelect(item) {
  601. console.log(item);
  602. this.capacityList.forEach(e => {
  603. if (item.capacityNumber === e.capacityNumber) {
  604. this.capacityNumber = e.capacityNumber;
  605. this.capacityId = e.capacityId;
  606. }
  607. });
  608. },
  609. updateSendStation(selection, row) {
  610. let sendStation = this.sendStations.find(
  611. item => item.sendStationId == row.sendStationId
  612. );
  613. row.sendStation = sendStation.sendStation;
  614. console.log("sendStation", sendStation);
  615. console.log("row:", row);
  616. },
  617. updateCapacity(row) {
  618. row.isIwardSteel = 4;
  619. row.saleOrderMaterialId = row.saleOrderId;
  620. row.capacityId = row.newsCapacityId;
  621. if (row.newsCapacityId == null) {
  622. this.$message.warning("请先注册车牌号或者选中弹出后再提交!");
  623. return;
  624. }
  625. if (!isVehicleNumber(row.capacityNo)) {
  626. this.$message.error("请输入正确格式的车牌号!");
  627. return;
  628. }
  629. if (row.capacityIds != 0) {
  630. const loading = this.$loading({
  631. lock: true,
  632. text: "正在变更车牌号",
  633. spinner: "el-icon-loading",
  634. background: "rgba(0, 0, 0, 0.7)"
  635. });
  636. console.log("updateCapacityRow:", row);
  637. this.axios
  638. .post("/api/v1/ams/updateCapacityNumberInFactory", row)
  639. .then(res => {
  640. if (res.data.code == "200") {
  641. this.$message.success("变更车牌号成功!");
  642. this.getSteelReport();
  643. loading.close();
  644. } else {
  645. this.$message.success("变更失败,请联系管理员");
  646. this.getSteelReport();
  647. loading.close();
  648. }
  649. })
  650. .catch(() => {
  651. this.$message.success("变更失败,请联系管理员");
  652. this.getSteelReport();
  653. loading.close();
  654. });
  655. } else {
  656. if (row.carrierIds == 0) {
  657. this.$message.error("请先选择承运商!");
  658. return;
  659. }
  660. if (row.sendStation == null || row.sendStation == "") {
  661. this.$message.error("请先选择发站");
  662. return;
  663. }
  664. row.driverTel = row.capacityTel;
  665. row.capacityNumber = row.capacityNo;
  666. let arr = [];
  667. arr.push(row);
  668. if (arr[0].sendStation == "达州站") {
  669. arr.forEach(item => {
  670. item.lineId = this.lineDazhou[arr.length];
  671. item.lineName = "达州站";
  672. });
  673. } else if (arr[0].sendStation == "专用线") {
  674. arr.forEach(item => {
  675. item.lineId = this.lineZhuanxian[arr.length];
  676. item.lineName = "专用线";
  677. });
  678. } else {
  679. console.log("没有该发站的线路");
  680. this.$message.error("未匹配到线路,请联系管理员");
  681. this.getSteelReport();
  682. return;
  683. }
  684. let map = {
  685. sendStationId: row.sendStationId,
  686. saleOrderId: row.saleOrderId,
  687. mapList: arr
  688. };
  689. console.log("map", map);
  690. if (!map.saleOrderId || !map.sendStationId || !map.mapList) {
  691. this.$message.warning("数据异常,请确认已选发站");
  692. return;
  693. }
  694. console.log("map:", map);
  695. const loading = this.$loading({
  696. lock: true,
  697. text: "正在派车",
  698. spinner: "el-icon-loading",
  699. background: "rgba(0, 0, 0, 0.7)"
  700. });
  701. this.axios
  702. .post("/api/v1/ams/dispatchInwardTruckOrderBySale", map)
  703. .then(res => {
  704. if (res.data.code == "200") {
  705. this.$message.success("派车成功!");
  706. this.getSteelReport();
  707. loading.close();
  708. } else {
  709. this.$message.error("派车失败,请联系管理员");
  710. this.getSteelReport();
  711. loading.close();
  712. }
  713. })
  714. .catch(() => {
  715. this.$message.error("派车失败,请联系管理员");
  716. this.getSteelReport();
  717. loading.close();
  718. });
  719. }
  720. },
  721. //多拼派车
  722. updateMulCapacity() {
  723. let i = 0;
  724. if (this.capacityId == null) {
  725. this.$message.error("请选择车牌号后再派发");
  726. return;
  727. }
  728. this.selection.forEach(item => {
  729. item.isIwardSteel = 4;
  730. item.saleOrderMaterialId = item.saleOrderId;
  731. item.capacityNumber = this.capacityNumber;
  732. });
  733. if (this.selection[0].sendStation == "达州站") {
  734. this.selection.forEach(item => {
  735. item.lineId = this.lineDazhou[this.selection.length];
  736. item.lineName = "达州站";
  737. });
  738. } else if (this.selection[0].sendStation == "专用线") {
  739. this.selection.forEach(item => {
  740. item.lineId = this.lineZhuanxian[this.selection.length];
  741. item.lineName = "专用线";
  742. });
  743. } else {
  744. console.log("没有该发站的线路");
  745. this.$message.error("未匹配到线路,请联系管理员");
  746. this.getSteelReport();
  747. return;
  748. }
  749. let map = {
  750. sendStationId: this.selection[0].sendStationId,
  751. saleOrderId: this.selection[0].saleOrderId,
  752. mapList: this.selection
  753. };
  754. console.log("map", map);
  755. if (!map.saleOrderId || !map.sendStationId || !map.mapList) {
  756. this.$message.warning("数据异常,请确认已选发站");
  757. return;
  758. }
  759. const loading = this.$loading({
  760. lock: true,
  761. text: "正在派车",
  762. spinner: "el-icon-loading",
  763. background: "rgba(0, 0, 0, 0.7)"
  764. });
  765. this.axios
  766. .post("/api/v1/ams/dispatchInwardTruckOrderBySale", map)
  767. .then(res => {
  768. if (res.data.code == "200") {
  769. this.$message.success("派车成功!");
  770. this.getSteelReport();
  771. loading.close();
  772. this.capacityId = null;
  773. this.dialogTableVisible = false;
  774. } else {
  775. this.$message.error("派车失败,请联系管理员");
  776. this.getSteelReport();
  777. loading.close();
  778. this.capacityId = null;
  779. this.dialogTableVisible = false;
  780. }
  781. })
  782. .catch(() => {
  783. this.$message.error("派车失败,请联系管理员");
  784. this.getSteelReport();
  785. loading.close();
  786. this.capacityId = null;
  787. this.dialogTableVisible = false;
  788. });
  789. },
  790. //修改司机电话号码
  791. updateDriverTel(row) {
  792. const loading = this.$loading({
  793. lock: true,
  794. text: "修改电话号码中",
  795. spinner: "el-icon-loading",
  796. background: "rgba(0, 0, 0, 0.7)"
  797. });
  798. if (row.capacityTel == null || row.capacityTel == "") {
  799. this.$message.error("电话号码不能为空");
  800. return;
  801. }
  802. this.axios
  803. .post("/api/v1/uc/updateDriverTel", {
  804. orderId: parseInt(row.orderId),
  805. driverTel: row.capacityTel
  806. })
  807. .then(res => {
  808. if (res.data.code == "200") {
  809. this.$message.success("修改成功");
  810. this.getSteelReport();
  811. loading.close();
  812. } else {
  813. this.$message.error("修改失败");
  814. this.getSteelReport();
  815. loading.close();
  816. }
  817. })
  818. .catch(() => {
  819. this.$message.error("修改失败");
  820. this.getSteelReport();
  821. loading.close();
  822. });
  823. },
  824. //关闭车辆金蝶分录
  825. deleteEasEntryId(row) {
  826. this.$confirm("确定关闭该车金蝶分录吗?", "提示", {
  827. confirmButtonText: "是",
  828. cancelButtonText: "否",
  829. center: true,
  830. type: "warning"
  831. })
  832. .then(() => {
  833. let map = row;
  834. map.isCloseEas = Number(0);
  835. const loading = this.$loading({
  836. lock: true,
  837. text: "正在关闭车辆",
  838. spinner: "el-icon-loading",
  839. background: "rgba(0, 0, 0, 0.7)"
  840. });
  841. this.axios
  842. .post("/api/v1/ams/updateCarAddress", map)
  843. .then(res => {
  844. if (res.data.code == "200") {
  845. this.$message.success("关闭车辆成功");
  846. this.getSteelReport();
  847. loading.close();
  848. } else {
  849. this.$message.error("关闭车辆失败");
  850. this.getSteelReport();
  851. loading.close();
  852. }
  853. })
  854. .catch(() => {
  855. this.$message.error("关闭车辆失败");
  856. this.getSteelReport();
  857. loading.close();
  858. });
  859. })
  860. .catch(() => {
  861. this.$message.info("取消关闭");
  862. });
  863. },
  864. //修改承运商授权
  865. updateTruckCarrier(row) {
  866. if (!row.saleOrderMaterialId) {
  867. row.saleOrderMaterialId = row.saleOrderId;
  868. }
  869. if (row.newCarrierId == null) {
  870. this.$message.warning("请注册承运商或者选中弹出层之后再提交!");
  871. this.getSteelReport();
  872. return;
  873. }
  874. console.log("carrierIdRow:", row);
  875. if (row.carrierIds != 0) {
  876. const loading = this.$loading({
  877. lock: true,
  878. text: "正在修改承运商授权",
  879. spinner: "el-icon-loading",
  880. background: "rgba(0, 0, 0, 0.7)"
  881. });
  882. this.axios
  883. .post("/api/v1/ams/updateTruckNoCarrier", row)
  884. .then(res => {
  885. if (res.data.code == "200") {
  886. this.$message.success("修改承运商授权成功");
  887. this.getSteelReport();
  888. loading.close();
  889. } else {
  890. this.$message.error("修改失败,请联系管理员!");
  891. this.getSteelReport();
  892. loading.close();
  893. }
  894. })
  895. .catch(() => {
  896. this.$message.error("修改失败,请联系管理员!");
  897. this.getSteelReport();
  898. loading.close();
  899. });
  900. } else {
  901. //授权承运商
  902. let arr = [];
  903. arr.push(row);
  904. const loading = this.$loading({
  905. lock: true,
  906. text: "正在授权承运商",
  907. spinner: "el-icon-loading",
  908. background: "rgba(0, 0, 0, 0.7)"
  909. });
  910. this.axios
  911. .post("/api/v1/ams/dispatchToCarrier", arr)
  912. .then(res => {
  913. if (res.data.code == "0") {
  914. this.$message.success("授权承运商成功");
  915. this.getSteelReport();
  916. loading.close();
  917. } else {
  918. this.$message.error("授权失败,请联系管理员");
  919. this.getSteelReport();
  920. loading.close();
  921. }
  922. })
  923. .catch(() => {
  924. this.$message.error("授权失败,请联系管理员");
  925. this.getSteelReport();
  926. loading.close();
  927. });
  928. }
  929. },
  930. //记录每一行的合并数
  931. getSpanArr(data) {
  932. //每次调用方法初始化
  933. this.spanArr = [];
  934. for (var i = 0; i < data.length; i++) {
  935. if (i === 0) {
  936. this.spanArr.push(1);
  937. data[i].group = i;
  938. this.pos = 0;
  939. } else {
  940. // 判断当前元素与上一个元素是否相同
  941. if (
  942. data[i].orderId === data[i - 1].orderId &&
  943. data[i].orderId != null &&
  944. data[i - 1].orderId != null
  945. ) {
  946. this.spanArr[this.pos] += 1;
  947. data[i].group = data[i - 1].group;
  948. this.spanArr.push(0);
  949. } else {
  950. this.spanArr.push(1);
  951. this.pos = i;
  952. data[i].group = data[i - 1].group + 1;
  953. }
  954. }
  955. this.totalCapacity = data[data.length - 1].group + 1;
  956. this.totalNumber = data.reduce(function(prev, item) {
  957. return prev + item.materialNum;
  958. }, 0);
  959. }
  960. },
  961. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  962. if (this.mergeList.includes(column.property)) {
  963. const _row = this.spanArr[rowIndex];
  964. const _col = _row > 0 ? 1 : 0;
  965. return {
  966. rowspan: _row,
  967. colspan: _col
  968. };
  969. }
  970. },
  971. // //减少物资件数
  972. // updateBillOrder(row) {
  973. // const loading = this.$loading({
  974. // lock: true,
  975. // text: "修改物资件数中",
  976. // spinner: "el-icon-loading",
  977. // background: "rgba(0, 0, 0, 0.7)"
  978. // });
  979. // let map = {
  980. // materialId: row.materialId,
  981. // materialNum: row.materialNum
  982. // };
  983. // let arr = [];
  984. // arr.push(map);
  985. // let updateMap = {
  986. // orderId: row.orderId,
  987. // saleOrderId: row.saleOrderId,
  988. // saleOrderMaterialId: row.saleOrderMaterialId,
  989. // mapList: arr
  990. // };
  991. // this.axios
  992. // .post("/api/v1/oms/updateMaterialMes", updateMap)
  993. // .then(res => {
  994. // if (res.data.code == "200") {
  995. // this.$message.success("修改物资数量成功");
  996. // this.getSteelReport();
  997. // loading.close();
  998. // } else {
  999. // this.$message.error("修改物资数量失败,请联系管理员");
  1000. // this.getSteelReport();
  1001. // loading.close();
  1002. // }
  1003. // })
  1004. // .catch(() => {
  1005. // this.$message.error("修改物资数量失败,请联系管理员");
  1006. // this.getSteelReport();
  1007. // loading.close();
  1008. // });
  1009. // },
  1010. //关闭单条分录
  1011. closeEasEntryId(row) {
  1012. console.log(row);
  1013. this.$prompt("确定关闭该条分录吗?", "警告", {
  1014. confirmButtonText: "确定",
  1015. cancelButtonText: "取消",
  1016. center: true,
  1017. inputPlaceholder: "请输入关闭理由"
  1018. })
  1019. .then(({ value }) => {
  1020. if (value != null || value != "") {
  1021. const loading = this.$loading({
  1022. lock: true,
  1023. text: "正在关闭该条分录",
  1024. spinner: "el-icon-loading",
  1025. background: "rgba(0, 0, 0, 0.7)"
  1026. });
  1027. let map = {
  1028. orderId: row.orderId,
  1029. saleOrderMaterialId: row.saleOrderMaterialId,
  1030. saleMaterialId: row.saleMaterialId,
  1031. reason: value,
  1032. number: row.saleOrderNo,
  1033. closeEntryId: row.closeEntryId
  1034. };
  1035. this.axios
  1036. .post("/api/v1/ams/closeSteelMaterialId", map)
  1037. .then(res => {
  1038. if (res.data.code == "200") {
  1039. this.$message.success("关闭成功");
  1040. this.getSteelReport();
  1041. loading.close();
  1042. } else {
  1043. this.$message.error("关闭失败,请联系管理员");
  1044. this.getSteelReport();
  1045. loading.close();
  1046. }
  1047. })
  1048. .catch(() => {
  1049. this.$message.error("关闭失败,请联系管理员");
  1050. this.getSteelReport();
  1051. loading.close();
  1052. });
  1053. }
  1054. })
  1055. .catch(() => {
  1056. this.$message.info("取消输入");
  1057. });
  1058. },
  1059. //查询,输入查询条件
  1060. onclick() {
  1061. let startTime = null;
  1062. let endTime = null;
  1063. let consigneeName = null;
  1064. let capacityNo = null;
  1065. let remark = null;
  1066. if (this.startTime && this.endTime) {
  1067. startTime = sjTime(this.startTime);
  1068. endTime = sjTime(this.endTime);
  1069. }
  1070. if (this.screen == "收货单位") {
  1071. consigneeName = this.input;
  1072. } else if (this.screen == "车牌号") {
  1073. capacityNo = this.input;
  1074. } else {
  1075. remark = this.input;
  1076. }
  1077. this.axios
  1078. .post(
  1079. "/api/v1/tms/getInwardSaleSteelOrder?startTime=" +
  1080. startTime +
  1081. "&endTime=" +
  1082. endTime +
  1083. "&i=" +
  1084. new Date() +
  1085. "&remark=" +
  1086. remark +
  1087. "&consigneeName=" +
  1088. consigneeName +
  1089. "&capacityNo=" +
  1090. capacityNo
  1091. )
  1092. .then(res => {
  1093. this.tableData = res.data.data;
  1094. this.getSpanArr(res.data.data);
  1095. });
  1096. },
  1097. //重新获取表格数据
  1098. refresh() {
  1099. this.getSteelReport();
  1100. },
  1101. //获取钢材订单报表
  1102. getSteelReport() {
  1103. this.axios
  1104. .post(
  1105. "/api/v1/tms/getInwardSaleSteelOrder?startTime=" +
  1106. null +
  1107. "&endTime=" +
  1108. null +
  1109. "&i=" +
  1110. new Date()
  1111. )
  1112. .then(res => {
  1113. this.tableData = res.data.data;
  1114. this.getSpanArr(res.data.data);
  1115. });
  1116. },
  1117. //控制列自动撑开
  1118. flexColumnWidth(str, tableData, flag) {
  1119. // str为该列的字段名(传字符串);tableData为该表格的数据源(传变量);
  1120. // flag为可选值,可不传该参数,传参时可选'max'或'equal',默认为'max'
  1121. // flag为'max'则设置列宽适配该列中最长的内容,flag为'equal'则设置列宽适配该列中第一行内容的长度。
  1122. str = str + "";
  1123. let columnContent = "";
  1124. if (
  1125. !tableData ||
  1126. !tableData.length ||
  1127. tableData.length === 0 ||
  1128. tableData === undefined
  1129. ) {
  1130. return;
  1131. }
  1132. if (!str || !str.length || str.length === 0 || str === undefined) {
  1133. return;
  1134. }
  1135. if (flag === "equal") {
  1136. // 获取该列中第一个不为空的数据(内容)
  1137. for (let i = 0; i < tableData.length; i++) {
  1138. if (tableData[i][str].length > 0) {
  1139. columnContent = tableData[i][str] + "";
  1140. break;
  1141. }
  1142. }
  1143. } else {
  1144. // 获取该列中最长的数据(内容)
  1145. let index = 0;
  1146. for (let i = 0; i < tableData.length; i++) {
  1147. if (tableData[i][str] === null) {
  1148. // 当数据为空时跳过本次循环获取下一条数据长度
  1149. continue;
  1150. }
  1151. const now_temp = tableData[i][str] + "";
  1152. const max_temp = tableData[index][str] + "";
  1153. if (now_temp.length > max_temp.length) {
  1154. index = i;
  1155. }
  1156. }
  1157. columnContent = tableData[index][str] + "";
  1158. } // 以下分配的单位长度可根据实际需求进行调整
  1159. let flexWidth = 0;
  1160. if (columnContent != undefined) {
  1161. for (const char of columnContent) {
  1162. if ((char >= "A" && char <= "Z") || (char >= "a" && char <= "z")) {
  1163. // 如果是英文字符,为字符分配10个单位宽度
  1164. flexWidth += 10;
  1165. } else if (char >= "\u4e00" && char <= "\u9fa5") {
  1166. // 如果是中文字符,为字符分配16个单位宽度
  1167. flexWidth += 14;
  1168. } else {
  1169. // 其他种类字符,为字符分配10个单位宽度
  1170. flexWidth += 10;
  1171. }
  1172. }
  1173. }
  1174. if (flexWidth < 80) {
  1175. // 设置最小宽度
  1176. flexWidth = 80;
  1177. }
  1178. if (flexWidth > 500) {
  1179. // 设置最大宽度
  1180. flexWidth = 500;
  1181. }
  1182. return flexWidth + "px";
  1183. },
  1184. //多拼弹出层
  1185. showDialog() {
  1186. let selection = this.$refs.tableRef.selection;
  1187. console.log("selection", selection);
  1188. if (selection && selection.length > 0) {
  1189. if (
  1190. selection.find(
  1191. item =>
  1192. item.lineId != selection[0].lineId ||
  1193. item.saleOrderId != selection[0].saleOrderId
  1194. )
  1195. ) {
  1196. this.$message({
  1197. message: "无法生成多拼,订单或者线路不一致",
  1198. type: "warning"
  1199. });
  1200. return;
  1201. } else if (!selection[0].sendStationId) {
  1202. this.$message({
  1203. message: "无法生成多拼,请先选择发站",
  1204. type: "warning"
  1205. });
  1206. return;
  1207. }
  1208. this.dialogTableVisible = true;
  1209. this.selection = selection;
  1210. this.capacityNo = selection[0].capacityNo;
  1211. } else {
  1212. this.$message({
  1213. message: "请先勾选再生成多拼",
  1214. type: "warning"
  1215. });
  1216. }
  1217. }
  1218. }
  1219. };
  1220. </script>
  1221. <style lang="scss" scoped>
  1222. .purchasFuelNewMonitor {
  1223. .tableTop {
  1224. margin-left: 20px;
  1225. margin-top: 20px;
  1226. }
  1227. .table {
  1228. margin-left: 20px;
  1229. margin-top: 20px;
  1230. }
  1231. .address {
  1232. .button-box {
  1233. display: flex;
  1234. justify-content: center;
  1235. align-items: center;
  1236. }
  1237. }
  1238. }
  1239. </style>