新购,盘点编码问题优化

This commit is contained in:
BianLzhaoMin 2024-08-29 15:14:44 +08:00
parent 9ceacbde8d
commit 78d6b4b2ad
3 changed files with 249 additions and 90 deletions

View File

@ -156,7 +156,7 @@
:title="title"
:visible.sync="open"
v-if="open"
width="1000px"
width="80%"
append-to-body
:close-on-click-modal="false"
>
@ -165,32 +165,39 @@
:model="form"
:rules="codeRules"
:inline="true"
label-width="78px"
label-width="100px"
v-if="!isDetail"
>
<el-input v-model="form.typeId" disabled v-show="false" />
<el-form-item label="编码前缀" prop="exCode">
<el-input v-model="form.exCode" @change="fillingCodeList" />
<el-input v-model="form.exCode" />
</el-form-item>
<el-form-item label="后缀范围" prop="suffixOneCode">
<el-form-item label="后缀起始值" prop="suffixOneCode">
<el-input
v-model="form.suffixOneCode"
placeholder="0001"
maxlength="4"
style="width: 100px"
maxlength="99999999"
clearable
/>
</el-form-item>
<el-form-item prop="suffixTwoCode">
<el-form-item label="编码数量" prop="codeNum">
<el-input
v-model="form.codeNum"
style="width: 120px"
clearable
/>
</el-form-item>
<!-- <el-form-item prop="suffixTwoCode">
<el-input
v-model="form.suffixTwoCode"
placeholder="0005"
maxlength="4"
style="width: 100px"
/>
</el-form-item>
</el-form-item> -->
<el-form-item label="固定资产" prop="fixCode">
<el-select
v-model="form.fixCode"
@ -223,7 +230,7 @@
</el-form>
<el-row class="surplus-code">
剩余待编码数量<span style="color: red">{{
待编码数量<span style="color: red">{{
surplusNoBindNum
}}</span>
</el-row>
@ -289,7 +296,7 @@
size="mini"
type="text"
icon="el-icon-delete"
@click="delCode(scope.row)"
@click="delCode(scope.$index)"
>删除</el-button
>
</template>
@ -379,6 +386,7 @@ export default {
// pageSize: 10,
typeName: undefined,
},
codeInfo: null,
//
form: {
exCode: '',
@ -387,8 +395,9 @@ export default {
fixCode: '1',
typeId: '',
suffixOneCode: 0,
suffixOneCode: '',
suffixTwoCode: 0,
codeNum: '',
},
codeList: [], //list
getCodeList: [], //list
@ -407,23 +416,33 @@ export default {
},
codeRules: {
exCode: [
{
required: true,
message: '请输入前缀',
trigger: 'blur',
},
],
codeNum: [
{
required: true,
message: '请输入编码数量',
trigger: 'blur',
},
{
pattern: /^[1-9][0-9]*$/,
message: '请输入大于0且不能以0开头的正整数',
},
],
suffixOneCode: [
{
required: true,
message: '请输入后缀范围',
message: '请输入后缀起始值',
trigger: 'blur',
},
// {
// pattern: /^[1-9]\d*$/,
// message: '',
// trigger: 'blur',
// },
],
suffixTwoCode: [
{
required: true,
message: '请输入后缀范围',
trigger: 'blur',
pattern: /^[1-9][0-9]*$/,
message: '请输入大于0且不能以0开头的正整数',
},
// {
// pattern: /^[1-9]\d*$/,
@ -431,6 +450,18 @@ export default {
// trigger: 'blur',
// },
],
// suffixTwoCode: [
// {
// required: true,
// message: '',
// trigger: 'blur',
// },
// // {
// // pattern: /^[1-9]\d*$/,
// // message: '',
// // trigger: 'blur',
// // },
// ],
},
isDetail: false,
@ -453,6 +484,7 @@ export default {
})
},
selectType(id) {
console.log(id)
getListByMaType({ typeId: id }).then((response) => {
this.modelList = response.data
})
@ -467,8 +499,12 @@ export default {
},
//
cancel() {
this.reset()
// this.reset()
this.resetForm('formCodeRef')
this.open = false
// this.form.suffixOneCode = ''
// this.form.codeNum = ''
},
//
reset() {
@ -504,36 +540,37 @@ export default {
}, //getCodeList newCodeList
/** 编码按钮操作 */ handleCode(row) {
console.log(row)
this.reset()
this.form = row
// this.reset()
// this.form = row
this.codeInfo = row
if (!this.form.fixCode) {
this.form.fixCode = '1'
}
this.$set(this.form, 'str', '')
this.$set(this.form, 'str1', '')
// this.$set(this.form, 'str', '')
// this.$set(this.form, 'str1', '')
// this.$set(this.form,'fixCode','1')
let arr = this.form.arrivalTime.split('-')
let arr = row.arrivalTime.split('-')
// this.form.exCode = ;
// this.form.typeCode=111
if (!this.form.typeCode) {
this.form.typeCode = ''
}
if (!this.form.specsCode) {
this.form.specsCode = ''
}
this.$set(
this.form,
'exCode',
'NSJJ' +
this.form.typeCode +
this.form.specsCode +
arr[0][2] +
arr[0][3] +
arr[1],
)
// if (!this.form.typeCode) {
// this.form.typeCode = ''
// }
// if (!this.form.specsCode) {
// this.form.specsCode = ''
// }
// this.$set(
// this.form,
// 'exCode',
// 'NSJJ' +
// this.form.typeCode +
// this.form.specsCode +
// arr[0][2] +
// arr[0][3] +
// arr[1],
// )
this.form.count = row.checkNum
this.form.exCode = 'NSJJ' + arr[0][2] + arr[0][3] + arr[1]
// this.form.count = row.checkNum
this.codeList = []
this.open = true
this.title = '生成编码'
@ -548,7 +585,7 @@ export default {
// });
this.surplusNoBindNum =
parseInt(this.form.checkNum) - parseInt(this.form.bindNum)
parseInt(row.checkNum) - parseInt(row.bindNum)
},
//codeList
createCodeList() {
@ -570,8 +607,74 @@ export default {
// this.codeList = this.getCodeList.concat(this.newCodeList)
// }
},
//
onChangeCodeNum(val) {
this.$message.closeAll()
let regex = /^[1-9][0-9]*$/
if (!regex.test(val)) {
this.$message.error('请输入大于0且不能以0开头的正整数')
return
}
if (val * 1 > this.surplusNoBindNum) {
this.$message.error('编码数量不能大于待编码数量')
this.form.codeNum = this.surplusNoBindNum
return
}
},
//
fillingCodeList() {
this.$message.closeAll()
this.$refs['formCodeRef'].validate((valid) => {
if (valid) {
if (this.form.codeNum * 1 > this.surplusNoBindNum) {
this.$message.error('编码数量不能大于待编码数量')
this.form.codeNum = this.surplusNoBindNum
return
}
this.codeList = []
let codeNum = 0
if (
!this.form.codeNum ||
this.form.codeNum == this.surplusNoBindNum
) {
codeNum = this.surplusNoBindNum
} else {
codeNum = this.form.codeNum
}
for (let i = 0; i < codeNum; i++) {
let obj = {
typeName: this.codeInfo.typeName,
specificationType: this.codeInfo.specificationType,
typeId: this.codeInfo.typeId,
taskId: this.codeInfo.taskId,
maCode: this.form.suffixOneCode * 1 + i,
assetsCode: '',
fixCode: this.form.fixCode,
}
this.codeList.push(obj)
}
this.codeList.forEach((e) => {
if (e.maCode < 10) {
e.maCode = `000${e.maCode}`
} else if (e.maCode < 100) {
e.maCode = `00${e.maCode}`
} else if (e.maCode < 1000) {
e.maCode = `0${e.maCode}`
} else {
}
})
this.codeList.forEach((e) => {
e.maCode = this.form.exCode + e.maCode
})
// console.log(this.codeList, 'this.codeList')
}
})
if (true) return
// console.log(Number(this.form.str))
// this.codeList = []
// let num = Number(this.form.str)
@ -768,15 +871,17 @@ export default {
this.codeList = this.getCodeList.concat(this.newCodeList)
})
},
delCode(row) {
console.log(row)
this.codeList.forEach((item, index) => {
if (item.maCode == row.maCode) {
delCode(index) {
this.codeList.splice(index, 1)
}
})
console.log(index, '索引')
// console.log(row)
// this.codeList.forEach((item, index) => {
// if (item.maCode == row.maCode) {
// this.codeList.splice(index, 1)
// }
// })
this.surplusNoBindNum += 1
// this.surplusNoBindNum += 1
// const maCode = row.maCode ;
// this.$modal.confirm('').then(function() {
// return delMacodeList(maCode);
@ -791,8 +896,9 @@ export default {
this.$tab.closeOpenPage(obj)
},
async handleBindDetails(row) {
console.log('🚀 ~ handleBindDetails ~ row:', row.taskId, row)
this.surplusNoBindNum = row.checkNum - row.bindNum
console.log('🚀 ~ handleBindDetails ~ row:', row.taskId)
this.surplusNoBindNum =
parseInt(row.checkNum) - parseInt(row.bindNum)
this.open = true
this.isDetail = true
this.title = '编码绑定详情'
@ -811,7 +917,8 @@ export default {
handler(newValue) {
if (!newValue) {
this.form.suffixOneCode = ''
this.form.suffixTwoCode = ''
// this.form.suffixTwoCode = ''
this.form.codeNum = ''
this.form.fixCode = '1'
}
},

View File

@ -68,7 +68,7 @@
"
/>
<el-table-column label="入库来源" align="center" prop="putInType" />
<el-table-column
<!-- <el-table-column
label="工程名称"
align="center"
prop="projectName"
@ -79,7 +79,7 @@
align="center"
prop="unitName"
:show-overflow-tooltip="true"
/>
/> -->
<el-table-column
label="单号"
align="center"
@ -249,7 +249,7 @@
<el-col :span="10">
<el-form-item
label="后缀范围"
label="后缀起始值"
label-width="130px"
prop="codeSuffixStart"
v-if="!isNumCheck"
@ -257,15 +257,12 @@
<el-input
v-model="codeForm.codeSuffixStart"
clearable
placeholder="请输入后缀范围起始值"
maxlength="10"
style="width: 185px"
@change="
changeSuffixStart(codeForm.codeSuffixStart)
"
placeholder="请输入后缀起始值"
maxlength="99999999"
style="width: 400px"
/>
</el-form-item>
<el-form-item
<!-- <el-form-item
label="~"
label-width="auto"
prop="codeSuffixEnd"
@ -279,7 +276,7 @@
style="width: 185px"
@change="changeSuffixEnd"
/>
</el-form-item>
</el-form-item> -->
</el-col>
<el-col :span="7">
<el-form-item
@ -360,10 +357,17 @@
if (codeForm.thisCheckTime) {
let today = new Date()
today.setHours(0, 0, 0, 0)
return time.getTime() < today.getTime() || time.getTime() < new Date(codeForm.thisCheckTime).getTime()
return (
time.getTime() <
today.getTime() ||
time.getTime() <
new Date(
codeForm.thisCheckTime,
).getTime()
)
}
return false
}
},
}"
/>
</el-form-item>
@ -478,7 +482,7 @@
type="textarea"
placeholder="请输入备注"
maxlength="100"
rows="4"
rows="1"
show-word-limit
style="width: 400px"
/>
@ -537,6 +541,7 @@
:data="codeTableList"
v-if="!isNumCheck"
@selection-change="handleSelectionChange"
height="400"
:stripe="true"
>
<!-- <el-table-column type="selection" width="55" align="center" /> -->
@ -552,7 +557,7 @@
:show-overflow-tooltip="true"
>
<template v-slot:header>
<span style="color: red;">* </span>设备编码
<span style="color: red">* </span>设备编码
</template>
<template v-slot:default="{ row }" v-if="!isNumCheck">
<el-input
@ -633,10 +638,16 @@
if (row.thisCheckTime) {
let today = new Date()
today.setHours(0, 0, 0, 0)
return time.getTime() < today.getTime() || time.getTime() < new Date(row.thisCheckTime).getTime()
return (
time.getTime() < today.getTime() ||
time.getTime() <
new Date(
row.thisCheckTime,
).getTime()
)
}
return false
}
},
}"
></el-date-picker>
</template>
@ -930,7 +941,7 @@ export default {
remarks: undefined,
typeId: undefined,
num: undefined,
codePrefix: undefined,
codePrefix: 'PD-CODE',
codeSuffixStart: undefined,
codeSuffixEnd: undefined,
buyPrice: undefined,
@ -960,6 +971,20 @@ export default {
],
},
codeFormRules: {
codePrefix: [
{ required: true, message: '请输入前缀', trigger: 'blur' },
],
codeSuffixStart: [
{
required: true,
message: '请输入后缀起始值',
trigger: 'blur',
},
{
pattern: /^[1-9][0-9]*$/,
message: '请输入大于0且不能以0开头的正整数',
},
],
putInType: [
{
required: true,
@ -1054,7 +1079,7 @@ export default {
remarks: undefined,
typeId: null,
num: undefined,
codePrefix: undefined,
codePrefix: 'PD-CODE',
codeSuffixStart: undefined,
codeSuffixEnd: undefined,
buyPrice: undefined,
@ -1129,7 +1154,7 @@ export default {
// : codeForm.buyPrice
const buyPrice = this.codeForm.buyPrice || 0
this.codeTableList.push({
maCode,
maCode: this.codeForm.codeSuffixStart * 1 + i,
outFacCode,
maVender,
thisCheckTime,
@ -1137,6 +1162,20 @@ export default {
buyPrice,
})
}
this.codeTableList.forEach((e) => {
if (e.maCode < 10) {
e.maCode = `000${e.maCode}`
} else if (e.maCode < 100) {
e.maCode = `00${e.maCode}`
} else if (e.maCode < 1000) {
e.maCode = `0${e.maCode}`
} else {
}
})
this.codeTableList.forEach((e) => {
e.maCode = this.codeForm.codePrefix + e.maCode
})
}
})
},
@ -1147,7 +1186,10 @@ export default {
this.codeForm.codeSuffixStart =
this.codeForm.codeSuffixStart.replace(/[^\d]/g, '')
}
if (isNaN(this.codeForm.codeSuffixStart) || this.codeForm.codeSuffixStart.includes('.')) {
if (
isNaN(this.codeForm.codeSuffixStart) ||
this.codeForm.codeSuffixStart.includes('.')
) {
this.$message.error('后缀范围请输入整数类型')
this.codeForm.codeSuffixStart = ''
}
@ -1156,7 +1198,10 @@ export default {
if (!this.codeForm.codeSuffixStart) {
this.$message.error('请输入后缀范围起始值')
this.codeForm.codeSuffixEnd = ''
} else if (isNaN(this.codeForm.codeSuffixEnd) || this.codeForm.codeSuffixEnd.includes('.')) {
} else if (
isNaN(this.codeForm.codeSuffixEnd) ||
this.codeForm.codeSuffixEnd.includes('.')
) {
this.$message.error('后缀范围请输入整数类型')
this.codeForm.codeSuffixEnd =
this.codeForm.codeSuffixStart.replace(/[^\d]/g, '')
@ -1415,24 +1460,28 @@ export default {
}
const res = await getDeviceTypeTree(params)
if (type) {
this.disableNodes(res.data, '1');
this.disableNodes(res.data, '1')
} else {
this.disableNodes(res.data, '0');
this.disableNodes(res.data, '0')
}
this.deviceTypeTree = res.data
},
//
disableNodes(nodes, manageType, level = 1) {
nodes.forEach(node => {
nodes.forEach((node) => {
node.level = level
if (node.children) {
this.disableNodes(node.children, manageType, level + 1);
this.disableNodes(node.children, manageType, level + 1)
} else if (!node.children && node.level < 4) {
node.disabled = true
} else if(node.manageType && node.level == 4 && node.manageType != manageType) {
} else if (
node.manageType &&
node.level == 4 &&
node.manageType != manageType
) {
node.disabled = true
}
});
})
},
///////
deviceTypeChange(val) {
@ -1571,7 +1620,10 @@ export default {
},
//
changeCheckTime() {
if (this.codeForm.nextCheckTime && this.codeForm.thisCheckTime > this.codeForm.nextCheckTime) {
if (
this.codeForm.nextCheckTime &&
this.codeForm.thisCheckTime > this.codeForm.nextCheckTime
) {
this.codeForm.nextCheckTime = ''
this.$message.warning('下次检验日期不能早于检验日期!')
} else if (!this.codeForm.thisCheckTime) {

View File

@ -44,7 +44,7 @@ module.exports = {
// target: `http://192.168.2.152:39080`, //超
// target: `http://10.40.92.81:8080`, //韩/
target: `http://192.168.2.81:49080`,//旭/
target: `http://192.168.2.81:39080`,//旭/
// target: `http://10.40.92.138:28080`, //帅
// target: `http://192.168.2.218:39080`, //福
// target: `http://192.168.2.120:39080`, //跃