新购,盘点编码问题优化

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

View File

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

View File

@ -44,7 +44,7 @@ module.exports = {
// target: `http://192.168.2.152:39080`, //超 // target: `http://192.168.2.152:39080`, //超
// target: `http://10.40.92.81:8080`, //韩/ // 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://10.40.92.138:28080`, //帅
// target: `http://192.168.2.218:39080`, //福 // target: `http://192.168.2.218:39080`, //福
// target: `http://192.168.2.120:39080`, //跃 // target: `http://192.168.2.120:39080`, //跃