saleTruckPreview.vue 38 KB

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