绑定编码问题优化

This commit is contained in:
BianLzhaoMin 2024-08-27 18:09:30 +08:00
parent 212095bea9
commit 1eab23e306
1 changed files with 117 additions and 31 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,7 +165,7 @@
: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" />
@ -174,23 +174,32 @@
<el-input v-model="form.exCode" @change="fillingCodeList" />
</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"
type="number"
style="width: 120px"
@change="onChangeCodeNum"
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 +232,7 @@
</el-form>
<el-row class="surplus-code">
剩余待编码数量<span style="color: red">{{
待编码数量<span style="color: red">{{
surplusNoBindNum
}}</span>
</el-row>
@ -289,7 +298,7 @@
size="mini"
type="text"
icon="el-icon-delete"
@click="delCode(scope.row)"
@click="delCode(scope.$index)"
>删除</el-button
>
</template>
@ -389,6 +398,7 @@ export default {
suffixOneCode: 0,
suffixTwoCode: 0,
codeNum: 0,
},
codeList: [], //list
getCodeList: [], //list
@ -407,23 +417,22 @@ export default {
},
codeRules: {
exCode: [
{
required: true,
message: '请输入前缀',
trigger: 'blur',
},
],
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 +440,18 @@ export default {
// trigger: 'blur',
// },
],
// suffixTwoCode: [
// {
// required: true,
// message: '',
// trigger: 'blur',
// },
// // {
// // pattern: /^[1-9]\d*$/,
// // message: '',
// // trigger: 'blur',
// // },
// ],
},
isDetail: false,
@ -571,8 +592,68 @@ 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.codeList = []
this.$refs['formCodeRef'].validate((valid) => {
if (valid) {
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.form.typeName,
specificationType: this.form.specificationType,
typeId: this.form.typeId,
taskId: this.form.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)
@ -769,15 +850,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);
@ -793,6 +876,8 @@ export default {
},
async handleBindDetails(row) {
console.log('🚀 ~ handleBindDetails ~ row:', row.taskId)
this.surplusNoBindNum =
parseInt(row.checkNum) - parseInt(row.bindNum)
this.open = true
this.isDetail = true
this.title = '编码绑定详情'
@ -810,8 +895,9 @@ export default {
open: {
handler(newValue) {
if (!newValue) {
this.form.suffixOneCode = ''
this.form.suffixTwoCode = ''
this.form.suffixOneCode = 0
// this.form.suffixTwoCode = ''
this.form.codeNum = 0
this.form.fixCode = '1'
}
},