precontainers.vue 31 KB

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