precontainers.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option" :table-loading="loading" :data="assemblyForm.preContainersList" :page.sync="page"
  4. :permission="permissionList" :before-open="beforeOpen" v-model="form"
  5. :cell-style="{ padding: '0px', textAlign: 'center' }" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
  6. @row-del="rowDel" @selection-change="selectionChange" @refresh-change="refreshChange"
  7. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 487)"
  8. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 487)">
  9. <template slot="menuLeft">
  10. <el-button type="primary" size="small"
  11. :disabled="seeDisabled || assemblyForm.preContainersList.filter(item => item.containerNumberStatus == '已选择').length > 0"
  12. @click.stop="addfun">新 增</el-button>
  13. <el-button type="danger" size="small" plain
  14. :disabled="seeDisabled || assemblyForm.preContainersList.length == 0 || assemblyForm.preContainersList.filter(item => item.containerNumberStatus == '已选择').length > 0"
  15. @click.stop="handleDelete">一键删除
  16. </el-button>
  17. <el-button type="primary" size="small"
  18. :disabled="seeDisabled || assemblyForm.preContainersList.length == 0"
  19. @click="batchSavefun">一键保存</el-button>
  20. <el-button type="info" plain size="small"
  21. :disabled="seeDisabled || assemblyForm.preContainersList.length == 0" @click="onclickEdit">一键编辑
  22. </el-button>
  23. </template>
  24. <template slot-scope="{row,index}" slot="menu">
  25. <el-button v-if="row.id && row.containerNumberStatus == '录入' && assemblyForm.billType != 'MM'"
  26. size="mini" type="text" @click.stop="pick(row)" :disabled="seeDisabled">
  27. 选择
  28. </el-button>
  29. <el-button v-if="row.id && row.containerNumberStatus == '已选择' && assemblyForm.billType != 'MM'"
  30. size="mini" type="text" @click.stop="rowRevoke(row)" :disabled="seeDisabled">
  31. 撤销
  32. </el-button>
  33. <el-button v-if="row.id && row.containerNumberStatus == '已选择' && assemblyForm.billType != 'MM'"
  34. size="mini" type="text" @click.stop="rowView(row)" :disabled="seeDisabled">
  35. 查看放箱号
  36. </el-button>
  37. </template>
  38. <template slot-scope="{row}" slot="cntrTypeCodeForm">
  39. <search-query :datalist="cntrTypeCodeData" :selectValue="row.cntrTypeCode" :filterable="true"
  40. :clearable="true" :remote="true" :buttonIf="false"
  41. :forParameter="{ key: 'id', label: 'cnName', value: 'cnName' }" placeholder="请选择尺码箱型"
  42. @remoteMethod="remoteMethod($event, 'cntrTypeCode')" @corpChange="corpChange($event, row)"
  43. @corpFocus="remoteMethod($event, 'cntrTypeCode')" @corpClear="corpClear($event, row)">
  44. </search-query>
  45. </template>
  46. <template slot="number" slot-scope="{ row }">
  47. <el-input v-if="row.$cellEdit" style="width: 100%;" v-model="row.number" size="small" autocomplete="off"
  48. min="0" @blur="numberBlur(row)" clearable placeholder="请输入件数"></el-input>
  49. <span v-else>{{ row.number }}</span>
  50. </template>
  51. <template slot="grossWeight" slot-scope="{ row }">
  52. <el-input v-if="row.$cellEdit" style="width: 100%;" v-model="row.grossWeight" size="small"
  53. autocomplete="off" min="0" @blur="grossWeightBlur(row)" clearable placeholder="请输入毛重"></el-input>
  54. <span v-else>{{ row.grossWeight }}</span>
  55. </template>
  56. <template slot="measurement" slot-scope="{ row }">
  57. <el-input v-if="row.$cellEdit" style="width: 100%;" v-model="row.measurement" size="small"
  58. autocomplete="off" min="0" @blur="measurementBlur(row)" clearable placeholder="请输入尺码"></el-input>
  59. <span v-else>{{ row.measurement }}</span>
  60. </template>
  61. </avue-crud>
  62. <el-dialog title="查看放箱号" :visible.sync="dialogVisible" width="50%" :before-close="handleClose" append-to-body>
  63. <span>
  64. <avue-crud ref="crud2" :option="containerOption" :data="containerNumberItemList"
  65. @resetColumn="resetColumnTwo('crud2', 'containerOption', 'containerOptionBack', 488)"
  66. @saveColumn="saveColumnTwo('crud2', 'containerOption', 'containerOptionBack', 488)">
  67. <template slot="occupyNum" slot-scope="{ row }">
  68. <el-input-number v-if="!row.id" v-model="row.occupyNum" :min="0" :max="row.remainingNum"
  69. placeholder="请输入占用箱量" size="small" :controls="false" style="width: 100%;"></el-input-number>
  70. <span v-else>{{ row.occupyNum }}</span>
  71. </template>
  72. </avue-crud>
  73. </span>
  74. <span slot="footer" class="dialog-footer">
  75. <el-button @click="dialogVisible = false" size="mini">{{ editStatus ? '取 消' : '关 闭' }}</el-button>
  76. <el-button v-if="editStatus" type="primary" @click="submit" size="mini">确 定</el-button>
  77. </span>
  78. </el-dialog>
  79. </basic-container>
  80. </template>
  81. <script>
  82. import {
  83. precontainersList,
  84. precontainersDetail,
  85. precontainersSubmit,
  86. precontainersRemove,
  87. precontainersSubmitList,
  88. getItemListHY,
  89. selectedContainerNumber,
  90. revokeSelectedContainerNumber,
  91. } from "@/api/iosBasicData/ReceivingOrders/precontainers";
  92. import { getWorkDicts } from "@/api/system/dictbiz";
  93. import { mapGetters } from "vuex";
  94. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  95. import { bcntrtypesList } from "@/api/iosBasicData/bcntrtypes";
  96. import { containersEqualDistribution } from "@/api/iosBasicData/containers";
  97. import { requiredMessage } from "@/util/messageReminder";
  98. import { Header } from "element-ui";
  99. export default {
  100. components: { SearchQuery },
  101. props: {
  102. pid: {},
  103. assemblyForm: {
  104. type: Object,
  105. default: {}
  106. },
  107. seeDisabled: {
  108. type: Boolean,
  109. default: false,
  110. },
  111. showLock: {
  112. type: Boolean,
  113. default: false
  114. }
  115. },
  116. data() {
  117. return {
  118. editStatus: false,
  119. dialogVisible: false,
  120. // 集装箱尺码箱型
  121. cntrTypeCodeData: [],
  122. containerNumberItemList: [],
  123. form: {},
  124. query: {},
  125. loading: false,
  126. page: {
  127. pageSize: 10,
  128. currentPage: 1,
  129. total: 0
  130. },
  131. selectionList: [],
  132. option: {},
  133. optionBack: {
  134. maxHeight: '150px',
  135. // calcHeight: 30,
  136. calcHeight: 30,
  137. menuWidth: 120,
  138. tip: false,
  139. border: true,
  140. addBtn: false,
  141. viewBtn: false,
  142. editBtn: false,
  143. delBtn: false,
  144. refreshBtn: false,
  145. selection: true,
  146. align: 'center',
  147. menu: true,
  148. index: true,
  149. column: [
  150. {
  151. label: "箱型",
  152. prop: "cntrTypeCode",
  153. formslot: true,
  154. cell: true,
  155. width: '120',
  156. rules: [{
  157. required: true,
  158. message: "请选择箱型",
  159. trigger: "blur"
  160. }]
  161. },
  162. {
  163. label: "箱量",
  164. prop: "quantity",
  165. type: "number",
  166. cell: true,
  167. controls: false,
  168. precision: 0,
  169. width: '120',
  170. rules: [{
  171. required: true,
  172. message: "请输入箱量",
  173. trigger: "blur"
  174. }]
  175. },
  176. {
  177. label: "件数",
  178. prop: "number",
  179. type: "number",
  180. width: '120',
  181. // cell:true,
  182. controls: false,
  183. precision: 0,
  184. },
  185. {
  186. label: "毛重(KGS)",
  187. prop: "grossWeight",
  188. width: '120',
  189. type: "number",
  190. // cell:true,
  191. controls: false,
  192. },
  193. {
  194. label: "净重(KGS)",
  195. prop: "netWeight",
  196. width: '120',
  197. type: "number",
  198. cell: true,
  199. controls: false,
  200. },
  201. {
  202. label: "体积(CBM)",
  203. prop: "measurement",
  204. width: '120',
  205. type: "number",
  206. // cell:true,
  207. controls: false,
  208. },
  209. {
  210. label: "温度",
  211. prop: "temperature",
  212. cell: true,
  213. controls: false,
  214. // type:"number",
  215. width: "120"
  216. },
  217. {
  218. label: "温度单位",
  219. prop: "temperatureUnit",
  220. type: 'select',
  221. cell: true,
  222. dicData: [{
  223. label: '摄氏度',
  224. value: 'C'
  225. }, {
  226. label: '华氏度',
  227. value: 'F'
  228. }]
  229. },
  230. {
  231. label: "通风度",
  232. prop: "ventilation",
  233. cell: true,
  234. controls: false,
  235. // type:"number",
  236. width: "120"
  237. },
  238. {
  239. label: "湿度",
  240. prop: "humidity",
  241. cell: true,
  242. controls: false,
  243. // type:"number",
  244. width: "120"
  245. },
  246. {
  247. label: "SOC",
  248. prop: "isSoc",
  249. width: '120',
  250. type: 'select',
  251. cell: true,
  252. dicData: [{
  253. label: '否',
  254. value: 0
  255. }, {
  256. label: '是',
  257. value: 1
  258. }]
  259. },
  260. {
  261. label: "单程",
  262. prop: "isOneway",
  263. type: 'select',
  264. cell: true,
  265. dicData: [{
  266. label: '否',
  267. value: 0
  268. }, {
  269. label: '是',
  270. value: 1
  271. }]
  272. },
  273. {
  274. label: "NOR",
  275. prop: "nor",
  276. width: '100',
  277. type: 'select',
  278. cell: true,
  279. dicData: [{
  280. label: '否',
  281. value: 0
  282. }, {
  283. label: '是',
  284. value: 1
  285. }]
  286. },
  287. {
  288. label: "OOG",
  289. prop: "oog",
  290. width: '120',
  291. type: 'select',
  292. cell: true,
  293. dicData: [{
  294. label: '否',
  295. value: 0
  296. }, {
  297. label: '是',
  298. value: 1
  299. }]
  300. },
  301. {
  302. label: "左超(CM)",
  303. prop: "overLeft",
  304. type: "number",
  305. cell: true,
  306. controls: false,
  307. },
  308. {
  309. label: "右超(CM)",
  310. prop: "overRight",
  311. type: "number",
  312. cell: true,
  313. controls: false,
  314. },
  315. {
  316. label: "前超(CM)",
  317. prop: "overFront",
  318. type: "number",
  319. cell: true,
  320. controls: false,
  321. },
  322. {
  323. label: "后超(CM)",
  324. prop: "overBack",
  325. type: "number",
  326. cell: true,
  327. controls: false,
  328. },
  329. {
  330. label: "超高(CM)",
  331. prop: "overHeight",
  332. type: "number",
  333. cell: true,
  334. controls: false,
  335. },
  336. {
  337. label: "备注",
  338. prop: "remarks",
  339. span: 24,
  340. type: 'textarea',
  341. slot: true,
  342. minRows: 3,
  343. },
  344. ]
  345. },
  346. data: [],
  347. containerOption: {},
  348. containerOptionBack: {
  349. height: '500',
  350. // calcHeight: 30,
  351. calcHeight: 30,
  352. menuWidth: 160,
  353. tip: false,
  354. border: true,
  355. addBtn: false,
  356. viewBtn: false,
  357. editBtn: false,
  358. delBtn: false,
  359. refreshBtn: false,
  360. align: 'center',
  361. menu: false,
  362. index: true,
  363. column: [
  364. {
  365. label: "放箱号",
  366. prop: "containerNumber",
  367. width: 100,
  368. overHidden: true,
  369. },
  370. {
  371. label: "内部放箱号",
  372. prop: "internalContainerNumber",
  373. width: 100,
  374. overHidden: true,
  375. },
  376. {
  377. label: "放箱号类型",
  378. prop: "busType",
  379. width: 100,
  380. overHidden: true,
  381. },
  382. {
  383. label: "场站",
  384. prop: "polStationCname",
  385. width: 100,
  386. overHidden: true,
  387. },
  388. {
  389. label: "箱型",
  390. prop: "boxType",
  391. width: 100,
  392. overHidden: true,
  393. },
  394. {
  395. label: "可用箱数",
  396. prop: "remainingNum",
  397. width: 100,
  398. overHidden: true,
  399. },
  400. {
  401. label: "占用箱量",
  402. prop: "occupyNum",
  403. width: 100,
  404. overHidden: true,
  405. },
  406. {
  407. label: "优先等级",
  408. prop: "priorityLevel",
  409. width: 100,
  410. overHidden: true,
  411. },
  412. {
  413. label: "箱管备注",
  414. prop: "boxRemarks",
  415. width: 100,
  416. overHidden: true,
  417. },
  418. {
  419. label: "备注",
  420. prop: "remarks",
  421. width: 100,
  422. overHidden: true,
  423. },
  424. ]
  425. },
  426. };
  427. },
  428. computed: {
  429. ...mapGetters(["permission"]),
  430. permissionList() {
  431. return {
  432. addBtn: this.vaildData(this.permission.precontainers_add, false),
  433. viewBtn: this.vaildData(this.permission.precontainers_view, false),
  434. delBtn: this.vaildData(this.permission.precontainers_delete, false),
  435. editBtn: this.vaildData(this.permission.precontainers_edit, false)
  436. };
  437. },
  438. ids() {
  439. let ids = [];
  440. this.selectionList.forEach(ele => {
  441. ids.push(ele.id);
  442. });
  443. return ids.join(",");
  444. }
  445. },
  446. async created() {
  447. this.option = await this.getColumnData(this.getColumnName(487), this.optionBack);
  448. this.containerOption = await this.getColumnData(this.getColumnName(488), this.containerOptionBack);
  449. },
  450. methods: {
  451. submit() {
  452. // let obj = {
  453. // containerNumberItemList:
  454. // }
  455. // for (let item of ) {
  456. // if (!(item.occupyNum > 0)) {
  457. // return this.$message.error("占用箱量必须大于0!");
  458. // }
  459. // }
  460. if (this.containerNumberItemList.filter(item => item.occupyNum > 0).length == 0) {
  461. return this.$message.error("至少有一条占用箱量大于0!");
  462. }
  463. selectedContainerNumber(this.containerNumberItemList).then(res => {
  464. this.$message.success("操作成功!");
  465. this.dialogVisible = false
  466. this.$emit('billsDetailfun')
  467. })
  468. },
  469. pick(row) {
  470. this.containerNumberItemList = []
  471. if (!this.assemblyForm.polId) {
  472. return this.$message.error("请选择装货港");
  473. }
  474. if (!this.assemblyForm.podId) {
  475. return this.$message.error("请选择卸货港");
  476. }
  477. let obj = {
  478. boxType: row.cntrTypeCode,
  479. polId: this.assemblyForm.polId,
  480. podId: this.assemblyForm.podId,
  481. cabinType: this.assemblyForm.cabinType,
  482. airlineId: this.assemblyForm.airlineId,
  483. etd: this.assemblyForm.etd + ' 00:00:00',
  484. }
  485. getItemListHY(obj).then(res => {
  486. if (res.data.data) {
  487. res.data.data.forEach(item => {
  488. item.pid = this.assemblyForm.id
  489. })
  490. this.editStatus = true
  491. this.containerNumberItemList = res.data.data
  492. }
  493. })
  494. this.dialogVisible = true
  495. },
  496. rowRevoke(row) {
  497. let obj = {
  498. boxType: row.cntrTypeCode,
  499. billId: this.assemblyForm.id
  500. }
  501. revokeSelectedContainerNumber(obj).then(res => {
  502. this.$message.success("操作成功!");
  503. this.$emit('billsDetailfun')
  504. })
  505. },
  506. rowView(row) {
  507. this.containerNumberItemList = []
  508. this.editStatus = false
  509. this.dialogVisible = true
  510. this.containerNumberItemList = this.assemblyForm.containerNumberItemList.filter(item => row.cntrTypeCode == item.boxType && item.occupyNum > 0)
  511. },
  512. handleClose() {
  513. this.dialogVisible = false
  514. this.editStatus = false
  515. },
  516. onclickEdit() {
  517. // for (let item of this.assemblyForm.preContainersList) {
  518. // if(item.containerNumberStatus == '已选择'){
  519. // return this.$message.error('请撤销放箱号,再进行编辑!')
  520. // }else{
  521. // this.$delete(item, '$cellEdit')
  522. // this.$set(item, '$cellEdit', true)
  523. // }
  524. // }
  525. console.log()
  526. if (this.assemblyForm.containersList.length > 0) {
  527. this.$alert('当前数据已经均分箱量,请撤销之后再修改', '提示', {
  528. confirmButtonText: '确定',
  529. });
  530. } else {
  531. for (let item of this.assemblyForm.preContainersList) {
  532. this.$delete(item, '$cellEdit')
  533. this.$set(item, '$cellEdit', true)
  534. }
  535. }
  536. },
  537. // 件数失焦事件
  538. numberBlur(row) {
  539. let quantityNum = 0
  540. for (let item of this.assemblyForm.preContainersList) {
  541. if (item.number) {
  542. quantityNum += Number(item.number)
  543. }
  544. }
  545. if (quantityNum != 0) {
  546. this.assemblyForm.quantity = quantityNum
  547. }
  548. },
  549. // 毛重失焦事件
  550. grossWeightBlur(row) {
  551. let grossWeightNum = 0
  552. for (let item of this.assemblyForm.preContainersList) {
  553. if (item.grossWeight) {
  554. grossWeightNum += Number(item.grossWeight)
  555. }
  556. }
  557. if (grossWeightNum != 0) {
  558. this.assemblyForm.grossWeight = grossWeightNum
  559. }
  560. },
  561. // 尺码失焦事件
  562. measurementBlur(row) {
  563. let measurementNum = 0
  564. for (let item of this.assemblyForm.preContainersList) {
  565. if (item.measurement) {
  566. measurementNum += Number(item.measurement)
  567. }
  568. }
  569. if (measurementNum != 0) {
  570. this.assemblyForm.measurement = measurementNum
  571. }
  572. },
  573. // 一键编辑
  574. oneTouchEditefun() {
  575. for (let item of this.assemblyForm.preContainersList) {
  576. this.$refs.crud.rowCell(item, item.$index)
  577. }
  578. console.log(this.assemblyForm.preContainersList, 294)
  579. // $cellEdit
  580. },
  581. // 批量保存
  582. batchSavefun() {
  583. if (!this.assemblyForm.id) {
  584. this.$message({
  585. message: '请先点击右上角保存按钮,保存数据之后才能添加!',
  586. type: 'warning'
  587. });
  588. return
  589. }
  590. // let numberSum = 0
  591. // let grossWeightSum = 0
  592. // let measurementSum = 0
  593. // for (let item of this.assemblyForm.preContainersList) {
  594. // numberSum += Number(item.number)
  595. // grossWeightSum += Number(item.grossWeight)
  596. // measurementSum += Number(item.measurement)
  597. // if (!item.cntrTypeCode) {
  598. // this.$message.warning('请选择尺码箱型')
  599. // return;
  600. // }
  601. // if (!item.quantity) {
  602. // this.$message.warning('请输入箱量')
  603. // return;
  604. // }
  605. // item.pid = this.assemblyForm.id
  606. // }
  607. // if (numberSum>0&&(numberSum != this.assemblyForm.quantity)) return this.$message.error('箱型所有的件数不等于总件数')
  608. // this.$confirm("批量保存后,需要重新配箱,确认继续?", {
  609. // confirmButtonText: "确定",
  610. // cancelButtonText: "取消",
  611. // type: "warning"
  612. // }).then(() => {
  613. // precontainersSubmitList(this.assemblyForm.preContainersList).then(res => {
  614. // this.$message({
  615. // type: "success",
  616. // message: "操作成功!"
  617. // });
  618. // this.$emit('billsDetailfun')
  619. // })
  620. // })
  621. // assemblyForm.containersList
  622. for (let item of this.assemblyForm.preContainersList) {
  623. if (this.assemblyForm.containersList.filter(e => item.cntrTypeCode == e.cntrTypeCode).length != item.quantity) {
  624. this.$confirm("箱型箱量改变,请检查预录费用信息?", {
  625. confirmButtonText: "确定",
  626. cancelButtonText: "取消",
  627. showCancelButton: false,
  628. type: "error"
  629. }).then(() => {
  630. precontainersSubmitList(this.assemblyForm.preContainersList).then(res => {
  631. this.$message({
  632. type: "success",
  633. message: "操作成功!"
  634. });
  635. this.$emit('billsDetailfun')
  636. })
  637. })
  638. return
  639. }
  640. }
  641. precontainersSubmitList(this.assemblyForm.preContainersList).then(res => {
  642. this.$message({
  643. type: "success",
  644. message: "操作成功!"
  645. });
  646. this.$emit('billsDetailfun')
  647. })
  648. },
  649. // 平均箱量
  650. equalDistribution(type) {
  651. if (!this.assemblyForm.id) {
  652. this.$message({
  653. message: '请先点击右上角保存按钮,保存数据之后才能添加!',
  654. type: 'warning'
  655. });
  656. return
  657. }
  658. if (this.assemblyForm.waitingBoxList.length <= 0) {
  659. this.$message({
  660. type: "warning",
  661. message: "请先添加集装箱数据!"
  662. });
  663. return
  664. }
  665. if (this.assemblyForm.preContainersList <= 0) {
  666. this.$message({
  667. type: "warning",
  668. message: "请先添加箱型数据!"
  669. });
  670. return
  671. }
  672. this.$confirm("确定平均分配?", {
  673. confirmButtonText: "确定",
  674. cancelButtonText: "取消",
  675. type: "warning"
  676. }).then(() => {
  677. this.containersEqualDistributionfun(type)
  678. })
  679. },
  680. // 平均分配接口
  681. containersEqualDistributionfun(type) {
  682. containersEqualDistribution({
  683. pid: this.assemblyForm.id,
  684. type: type,
  685. waitingBox: this.assemblyForm.waitingBoxList[0]
  686. }).then(res => {
  687. if (res.data.data instanceof Array) {
  688. this.$message({
  689. type: "success",
  690. message: "操作成功!"
  691. })
  692. this.$emit('billsDetailfun')
  693. } else {
  694. // 没有除开
  695. this.$message({
  696. type: 'warning',
  697. dangerouslyUseHTMLString: true,
  698. message: '<span style="color:red">注意!!!件数不能平均分 ,请手工配箱,或者修改件数.</span>\n' +
  699. '<table border="1">\n' +
  700. ' <thead>\n' +
  701. ' <tr>\n' +
  702. ' <th></th>\n' +
  703. ' <th>件数</th>\n' +
  704. ' <th>毛重</th>\n' +
  705. ' <th>尺码</th>\n' +
  706. ' </tr>\n' +
  707. ' </thead>\n' +
  708. ' <tbody>\n' +
  709. ' <tr>\n' +
  710. ' <td>总数</td>\n' +
  711. ' <td>' + res.data.data.total.quantity + '</td>\n' +
  712. ' <td>' + res.data.data.total.grossWeight + '</td>\n' +
  713. ' <td>' + res.data.data.total.grossWeight + '</td>\n' +
  714. ' </tr>\n' +
  715. ' <tr>\n' +
  716. ' <td>入箱</td>\n' +
  717. ' <td>' + res.data.data.average.quantity + '</td>\n' +
  718. ' <td>' + res.data.data.average.grossWeight + '</td>\n' +
  719. ' <td>' + res.data.data.average.grossWeight + '</td>\n' +
  720. ' </tr>\n' +
  721. ' <tr>\n' +
  722. ' <td>差额</td>\n' +
  723. ' <td>' + res.data.data.subtract.quantity + '</td>\n' +
  724. ' <td>' + res.data.data.subtract.grossWeight + '</td>\n' +
  725. ' <td>' + res.data.data.subtract.grossWeight + '</td>\n' +
  726. ' </tr>\n' +
  727. ' </tbody>\n' +
  728. '</table>',
  729. duration: 5000
  730. });
  731. }
  732. })
  733. },
  734. corpClear(value, row) {
  735. this.$set(row, 'cntrTypeCode', null)
  736. this.$set(row, 'cntrTypeCodeId', null)
  737. this.$set(row, 'teu', null)
  738. },
  739. // 选择框的回调
  740. corpChange(value, row) {
  741. if (this.assemblyForm.preContainersList.filter(e => value == e.cntrTypeCode).length) {
  742. this.$set(row, 'cntrTypeCode', null)
  743. this.$set(row, 'cntrTypeCodeId', null)
  744. this.$set(row, 'teu', null)
  745. return this.$message.error('箱型不能重复')
  746. }
  747. for (let item of this.cntrTypeCodeData) {
  748. if (item.cnName == value) {
  749. this.$set(row, 'cntrTypeCode', item.cnName)
  750. this.$set(row, 'cntrTypeCodeId', item.id)
  751. this.$set(row, 'teu', item.teu)
  752. }
  753. }
  754. },
  755. // 筛选数据模糊查找
  756. remoteMethod(value, name) {
  757. this.bcntrtypesListfun(value)
  758. },
  759. // 获取箱型字典数据
  760. bcntrtypesListfun(cnName) {
  761. bcntrtypesList(1, 10, { cnName }).then(res => {
  762. this.cntrTypeCodeData = res.data.data.records
  763. })
  764. },
  765. // 添加按钮确认
  766. rowSave(row, done, loading) {
  767. row.pid = this.pid
  768. // 如果是冻柜,则需要输入相应的通度和温度、温度,如果不是冻柜,不需要输入相应的温度等内容;
  769. if (this.assemblyForm.cargoType == 'reefer') {
  770. // 要判断的必填
  771. const arr = [
  772. {
  773. name: "温度",
  774. value: "temperature",
  775. },
  776. {
  777. name: "温度单位",
  778. value: "temperatureUnit",
  779. },
  780. {
  781. name: "通风度",
  782. value: "ventilation",
  783. },
  784. {
  785. name: "湿度",
  786. value: "humidity",
  787. },
  788. ]
  789. if (!requiredMessage(row, arr)) {
  790. loading(); // 按钮的禁用关闭
  791. return;
  792. }
  793. }
  794. precontainersSubmit(row).then(() => {
  795. this.$message({
  796. type: "success",
  797. message: "操作成功!"
  798. });
  799. this.$emit('billsDetailfun')
  800. done();
  801. }, error => {
  802. loading();
  803. window.console.log(error);
  804. });
  805. },
  806. // 编辑确认按钮
  807. rowUpdate(row, index) {
  808. let rulesRow = [
  809. {
  810. name: "尺码箱型",
  811. value: "cntrTypeCode",
  812. },
  813. {
  814. name: "箱量",
  815. value: "quantity",
  816. },
  817. ]
  818. if (!requiredMessage(row, rulesRow)) {
  819. return;
  820. }
  821. // 如果是冻柜,则需要输入相应的通度和温度、温度,如果不是冻柜,不需要输入相应的温度等内容;
  822. if (this.assemblyForm.cargoType == 'reefer') {
  823. // 要判断的必填
  824. const arr = [
  825. {
  826. name: "温度",
  827. value: "temperature",
  828. },
  829. {
  830. name: "温度单位",
  831. value: "temperatureUnit",
  832. },
  833. {
  834. name: "通风度",
  835. value: "ventilation",
  836. },
  837. {
  838. name: "湿度",
  839. value: "humidity",
  840. },
  841. ]
  842. if (!requiredMessage(row, arr)) {
  843. return;
  844. }
  845. }
  846. if (!this.pid) {
  847. this.$message({
  848. message: '请先保存数据之后才能添加',
  849. type: 'warning'
  850. });
  851. return
  852. }
  853. if (row.id) {
  854. this.$confirm("已经存在配箱信息,如果修改预配箱数据 要清除全部配箱信息?", {
  855. confirmButtonText: "确定",
  856. cancelButtonText: "取消",
  857. type: "warning"
  858. }).then(() => {
  859. precontainersSubmit(row).then(() => {
  860. this.$message({
  861. type: "success",
  862. message: "操作成功!"
  863. });
  864. this.$set(row, '$cellEdit', false)
  865. this.$emit('billsDetailfun')
  866. })
  867. })
  868. } else {
  869. row.pid = this.pid
  870. precontainersSubmit(row).then(() => {
  871. this.$message({
  872. type: "success",
  873. message: "操作成功!"
  874. });
  875. this.$set(row, '$cellEdit', false)
  876. this.$emit('billsDetailfun')
  877. }, error => {
  878. console.log(error);
  879. });
  880. }
  881. },
  882. rowDel(row) {
  883. this.$confirm("确定将选择数据删除?", {
  884. confirmButtonText: "确定",
  885. cancelButtonText: "取消",
  886. type: "warning"
  887. })
  888. .then(() => {
  889. if (!row.id) {
  890. this.$message({
  891. type: "success",
  892. message: "操作成功!"
  893. });
  894. this.assemblyForm.preContainersList.splice(row.$index, 1)
  895. } else {
  896. precontainersRemove(row.id).then(() => {
  897. this.$message({
  898. type: "success",
  899. message: "操作成功!"
  900. });
  901. this.$emit('billsDetailfun')
  902. });
  903. }
  904. })
  905. },
  906. // 新增
  907. addfun() {
  908. this.$refs.crud.rowCellAdd({ pid: this.assemblyForm.id })
  909. // this.$refs.crud.rowAdd()
  910. },
  911. // 编辑
  912. editfun(row, index) {
  913. if (row.$cellEdit) {
  914. // 保存
  915. this.rowUpdate(row, index)
  916. // this.$set(row,'$cellEdit',false)
  917. } else {
  918. if (!this.assemblyForm.id) {
  919. this.$set(row, '$cellEdit', true)
  920. return
  921. }
  922. if (Number(this.assemblyForm.quantity) != Number(this.assemblyForm.waitingBoxList[0].quantity)) {
  923. this.$alert('当前数据已经均分箱量,请撤销之后再修改', '提示', {
  924. confirmButtonText: '确定',
  925. });
  926. } else {
  927. this.$set(row, '$cellEdit', true)
  928. }
  929. }
  930. // this.$refs.crud.rowEdit(row,index)
  931. },
  932. // 多选删除
  933. handleDelete() {
  934. if (this.selectionList.length === 0) {
  935. this.$message.warning("请选择至少一条数据");
  936. return;
  937. }
  938. this.$confirm("确定将选择数据删除?", {
  939. confirmButtonText: "确定",
  940. cancelButtonText: "取消",
  941. type: "warning"
  942. })
  943. .then(() => {
  944. this.precontainersRemovefun()
  945. })
  946. },
  947. // 删除接口
  948. precontainersRemovefun() {
  949. let multiList = this.selectionList
  950. let arr = this.assemblyForm.preContainersList
  951. // 获取有id 的数据
  952. const itemsWithId = multiList.filter(item => item.hasOwnProperty('id'));
  953. let arrIds = itemsWithId.map(item => item.id) // 获取id 数据
  954. // 把选中的删除掉
  955. multiList.forEach((item) => {
  956. for (let index in arr) {
  957. if (JSON.stringify(item) == JSON.stringify(arr[index])) {
  958. arr.splice(Number(index), 1)
  959. }
  960. }
  961. })
  962. // 有id 的处理
  963. if (itemsWithId.length != 0) {
  964. precontainersRemove(arrIds.join(',')).then(() => {
  965. this.$message({
  966. type: "success",
  967. message: "操作成功!"
  968. });
  969. // this.$emit('billsDetailfun')
  970. this.$refs.crud.toggleSelection();
  971. })
  972. };
  973. },
  974. beforeOpen(done, type) {
  975. if (["edit", "view"].includes(type)) {
  976. precontainersDetail(this.form.id).then(res => {
  977. this.form = res.data.data;
  978. });
  979. }
  980. done();
  981. },
  982. selectionChange(list) {
  983. this.selectionList = list;
  984. },
  985. selectionClear() {
  986. this.selectionList = [];
  987. this.$refs.crud.toggleSelection();
  988. },
  989. refreshChange() {
  990. console.log('刷新')
  991. },
  992. //自定义列保存
  993. async saveColumnTwo(ref, option, optionBack, code) {
  994. /**
  995. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  996. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  997. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  998. */
  999. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  1000. if (inSave) {
  1001. this.$message.success("保存成功");
  1002. //关闭窗口
  1003. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  1004. }
  1005. },
  1006. //自定义列重置
  1007. async resetColumnTwo(ref, option, optionBack, code) {
  1008. this[option] = this[optionBack];
  1009. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  1010. if (inSave) {
  1011. this.$message.success("重置成功");
  1012. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  1013. }
  1014. },
  1015. }
  1016. };
  1017. </script>
  1018. <style scoped lang="scss">
  1019. ::v-deep .el-dialog__body {
  1020. padding: 0px 10px !important;
  1021. }
  1022. </style>