|
|
@@ -74,6 +74,10 @@ export default {
|
|
|
type: 'copyIce',
|
|
|
title: '复制冰排',
|
|
|
icon: 'el-icon-copy-document',
|
|
|
+ }, {
|
|
|
+ type: 'batchEdit',
|
|
|
+ title: '批量修改',
|
|
|
+ icon: 'el-icon-edit-outline',
|
|
|
}],
|
|
|
formList: [{
|
|
|
type: 'input',
|
|
|
@@ -125,6 +129,7 @@ export default {
|
|
|
limitNoil: true,
|
|
|
iceCode: [],
|
|
|
copyFlag: false,
|
|
|
+ batchEditRows: [],
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -143,6 +148,77 @@ export default {
|
|
|
this.getList()
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 组装冷冻要求
|
|
|
+ formatFreezeClaim(nums = []) {
|
|
|
+ let arr2 = []
|
|
|
+ nums.forEach(item => {
|
|
|
+ if (typeof item === 'number') {
|
|
|
+ arr2.push(item)
|
|
|
+ } else if (typeof item === 'string') {
|
|
|
+ const arr1 = item.split('小时')
|
|
|
+ const num = Number(arr1[0])
|
|
|
+ if (!isNaN(num)) {
|
|
|
+ arr2.push(num)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return arr2
|
|
|
+ },
|
|
|
+ // 批量修改可用表单
|
|
|
+ getBatchFormRules() {
|
|
|
+ const source = this.iceColdFlag ? formRulesCold() : formRules()
|
|
|
+ return source.filter(item => item.field !== 'code' && item.field !== 'copyflag').map(rule => {
|
|
|
+ const newRule = {
|
|
|
+ ...rule
|
|
|
+ }
|
|
|
+ if (newRule.rules) {
|
|
|
+ newRule.rules = newRule.rules.map(r => ({
|
|
|
+ ...r,
|
|
|
+ required: false
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ return newRule
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 重置表单
|
|
|
+ resetRuleFormFields() {
|
|
|
+ this.ruleForm.code = ''
|
|
|
+ this.ruleForm.status = null
|
|
|
+ this.ruleForm.freezeClaim = []
|
|
|
+ this.ruleForm.coolerBoxId = []
|
|
|
+ this.ruleForm.label = ''
|
|
|
+ this.ruleForm.suitableForCold = ''
|
|
|
+ this.ruleForm.forColdTime = null
|
|
|
+ this.ruleForm.iceColdAddress = ''
|
|
|
+ this.ruleForm.sort = null
|
|
|
+ this.ruleForm.copyNumber = null
|
|
|
+ },
|
|
|
+ hasBatchEditChanges() {
|
|
|
+ const commonFields = ['status', 'label', 'suitableForCold', 'forColdTime', 'iceColdAddress', 'sort']
|
|
|
+ const freezeChanged = Array.isArray(this.ruleForm.freezeClaim) && this.ruleForm.freezeClaim.length > 0
|
|
|
+ const otherChanged = commonFields.some(field => this.ruleForm[field] !== '' && this.ruleForm[field] !== null && this.ruleForm[field] !== undefined)
|
|
|
+ return freezeChanged || otherChanged
|
|
|
+ },
|
|
|
+ buildBatchEditParams(row) {
|
|
|
+ const freezeClaim = (Array.isArray(this.ruleForm.freezeClaim) && this.ruleForm.freezeClaim.length > 0) ? this.formatFreezeClaim(this.ruleForm.freezeClaim) : row.freezeClaim
|
|
|
+ const formatNumber = (fieldValue, fallback) => {
|
|
|
+ if (fieldValue === '' || fieldValue === null || fieldValue === undefined) {
|
|
|
+ return fallback
|
|
|
+ }
|
|
|
+ return Number(fieldValue)
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ id: row.id,
|
|
|
+ code: row.code,
|
|
|
+ status: this.ruleForm.status === null || this.ruleForm.status === undefined ? row.status : this.ruleForm.status,
|
|
|
+ freezeClaim: freezeClaim || [],
|
|
|
+ label: this.ruleForm.label !== '' && this.ruleForm.label !== null ? this.ruleForm.label : row.label,
|
|
|
+ suitableForCold: this.ruleForm.suitableForCold !== '' && this.ruleForm.suitableForCold !== null ? this.ruleForm.suitableForCold : row.suitableForCold,
|
|
|
+ forColdTime: formatNumber(this.ruleForm.forColdTime, row.forColdTime),
|
|
|
+ iceColdAddress: this.ruleForm.iceColdAddress !== '' && this.ruleForm.iceColdAddress !== null ? this.ruleForm.iceColdAddress : row.iceColdAddress,
|
|
|
+ sort: formatNumber(this.ruleForm.sort, row.sort),
|
|
|
+ }
|
|
|
+ },
|
|
|
// 搜索
|
|
|
searchProtocol(value) {
|
|
|
this.Pagination.PageIndex = 1
|
|
|
@@ -173,15 +249,6 @@ export default {
|
|
|
handleAdd() {
|
|
|
let flag = this.$refs['childRules'].validateForm();
|
|
|
if (flag) {
|
|
|
- var turnNum = function (nums) {
|
|
|
- let arrNum = nums
|
|
|
- let arr2 = []
|
|
|
- arrNum.forEach(item => {
|
|
|
- var arr1 = item.split('小时')
|
|
|
- arr2.push(Number(arr1[0]))
|
|
|
- })
|
|
|
- return arr2;
|
|
|
- }
|
|
|
if (this.operationType == 'add') {
|
|
|
this.confirmLoading = true
|
|
|
let arr = []
|
|
|
@@ -189,7 +256,7 @@ export default {
|
|
|
var params = {
|
|
|
codeList: arr,
|
|
|
status: this.ruleForm.status,
|
|
|
- freezeClaim: turnNum(this.ruleForm.freezeClaim),
|
|
|
+ freezeClaim: this.formatFreezeClaim(this.ruleForm.freezeClaim),
|
|
|
label: this.ruleForm.label,
|
|
|
suitableForCold: this.ruleForm.suitableForCold,
|
|
|
forColdTime: Number(this.ruleForm.forColdTime),
|
|
|
@@ -218,7 +285,7 @@ export default {
|
|
|
id: this.selectingData.id,
|
|
|
code: this.ruleForm.code,
|
|
|
status: this.ruleForm.status,
|
|
|
- freezeClaim: turnNum(this.ruleForm.freezeClaim),
|
|
|
+ freezeClaim: this.formatFreezeClaim(this.ruleForm.freezeClaim),
|
|
|
label: this.ruleForm.label,
|
|
|
suitableForCold: this.ruleForm.suitableForCold,
|
|
|
forColdTime: Number(this.ruleForm.forColdTime),
|
|
|
@@ -277,6 +344,35 @@ export default {
|
|
|
}).catch(() => {
|
|
|
this.confirmLoading = false
|
|
|
})
|
|
|
+ } else if (this.operationType == 'batchEdit') {
|
|
|
+ if (!this.batchEditRows.length) {
|
|
|
+ this.$message.warning('请先选择需要批量修改的冰排')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.hasBatchEditChanges()) {
|
|
|
+ this.$message.warning('请至少填写一个需要修改的字段')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.confirmLoading = true
|
|
|
+ const requests = this.batchEditRows.map(row => {
|
|
|
+ const params = this.buildBatchEditParams(row)
|
|
|
+ return putIceRaft(params)
|
|
|
+ })
|
|
|
+ Promise.all(requests).then(res => {
|
|
|
+ this.$message({
|
|
|
+ message: '批量修改成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.getList()
|
|
|
+ if (this.$refs.refWaybill) {
|
|
|
+ this.$refs.refWaybill.clearSelected()
|
|
|
+ }
|
|
|
+ this.staffDialogVisible = false
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message.error('批量修改失败')
|
|
|
+ }).finally(() => {
|
|
|
+ this.confirmLoading = false
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
this.$message.error('表单信息不完整,请继续填写完整');
|
|
|
@@ -381,6 +477,22 @@ export default {
|
|
|
type: 'warning'
|
|
|
});
|
|
|
}
|
|
|
+ } else if (type == 'batchEdit') {
|
|
|
+ const selectedRows = this.$refs.refWaybill ? this.$refs.refWaybill.waybillIds : []
|
|
|
+ if (!selectedRows || selectedRows.length === 0) {
|
|
|
+ this.$message({
|
|
|
+ message: '请先选择需要批量修改的冰排',
|
|
|
+ type: 'warning'
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.batchEditRows = JSON.parse(JSON.stringify(selectedRows))
|
|
|
+ this.copyFlag = false
|
|
|
+ this.iceTracing = false
|
|
|
+ this.staffTitle = '批量修改'
|
|
|
+ this.formRuleList = this.getBatchFormRules()
|
|
|
+ this.resetRuleFormFields()
|
|
|
+ this.staffDialogVisible = true
|
|
|
} else if (type == 'copyIce') {
|
|
|
this.operationType = 'add'
|
|
|
const arrID = this.$refs.refWaybill.waybillIds
|
|
|
@@ -531,6 +643,8 @@ export default {
|
|
|
// 清空表单
|
|
|
closeDialog() {
|
|
|
this.copyFlag = false
|
|
|
+ this.batchEditRows = []
|
|
|
+ this.resetRuleFormFields()
|
|
|
this.$refs.childRules.resetCheck();
|
|
|
}
|
|
|
},
|