优化页面

This commit is contained in:
BianLzhaoMin 2024-08-01 11:21:26 +08:00
parent 2b65a0fd6c
commit e7f64beeb5
1 changed files with 246 additions and 94 deletions

View File

@ -155,61 +155,55 @@
<el-dialog
:title="title"
:visible.sync="open"
v-if="open"
width="1000px"
append-to-body
:close-on-click-modal="false"
>
<el-row :gutter="24" class="mb8">
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="78px"
v-if="!isDetail"
>
<el-input v-model="form.typeId" disabled v-show="false" />
<el-col :span="7">
<el-form-item label="编码前缀" prop="exCode">
<el-input
v-model="form.exCode"
@change="fillingCodeList"
/>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item label="后缀范围">
<div style="display: flex">
<el-input
v-model="form.str"
placeholder="0001"
maxlength="4"
@change="fillingCodeList"
></el-input>
-
<el-input
v-model="form.str1"
placeholder="0005"
maxlength="4"
@change="fillingCodeList"
></el-input>
</div>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="固定资产" prop="fixCode">
<el-select
v-model="form.fixCode"
placeholder="是否为固定资产"
@change="fillingCodeList"
clearable
allow-create
>
<el-option label="是" value="0" />
<el-option label="否" value="1" />
</el-select>
</el-form-item>
</el-col>
<!-- <el-col :span="2">
<el-form
ref="formCodeRef"
:model="form"
:rules="codeRules"
:inline="true"
label-width="78px"
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-form-item>
<el-form-item label="后缀范围" prop="suffixOneCode">
<el-input
v-model="form.suffixOneCode"
placeholder="0001"
maxlength="4"
style="width: 100px"
/>
</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 label="固定资产" prop="fixCode">
<el-select
v-model="form.fixCode"
placeholder="是否为固定资产"
clearable
allow-create
style="width: 100px"
>
<el-option label="是" value="0" />
<el-option label="否" value="1" />
</el-select>
</el-form-item>
<!-- <el-col :span="2">
<el-button
type="primary"
plain
@ -217,16 +211,21 @@
@click="createCodeList"
>生成</el-button>
</el-col>-->
<el-col :span="2">
<el-button
type="primary"
plain
size="mini"
@click="fillingCodeList"
>填充</el-button
>
</el-col>
</el-form>
<el-form-item>
<el-button
type="primary"
plain
size="mini"
@click="fillingCodeList"
>填充</el-button
>
</el-form-item>
</el-form>
<el-row class="surplus-code">
剩余待编码数量<span style="color: red">{{
surplusNoBindNum
}}</span>
</el-row>
<el-table v-loading="loading" :data="codeList" height="400">
<!-- <el-table-column type="selection" width="50" align="center" /> -->
@ -253,10 +252,12 @@
>
<template slot-scope="scope">
<el-input
:ref="`inputRef-${scope.row.id}`"
v-if="!isDetail"
v-model="scope.row.maCode"
:disabled="scope.row.statusFlag == 0"
οninput="value=value.replace(/[^0-9.]/g,'')"
maxlength="24"
></el-input>
<span v-else>{{ scope.row.maCode }}</span>
</template>
@ -296,7 +297,11 @@
</el-table>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button type="primary" @click="submitForm" v-if="!isDetail"
<el-button
type="primary"
@click="submitForm"
v-if="!isDetail"
:loading="codingLoading"
> </el-button
>
<el-button @click="cancel"> </el-button>
@ -381,6 +386,9 @@ export default {
str1: '',
fixCode: '1',
typeId: '',
suffixOneCode: 0,
suffixTwoCode: 0,
},
codeList: [], //list
getCodeList: [], //list
@ -397,7 +405,37 @@ export default {
// { required: true, message: "", trigger: "blur" }
// ],
},
codeRules: {
suffixOneCode: [
{
required: true,
message: '请输入后缀范围',
trigger: 'blur',
},
// {
// pattern: /^[1-9]\d*$/,
// message: '',
// trigger: 'blur',
// },
],
suffixTwoCode: [
{
required: true,
message: '请输入后缀范围',
trigger: 'blur',
},
// {
// pattern: /^[1-9]\d*$/,
// message: '',
// trigger: 'blur',
// },
],
},
isDetail: false,
surplusNoBindNum: 0,
codingLoading: false,
}
},
mounted() {
@ -466,7 +504,7 @@ export default {
this.multiple = !selection.length
}, //getCodeList newCodeList
/** 编码按钮操作 */ handleCode(row) {
console.log(row, '编码管理---')
console.log(row)
this.reset()
this.form = row
@ -488,7 +526,7 @@ export default {
this.$set(
this.form,
'exCode',
'CSJJ' +
'NSJJ' +
this.form.typeCode +
this.form.specsCode +
arr[0][2] +
@ -509,6 +547,9 @@ export default {
// this.codeList = response.data;
// });
this.surplusNoBindNum =
parseInt(this.form.checkNum) - parseInt(this.form.bindNum)
},
//codeList
createCodeList() {
@ -532,15 +573,91 @@ export default {
},
//
fillingCodeList() {
console.log(Number(this.form.str))
this.codeList = []
let num = Number(this.form.str)
// console.log(Number(this.form.str1))
let num1 = Number(this.form.str1)
let count = num1 - num + 1 //
console.log()
let sum = count + this.form.bindNum
console.log(sum)
// console.log(Number(this.form.str))
// this.codeList = []
// let num = Number(this.form.str)
// // console.log(Number(this.form.str1))
// let num1 = Number(this.form.str1)
// let count = num1 - num + 1 //
// console.log()
// let sum = count + this.form.bindNum
// console.log(sum)
if (this.codeList.length === this.surplusNoBindNum) {
this.$modal.msgError('当前编码已填充,不可重复操作!')
return
}
this.$refs['formCodeRef'].validate((valid) => {
if (valid) {
if (
isNaN(this.form.suffixOneCode) ||
isNaN(this.form.suffixTwoCode) ||
parseInt(this.form.suffixOneCode) >
parseInt(this.form.suffixTwoCode)
) {
this.$modal.msgError('编码后缀范围输入格式不正确')
return
}
let suffixOneCode = parseInt(this.form.suffixOneCode)
let suffixTwoCode = parseInt(this.form.suffixTwoCode)
let sumNum = suffixTwoCode - suffixOneCode + 1
if (sumNum > this.surplusNoBindNum) {
this.$modal.msgError(
'当前选择的编码数量已超过剩余未编码数量!',
)
return
}
if (this.codeList.length === 0) {
for (let i = 0; i < sumNum; i++) {
let obj = {
typeName: this.form.typeName,
specificationType: this.form.specificationType,
typeId: this.form.typeId,
taskId: this.form.taskId,
maCode:
this.form.exCode +
('00000' + (suffixOneCode + i)).slice(-4),
assetsCode: '',
fixCode: this.form.fixCode,
id: ('00000' + (suffixOneCode + i)).slice(-4),
}
this.codeList.push(obj)
}
this.surplusNoBindNum -= this.codeList.length
} else {
for (let i = 0; i < sumNum; i++) {
let obj = {
typeName: this.form.typeName,
specificationType: this.form.specificationType,
typeId: this.form.typeId,
taskId: this.form.taskId,
maCode:
this.form.exCode +
('00000' + (suffixOneCode + i)).slice(-4),
assetsCode: '',
fixCode: this.form.fixCode,
id: ('00000' + (suffixOneCode + i)).slice(-4),
}
const isRepeat = this.codeList.every(
(e) => e.id != obj.id,
)
if (isRepeat) {
this.codeList.push(obj)
this.surplusNoBindNum -= 1
}
}
}
}
})
if (true) {
return
}
if (sum > this.form.checkNum) {
this.$modal.msgError(
'已绑定编码' +
@ -572,12 +689,23 @@ export default {
/** 提交按钮 */
submitForm: function () {
// console.log(this.codeList)
if (this.form.fixCode == 0) {
if (this.hasDuplicateField(this.codeList, 'assetsCode')) {
this.$modal.msgError('固定资产编码不能为空')
return false
}
// if (this.form.fixCode == 0) {
// if (this.hasDuplicateField(this.codeList, 'assetsCode')) {
// this.$modal.msgError('')
// return false
// }
// }
let noCode = this.codeList.filter((e) => e.maCode === '')
if (noCode.length > 0) {
this.$modal.msgError('编码不可为空')
noCode.map((e, index) => {
if (index === 0) {
this.$refs[`inputRef-${e.id}`].focus()
}
})
}
if (this.codeList.length == 0) {
this.$modal.msgError('无新增编码绑定')
} else {
@ -587,32 +715,36 @@ export default {
for (const item of this.codeList) {
const maCode = item.maCode
console.log(maCodeSet.has(maCode), '是否有编码')
if (maCodeSet.has(maCode)) {
hasDuplicates = true
break
}
maCodeSet.add(maCode)
}
console.log('codeList:', this.codeList)
if (hasDuplicates) {
this.$modal.msgError(
'编码绑定失败,存在重复编码,请重新输入',
)
return //
}
editPurchaseMacode(this.codeList).then((response) => {
console.log(this.codeList)
if (response.data && response.data.length > 0) {
this.codeList = response.data
this.$modal.msgError(
'编码绑定失败,存在重复编码,请重新输入',
)
} else {
this.$modal.msgSuccess('编码绑定成功')
this.open = false
this.getList()
}
})
this.codingLoading = true
editPurchaseMacode(this.codeList)
.then((response) => {
if (response.data && response.data.length > 0) {
this.codeList = response.data
this.$modal.msgError(
'编码绑定失败,存在重复编码,请重新输入',
)
} else {
this.$modal.msgSuccess('编码绑定成功')
this.open = false
this.getList()
}
})
.finally(() => {
this.codingLoading = false
})
}
},
hasDuplicateField(array, field) {
@ -644,6 +776,8 @@ export default {
this.codeList.splice(index, 1)
}
})
this.surplusNoBindNum += 1
// const maCode = row.maCode ;
// this.$modal.confirm('').then(function() {
// return delMacodeList(maCode);
@ -663,15 +797,27 @@ export default {
this.isDetail = true
this.title = '编码绑定详情'
this.codeList = []
// const res = await getBindCodeDetails({ taskId: row.taskId })
const res = await getBindCodeDetails({
typeId: row.typeId,
taskId: row.taskId,
typeId: row.typeId,
})
console.log('🚀 ~ handleBindDetails ~ res:', res)
this.codeList = res.data
},
},
watch: {
open: {
handler(newValue) {
if (!newValue) {
this.form.suffixOneCode = ''
this.form.suffixTwoCode = ''
this.form.fixCode = '1'
}
},
deep: true,
},
},
}
</script>
@ -685,4 +831,10 @@ export default {
width: 60px !important;
margin-bottom: 10px;
}
.surplus-code {
padding-bottom: 10px;
padding-left: 8px;
font-size: 16px;
}
</style>