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