saleTruckPreview.vue 38 KB

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