precontainers.vue 37 KB

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