addSaleOrderSteelSendCarrier.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. <template>
  2. <div class="addSaleOrderSend">
  3. <page-title>新增销售订单钢材派车</page-title>
  4. <!-- 派车表格 -->
  5. <div class="selectionTable from">
  6. <el-table
  7. :data="selectionList"
  8. border
  9. style="width: 100%"
  10. highlight-current-row
  11. :span-method="cellMerge"
  12. >
  13. <el-table-column
  14. v-for="(item, i) in tableTop"
  15. :key="i"
  16. :prop="item.prop"
  17. :label="item.label"
  18. :width="item.width"
  19. align="center"
  20. show-overflow-tooltip
  21. >
  22. <template slot="scope" v-if="item.label !== '车牌号'">
  23. <span>{{ item.label }}</span>
  24. </template>
  25. <template slot="scope" v-if="item.label !== '承运商'">
  26. <span>{{ item.label }}</span>
  27. </template>
  28. <template slot="scope" v-if="item.label !== '件数'">
  29. <span>{{ item.label }}</span>
  30. </template>
  31. <template slot="scope" v-if="item.label !== '运输线路'">
  32. <span>{{ item.label }}</span>
  33. </template>
  34. <template slot="scope" v-if="item.label !== '运输单价'">
  35. <span>{{ item.label }}</span>
  36. </template>
  37. <template slot="scope" v-if="item.label !== '订单有效期'">
  38. <span>{{ item.label }}</span>
  39. </template>
  40. <template slot="scope" v-if="item.label !== '收货客户'">
  41. <span>{{ item.label }}</span>
  42. </template>
  43. <template slot="scope" v-if="item.label !== '收货客户电话号码'">
  44. <span>{{ item.label }}</span>
  45. </template>
  46. <template slot="scope" v-if="item.label !== '备注'">
  47. <span>{{ item.label }}</span>
  48. </template>
  49. <!-- 插入输入框 -->
  50. <template slot-scope="scope">
  51. <template v-if="item.slot">
  52. <!-- 车牌号 -->
  53. <template v-if="item.prop == 'capacityNumber'">
  54. <el-autocomplete
  55. class="inline-input"
  56. v-model="scope.row.capacityNumber"
  57. :fetch-suggestions="querySearch"
  58. placeholder="(必填)"
  59. :trigger-on-focus="false"
  60. @select="handleSelect(scope.row, scope.$index)"
  61. @blur="checkRelationship(scope.$index)"
  62. @change="batchUpdateValue(scope.row, scope.$index)"
  63. ></el-autocomplete>
  64. </template>
  65. <!-- 司机电话号码 -->
  66. <template v-if="item.prop == 'driverTel'">
  67. <el-input
  68. class="textinput"
  69. placeholder="(必填)"
  70. @blur="checkIsTelephone(scope.$index)"
  71. v-model="scope.row.driverTel"
  72. ></el-input>
  73. </template>
  74. <!-- 承运商 -->
  75. <template v-if="item.prop == 'carrierName'">
  76. <el-select
  77. v-model="scope.row.carrierName"
  78. placeholder="请选择"
  79. @change="batchUpdateValue(scope.row, scope.$index)"
  80. disabled
  81. >
  82. <el-option
  83. v-for="item in carrierNameOptions[scope.$index]"
  84. :key="item.value"
  85. :label="item.label"
  86. :value="item.value"
  87. >
  88. </el-option>
  89. </el-select>
  90. </template>
  91. <!-- 物资件数 -->
  92. <template v-if="item.prop == 'orderPlanWeight'">
  93. <el-input
  94. class="textinput"
  95. @input="onInput"
  96. placeholder="(必填)"
  97. v-model.number="scope.row.orderPlanWeight"
  98. disabled
  99. ></el-input>
  100. </template>
  101. <!-- 物资重量 -->
  102. <template v-if="item.prop == 'materialWeight'">
  103. <el-input
  104. class="textinput"
  105. v-model.number="scope.row.materialWeight"
  106. disabled
  107. ></el-input>
  108. </template>
  109. <!-- 运输单价id -->
  110. <template v-if="item.prop == 'priceValue'">
  111. <el-input v-model="scope.row.priceValue" disabled> </el-input>
  112. </template>
  113. <!-- 订单有效期 -->
  114. <template v-if="item.prop == 'saleDateOfReceipt'">
  115. <el-date-picker
  116. class="textinput3"
  117. type="date"
  118. v-model.number="scope.row.saleDateOfReceipt"
  119. style="width:135px"
  120. disabled
  121. ></el-date-picker>
  122. </template>
  123. <!-- 收货客户 -->
  124. <template v-if="item.prop == 'saleOrderConsignee'">
  125. <el-input
  126. class="textinput4"
  127. placeholder="(非必填)"
  128. v-model.number="scope.row.saleOrderConsignee"
  129. disabled
  130. ></el-input>
  131. </template>
  132. <!-- 收货客户电话号码 -->
  133. <template v-if="item.prop == 'saleOrderConsigneeTel'">
  134. <el-input
  135. class="textinput5"
  136. placeholder="(非必填)"
  137. v-model.number="scope.row.saleOrderConsigneeTel"
  138. @input="onInput"
  139. disabled
  140. ></el-input>
  141. </template>
  142. </template>
  143. <template v-else>
  144. <span>{{ scope.row[item.prop] }}</span>
  145. </template>
  146. </template>
  147. </el-table-column>
  148. <!-- 操作列 -->
  149. <!-- <el-table-column fixed="right" label="操作" width="100">
  150. </el-table-column> -->
  151. </el-table>
  152. </div>
  153. <div class="button_box">
  154. <el-button @click="cancel">取消</el-button>
  155. <el-button type="primary" @click="makeSure" :loading="isLoading"
  156. >确定</el-button
  157. >
  158. </div>
  159. </div>
  160. </template>
  161. <script>
  162. import PageTitle from "@/components/Page/Title";
  163. import { getCookie } from "@/utils/util.js";
  164. import { sjTime, isNumber, isIntegerNumber } from "@/utils/sharedJsFile";
  165. export default {
  166. components: { PageTitle },
  167. data() {
  168. return {
  169. //是否正在加载
  170. isLoading: false,
  171. //存放每一行记录的合并数
  172. spanArr: [],
  173. //pos是spanArr的索引
  174. pos: 0,
  175. //加载
  176. selectLineLoading: false,
  177. //承运商下拉框中的值
  178. carrierNameOptions: [],
  179. //当前车序号物资
  180. selectionList: [],
  181. driverTel1: null,
  182. //是否可发送请求
  183. canSend: 1,
  184. tableTop: [
  185. {
  186. prop: "truckNo",
  187. label: "车序号",
  188. width: "50"
  189. },
  190. {
  191. prop: "capacityNumber",
  192. label: "车牌号",
  193. width: "130",
  194. slot: true
  195. },
  196. {
  197. prop: "driverTel",
  198. label: "司机电话号码",
  199. width: "150",
  200. slot: true
  201. },
  202. {
  203. prop: "carrierName",
  204. label: "承运商",
  205. width: "240",
  206. slot: true
  207. },
  208. {
  209. prop: "materialName",
  210. label: "物资名称",
  211. width: "140"
  212. },
  213. {
  214. prop: "Specification",
  215. label: "规格型号",
  216. width: "140"
  217. },
  218. {
  219. prop: "orderPlanWeight",
  220. label: "件数",
  221. width: "80",
  222. slot: true
  223. },
  224. {
  225. prop: "materialWeight",
  226. label: "重量",
  227. width: "80",
  228. slot: true
  229. },
  230. {
  231. prop: "lineName",
  232. label: "厂内运输线路",
  233. width: "220"
  234. },
  235. {
  236. prop: "saleDateOfReceipt",
  237. label: "订单有效期",
  238. width: "150",
  239. slot: true
  240. },
  241. {
  242. prop: "saleShipperAddressName",
  243. label: "收货地址",
  244. width: "300"
  245. },
  246. {
  247. prop: "priceValue",
  248. label: "运输单价",
  249. width: "80",
  250. slot: true
  251. },
  252. {
  253. prop: "saleOrderConsignee",
  254. label: "收货客户",
  255. width: "150",
  256. slot: true
  257. },
  258. {
  259. prop: "saleOrderConsigneeTel",
  260. label: "收货客户电话号码",
  261. slot: true,
  262. width: "150"
  263. },
  264. {
  265. prop: "materialCode",
  266. label: "物资编码",
  267. width: "140"
  268. },
  269. {
  270. prop: "truckRemark",
  271. label: "备注",
  272. width: "140"
  273. }
  274. ]
  275. };
  276. },
  277. created() {
  278. this.getValue();
  279. },
  280. methods: {
  281. getValue() {
  282. let map = {};
  283. if (getCookie("orgCode") == "chengyunshang") {
  284. map.saleOrderId = this.$route.params.saleOrderId;
  285. map.carrierSsoId = getCookie("userId");
  286. } else {
  287. map.saleOrderId = this.$route.params.saleOrderId;
  288. }
  289. this.axios
  290. .post("/api/v1/ams/getCarrierTruckNoAndMaterialList", map)
  291. .then(res => {
  292. if (res.data.data.length == 0) {
  293. this.$confirm("该销售订单尚未排车!是否先进行排车?", "提示", {
  294. confirmButtonText: "确定",
  295. cancelButtonText: "取消",
  296. type: "warning",
  297. center: true
  298. })
  299. .then(() => {
  300. this.$router.push(
  301. "/addSaleOrderArrange/" + this.$route.params.saleOrderId
  302. );
  303. })
  304. .catch(() => {
  305. this.$message({ type: "info", message: "取消!" });
  306. });
  307. }
  308. console.log("res.data.data", res.data.data);
  309. //赋值派车表格
  310. res.data.data.forEach((e, i) => {
  311. if (e.saleOrderConsignee == "null") {
  312. e.saleOrderConsignee = null;
  313. }
  314. if (e.saleOrderConsigneeTel == "null") {
  315. e.saleOrderConsigneeTel = null;
  316. }
  317. //带承运商初始化派车表格
  318. var addmap = {
  319. truckNo: e.truckNo,
  320. saleOrderMaterialId: e.saleOrderMaterialId,
  321. capacityNumber: null,
  322. driverTel: null,
  323. carrierName: e.carrierName,
  324. carrierId: e.carrierId,
  325. materialId: e.materialId,
  326. materialName: e.materialName,
  327. Specification: e.materialModelSpecification,
  328. materialCode: e.materialCode,
  329. orderPlanWeight: e.materialNumber,
  330. materialWeight: e.materialWeight,
  331. lineName: null,
  332. lineId: null,
  333. saleShipperAddressId: e.placeId,
  334. saleShipperAddressName: e.place,
  335. saleDateOfReceipt: e.receiptDate,
  336. saleOrderConsignee: e.saleOrderConsignee,
  337. saleOrderConsigneeTel: e.saleOrderConsigneeTel,
  338. truckRemark: e.truckRemark
  339. };
  340. this.selectionList.push(addmap);
  341. //调用记录每一行的合并数的方法
  342. this.getSpanArr(this.selectionList);
  343. //初始化每个车的线路
  344. this.initializeLine();
  345. });
  346. });
  347. },
  348. onInput(val) {
  349. if (!isNumber(val)) {
  350. this.$message.warning("重量/电话号码请输入数字");
  351. }
  352. },
  353. //校验是否为车牌
  354. isVehicleNumber(vehicleNumber) {
  355. var result = false;
  356. if (vehicleNumber != null) {
  357. if (vehicleNumber.length == 7) {
  358. var express = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
  359. result = express.test(vehicleNumber);
  360. }
  361. }
  362. return result;
  363. },
  364. //绑定车牌号和承运商的关系
  365. bindRelationship(mapValue) {
  366. let RmsCapacity = {
  367. capacityTypeId: 1,
  368. capacityNumber: mapValue.capacityNumber,
  369. capacityCorlor: "黄",
  370. capacityOwneris: "否",
  371. capacityVip: "否",
  372. capacityBlacklist: "否",
  373. remark: null,
  374. carrierId: mapValue.carrierId,
  375. state: mapValue.carrierName
  376. };
  377. this.$confirm(
  378. "车牌号(" +
  379. mapValue.capacityNumber +
  380. ")与承运商未有绑定关系, 是否立即绑定该车牌号和承运商?",
  381. "提示",
  382. {
  383. confirmButtonText: "确定",
  384. cancelButtonText: "取消",
  385. type: "warning"
  386. }
  387. )
  388. .then(() => {
  389. this.axios
  390. .post("/api/v1/rms/insertCapacity", RmsCapacity)
  391. .then(res => {
  392. console.log("res", res);
  393. if (res.data.data == 0) {
  394. this.$message.success("该车牌号与承运商绑定关系成功!");
  395. }
  396. });
  397. })
  398. .catch(() => {
  399. this.$message({ type: "info", message: "已取消删除" });
  400. });
  401. },
  402. //失焦事件后确定车牌号与承运商是否有绑定关系
  403. checkRelationship(index) {
  404. if (this.selectionList[index].carrierId != null) {
  405. //暂存车牌号
  406. var capacityNumber1;
  407. if (this.isVehicleNumber(this.selectionList[index].capacityNumber)) {
  408. let mapValue = {
  409. capacityNumber: this.selectionList[index].capacityNumber,
  410. carrierId: this.selectionList[index].carrierId,
  411. carrierName: this.selectionList[index].carrierName
  412. };
  413. this.axios
  414. .post("/api/v1/uc/isInCapacityCarrier", mapValue)
  415. .then(res => {
  416. if (res.data.code == "201") {
  417. capacityNumber1 = res.data.data;
  418. if (capacityNumber1 == null) {
  419. this.selectionList[index].capacityNumber = null;
  420. this.$message.error("该车牌号未注册,请先前往注册!");
  421. } else {
  422. this.bindRelationship(mapValue);
  423. }
  424. }
  425. });
  426. }
  427. }
  428. },
  429. //车牌号弹出层
  430. handleSelect(row, index) {
  431. this.axios
  432. .post(
  433. "/api/v1/ams/matchingDriverTelRecently?capacityNumber=" +
  434. row.capacityNumber
  435. )
  436. .then(res => {
  437. row.driverTel = res.data.data;
  438. });
  439. },
  440. //以下是车牌号边输边查搜索
  441. querySearch(queryString, cb) {
  442. this.axios
  443. .post("/api/v1/uc/getCapacityByLike?index=" + queryString)
  444. .then(res => {
  445. if (res.data.code == "200") {
  446. var restaurants = res.data.data;
  447. var results = queryString
  448. ? restaurants.filter(this.createFilter(queryString))
  449. : restaurants;
  450. // 调用 callback 返回建议列表的数据
  451. cb(results);
  452. }
  453. });
  454. },
  455. createFilter(queryString) {
  456. return restaurants => {
  457. return (
  458. restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >
  459. -1
  460. );
  461. };
  462. },
  463. //以上是车牌号边输边查搜索
  464. //校验是否为电话号码
  465. checkIsTelephone(index) {
  466. //电话号码校验
  467. var reg = /^[1][345789]\d{9}$/;
  468. if (!reg.test(this.selectionList[index].driverTel)) {
  469. this.canSend = -1;
  470. this.$message.warning("电话号码格式不正确,请输入正确的电话号码!");
  471. } else {
  472. this.canSend = 1;
  473. }
  474. },
  475. //点击确定按钮的事件
  476. makeSure() {
  477. this.isLoading = true;
  478. //是否可发送请求
  479. if (this.canSend == -1) {
  480. this.$message.warning("电话号码格式不正确,请输入正确的电话号码!");
  481. } else {
  482. this.$confirm("是否确定进行钢材派单!", "提示", {
  483. confirmButtonText: "确定",
  484. cancelButtonText: "取消",
  485. type: "warning",
  486. center: true
  487. })
  488. .then(() => {
  489. var mapList = [];
  490. for (var i = 0; i < this.spanArr.length; i++) {
  491. if (this.spanArr[i] > 0 && this.selectionList[i].capacityNumber) {
  492. var mapItem = {
  493. //车牌号
  494. capacityNumber: null,
  495. //司机电话号码
  496. driverTel: null,
  497. //车序号主键
  498. saleOrderMaterialId: 0,
  499. //承运商Id
  500. carrierId: 0,
  501. //线路Id
  502. lineId: 0
  503. };
  504. mapItem.capacityNumber = this.selectionList[i].capacityNumber;
  505. mapItem.driverTel = this.selectionList[i].driverTel;
  506. mapItem.saleOrderMaterialId = this.selectionList[
  507. i
  508. ].saleOrderMaterialId;
  509. mapItem.carrierId = this.selectionList[i].carrierId;
  510. mapItem.lineId = this.selectionList[i].lineId;
  511. mapList.push(mapItem);
  512. }
  513. }
  514. this.axios
  515. .post("/api/v1/ams/dispatchSteelOrder", mapList)
  516. .then(res => {
  517. if (res.data.code == "200") {
  518. this.cancel();
  519. this.$message.success("派单成功!");
  520. } else {
  521. this.$message.error("派单失败:" + res.data.data);
  522. }
  523. this.isLoading = false;
  524. });
  525. })
  526. .catch(() => {
  527. this.$message({ type: "info", message: "取消!" });
  528. });
  529. }
  530. },
  531. //点击取消按钮的事件
  532. cancel() {
  533. this.$router.push("/saleOrderSteelCarrier");
  534. },
  535. //批量修改内层值
  536. batchUpdateValue(row, index) {
  537. for (var i = index; i < this.spanArr[index] + index; i++) {
  538. this.selectionList[i].capacityNumber = row.capacityNumber;
  539. this.selectionList[i].driverTel = this.driverTel1;
  540. }
  541. },
  542. //初始化线路
  543. initializeLine() {
  544. for (var i = 0; i < this.spanArr.length; i++) {
  545. if (this.spanArr[i] == 1) {
  546. for (var j = i; j < this.spanArr[i] + i; j++) {
  547. this.selectionList[j].lineName =
  548. "总厂:销售钢材单拼路线" + " " + "进厂-计皮-装货-计毛-出厂";
  549. this.selectionList[j].lineId = 110001;
  550. }
  551. }
  552. if (this.spanArr[i] == 2) {
  553. for (var j = i; j < this.spanArr[i] + i; j++) {
  554. this.selectionList[j].lineName =
  555. "总厂:销售钢材二拼路线" +
  556. " " +
  557. "计皮-进厂-装货-计毛-计皮-装货-计毛-出厂";
  558. this.selectionList[j].lineId = 110002;
  559. }
  560. }
  561. if (this.spanArr[i] == 3) {
  562. for (var j = i; j < this.spanArr[i] + i; j++) {
  563. this.selectionList[j].lineName =
  564. "总厂:销售钢材三拼路线" +
  565. " " +
  566. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  567. this.selectionList[j].lineId = 110003;
  568. }
  569. }
  570. if (this.spanArr[i] == 4) {
  571. for (var j = i; j < this.spanArr[i] + i; j++) {
  572. this.selectionList[j].lineName =
  573. "总厂:销售钢材四拼路线" +
  574. " " +
  575. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  576. this.selectionList[j].lineId = 110004;
  577. }
  578. }
  579. if (this.spanArr[i] == 5) {
  580. for (var j = i; j < this.spanArr[i] + i; j++) {
  581. this.selectionList[j].lineName =
  582. "总厂:销售钢材五拼路线" +
  583. " " +
  584. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  585. this.selectionList[j].lineId = 110005;
  586. }
  587. }
  588. if (this.spanArr[i] == 6) {
  589. for (var j = i; j < this.spanArr[i] + i; j++) {
  590. this.selectionList[j].lineName =
  591. "总厂:销售钢材六拼路线" +
  592. " " +
  593. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  594. this.selectionList[j].lineId = 110006;
  595. }
  596. }
  597. if (this.spanArr[i] == 7) {
  598. for (var j = i; j < this.spanArr[i] + i; j++) {
  599. this.selectionList[j].lineName =
  600. "总厂:销售钢材七拼路线" +
  601. " " +
  602. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  603. this.selectionList[j].lineId = 110007;
  604. }
  605. }
  606. if (this.spanArr[i] == 8) {
  607. for (var j = i; j < this.spanArr[i] + i; j++) {
  608. this.selectionList[j].lineName =
  609. "总厂:销售钢材八拼路线" +
  610. " " +
  611. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  612. this.selectionList[j].lineId = 110008;
  613. }
  614. }
  615. if (this.spanArr[i] == 9) {
  616. for (var j = i; j < this.spanArr[i] + i; j++) {
  617. this.selectionList[j].lineName =
  618. "总厂:销售钢材九拼路线" +
  619. " " +
  620. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  621. this.selectionList[j].lineId = 110009;
  622. }
  623. }
  624. if (this.spanArr[i] == 10) {
  625. for (var j = i; j < this.spanArr[i] + i; j++) {
  626. this.selectionList[j].lineName =
  627. "总厂:销售钢材十拼路线" +
  628. " " +
  629. "进厂-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-计皮-装货-计毛-出厂";
  630. this.selectionList[j].lineId = 110010;
  631. }
  632. }
  633. }
  634. },
  635. //记录每一行的合并数
  636. getSpanArr(data) {
  637. //每次调用方法初始化
  638. this.spanArr = [];
  639. for (var i = 0; i < data.length; i++) {
  640. if (i === 0) {
  641. this.spanArr.push(1);
  642. this.pos = 0;
  643. } else {
  644. // 判断当前元素与上一个元素是否相同
  645. if (data[i].truckNo === data[i - 1].truckNo) {
  646. this.spanArr[this.pos] += 1;
  647. this.spanArr.push(0);
  648. } else {
  649. this.spanArr.push(1);
  650. this.pos = i;
  651. }
  652. }
  653. }
  654. },
  655. //根据条件合并行
  656. cellMerge({ row, column, rowIndex, columnIndex }) {
  657. if (columnIndex === 0) {
  658. const _row = this.spanArr[rowIndex];
  659. const _col = _row > 0 ? 1 : 0;
  660. return {
  661. rowspan: _row,
  662. colspan: _col
  663. };
  664. }
  665. if (columnIndex === 1) {
  666. const _row = this.spanArr[rowIndex];
  667. const _col = _row > 0 ? 1 : 0;
  668. return {
  669. rowspan: _row,
  670. colspan: _col
  671. };
  672. }
  673. if (columnIndex === 2) {
  674. const _row = this.spanArr[rowIndex];
  675. const _col = _row > 0 ? 1 : 0;
  676. return {
  677. rowspan: _row,
  678. colspan: _col
  679. };
  680. }
  681. if (columnIndex === 3) {
  682. const _row = this.spanArr[rowIndex];
  683. const _col = _row > 0 ? 1 : 0;
  684. return {
  685. rowspan: _row,
  686. colspan: _col
  687. };
  688. }
  689. if (columnIndex === 8) {
  690. const _row = this.spanArr[rowIndex];
  691. const _col = _row > 0 ? 1 : 0;
  692. return {
  693. rowspan: _row,
  694. colspan: _col
  695. };
  696. }
  697. if (columnIndex === 9) {
  698. const _row = this.spanArr[rowIndex];
  699. const _col = _row > 0 ? 1 : 0;
  700. return {
  701. rowspan: _row,
  702. colspan: _col
  703. };
  704. }
  705. if (columnIndex === 10) {
  706. const _row = this.spanArr[rowIndex];
  707. const _col = _row > 0 ? 1 : 0;
  708. return {
  709. rowspan: _row,
  710. colspan: _col
  711. };
  712. }
  713. if (columnIndex === 11) {
  714. const _row = this.spanArr[rowIndex];
  715. const _col = _row > 0 ? 1 : 0;
  716. return {
  717. rowspan: _row,
  718. colspan: _col
  719. };
  720. }
  721. if (columnIndex === 12) {
  722. const _row = this.spanArr[rowIndex];
  723. const _col = _row > 0 ? 1 : 0;
  724. return {
  725. rowspan: _row,
  726. colspan: _col
  727. };
  728. }
  729. if (columnIndex === 13) {
  730. const _row = this.spanArr[rowIndex];
  731. const _col = _row > 0 ? 1 : 0;
  732. return {
  733. rowspan: _row,
  734. colspan: _col
  735. };
  736. }
  737. if (columnIndex === 15) {
  738. const _row = this.spanArr[rowIndex];
  739. const _col = _row > 0 ? 1 : 0;
  740. return {
  741. rowspan: _row,
  742. colspan: _col
  743. };
  744. }
  745. }
  746. }
  747. };
  748. </script>
  749. <style lang="scss">
  750. .addSaleOrderSend {
  751. .from {
  752. margin-top: 20px;
  753. .line {
  754. display: flex;
  755. justify-content: center;
  756. align-items: center;
  757. .el-input {
  758. width: 350px;
  759. margin-left: 10px;
  760. margin-right: 10px;
  761. }
  762. }
  763. .sendCar {
  764. display: flex;
  765. justify-content: center;
  766. align-items: center;
  767. .el-input {
  768. width: 70px;
  769. margin-left: 10px;
  770. margin-right: 10px;
  771. margin-top: 10px;
  772. }
  773. }
  774. .vehicle {
  775. display: flex;
  776. justify-content: center;
  777. align-items: center;
  778. margin-top: 20px;
  779. .el-button {
  780. width: 250px;
  781. margin-left: 10px;
  782. margin-right: 10px;
  783. }
  784. .span {
  785. width: 70px;
  786. }
  787. }
  788. }
  789. .tablecls {
  790. margin-top: 20px;
  791. }
  792. .button_box {
  793. display: flex;
  794. justify-content: center;
  795. margin: 20px;
  796. .el-button {
  797. width: 100px;
  798. margin-left: 20px;
  799. }
  800. }
  801. }
  802. </style>