containers.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. <template>
  2. <div>
  3. <avue-crud
  4. :option="option"
  5. :table-loading="loading"
  6. :data="assemblyForm.containersList"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. id="out-table"
  11. :header-cell-class-name="headerClassName"
  12. ref="crud"
  13. :row-style="{ height: '20px' }"
  14. :cell-style="{ padding: '0px' }"
  15. @row-update="rowUpdate"
  16. @row-save="rowSave"
  17. @row-del="rowDel"
  18. @selection-change="selectionChange"
  19. @refresh-change="refreshChange"
  20. >
  21. <template slot="menuLeft">
  22. <div style="display: flex;align-items: center;justify-content: space-between">
  23. <div>
  24. <!--<el-button type="primary" size="small" @click="DistributionBox">配箱</el-button>-->
  25. <el-button type="success" size="small" plain :disabled="seeDisabled || pleasereviewType || showLock" @click.stop="equalDistribution2()"
  26. >配箱
  27. </el-button>
  28. <!-- <el-button type="success" size="small" plain :disabled="seeDisabled||pleasereviewType||showLock"
  29. @click.stop="equalDistribution(1)">按TEU配箱
  30. </el-button>
  31. <el-button type="success" size="small" plain :disabled="seeDisabled||pleasereviewType||showLock"
  32. @click.stop="equalDistribution(2)">按箱量配箱
  33. </el-button> -->
  34. <el-button
  35. type="primary"
  36. size="small"
  37. :disabled="detailData.seeDisabled || pleasereviewType || showLock || assemblyForm.containersList.length == 0"
  38. @click="rootEditfun"
  39. >一键编辑
  40. </el-button>
  41. <el-button
  42. type="primary"
  43. size="small"
  44. :disabled="detailData.seeDisabled || pleasereviewType || showLock || assemblyForm.containersList.length == 0"
  45. @click="containersSubmitListfun"
  46. >一键保存
  47. </el-button>
  48. <el-button
  49. type="success"
  50. size="small"
  51. :disabled="detailData.seeDisabled || !assemblyForm.id || pleasereviewType || showLock"
  52. @click="oepnexcelBox"
  53. >导入箱号铅封号
  54. </el-button>
  55. <!-- <el-button type="success" size="small" :loading="loadingButton"
  56. :disabled="detailData.seeDisabled || !assemblyForm.id || pleasereviewType || showLock"
  57. @click="extractBoxInformation">提取箱信息
  58. </el-button> -->
  59. <el-button
  60. type="warning"
  61. size="small"
  62. :disabled="detailData.seeDisabled || pleasereviewType || showLock || assemblyForm.containersList.length == 0"
  63. @click="cleanCntrNofun"
  64. >清除箱号
  65. </el-button>
  66. <el-button
  67. type="danger"
  68. size="small"
  69. :disabled="detailData.seeDisabled || pleasereviewType || showLock || assemblyForm.containersList.length == 0"
  70. @click="revokefun"
  71. >清除件重尺
  72. </el-button>
  73. <el-button
  74. type="danger"
  75. size="small"
  76. :disabled="detailData.seeDisabled || pleasereviewType || showLock || assemblyForm.containersList.length == 0"
  77. @click="wholeRevokefun"
  78. >清除全部件重尺
  79. </el-button>
  80. <el-button
  81. type="danger"
  82. size="small"
  83. :disabled="detailData.seeDisabled || pleasereviewType || showLock || assemblyForm.containersList.length == 0"
  84. @click="handleDelete"
  85. >删除配箱
  86. </el-button>
  87. </div>
  88. </div>
  89. </template>
  90. <template slot-scope="scope" slot="menu">
  91. <el-button v-if="scope.row.edit" :type="scope.type" :size="scope.size" icon="el-icon-edit" @click.stop="rowSavefun(scope.row, scope.index)"
  92. >保存
  93. </el-button>
  94. <el-button
  95. v-else
  96. :type="scope.type"
  97. :size="scope.size"
  98. icon="el-icon-edit"
  99. :disabled="detailData.seeDisabled || pleasereviewType || showLock"
  100. @click.stop="rowCellfun(scope.row, scope.index)"
  101. >编辑
  102. </el-button>
  103. <el-button
  104. :type="scope.type"
  105. :size="scope.size"
  106. icon="el-icon-delete"
  107. :disabled="detailData.seeDisabled || pleasereviewType || showLock"
  108. @click.stop="rowDel(scope.row, scope.index)"
  109. >删除
  110. </el-button>
  111. </template>
  112. <template slot-scope="scope" slot="cntrNo">
  113. <el-input
  114. v-if="scope.row.edit"
  115. v-model="scope.row.cntrNo"
  116. maxlength="11"
  117. size="small"
  118. clearable
  119. placeholder="请输入箱号"
  120. @input="cntrNoInput(scope.row, 'cntrNo')"
  121. @change="verifyChange(scope.row, 'cntrNo')"
  122. ></el-input>
  123. <span v-else>{{ scope.row.cntrNo }}</span>
  124. </template>
  125. <template slot-scope="scope" slot="sealNo">
  126. <el-input
  127. v-if="scope.row.edit"
  128. v-model="scope.row.sealNo"
  129. maxlength="11"
  130. size="small"
  131. clearable
  132. placeholder="请输入封号"
  133. @input="cntrNoInput(scope.row, 'sealNo')"
  134. ></el-input>
  135. <span v-else>{{ scope.row.sealNo }}</span>
  136. </template>
  137. <template slot-scope="scope" slot="quantity">
  138. <el-input v-if="scope.row.edit" v-model="scope.row.quantity" size="small" clearable placeholder="请输入件数"></el-input>
  139. <span v-else>{{ Number(scope.row.quantity).toFixed(0) }}</span>
  140. </template>
  141. <template slot-scope="scope" slot="grossWeight">
  142. <el-input
  143. v-if="scope.row.edit"
  144. v-model="scope.row.grossWeight"
  145. size="small"
  146. clearable
  147. placeholder="请输入毛重"
  148. @change="computeChange(scope.row)"
  149. ></el-input>
  150. <span v-else>{{ scope.row.grossWeight }}</span>
  151. </template>
  152. <template slot-scope="scope" slot="netWeight">
  153. <el-input v-if="scope.row.edit" v-model="scope.row.netWeight" size="small" clearable placeholder="请输入净重"></el-input>
  154. <span v-else>{{ scope.row.netWeight }}</span>
  155. </template>
  156. <template slot-scope="scope" slot="measurement">
  157. <el-input v-if="scope.row.edit" v-model="scope.row.measurement" size="small" clearable placeholder="请输入尺码"></el-input>
  158. <span v-else>{{ scope.row.measurement }}</span>
  159. </template>
  160. <template slot-scope="scope" slot="remarks">
  161. <el-input v-if="scope.row.edit" v-model="scope.row.remarks" size="small" clearable placeholder="请输入备注"></el-input>
  162. <span v-else>{{ scope.row.remarks }}</span>
  163. </template>
  164. <template slot-scope="scope" slot="marks">
  165. <el-input v-if="scope.row.edit" v-model="scope.row.marks" size="small" clearable placeholder="请输入MARKS"></el-input>
  166. <span v-else>{{ scope.row.marks }}</span>
  167. </template>
  168. <template slot-scope="{ row }" slot="tare">
  169. <el-input v-if="row.edit" v-model="row.tare" size="small" clearable placeholder="请输入箱皮重" @change="computeChange(row)"></el-input>
  170. <span v-else>{{ row.tare }}</span>
  171. </template>
  172. <!-- <template slot-scope="{row}" slot="vgmWeight">
  173. <el-input v-if="row.edit" v-model="row.vgmWeight" size="small" clearable
  174. placeholder="请输入VGM总重(KGM)"></el-input>
  175. <span v-else>{{ row.vgmWeight }}</span>
  176. </template> -->
  177. <tempalte slot="podStationCname" slot-scope="{ row }">
  178. <dic-select
  179. v-if="row.edit"
  180. v-model="row.podStationCname"
  181. placeholder="目的港还箱场站"
  182. label="cnName"
  183. res="records"
  184. url="/blade-los/bcorps/selectList?current=1&size=5&corpTypeName=POD堆场&status=0"
  185. :filterable="true"
  186. :remote="true"
  187. dataName="cnName"
  188. @selectChange="rowDicChange('podStationCname', $event, row)"
  189. :slotRight="true"
  190. rightLabel="code"
  191. ></dic-select>
  192. <span v-else>{{ row.podStationCname }}</span>
  193. </tempalte>
  194. </avue-crud>
  195. <el-dialog title="导入箱号,铅封号" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false" v-dialog-drag>
  196. <avue-form :option="excelOption" v-model="excelForm" :table-loading="excelLoading" :upload-before="uploadBefore" :upload-after="onSuccess">
  197. <template slot="excelTemplate">
  198. <el-button type="primary" @click="handleGet"> 点击下载<i class="el-icon-download el-icon--right"></i> </el-button>
  199. </template>
  200. </avue-form>
  201. <p style="text-align: center;color: #DC0505">
  202. 温馨提示 第一次导入时请先下载模板
  203. </p>
  204. </el-dialog>
  205. <!--提取的数据展示框-->
  206. <el-dialog
  207. append-to-body
  208. title="预览数据"
  209. class="el-dialogDeep"
  210. :visible.sync="extractDialogvisible"
  211. width="80%"
  212. :close-on-click-modal="false"
  213. :destroy-on-close="true"
  214. :close-on-press-escape="false"
  215. v-dialog-drag
  216. >
  217. <extract-box-information :luHaiTongData="luHaiTongData"></extract-box-information>
  218. <span slot="footer" class="dialog-footer">
  219. <el-button @click="extractDialogvisible = false">取 消</el-button>
  220. <el-button type="primary" @click="extractDialogfun">导 入</el-button>
  221. </span>
  222. </el-dialog>
  223. <business-reports
  224. :id="assemblyForm.id"
  225. :itemIds="itemIds"
  226. ref="print"
  227. businessValue="HYCK"
  228. classifyCode="业务"
  229. groupCode="配箱预览"
  230. :treeType="false"
  231. :type="1"
  232. ></business-reports>
  233. </div>
  234. </template>
  235. <script>
  236. import {
  237. containersDetail,
  238. containersSubmit,
  239. containersRemove,
  240. containersCleanBoxNo,
  241. containersRevoke,
  242. containersEqualDistribution,
  243. distributionBox,
  244. containersSubmitList,
  245. containersExportContainers,
  246. containersImportBoxNo,
  247. containersList,
  248. luHaiTongApiDetail
  249. } from "@/api/iosBasicData/containers";
  250. import { submit } from "@/api/iosBasicData/businessCenter/bookingCabin.js";
  251. import { getAccurate } from "@/api/boxManagement/buyContainer/index.js";
  252. import { mapGetters } from "vuex";
  253. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  254. import bports from "@/views/iosBasicData/bports/index.vue";
  255. import { bportsList } from "@/api/iosBasicData/bports";
  256. import { getToken } from "@/util/auth";
  257. import { decryptLhtData } from "@/util/lhtDataDesc";
  258. import extractBoxInformation from "@/views/iosBasicData/SeafreightExportF/bills/assembly/DistributionBox/extractBoxInformation.vue";
  259. import { billsAdd } from "@/api/iosBasicData/bills";
  260. import dicSelect from "@/components/dicSelect/main";
  261. import businessReports from "@/components/tradeAgency/businessReportsJK.vue";
  262. export default {
  263. components: { SearchQuery, bports, extractBoxInformation, dicSelect, businessReports },
  264. props: {
  265. assemblyForm: {},
  266. detailData: {},
  267. // 请核禁用
  268. pleasereviewType: {
  269. type: Boolean,
  270. default: false
  271. },
  272. showLock: {
  273. type: Boolean,
  274. default: false
  275. }
  276. },
  277. data() {
  278. return {
  279. headers: { "Blade-Auth": "Bearer " + getToken() },
  280. // 是否禁用
  281. extendedDisabled: false,
  282. // 装货港数据
  283. polData: [],
  284. // 附件配置
  285. excelOption: {
  286. submitBtn: false,
  287. emptyBtn: false,
  288. column: [
  289. {
  290. label: "模板下载",
  291. prop: "excelTemplate",
  292. formslot: true,
  293. span: 24
  294. },
  295. {
  296. label: "模板上传",
  297. prop: "excelFile",
  298. type: "upload",
  299. drag: true,
  300. loadText: "模板上传中,请稍等",
  301. span: 24,
  302. propsHttp: {
  303. res: "data"
  304. },
  305. tip: "请上传 .xls,.xlsx 标准格式文件",
  306. action: "/api/blade-los/containers/importBoxNo"
  307. }
  308. ]
  309. },
  310. excelForm: {},
  311. excelLoading: false,
  312. excelBox: false,
  313. form: {},
  314. query: {},
  315. loading: false,
  316. loadingButton: false,
  317. // page: {
  318. // pageSize: 10,
  319. // currentPage: 1,
  320. // total: 0
  321. // },
  322. selectionList: [],
  323. option: {
  324. stripe: true,
  325. height: "250",
  326. calcHeight: 30,
  327. tip: false,
  328. searchShow: true,
  329. searchMenuSpan: 6,
  330. border: true,
  331. index: true,
  332. viewBtn: true,
  333. selection: true,
  334. dialogClickModal: false,
  335. refreshBtn: false,
  336. columnBtn: false,
  337. menu: false,
  338. column: [
  339. {
  340. label: "箱型",
  341. prop: "cntrTypeCode",
  342. width: "100"
  343. },
  344. {
  345. label: "箱号",
  346. prop: "cntrNo",
  347. width: "140",
  348. overHidden: true
  349. },
  350. {
  351. label: "封号",
  352. prop: "sealNo",
  353. width: "140",
  354. overHidden: true
  355. },
  356. {
  357. label: "件数",
  358. prop: "quantity",
  359. width: "100"
  360. },
  361. {
  362. label: "毛重(KGM)",
  363. prop: "grossWeight",
  364. width: "120"
  365. },
  366. // {
  367. // label: "净重(KGM)",
  368. // prop: "netWeight",
  369. // width: "120",
  370. // },
  371. {
  372. label: "尺码/体积(CBM)",
  373. prop: "measurement",
  374. width: "140"
  375. },
  376. {
  377. label: "箱皮重",
  378. prop: "tare",
  379. width: "140",
  380. overHidden: true
  381. },
  382. {
  383. label: "VGM总重(KGM)",
  384. prop: "vgmWeight",
  385. width: "140",
  386. overHidden: true
  387. },
  388. {
  389. label: "备注",
  390. prop: "remarks",
  391. type: "textarea",
  392. width: 180,
  393. slot: true,
  394. minRows: 3,
  395. span: 24
  396. }
  397. // {
  398. // label: "POD堆场",
  399. // prop: "podStationCname",
  400. // width: "140",
  401. // },
  402. // {
  403. // label: "MARKS",
  404. // prop: "marks",
  405. // },
  406. ]
  407. },
  408. data: [],
  409. luHaiTongData: [], // 提取请求到解析的数据
  410. extractDialogvisible: false // 提取请求到的数据展示
  411. };
  412. },
  413. computed: {
  414. ...mapGetters(["permission"]),
  415. permissionList() {
  416. return {
  417. addBtn: this.vaildData(this.permission.containers_add, false),
  418. viewBtn: this.vaildData(this.permission.containers_view, false),
  419. delBtn: this.vaildData(this.permission.containers_delete, false),
  420. editBtn: this.vaildData(this.permission.containers_edit, false)
  421. };
  422. },
  423. ids() {
  424. let ids = [];
  425. this.selectionList.forEach(ele => {
  426. ids.push(ele.id);
  427. });
  428. return ids.join(",");
  429. }
  430. },
  431. created() {},
  432. methods: {
  433. computeChange(row) {
  434. row.vgmWeight = Number(Number(row.grossWeight ? row.grossWeight : 0) + Number(row.tare ? row.tare : 0)).toFixed(3);
  435. },
  436. rowDicChange(name, row, el) {
  437. if (name == "podStationCname") {
  438. if (row) {
  439. el.podStationId = row.id;
  440. el.podStationCode = row.code;
  441. el.podStationEname = row.enName;
  442. } else {
  443. el.podStationId = null;
  444. el.podStationCode = null;
  445. el.podStationEname = null;
  446. el.podStationCname = null;
  447. }
  448. }
  449. },
  450. // 提取箱信息
  451. extractBoxInformation() {
  452. if (!this.assemblyForm.id) {
  453. return this.$message.warning("请先保存数据");
  454. }
  455. if (!this.assemblyForm.mblno) {
  456. return this.$message.warning("请先填写MB/L NO");
  457. }
  458. if (!this.assemblyForm.cyCode) {
  459. return this.$message.warning("请先选择场站");
  460. }
  461. if (this.assemblyForm.containersList.length == 0) {
  462. return this.$message.warning("请先进行配箱");
  463. }
  464. this.loadingButton = true;
  465. luHaiTongApiDetail({
  466. billNo: this.assemblyForm.mblno,
  467. station: this.assemblyForm.cyCode
  468. }).then(res => {
  469. this.loadingButton = false;
  470. this.luHaiTongData = decryptLhtData(JSON.parse(res.data.data).data);
  471. console.log(this.luHaiTongData, 348);
  472. if (this.luHaiTongData.containerCargoInfos.length == 0) {
  473. return this.$message.warning("提取到的数据为空");
  474. }
  475. this.extractDialogvisible = true;
  476. });
  477. },
  478. // 提取箱信息弹窗里的导入
  479. extractDialogfun() {
  480. // if (this.assemblyForm.containersList.length != this.luHaiTongData.containerCargoInfos.length) {
  481. // this.$confirm(`箱量不相等,委托数量为${this.assemblyForm.containersList.length},场站数量为${this.luHaiTongData.containerCargoInfos.length}?是否继续`, '提示', {
  482. // confirmButtonText: '确定',
  483. // cancelButtonText: '取消',
  484. // type: 'warning'
  485. // }).then(()=>{
  486. // this.extractionProcessing()
  487. // }).catch(()=>{
  488. // return
  489. // })
  490. // }else {
  491. // this.extractionProcessing()
  492. // }
  493. this.extractionProcessing();
  494. },
  495. // 数据处理
  496. extractionProcessing() {
  497. let returnType = 0; // 判断是否需要合计
  498. // 把请求到的箱号和封号赋值
  499. this.luHaiTongData.containerCargoInfos.map((luHaiTongItem, luHaiTongIndex) => {
  500. if (!this.assemblyForm.containersList[luHaiTongIndex].cyCntrCode) {
  501. return this.$message.warning("请先去基础资料集装箱里维护数据");
  502. }
  503. if (luHaiTongItem.size + "" + luHaiTongItem.property == this.assemblyForm.containersList[luHaiTongIndex].cyCntrCode) {
  504. this.assemblyForm.containersList[luHaiTongIndex].cntrNo = luHaiTongItem.containerNo;
  505. this.assemblyForm.containersList[luHaiTongIndex].sealNo = luHaiTongItem.sealNo;
  506. // 判断没有没有返厂时间,如果没有不合计前面的
  507. if (!luHaiTongItem.returnDate) {
  508. returnType++;
  509. }
  510. }
  511. });
  512. // 统计提取同一箱号的好件重尺合计赋值
  513. let quantitySum = 0;
  514. let grossWeightSum = 0;
  515. let measurementSum = 0;
  516. this.assemblyForm.containersList.map((containersItem, containersIndex) => {
  517. let numberSum = 0;
  518. let weightSum = 0;
  519. let volSum = 0;
  520. for (let loadingItem of this.luHaiTongData.loadingInfos) {
  521. if (loadingItem.containerNo == containersItem.cntrNo) {
  522. numberSum += loadingItem.number;
  523. weightSum += loadingItem.weight;
  524. volSum += loadingItem.vol;
  525. }
  526. }
  527. containersItem.quantity = numberSum;
  528. containersItem.grossWeight = weightSum;
  529. containersItem.measurement = volSum;
  530. // 把件重尺进行合计判断主表件重尺是否相等
  531. quantitySum += containersItem.quantity;
  532. grossWeightSum += containersItem.grossWeight;
  533. measurementSum += containersItem.measurement;
  534. });
  535. console.log(quantitySum, grossWeightSum, measurementSum, 366);
  536. // 判断合计的件重尺是否等于朱标的件重尺
  537. if (
  538. this.assemblyForm.containersList.length == this.luHaiTongData.containerCargoInfos.length &&
  539. this.assemblyForm.quantity == quantitySum &&
  540. this.assemblyForm.grossWeight == grossWeightSum &&
  541. this.assemblyForm.measurement == measurementSum
  542. ) {
  543. this.extractDialogvisible = false;
  544. this.$emit("billsAddfun"); // 全都相等直接走大保存
  545. } else {
  546. this.$alert(
  547. "<div>委托:箱数,件重尺 场站:箱数,件重尺不相等</div>" +
  548. '<table border="1" width="100%">\n' +
  549. " <thead>\n" +
  550. " <tr>\n" +
  551. " <th></th>\n" +
  552. " <th>箱数</th>\n" +
  553. " <th>件数</th>\n" +
  554. " <th>毛重</th>\n" +
  555. " <th>尺码</th>\n" +
  556. " </tr>\n" +
  557. " </thead>\n" +
  558. " <tbody>\n" +
  559. " <tr>\n" +
  560. " <td>委托</td>\n" +
  561. " <td>" +
  562. this.assemblyForm.containersList.length +
  563. "</td>\n" +
  564. " <td>" +
  565. this.assemblyForm.quantity +
  566. "</td>\n" +
  567. " <td>" +
  568. this.assemblyForm.grossWeight +
  569. "</td>\n" +
  570. " <td>" +
  571. this.assemblyForm.measurement +
  572. "</td>\n" +
  573. " </tr>\n" +
  574. " <tr>\n" +
  575. " <td>场站</td>\n" +
  576. " <td>" +
  577. this.luHaiTongData.containerCargoInfos.length +
  578. "</td>\n" +
  579. " <td>" +
  580. quantitySum +
  581. "</td>\n" +
  582. " <td>" +
  583. grossWeightSum +
  584. "</td>\n" +
  585. " <td>" +
  586. measurementSum +
  587. "</td>\n" +
  588. " </tr>\n" +
  589. " </tbody>\n" +
  590. "</table>",
  591. "提示",
  592. {
  593. dangerouslyUseHTMLString: true,
  594. confirmButtonText: "确定",
  595. cancelButtonText: "关闭",
  596. // showCancelButton:true,
  597. type: "warning"
  598. }
  599. )
  600. .then(() => {
  601. console.log("确认");
  602. // 箱数不等 不更新前面的
  603. if (this.assemblyForm.containersList.length == this.luHaiTongData.containerCargoInfos.length) {
  604. for (let item of this.assemblyForm.preContainersList) {
  605. let pieceSum = 0;
  606. let weightSum = 0;
  607. let chiSum = 0;
  608. for (let ite of this.assemblyForm.containersList) {
  609. if (item.cntrTypeCode == ite.cyCntrCode) {
  610. pieceSum += ite.quantity;
  611. weightSum += ite.grossWeight;
  612. chiSum += ite.measurement;
  613. }
  614. }
  615. item.number = pieceSum;
  616. item.grossWeight = weightSum;
  617. item.measurement = chiSum;
  618. }
  619. this.assemblyForm.quantity = quantitySum;
  620. this.assemblyForm.grossWeight = grossWeightSum;
  621. this.assemblyForm.measurement = measurementSum;
  622. }
  623. this.extractDialogvisible = false;
  624. this.$emit("billsAddfun"); // 全都相等直接走大保存
  625. })
  626. .catch(() => {
  627. console.log("取消");
  628. });
  629. }
  630. },
  631. // 输入自动大写
  632. cntrNoInput(row, name) {
  633. this.$set(row, name, row[name].toLocaleUpperCase().replace(/[\W]/g, ""));
  634. },
  635. verifyChange(row, name) {
  636. if (row[name]) {
  637. getAccurate({ accurate: row[name] }).then(res => {
  638. if (res.data.data.records.length == 0) {
  639. const regex = /^([a-zA-Z]{4})([0-9]{7})$/;
  640. if (regex.test(row[name])) {
  641. if (this.calculateCheckDigit(row[name]) == row[name][10]) {
  642. // this.$message.success('集装箱校验正确!')
  643. } else {
  644. this.$confirm(`<strong><p style='color:#F56C6C'>箱号:${row[name]},格式不正确,是否强制加入系统?</p ></strong>`, "提示", {
  645. confirmButtonText: "确定",
  646. cancelButtonText: "取消",
  647. dangerouslyUseHTMLString: true,
  648. type: "warning"
  649. })
  650. .then(() => {
  651. // this.$message({
  652. // type: 'success',
  653. // message: '删除成功!'
  654. // });
  655. })
  656. .catch(() => {
  657. this.$set(row, [name], null);
  658. });
  659. }
  660. } else {
  661. this.$confirm(`<strong><p style='color:#F56C6C'>箱号:${row[name]},格式不正确,是否强制加入系统?</p ></strong>`, "提示", {
  662. confirmButtonText: "确定",
  663. cancelButtonText: "取消",
  664. dangerouslyUseHTMLString: true,
  665. type: "warning"
  666. })
  667. .then(() => {
  668. // this.$message({
  669. // type: 'success',
  670. // message: '删除成功!'
  671. // });
  672. })
  673. .catch(() => {
  674. this.$set(row, [name], null);
  675. });
  676. }
  677. }
  678. });
  679. }
  680. },
  681. calculateCheckDigit(containerNo) {
  682. let charCode = "0123456789A?BCDEFGHIJK?LMNOPQRSTU?VWXYZ";
  683. let num = 0;
  684. for (let i = 0; i < 10; i++) {
  685. let idx = charCode.indexOf(containerNo[i]);
  686. idx = idx * Math.pow(2, i);
  687. num += idx;
  688. }
  689. return (num = (num % 11) % 10);
  690. },
  691. oepnexcelBox() {
  692. if (!this.assemblyForm.id) {
  693. this.$message({
  694. message: "请先点击右上角保存按钮,保存数据之后才能添加!",
  695. type: "warning"
  696. });
  697. return;
  698. }
  699. this.findObject(this.excelOption.column, "excelFile").action = "/api/blade-los/containers/importBoxNo?billId=" + this.assemblyForm.id;
  700. this.excelBox = true;
  701. },
  702. uploadBefore(file, done, loading) {
  703. 681169;
  704. done();
  705. loading = true;
  706. },
  707. // 上传成功
  708. onSuccess(res, done, loading, column) {
  709. this.excelBox = false;
  710. // this.$message.success("导入成功!");
  711. this.containersListfun();
  712. loading = false;
  713. done();
  714. },
  715. // 箱列表
  716. containersListfun() {
  717. containersList(1, 100, { pid: this.assemblyForm.id }).then(res => {
  718. this.assemblyForm.containersList = res.data.data.records;
  719. });
  720. },
  721. equalDistribution2() {
  722. if (!this.assemblyForm.id) {
  723. this.$message({
  724. message: "请先点击右上角保存按钮,保存数据之后才能添加!",
  725. type: "warning"
  726. });
  727. return;
  728. }
  729. this.$confirm("是否确认配箱?", {
  730. confirmButtonText: "确定",
  731. cancelButtonText: "取消",
  732. type: "warning"
  733. }).then(() => {
  734. this.assemblyForm.businessType = "KHTS";
  735. this.assemblyForm.billNoFormat = "KHTS";
  736. this.assemblyForm.businessTypeCode = "KHTS";
  737. submit(this.assemblyForm).then(res => {
  738. distributionBox({ billId: this.assemblyForm.id }).then(res => {
  739. this.$message({
  740. type: "success",
  741. message: "操作成功!"
  742. });
  743. this.$emit("billsDetailfun");
  744. });
  745. });
  746. });
  747. },
  748. // 平均箱量
  749. equalDistribution(type) {
  750. if (!this.assemblyForm.id) {
  751. this.$message({
  752. message: "请先点击右上角保存按钮,保存数据之后才能添加!",
  753. type: "warning"
  754. });
  755. return;
  756. }
  757. if (this.assemblyForm.waitingBoxList.length <= 0) {
  758. this.$message({
  759. type: "warning",
  760. message: "请先添加集装箱数据!"
  761. });
  762. return;
  763. }
  764. if (this.assemblyForm.preContainersList <= 0) {
  765. this.$message({
  766. type: "warning",
  767. message: "请先添加箱型数据!"
  768. });
  769. return;
  770. }
  771. this.$confirm("确定平均分配?", {
  772. confirmButtonText: "确定",
  773. cancelButtonText: "取消",
  774. type: "warning"
  775. }).then(() => {
  776. this.containersEqualDistributionfun(type);
  777. });
  778. },
  779. // 平均分配接口
  780. containersEqualDistributionfun(type) {
  781. containersEqualDistribution({
  782. pid: this.assemblyForm.id,
  783. type: type,
  784. waitingBox: this.assemblyForm.waitingBoxList[0]
  785. }).then(res => {
  786. if (res.data.data instanceof Array) {
  787. this.$message({
  788. type: "success",
  789. message: "操作成功!"
  790. });
  791. this.$emit("billsDetailfun");
  792. } else {
  793. // 没有除开
  794. this.$message({
  795. type: "warning",
  796. dangerouslyUseHTMLString: true,
  797. message:
  798. '<span style="color:red">注意!!!件数不能平均分 ,请手工配箱,或者修改件数.</span>\n' +
  799. '<table border="1">\n' +
  800. " <thead>\n" +
  801. " <tr>\n" +
  802. " <th></th>\n" +
  803. " <th>件数</th>\n" +
  804. " <th>毛重</th>\n" +
  805. " <th>尺码</th>\n" +
  806. " </tr>\n" +
  807. " </thead>\n" +
  808. " <tbody>\n" +
  809. " <tr>\n" +
  810. " <td>总数</td>\n" +
  811. " <td>" +
  812. res.data.data.total.quantity +
  813. "</td>\n" +
  814. " <td>" +
  815. res.data.data.total.grossWeight +
  816. "</td>\n" +
  817. " <td>" +
  818. res.data.data.total.grossWeight +
  819. "</td>\n" +
  820. " </tr>\n" +
  821. " <tr>\n" +
  822. " <td>入箱</td>\n" +
  823. " <td>" +
  824. res.data.data.average.quantity +
  825. "</td>\n" +
  826. " <td>" +
  827. res.data.data.average.grossWeight +
  828. "</td>\n" +
  829. " <td>" +
  830. res.data.data.average.grossWeight +
  831. "</td>\n" +
  832. " </tr>\n" +
  833. " <tr>\n" +
  834. " <td>差额</td>\n" +
  835. " <td>" +
  836. res.data.data.subtract.quantity +
  837. "</td>\n" +
  838. " <td>" +
  839. res.data.data.subtract.grossWeight +
  840. "</td>\n" +
  841. " <td>" +
  842. res.data.data.subtract.grossWeight +
  843. "</td>\n" +
  844. " </tr>\n" +
  845. " </tbody>\n" +
  846. "</table>",
  847. duration: 5000
  848. });
  849. }
  850. });
  851. },
  852. // 下载模板
  853. handleGet() {
  854. window.open(`/api/blade-los/containers/exportContainers?${this.website.tokenHeader}=${getToken()}&pid=${this.assemblyForm.id}`);
  855. },
  856. // 查询件数是否为零
  857. numberfalsefun() {
  858. if (!this.assemblyForm.containersList) {
  859. return false;
  860. }
  861. for (let item of this.assemblyForm.containersList) {
  862. if (Number(item.quantity) >= 0) {
  863. return true;
  864. } else {
  865. return false;
  866. }
  867. }
  868. },
  869. // // 平均分配
  870. // equalDistribution() {
  871. // if (this.assemblyForm.waitingBoxList.length <= 0) {
  872. // this.$message({
  873. // type: "warning",
  874. // message: "请先添加集装箱数据!"
  875. // });
  876. // return
  877. // }
  878. // this.$confirm("确定平均分配?", {
  879. // confirmButtonText: "确定",
  880. // cancelButtonText: "取消",
  881. // type: "warning"
  882. // }).then(() => {
  883. // this.$emit('equalDistribution')
  884. // })
  885. // },
  886. // 一键编辑
  887. rootEditfun() {
  888. for (let item of this.assemblyForm.containersList) {
  889. this.$delete(item, "edit");
  890. this.$set(item, "edit", true);
  891. }
  892. },
  893. // 编辑
  894. rowCellfun(row, index) {
  895. this.$delete(row, "edit");
  896. this.$set(row, "edit", true);
  897. },
  898. // 保存
  899. rowSavefun(row) {
  900. this.$delete(row, "edit");
  901. this.$set(row, "edit", false);
  902. this.$emit("rowSavefun", row);
  903. },
  904. // 清除箱号
  905. cleanCntrNofun() {
  906. this.$confirm("确定将数据清除全部箱号?", {
  907. confirmButtonText: "确定",
  908. cancelButtonText: "取消",
  909. type: "warning"
  910. }).then(() => {
  911. let arrids = [];
  912. for (let item of this.assemblyForm.containersList.filter(item => !item.containerNumber)) {
  913. arrids.push(item.id);
  914. }
  915. this.assemblyForm.businessType = "KHTS";
  916. this.assemblyForm.billNoFormat = "KHTS";
  917. this.assemblyForm.businessTypeCode = "KHTS";
  918. // 清除箱号接口
  919. if (arrids.length) {
  920. submit(this.assemblyForm).then(res => {
  921. containersCleanBoxNo(arrids.join(",")).then(res => {
  922. this.$message({
  923. type: "success",
  924. message: "清除箱号成功!"
  925. });
  926. this.$emit("billsDetailfun");
  927. });
  928. });
  929. }
  930. });
  931. },
  932. // 全部撤销
  933. wholeRevokefun() {
  934. this.$confirm("是否清除所有数据的件重尺", {
  935. confirmButtonText: "确定",
  936. cancelButtonText: "取消",
  937. type: "warning"
  938. }).then(() => {
  939. let arrids = [];
  940. for (let item of this.assemblyForm.containersList.filter(item => !item.containerNumber)) {
  941. arrids.push(item.id);
  942. }
  943. this.assemblyForm.businessType = "KHTS";
  944. this.assemblyForm.billNoFormat = "KHTS";
  945. this.assemblyForm.businessTypeCode = "KHTS";
  946. if (arrids.length) {
  947. submit(this.assemblyForm).then(res => {
  948. containersRevoke(arr.join(",")).then(res => {
  949. this.$message({
  950. type: "success",
  951. message: "全部撤销成功!"
  952. });
  953. this.$emit("billsDetailfun");
  954. });
  955. });
  956. }
  957. });
  958. },
  959. // 撤销
  960. revokefun() {
  961. if (this.selectionList.length > 0) {
  962. let arrids = [];
  963. for (let item of this.selectionList) {
  964. if (item.containerNumber) {
  965. return this.$message.error("放箱号有值,不允许清空");
  966. }
  967. arrids.push(item.id);
  968. }
  969. this.assemblyForm.businessType = "KHTS";
  970. this.assemblyForm.billNoFormat = "KHTS";
  971. this.assemblyForm.businessTypeCode = "KHTS";
  972. if (arrids.length) {
  973. submit(this.assemblyForm).then(res => {
  974. containersRevoke(this.selectionList[0].id).then(res => {
  975. this.$message({
  976. type: "success",
  977. message: "撤销成功!"
  978. });
  979. this.$emit("billsDetailfun");
  980. });
  981. });
  982. }
  983. } else {
  984. this.$message({
  985. type: "warning",
  986. message: "请选选择要撤销的数据!"
  987. });
  988. }
  989. },
  990. // 配箱批量保存
  991. containersSubmitListfun() {
  992. if (!this.assemblyForm.id) {
  993. this.$message.warning("请先大保存");
  994. return;
  995. }
  996. for (let item of this.assemblyForm.containersList) {
  997. let textList = [];
  998. if (!item.cntrTypeCode) {
  999. textList.push("箱型");
  1000. }
  1001. if (!item.cntrNo) {
  1002. textList.push("箱号");
  1003. }
  1004. if (!item.sealNo) {
  1005. textList.push("封号");
  1006. }
  1007. if (!item.quantity || Number(item.quantity) == 0) {
  1008. textList.push("件数");
  1009. }
  1010. if (!item.grossWeight || Number(item.grossWeight) == 0) {
  1011. textList.push("毛重");
  1012. }
  1013. if (!item.measurement || Number(item.measurement) == 0) {
  1014. textList.push("尺码/体积");
  1015. }
  1016. if (textList.length) {
  1017. return this.$message.error(`请完善配箱信息的${textList.join(",")}!`);
  1018. }
  1019. }
  1020. this.$confirm("确定全部保存配箱?", {
  1021. confirmButtonText: "确定",
  1022. cancelButtonText: "取消",
  1023. type: "warning"
  1024. }).then(() => {
  1025. containersSubmitList(this.assemblyForm.containersList).then(res => {
  1026. this.$message({
  1027. type: "success",
  1028. message: "操作成功!"
  1029. });
  1030. this.assemblyForm.containersList = res.data.data;
  1031. // this.$emit('billsDetailfun')
  1032. });
  1033. });
  1034. },
  1035. rowSave(row, done, loading) {
  1036. containersSubmit(row).then(
  1037. () => {
  1038. // this.onLoad(this.page);
  1039. this.$message({
  1040. type: "success",
  1041. message: "操作成功!"
  1042. });
  1043. done();
  1044. },
  1045. error => {
  1046. loading();
  1047. window.console.log(error);
  1048. }
  1049. );
  1050. },
  1051. rowUpdate(row, index, done, loading) {
  1052. containersSubmit(row).then(
  1053. () => {
  1054. // this.onLoad(this.page);
  1055. this.$message({
  1056. type: "success",
  1057. message: "操作成功!"
  1058. });
  1059. done();
  1060. },
  1061. error => {
  1062. loading();
  1063. console.log(error);
  1064. }
  1065. );
  1066. },
  1067. // 删除
  1068. rowDel(row) {
  1069. this.$confirm("确定将选择数据删除?", {
  1070. confirmButtonText: "确定",
  1071. cancelButtonText: "取消",
  1072. type: "warning"
  1073. })
  1074. .then(() => {
  1075. return containersRemove(row.id);
  1076. })
  1077. .then(() => {
  1078. // this.onLoad(this.page);
  1079. this.$message({
  1080. type: "success",
  1081. message: "操作成功!"
  1082. });
  1083. this.$emit("billsDetailfun");
  1084. });
  1085. },
  1086. // 一键删除
  1087. handleDelete() {
  1088. for (let item of this.assemblyForm.containersList) {
  1089. if (item.quantity > 0) return this.$message.error("请先撤销,再删除配箱");
  1090. }
  1091. this.$confirm("确定将全部数据删除?", {
  1092. confirmButtonText: "确定",
  1093. cancelButtonText: "取消",
  1094. type: "warning"
  1095. }).then(() => {
  1096. let arrids = [];
  1097. for (let item of this.assemblyForm.containersList.filter(item => !item.containerNumber)) {
  1098. arrids.push(item.id);
  1099. }
  1100. this.assemblyForm.businessType = "KHTS";
  1101. this.assemblyForm.billNoFormat = "KHTS";
  1102. this.assemblyForm.businessTypeCode = "KHTS";
  1103. if (arrids.length) {
  1104. submit(this.assemblyForm).then(res => {
  1105. containersRemove(arrids.join(",")).then(() => {
  1106. // this.onLoad(this.page);
  1107. this.$message({
  1108. type: "success",
  1109. message: "操作成功!"
  1110. });
  1111. this.$emit("billsDetailfun");
  1112. this.$refs.crud.toggleSelection();
  1113. });
  1114. });
  1115. }
  1116. });
  1117. },
  1118. beforeOpen(done, type) {
  1119. if (["edit", "view"].includes(type)) {
  1120. containersDetail(this.form.id).then(res => {
  1121. this.form = res.data.data;
  1122. });
  1123. }
  1124. done();
  1125. },
  1126. // 当选择项发生变化时会触发该事件
  1127. selectionChange(list) {
  1128. let arr = [];
  1129. if (list.length > 1) {
  1130. this.$refs.crud.toggleSelection(); // 先清空所以选择的数据
  1131. arr = [list[list.length - 1]]; // 获取最新点击的数组
  1132. this.$refs.crud.toggleSelection(arr, true); // 把刚点击的数组变成选择状态
  1133. } else {
  1134. arr = list;
  1135. }
  1136. this.selectionList = arr;
  1137. this.$emit("selectionChange", this.selectionList);
  1138. },
  1139. inPitch() {
  1140. this.$refs.crud.toggleRowSelection(this.assemblyForm.containersList[0], true);
  1141. },
  1142. selectionClear() {
  1143. this.selectionList = [];
  1144. this.$refs.crud.toggleSelection();
  1145. },
  1146. refreshChange() {
  1147. console.log("刷新");
  1148. // this.onLoad(this.page, this.query);
  1149. },
  1150. // onLoad(page, params = {}) {
  1151. // this.loading = true;
  1152. // containersList(page.currentPage, page.pageSize, {...Object.assign(params, this.query),pid:this.pid}).then(res => {
  1153. // const data = res.data.data;
  1154. // this.page.total = data.total;
  1155. // this.data = data.records
  1156. // this.loading = false;
  1157. // this.selectionClear();
  1158. // });
  1159. // }
  1160. // 更改表格颜色
  1161. headerClassName(tab) {
  1162. //颜色间隔
  1163. let back = "";
  1164. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  1165. if (tab.columnIndex % 2 === 0) {
  1166. back = "back-one";
  1167. } else if (tab.columnIndex % 2 === 1) {
  1168. back = "back-two";
  1169. }
  1170. }
  1171. return back;
  1172. }
  1173. }
  1174. };
  1175. </script>
  1176. <style scoped>
  1177. ::v-deep#out-table .back-one {
  1178. background: #ecf5ff !important;
  1179. text-align: center;
  1180. padding: 4px 0;
  1181. }
  1182. ::v-deep#out-table .back-two {
  1183. background: #ecf5ff !important;
  1184. text-align: center;
  1185. padding: 4px 0;
  1186. }
  1187. </style>