| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037 |
- <template>
- <basic-container>
- <avue-crud :option="option" :table-loading="loading" :data="assemblyForm.preContainersList" :page.sync="page"
- :permission="permissionList" :before-open="beforeOpen" v-model="form"
- :cell-style="{ padding: '0px', textAlign: 'center' }" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
- @row-del="rowDel" @selection-change="selectionChange" @refresh-change="refreshChange"
- @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 487)"
- @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 487)">
- <template slot="menuLeft">
- <el-button type="primary" size="small"
- :disabled="seeDisabled || assemblyForm.preContainersList.filter(item => item.containerNumberStatus == '已选择').length > 0"
- @click.stop="addfun">新 增</el-button>
- <el-button type="danger" size="small" plain
- :disabled="seeDisabled || assemblyForm.preContainersList.length == 0 || assemblyForm.preContainersList.filter(item => item.containerNumberStatus == '已选择').length > 0"
- @click.stop="handleDelete">一键删除
- </el-button>
- <el-button type="primary" size="small"
- :disabled="seeDisabled || assemblyForm.preContainersList.length == 0"
- @click="batchSavefun">一键保存</el-button>
- <el-button type="info" plain size="small"
- :disabled="seeDisabled || assemblyForm.preContainersList.length == 0" @click="onclickEdit">一键编辑
- </el-button>
- </template>
- <template slot-scope="{row,index}" slot="menu">
- <el-button v-if="row.id && row.containerNumberStatus == '录入' && assemblyForm.billType != 'MM'"
- size="mini" type="text" @click.stop="pick(row)" :disabled="seeDisabled">
- 选择
- </el-button>
- <el-button v-if="row.id && row.containerNumberStatus == '已选择' && assemblyForm.billType != 'MM'"
- size="mini" type="text" @click.stop="rowRevoke(row)" :disabled="seeDisabled">
- 撤销
- </el-button>
- <el-button v-if="row.id && row.containerNumberStatus == '已选择' && assemblyForm.billType != 'MM'"
- size="mini" type="text" @click.stop="rowView(row)" :disabled="seeDisabled">
- 查看放箱号
- </el-button>
- </template>
- <template slot-scope="{row}" slot="cntrTypeCodeForm">
- <search-query :datalist="cntrTypeCodeData" :selectValue="row.cntrTypeCode" :filterable="true"
- :clearable="true" :remote="true" :buttonIf="false"
- :forParameter="{ key: 'id', label: 'cnName', value: 'cnName' }" placeholder="请选择尺码箱型"
- @remoteMethod="remoteMethod($event, 'cntrTypeCode')" @corpChange="corpChange($event, row)"
- @corpFocus="remoteMethod($event, 'cntrTypeCode')" @corpClear="corpClear($event, row)">
- </search-query>
- </template>
- <template slot="number" slot-scope="{ row }">
- <el-input v-if="row.$cellEdit" style="width: 100%;" v-model="row.number" size="small" autocomplete="off"
- min="0" @blur="numberBlur(row)" clearable placeholder="请输入件数"></el-input>
- <span v-else>{{ row.number }}</span>
- </template>
- <template slot="grossWeight" slot-scope="{ row }">
- <el-input v-if="row.$cellEdit" style="width: 100%;" v-model="row.grossWeight" size="small"
- autocomplete="off" min="0" @blur="grossWeightBlur(row)" clearable placeholder="请输入毛重"></el-input>
- <span v-else>{{ row.grossWeight }}</span>
- </template>
- <template slot="measurement" slot-scope="{ row }">
- <el-input v-if="row.$cellEdit" style="width: 100%;" v-model="row.measurement" size="small"
- autocomplete="off" min="0" @blur="measurementBlur(row)" clearable placeholder="请输入尺码"></el-input>
- <span v-else>{{ row.measurement }}</span>
- </template>
- </avue-crud>
- <el-dialog title="查看放箱号" :visible.sync="dialogVisible" width="50%" :before-close="handleClose" append-to-body>
- <span>
- <avue-crud ref="crud2" :option="containerOption" :data="containerNumberItemList"
- @resetColumn="resetColumnTwo('crud2', 'containerOption', 'containerOptionBack', 488)"
- @saveColumn="saveColumnTwo('crud2', 'containerOption', 'containerOptionBack', 488)">
- <template slot="occupyNum" slot-scope="{ row }">
- <el-input-number v-if="!row.id" v-model="row.occupyNum" :min="0" :max="row.remainingNum"
- placeholder="请输入占用箱量" size="small" :controls="false" style="width: 100%;"></el-input-number>
- <span v-else>{{ row.occupyNum }}</span>
- </template>
- </avue-crud>
- </span>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false" size="mini">{{ editStatus ? '取 消' : '关 闭' }}</el-button>
- <el-button v-if="editStatus" type="primary" @click="submit" size="mini">确 定</el-button>
- </span>
- </el-dialog>
- </basic-container>
- </template>
- <script>
- import {
- precontainersList,
- precontainersDetail,
- precontainersSubmit,
- precontainersRemove,
- precontainersSubmitList,
- getItemListHY,
- selectedContainerNumber,
- revokeSelectedContainerNumber,
- } from "@/api/iosBasicData/ReceivingOrders/precontainers";
- import { getWorkDicts } from "@/api/system/dictbiz";
- import { mapGetters } from "vuex";
- import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
- import { bcntrtypesList } from "@/api/iosBasicData/bcntrtypes";
- import { containersEqualDistribution } from "@/api/iosBasicData/containers";
- import { requiredMessage } from "@/util/messageReminder";
- import { Header } from "element-ui";
- export default {
- components: { SearchQuery },
- props: {
- pid: {},
- assemblyForm: {
- type: Object,
- default: {}
- },
- seeDisabled: {
- type: Boolean,
- default: false,
- },
- showLock: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- editStatus: false,
- dialogVisible: false,
- // 集装箱尺码箱型
- cntrTypeCodeData: [],
- containerNumberItemList: [],
- form: {},
- query: {},
- loading: false,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- selectionList: [],
- option: {},
- optionBack: {
- maxHeight: '150px',
- // calcHeight: 30,
- calcHeight: 30,
- menuWidth: 120,
- tip: false,
- border: true,
- addBtn: false,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- refreshBtn: false,
- selection: true,
- align: 'center',
- menu: true,
- index: true,
- column: [
- {
- label: "箱型",
- prop: "cntrTypeCode",
- formslot: true,
- cell: true,
- width: '120',
- rules: [{
- required: true,
- message: "请选择箱型",
- trigger: "blur"
- }]
- },
- {
- label: "箱量",
- prop: "quantity",
- type: "number",
- cell: true,
- controls: false,
- precision: 0,
- width: '120',
- rules: [{
- required: true,
- message: "请输入箱量",
- trigger: "blur"
- }]
- },
- {
- label: "件数",
- prop: "number",
- type: "number",
- width: '120',
- // cell:true,
- controls: false,
- precision: 0,
- },
- {
- label: "毛重(KGS)",
- prop: "grossWeight",
- width: '120',
- type: "number",
- // cell:true,
- controls: false,
- },
- {
- label: "净重(KGS)",
- prop: "netWeight",
- width: '120',
- type: "number",
- cell: true,
- controls: false,
- },
- {
- label: "体积(CBM)",
- prop: "measurement",
- width: '120',
- type: "number",
- // cell:true,
- controls: false,
- },
- {
- label: "温度",
- prop: "temperature",
- cell: true,
- controls: false,
- // type:"number",
- width: "120"
- },
- {
- label: "温度单位",
- prop: "temperatureUnit",
- type: 'select',
- cell: true,
- dicData: [{
- label: '摄氏度',
- value: 'C'
- }, {
- label: '华氏度',
- value: 'F'
- }]
- },
- {
- label: "通风度",
- prop: "ventilation",
- cell: true,
- controls: false,
- // type:"number",
- width: "120"
- },
- {
- label: "湿度",
- prop: "humidity",
- cell: true,
- controls: false,
- // type:"number",
- width: "120"
- },
- {
- label: "SOC",
- prop: "isSoc",
- width: '120',
- type: 'select',
- cell: true,
- dicData: [{
- label: '否',
- value: 0
- }, {
- label: '是',
- value: 1
- }]
- },
- {
- label: "单程",
- prop: "isOneway",
- type: 'select',
- cell: true,
- dicData: [{
- label: '否',
- value: 0
- }, {
- label: '是',
- value: 1
- }]
- },
- {
- label: "NOR",
- prop: "nor",
- width: '100',
- type: 'select',
- cell: true,
- dicData: [{
- label: '否',
- value: 0
- }, {
- label: '是',
- value: 1
- }]
- },
- {
- label: "OOG",
- prop: "oog",
- width: '120',
- type: 'select',
- cell: true,
- dicData: [{
- label: '否',
- value: 0
- }, {
- label: '是',
- value: 1
- }]
- },
- {
- label: "左超(CM)",
- prop: "overLeft",
- type: "number",
- cell: true,
- controls: false,
- },
- {
- label: "右超(CM)",
- prop: "overRight",
- type: "number",
- cell: true,
- controls: false,
- },
- {
- label: "前超(CM)",
- prop: "overFront",
- type: "number",
- cell: true,
- controls: false,
- },
- {
- label: "后超(CM)",
- prop: "overBack",
- type: "number",
- cell: true,
- controls: false,
- },
- {
- label: "超高(CM)",
- prop: "overHeight",
- type: "number",
- cell: true,
- controls: false,
- },
- {
- label: "备注",
- prop: "remarks",
- span: 24,
- type: 'textarea',
- slot: true,
- minRows: 3,
- },
- ]
- },
- data: [],
- containerOption: {},
- containerOptionBack: {
- height: '500',
- // calcHeight: 30,
- calcHeight: 30,
- menuWidth: 160,
- tip: false,
- border: true,
- addBtn: false,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- refreshBtn: false,
- align: 'center',
- menu: false,
- index: true,
- column: [
- {
- label: "放箱号",
- prop: "containerNumber",
- width: 100,
- overHidden: true,
- },
- {
- label: "内部放箱号",
- prop: "internalContainerNumber",
- width: 100,
- overHidden: true,
- },
- {
- label: "放箱号类型",
- prop: "busType",
- width: 100,
- overHidden: true,
- },
- {
- label: "场站",
- prop: "polStationCname",
- width: 100,
- overHidden: true,
- },
- {
- label: "箱型",
- prop: "boxType",
- width: 100,
- overHidden: true,
- },
- {
- label: "可用箱数",
- prop: "remainingNum",
- width: 100,
- overHidden: true,
- },
- {
- label: "占用箱量",
- prop: "occupyNum",
- width: 100,
- overHidden: true,
- },
- {
- label: "优先等级",
- prop: "priorityLevel",
- width: 100,
- overHidden: true,
- },
- {
- label: "箱管备注",
- prop: "boxRemarks",
- width: 100,
- overHidden: true,
- },
- {
- label: "备注",
- prop: "remarks",
- width: 100,
- overHidden: true,
- },
- ]
- },
- };
- },
- computed: {
- ...mapGetters(["permission"]),
- permissionList() {
- return {
- addBtn: this.vaildData(this.permission.precontainers_add, false),
- viewBtn: this.vaildData(this.permission.precontainers_view, false),
- delBtn: this.vaildData(this.permission.precontainers_delete, false),
- editBtn: this.vaildData(this.permission.precontainers_edit, false)
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach(ele => {
- ids.push(ele.id);
- });
- return ids.join(",");
- }
- },
- async created() {
- this.option = await this.getColumnData(this.getColumnName(487), this.optionBack);
- this.containerOption = await this.getColumnData(this.getColumnName(488), this.containerOptionBack);
- },
- methods: {
- submit() {
- // let obj = {
- // containerNumberItemList:
- // }
- // for (let item of ) {
- // if (!(item.occupyNum > 0)) {
- // return this.$message.error("占用箱量必须大于0!");
- // }
- // }
- if (this.containerNumberItemList.filter(item => item.occupyNum > 0).length == 0) {
- return this.$message.error("至少有一条占用箱量大于0!");
- }
- selectedContainerNumber(this.containerNumberItemList).then(res => {
- this.$message.success("操作成功!");
- this.dialogVisible = false
- this.$emit('billsDetailfun')
- })
- },
- pick(row) {
- this.containerNumberItemList = []
- if (!this.assemblyForm.polId) {
- return this.$message.error("请选择装货港");
- }
- if (!this.assemblyForm.podId) {
- return this.$message.error("请选择卸货港");
- }
- let obj = {
- boxType: row.cntrTypeCode,
- polId: this.assemblyForm.polId,
- podId: this.assemblyForm.podId,
- cabinType: this.assemblyForm.cabinType,
- airlineId: this.assemblyForm.airlineId,
- etd: this.assemblyForm.etd + ' 00:00:00',
- }
- getItemListHY(obj).then(res => {
- if (res.data.data) {
- res.data.data.forEach(item => {
- item.pid = this.assemblyForm.id
- })
- this.editStatus = true
- this.containerNumberItemList = res.data.data
- }
- })
- this.dialogVisible = true
- },
- rowRevoke(row) {
- let obj = {
- boxType: row.cntrTypeCode,
- billId: this.assemblyForm.id
- }
- revokeSelectedContainerNumber(obj).then(res => {
- this.$message.success("操作成功!");
- this.$emit('billsDetailfun')
- })
- },
- rowView(row) {
- this.containerNumberItemList = []
- this.editStatus = false
- this.dialogVisible = true
- this.containerNumberItemList = this.assemblyForm.containerNumberItemList.filter(item => row.cntrTypeCode == item.boxType && item.occupyNum > 0)
- },
- handleClose() {
- this.dialogVisible = false
- this.editStatus = false
- },
- onclickEdit() {
- // for (let item of this.assemblyForm.preContainersList) {
- // if(item.containerNumberStatus == '已选择'){
- // return this.$message.error('请撤销放箱号,再进行编辑!')
- // }else{
- // this.$delete(item, '$cellEdit')
- // this.$set(item, '$cellEdit', true)
- // }
- // }
- console.log()
- if (this.assemblyForm.containersList.length > 0) {
- this.$alert('当前数据已经均分箱量,请撤销之后再修改', '提示', {
- confirmButtonText: '确定',
- });
- } else {
- for (let item of this.assemblyForm.preContainersList) {
- this.$delete(item, '$cellEdit')
- this.$set(item, '$cellEdit', true)
- }
- }
- },
- // 件数失焦事件
- numberBlur(row) {
- let quantityNum = 0
- for (let item of this.assemblyForm.preContainersList) {
- if (item.number) {
- quantityNum += Number(item.number)
- }
- }
- if (quantityNum != 0) {
- this.assemblyForm.quantity = quantityNum
- }
- },
- // 毛重失焦事件
- grossWeightBlur(row) {
- let grossWeightNum = 0
- for (let item of this.assemblyForm.preContainersList) {
- if (item.grossWeight) {
- grossWeightNum += Number(item.grossWeight)
- }
- }
- if (grossWeightNum != 0) {
- this.assemblyForm.grossWeight = grossWeightNum
- }
- },
- // 尺码失焦事件
- measurementBlur(row) {
- let measurementNum = 0
- for (let item of this.assemblyForm.preContainersList) {
- if (item.measurement) {
- measurementNum += Number(item.measurement)
- }
- }
- if (measurementNum != 0) {
- this.assemblyForm.measurement = measurementNum
- }
- },
- // 一键编辑
- oneTouchEditefun() {
- for (let item of this.assemblyForm.preContainersList) {
- this.$refs.crud.rowCell(item, item.$index)
- }
- console.log(this.assemblyForm.preContainersList, 294)
- // $cellEdit
- },
- // 批量保存
- batchSavefun() {
- if (!this.assemblyForm.id) {
- this.$message({
- message: '请先点击右上角保存按钮,保存数据之后才能添加!',
- type: 'warning'
- });
- return
- }
- // let numberSum = 0
- // let grossWeightSum = 0
- // let measurementSum = 0
- // for (let item of this.assemblyForm.preContainersList) {
- // numberSum += Number(item.number)
- // grossWeightSum += Number(item.grossWeight)
- // measurementSum += Number(item.measurement)
- // if (!item.cntrTypeCode) {
- // this.$message.warning('请选择尺码箱型')
- // return;
- // }
- // if (!item.quantity) {
- // this.$message.warning('请输入箱量')
- // return;
- // }
- // item.pid = this.assemblyForm.id
- // }
- // if (numberSum>0&&(numberSum != this.assemblyForm.quantity)) return this.$message.error('箱型所有的件数不等于总件数')
- // this.$confirm("批量保存后,需要重新配箱,确认继续?", {
- // confirmButtonText: "确定",
- // cancelButtonText: "取消",
- // type: "warning"
- // }).then(() => {
- // precontainersSubmitList(this.assemblyForm.preContainersList).then(res => {
- // this.$message({
- // type: "success",
- // message: "操作成功!"
- // });
- // this.$emit('billsDetailfun')
- // })
- // })
- // assemblyForm.containersList
- for (let item of this.assemblyForm.preContainersList) {
- if (this.assemblyForm.containersList.filter(e => item.cntrTypeCode == e.cntrTypeCode).length != item.quantity) {
- this.$confirm("箱型箱量改变,请检查预录费用信息?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- showCancelButton: false,
- type: "error"
- }).then(() => {
- precontainersSubmitList(this.assemblyForm.preContainersList).then(res => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$emit('billsDetailfun')
- })
- })
- return
- }
- }
- precontainersSubmitList(this.assemblyForm.preContainersList).then(res => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$emit('billsDetailfun')
- })
- },
- // 平均箱量
- equalDistribution(type) {
- if (!this.assemblyForm.id) {
- this.$message({
- message: '请先点击右上角保存按钮,保存数据之后才能添加!',
- type: 'warning'
- });
- return
- }
- if (this.assemblyForm.waitingBoxList.length <= 0) {
- this.$message({
- type: "warning",
- message: "请先添加集装箱数据!"
- });
- return
- }
- if (this.assemblyForm.preContainersList <= 0) {
- this.$message({
- type: "warning",
- message: "请先添加箱型数据!"
- });
- return
- }
- this.$confirm("确定平均分配?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- this.containersEqualDistributionfun(type)
- })
- },
- // 平均分配接口
- containersEqualDistributionfun(type) {
- containersEqualDistribution({
- pid: this.assemblyForm.id,
- type: type,
- waitingBox: this.assemblyForm.waitingBoxList[0]
- }).then(res => {
- if (res.data.data instanceof Array) {
- this.$message({
- type: "success",
- message: "操作成功!"
- })
- this.$emit('billsDetailfun')
- } else {
- // 没有除开
- this.$message({
- type: 'warning',
- dangerouslyUseHTMLString: true,
- message: '<span style="color:red">注意!!!件数不能平均分 ,请手工配箱,或者修改件数.</span>\n' +
- '<table border="1">\n' +
- ' <thead>\n' +
- ' <tr>\n' +
- ' <th></th>\n' +
- ' <th>件数</th>\n' +
- ' <th>毛重</th>\n' +
- ' <th>尺码</th>\n' +
- ' </tr>\n' +
- ' </thead>\n' +
- ' <tbody>\n' +
- ' <tr>\n' +
- ' <td>总数</td>\n' +
- ' <td>' + res.data.data.total.quantity + '</td>\n' +
- ' <td>' + res.data.data.total.grossWeight + '</td>\n' +
- ' <td>' + res.data.data.total.grossWeight + '</td>\n' +
- ' </tr>\n' +
- ' <tr>\n' +
- ' <td>入箱</td>\n' +
- ' <td>' + res.data.data.average.quantity + '</td>\n' +
- ' <td>' + res.data.data.average.grossWeight + '</td>\n' +
- ' <td>' + res.data.data.average.grossWeight + '</td>\n' +
- ' </tr>\n' +
- ' <tr>\n' +
- ' <td>差额</td>\n' +
- ' <td>' + res.data.data.subtract.quantity + '</td>\n' +
- ' <td>' + res.data.data.subtract.grossWeight + '</td>\n' +
- ' <td>' + res.data.data.subtract.grossWeight + '</td>\n' +
- ' </tr>\n' +
- ' </tbody>\n' +
- '</table>',
- duration: 5000
- });
- }
- })
- },
- corpClear(value, row) {
- this.$set(row, 'cntrTypeCode', null)
- this.$set(row, 'cntrTypeCodeId', null)
- this.$set(row, 'teu', null)
- },
- // 选择框的回调
- corpChange(value, row) {
- if (this.assemblyForm.preContainersList.filter(e => value == e.cntrTypeCode).length) {
- this.$set(row, 'cntrTypeCode', null)
- this.$set(row, 'cntrTypeCodeId', null)
- this.$set(row, 'teu', null)
- return this.$message.error('箱型不能重复')
- }
- for (let item of this.cntrTypeCodeData) {
- if (item.cnName == value) {
- this.$set(row, 'cntrTypeCode', item.cnName)
- this.$set(row, 'cntrTypeCodeId', item.id)
- this.$set(row, 'teu', item.teu)
- }
- }
- },
- // 筛选数据模糊查找
- remoteMethod(value, name) {
- this.bcntrtypesListfun(value)
- },
- // 获取箱型字典数据
- bcntrtypesListfun(cnName) {
- bcntrtypesList(1, 10, { cnName }).then(res => {
- this.cntrTypeCodeData = res.data.data.records
- })
- },
- // 添加按钮确认
- rowSave(row, done, loading) {
- row.pid = this.pid
- // 如果是冻柜,则需要输入相应的通度和温度、温度,如果不是冻柜,不需要输入相应的温度等内容;
- if (this.assemblyForm.cargoType == 'reefer') {
- // 要判断的必填
- const arr = [
- {
- name: "温度",
- value: "temperature",
- },
- {
- name: "温度单位",
- value: "temperatureUnit",
- },
- {
- name: "通风度",
- value: "ventilation",
- },
- {
- name: "湿度",
- value: "humidity",
- },
- ]
- if (!requiredMessage(row, arr)) {
- loading(); // 按钮的禁用关闭
- return;
- }
- }
- precontainersSubmit(row).then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$emit('billsDetailfun')
- done();
- }, error => {
- loading();
- window.console.log(error);
- });
- },
- // 编辑确认按钮
- rowUpdate(row, index) {
- let rulesRow = [
- {
- name: "尺码箱型",
- value: "cntrTypeCode",
- },
- {
- name: "箱量",
- value: "quantity",
- },
- ]
- if (!requiredMessage(row, rulesRow)) {
- return;
- }
- // 如果是冻柜,则需要输入相应的通度和温度、温度,如果不是冻柜,不需要输入相应的温度等内容;
- if (this.assemblyForm.cargoType == 'reefer') {
- // 要判断的必填
- const arr = [
- {
- name: "温度",
- value: "temperature",
- },
- {
- name: "温度单位",
- value: "temperatureUnit",
- },
- {
- name: "通风度",
- value: "ventilation",
- },
- {
- name: "湿度",
- value: "humidity",
- },
- ]
- if (!requiredMessage(row, arr)) {
- return;
- }
- }
- if (!this.pid) {
- this.$message({
- message: '请先保存数据之后才能添加',
- type: 'warning'
- });
- return
- }
- if (row.id) {
- this.$confirm("已经存在配箱信息,如果修改预配箱数据 要清除全部配箱信息?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- precontainersSubmit(row).then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$set(row, '$cellEdit', false)
- this.$emit('billsDetailfun')
- })
- })
- } else {
- row.pid = this.pid
- precontainersSubmit(row).then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$set(row, '$cellEdit', false)
- this.$emit('billsDetailfun')
- }, error => {
- console.log(error);
- });
- }
- },
- rowDel(row) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- if (!row.id) {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.assemblyForm.preContainersList.splice(row.$index, 1)
- } else {
- precontainersRemove(row.id).then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$emit('billsDetailfun')
- });
- }
- })
- },
- // 新增
- addfun() {
- this.$refs.crud.rowCellAdd({ pid: this.assemblyForm.id })
- // this.$refs.crud.rowAdd()
- },
- // 编辑
- editfun(row, index) {
- if (row.$cellEdit) {
- // 保存
- this.rowUpdate(row, index)
- // this.$set(row,'$cellEdit',false)
- } else {
- if (!this.assemblyForm.id) {
- this.$set(row, '$cellEdit', true)
- return
- }
- if (Number(this.assemblyForm.quantity) != Number(this.assemblyForm.waitingBoxList[0].quantity)) {
- this.$alert('当前数据已经均分箱量,请撤销之后再修改', '提示', {
- confirmButtonText: '确定',
- });
- } else {
- this.$set(row, '$cellEdit', true)
- }
- }
- // this.$refs.crud.rowEdit(row,index)
- },
- // 多选删除
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- this.precontainersRemovefun()
- })
- },
- // 删除接口
- precontainersRemovefun() {
- let multiList = this.selectionList
- let arr = this.assemblyForm.preContainersList
- // 获取有id 的数据
- const itemsWithId = multiList.filter(item => item.hasOwnProperty('id'));
- let arrIds = itemsWithId.map(item => item.id) // 获取id 数据
- // 把选中的删除掉
- multiList.forEach((item) => {
- for (let index in arr) {
- if (JSON.stringify(item) == JSON.stringify(arr[index])) {
- arr.splice(Number(index), 1)
- }
- }
- })
- // 有id 的处理
- if (itemsWithId.length != 0) {
- precontainersRemove(arrIds.join(',')).then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- // this.$emit('billsDetailfun')
- this.$refs.crud.toggleSelection();
- })
- };
- },
- beforeOpen(done, type) {
- if (["edit", "view"].includes(type)) {
- precontainersDetail(this.form.id).then(res => {
- this.form = res.data.data;
- });
- }
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- refreshChange() {
- console.log('刷新')
- },
- //自定义列保存
- async saveColumnTwo(ref, option, optionBack, code) {
- /**
- * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
- * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
- * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
- */
- const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- }
- },
- //自定义列重置
- async resetColumnTwo(ref, option, optionBack, code) {
- this[option] = this[optionBack];
- const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
- if (inSave) {
- this.$message.success("重置成功");
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- }
- },
- }
- };
- </script>
- <style scoped lang="scss">
- ::v-deep .el-dialog__body {
- padding: 0px 10px !important;
- }
- </style>
|