precontainers.vue 34 KB

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