台账管理页面修改
This commit is contained in:
parent
41d92dd90f
commit
1d070e8054
|
|
@ -360,3 +360,11 @@ export const getDevDetailsApi = (data) => {
|
|||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取特征值
|
||||
export const getConfigApi = (data) => {
|
||||
return request({
|
||||
url: `/material-mall/equipment/field/getConfig`,
|
||||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,14 @@
|
|||
<el-input v-model="form.propertyUnit" placeholder="产权单位" readonly/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
|
||||
<el-col :span="6" v-for="(item, index) in form.fieldVoList" :key="index">
|
||||
<el-form-item :label="item.propertyName" >
|
||||
<el-input v-model="item.propertyValue" readonly/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
|
||||
<div style="display: flex; padding-bottom: 10px">
|
||||
|
|
@ -303,7 +311,7 @@
|
|||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="装备二维码" prop="">
|
||||
<el-form-item label="装备二维码111" prop="">
|
||||
<div class="qrcode-box" style="width: 150px;height: 150px">
|
||||
<QrcodeGenerator
|
||||
ref="qr3"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<template>
|
||||
<template>
|
||||
<!-- 弹窗内容区域 -->
|
||||
<el-dialog
|
||||
:title="pageTitle"
|
||||
|
|
@ -244,6 +244,63 @@
|
|||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
|
||||
<!-- 🔥 手动新增字段(插在产权单位后面) -->
|
||||
<el-col
|
||||
v-for="item in config"
|
||||
:key="item.id"
|
||||
:span="6"
|
||||
>
|
||||
<el-form-item
|
||||
:label="item.propertyName"
|
||||
:prop="item.propertyCode"
|
||||
:required="item.mustHave == '1'"
|
||||
>
|
||||
<!-- 输入框 -->
|
||||
<el-input
|
||||
v-if="item.inputType == 'INPUT'"
|
||||
v-model="form[item.propertyCode]"
|
||||
clearable
|
||||
maxlength="100"
|
||||
/>
|
||||
|
||||
<!-- 数字框 -->
|
||||
<el-input-number
|
||||
v-else-if="item.inputType == 'NUMBER'"
|
||||
v-model="form[item.propertyCode]"
|
||||
style="width: 100%"
|
||||
maxlength="100"
|
||||
/>
|
||||
|
||||
<!-- 日期 -->
|
||||
<el-date-picker
|
||||
v-else-if="item.inputType == 'DATE'"
|
||||
v-model="form[item.propertyCode]"
|
||||
type="date"
|
||||
:editable="false"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 100%"
|
||||
/>
|
||||
|
||||
<!-- 下拉选择 -->
|
||||
<el-select
|
||||
v-else-if="item.inputType == 'SELECT'"
|
||||
v-model="form[item.propertyCode]"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in parseSelectOptions(item.value)"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
|
||||
<div style="display: flex; padding-bottom: 10px">
|
||||
|
|
@ -460,10 +517,10 @@
|
|||
</div>
|
||||
</el-dialog>
|
||||
</el-dialog>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
<script>
|
||||
import {
|
||||
addInterDevice,
|
||||
getEquipmentAddIdApi,
|
||||
firstLevel,
|
||||
|
|
@ -471,16 +528,17 @@ import {
|
|||
fourthToSixthLevel,
|
||||
getDeviceApi,
|
||||
equipmentEditApiNew,
|
||||
getEquipmentPropertyTypeApi
|
||||
} from '@/api/EquipmentEntryApply'
|
||||
import { getManufacturerSelectApi } from '@/api/EquipmentLedger/index.js'
|
||||
import ImageUpload from '@/components/ImageUpload'
|
||||
import FileUpload from '@/components/FileImageUpload'
|
||||
import { handlePositiveNumberInput } from '@/utils/bonus.js'
|
||||
import { addFacturer } from '@/api/ma/supplier'
|
||||
import { deptTreeSelect } from '@/api/system/user'
|
||||
getEquipmentPropertyTypeApi,
|
||||
getConfigApi
|
||||
} from '@/api/EquipmentEntryApply'
|
||||
import { getManufacturerSelectApi } from '@/api/EquipmentLedger/index.js'
|
||||
import ImageUpload from '@/components/ImageUpload'
|
||||
import FileUpload from '@/components/FileImageUpload'
|
||||
import { handlePositiveNumberInput } from '@/utils/bonus.js'
|
||||
import { addFacturer } from '@/api/ma/supplier'
|
||||
import { deptTreeSelect } from '@/api/system/user'
|
||||
|
||||
export default {
|
||||
export default {
|
||||
name: 'EquipmentEntryEditDialog', // 明确组件名称
|
||||
emits: ['update:isVisible', 'submit', 'getOrderId'], // 声明事件
|
||||
dicts: ['dev_unit_type'],
|
||||
|
|
@ -540,26 +598,29 @@ export default {
|
|||
propertyUnitList: [], // 产权单位列表
|
||||
// 表单校验规则(所有字段均为必填)
|
||||
equipRules: {
|
||||
major: [{ required: true, message: '请选择专业', trigger: 'change' }],
|
||||
/* major: [{ required: true, message: '请选择专业', trigger: 'change' }],
|
||||
process: [{ required: true, message: '请选择工序', trigger: 'change' }],
|
||||
category: [{ required: true, message: '请选择装备类目', trigger: 'change' }],
|
||||
name: [{ required: true, message: '请输入装备名称', trigger: 'blur' }],
|
||||
specificationModel: [{ required: true, message: '请输入规格型号', trigger: 'blur' }],
|
||||
originalValue: [{ required: true, message: '请输入资产原值', trigger: 'blur' }],
|
||||
originalValue: [{ required: true, message: '请输入资产原值', trigger: 'blur' }], */
|
||||
// productionDate: [{ required: true, message: '请选择出厂日期', trigger: 'change' }],
|
||||
manufacturerId: [{ required: true, message: '请输入生产厂家', trigger: 'blur' }],
|
||||
/* manufacturerId: [{ required: true, message: '请输入生产厂家', trigger: 'blur' }], */
|
||||
// originalCode: [{ required: true, message: '请输入装备原始编码', trigger: 'blur' }],
|
||||
nextMaintenanceDate: [{ required: true, message: '请选择下次维保日期', trigger: 'change' }],
|
||||
maxServiceLifeYears: [{ required: true, message: '请输入装备寿命', trigger: 'blur' }],
|
||||
/* nextMaintenanceDate: [{ required: true, message: '请选择下次维保日期', trigger: 'change' }],
|
||||
maxServiceLifeYears: [{ required: true, message: '请输入装备寿命', trigger: 'blur' }], */
|
||||
// manageType: [{ required: true, message: '请选择管理方式', trigger: 'change' }],
|
||||
count: [{ required: true, message: '请输入装备数量', trigger: 'blur' }],
|
||||
unit: [{ required: true, message: '请输入计数单位', trigger: 'blur' }]
|
||||
/* count: [{ required: true, message: '请输入装备数量', trigger: 'blur' }],
|
||||
unit: [{ required: true, message: '请输入计数单位', trigger: 'blur' }] */
|
||||
// purchaseDate: [{ required: true, message: '请选择采购日期', trigger: 'change' }],
|
||||
// certificateList: [{ required: true, message: '请上传合格证', trigger: 'change' }],
|
||||
// inspectionList: [{ required: true, message: '请上传检测证书', trigger: 'change' }],
|
||||
// mainFileList: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
},
|
||||
propertyVoList: [] // 特征属性集合
|
||||
propertyVoList: [], // 特征属性集合
|
||||
isSystem:[], // 系统属性
|
||||
config:[], // 新增属性
|
||||
systemFieldMap: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
|
@ -574,7 +635,151 @@ export default {
|
|||
// }
|
||||
},
|
||||
methods: {
|
||||
/* getConfig(){
|
||||
getConfigApi().then(res => {
|
||||
this.config = res.data.config;
|
||||
this.isSystem = res.data.isSystem;
|
||||
|
||||
this.systemFieldMap = this.isSystem.reduce((map, item) => {
|
||||
map[item.propertyCode] = item
|
||||
return map
|
||||
}, {})
|
||||
|
||||
this.config.forEach(item => {
|
||||
if (this.form[item.propertyCode] == undefined) {
|
||||
if (item.inputType == 'SELECT') {
|
||||
this.$set(this.form, item.propertyCode, item.propertyValue || '')
|
||||
} else {
|
||||
this.$set(this.form, item.propertyCode, item.value || '')
|
||||
}
|
||||
}
|
||||
|
||||
if (item.mustHave == '1') {
|
||||
this.rules[item.propertyCode] = [
|
||||
{ required: true, message: `请输入${item.propertyName}`, trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 根据 isSystem 动态设置验证规则
|
||||
this.buildDynamicRules()
|
||||
})
|
||||
}, */
|
||||
|
||||
resetDynamicFields() {
|
||||
if (!this.config || this.config.length === 0) return
|
||||
|
||||
this.config.forEach(item => {
|
||||
if (!item.propertyCode) return
|
||||
// 根据类型决定默认值
|
||||
switch (item.inputType) {
|
||||
case 'INPUT':
|
||||
case 'SELECT':
|
||||
case 'DATE':
|
||||
this.$set(this.form, item.propertyCode, '')
|
||||
break
|
||||
case 'NUMBER':
|
||||
this.$set(this.form, item.propertyCode, null)
|
||||
break
|
||||
default:
|
||||
this.$set(this.form, item.propertyCode, '')
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 获取配置并初始化动态规则
|
||||
getConfig() {
|
||||
getConfigApi().then(res => {
|
||||
this.config = res.data.config || []
|
||||
this.isSystem = res.data.isSystem || []
|
||||
|
||||
// 构建系统属性映射
|
||||
this.systemFieldMap = this.isSystem.reduce((map, item) => {
|
||||
map[item.propertyCode] = item
|
||||
return map
|
||||
}, {})
|
||||
|
||||
// 初始化 form 字段 & rules
|
||||
this.config.forEach(item => {
|
||||
if (!item.propertyCode) return // 避免空字段
|
||||
|
||||
// 初始化 form 字段
|
||||
if (this.form[item.propertyCode] === undefined) {
|
||||
if (item.inputType === 'SELECT') {
|
||||
this.$set(this.form, item.propertyCode, item.propertyValue || '')
|
||||
} else {
|
||||
this.$set(this.form, item.propertyCode, item.value || '')
|
||||
}
|
||||
}
|
||||
|
||||
// 必填规则
|
||||
if (item.mustHave == '1') {
|
||||
const trigger = ['SELECT', 'DATE', 'IMAGE', 'FILE'].includes(item.inputType) ? 'change' : 'blur'
|
||||
this.$set(this.equipRules, item.propertyCode, [
|
||||
{ required: true, message: `请输入${item.propertyName}`, trigger }
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
// 根据 isSystem 动态设置规则
|
||||
this.isSystem.forEach(item => {
|
||||
if (!item.propertyCode) return
|
||||
if (item.mustHave == '1') {
|
||||
const trigger = ['SELECT', 'DATE', 'IMAGE', 'FILE'].includes(item.inputType) ? 'change' : 'blur'
|
||||
// 如果已经存在,不重复覆盖
|
||||
if (!this.equipRules[item.propertyCode]) {
|
||||
this.$set(this.equipRules, item.propertyCode, [
|
||||
{ required: true, message: `请填写${item.propertyName}`, trigger }
|
||||
])
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
parseSelectOptions(value) {
|
||||
if (!value) return []
|
||||
// 1️⃣ 统一中文、英文逗号
|
||||
const normalized = value.replace(/,/g, ',')
|
||||
// 2️⃣ 拆分并去空
|
||||
return normalized
|
||||
.split(',')
|
||||
.map(v => v.trim())
|
||||
.filter(v => v)
|
||||
.map(v => ({
|
||||
label: v,
|
||||
value: v
|
||||
}))
|
||||
},
|
||||
|
||||
buildDynamicRules() {
|
||||
const rules = {}
|
||||
|
||||
this.isSystem.forEach(item => {
|
||||
if (item.mustHave == '1') {
|
||||
let trigger = 'blur'
|
||||
|
||||
// 不同类型使用不同触发方式
|
||||
if (['SELECT', 'DATE', 'IMAGE', 'FILE'].includes(item.inputType)) {
|
||||
trigger = 'change'
|
||||
}
|
||||
|
||||
rules[item.propertyCode] = [
|
||||
{
|
||||
required: true,
|
||||
message: `请填写${item.propertyName}`,
|
||||
trigger
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
this.equipRules = rules
|
||||
},
|
||||
|
||||
async openDialog(id, type) {
|
||||
this.resetDynamicFields()
|
||||
this.getConfig()
|
||||
await this.getDeptTreeSelect()
|
||||
if (type === 'edit') {
|
||||
this.pageTitle = '编辑装备'
|
||||
|
|
@ -594,10 +799,24 @@ export default {
|
|||
async getInfo() {
|
||||
try {
|
||||
const res = await getDeviceApi(this.maId)
|
||||
console.log('🚀 ~ getInfo ~ res:', res)
|
||||
Object.assign(this.form, res.data)
|
||||
if (res.data) {
|
||||
let row = res.data
|
||||
if(row.fieldVoList){
|
||||
this.config = row.fieldVoList
|
||||
|
||||
// 遍历 fieldVoList,把值回显到 form
|
||||
this.config.forEach(item => {
|
||||
if (!item.propertyCode) return; // 避免空字段
|
||||
if (item.inputType == 'SELECT' && item.value) {
|
||||
// 下拉多选值可能是逗号分隔
|
||||
this.$set(this.form, item.propertyCode, item.propertyValue ? item.propertyValue.split(',') : []);
|
||||
} else {
|
||||
this.$set(this.form, item.propertyCode, item.propertyValue ?? '');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const propertyList = row.propertyVoList || []
|
||||
const property = propertyList
|
||||
// 过滤条件:item 存在 且 propertyValue 有值(避免空值干扰)
|
||||
|
|
@ -813,6 +1032,20 @@ export default {
|
|||
this.isSubmit = true
|
||||
const loading = this.$loading()
|
||||
try {
|
||||
var fieldVoList = [];
|
||||
// 遍历手动新增字段
|
||||
if (this.config && this.config.length > 0) {
|
||||
this.config.forEach(item => {
|
||||
fieldVoList.push({
|
||||
...item,
|
||||
propertyValue: this.form[item.propertyCode] ?? null // 表单里填写的值
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!this.form.orderId && !this.isEdit) {
|
||||
const result = await getEquipmentAddIdApi()
|
||||
this.orderId = result.data.id
|
||||
|
|
@ -904,7 +1137,8 @@ export default {
|
|||
certificates,
|
||||
inspectionReports,
|
||||
purchaseInvoices,
|
||||
propertyVoList: this.propertyVoList
|
||||
propertyVoList: this.propertyVoList,
|
||||
fieldVoList:fieldVoList
|
||||
}
|
||||
if (this.maId) {
|
||||
params.maId = this.maId
|
||||
|
|
@ -994,15 +1228,15 @@ export default {
|
|||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dialog-content {
|
||||
<style lang="scss" scoped>
|
||||
.dialog-content {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.page-header {
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
|
|
@ -1017,29 +1251,29 @@ export default {
|
|||
margin-left: 15px;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
.dialog-content {
|
||||
padding: 10px 0;
|
||||
min-height: 200px; // 确保有足够高度
|
||||
}
|
||||
}
|
||||
|
||||
.goBack-btn:hover {
|
||||
.goBack-btn:hover {
|
||||
cursor: pointer;
|
||||
color: #33b5a0;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px; // 按钮间距
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .el-input-number.is-without-controls .el-input__inner {
|
||||
::v-deep .el-input-number.is-without-controls .el-input__inner {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
.select-box {
|
||||
.select-box {
|
||||
width: 100%;
|
||||
height: 260px;
|
||||
border: 1px solid #dcdcdc;
|
||||
|
|
@ -1062,28 +1296,28 @@ export default {
|
|||
text-align: center;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 紧凑表单行距 */
|
||||
::v-deep .el-form-item {
|
||||
/* 紧凑表单行距 */
|
||||
::v-deep .el-form-item {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep.el-tag.el-tag--info {
|
||||
::v-deep.el-tag.el-tag--info {
|
||||
background-color: #F5F5F5;
|
||||
border-color: #B3B3B3;
|
||||
color: #B3B3B3;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep.el-tag.el-tag--warn {
|
||||
::v-deep.el-tag.el-tag--warn {
|
||||
background-color: rgba(255, 171, 41, 0.1);;
|
||||
border: #FFAB29;
|
||||
color: #FFAB29;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep.el-tag.el-tag--success {
|
||||
::v-deep.el-tag.el-tag--success {
|
||||
background-color: rgba(52, 226, 199, 0.1);
|
||||
border-color: #34E2C7;
|
||||
color: #34E2C7;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -346,6 +346,64 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
<!-- 动态生成 fieldVoList 列 -->
|
||||
<el-table-column
|
||||
v-for="(item, index) in fieldVoList"
|
||||
:key="index"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
:label="item.propertyName"
|
||||
:prop="item.propertyCode"
|
||||
min-width="200px"
|
||||
>
|
||||
<!-- <template v-slot="{ row }">
|
||||
<div
|
||||
v-if="
|
||||
(index + 1) % 2 === 0 &&
|
||||
row.isNew &&
|
||||
row.fieldVoList.length > 0 &&
|
||||
row.fieldVoList[(index + 1) / 2 - 1]
|
||||
"
|
||||
>
|
||||
<el-input
|
||||
v-if="row.fieldVoList[(index + 1) / 2 - 1].inputType == 1"
|
||||
autocomplete="off"
|
||||
maxlength="30"
|
||||
v-model="row.fieldVoList[(index + 1) / 2 - 1].propertyValue"
|
||||
clearable
|
||||
/>
|
||||
<el-select
|
||||
v-if="row.fieldVoList[(index + 1) / 2 - 1].inputType == 2"
|
||||
v-model="row.fieldVoList[(index + 1) / 2 - 1].propertyValue"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in row.fieldVoList[(index + 1) / 2 - 1].valueList"
|
||||
:key="index"
|
||||
:label="item.value"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
|
||||
</div>
|
||||
<span
|
||||
v-else-if="
|
||||
row.isNew &&
|
||||
row.fieldVoList.length > 0 &&
|
||||
row.fieldVoList[Math.ceil(index / 2)] &&
|
||||
row.fieldVoList[Math.ceil(index / 2)].mustHave != 0
|
||||
"
|
||||
style="color: red"
|
||||
>{{ getFeatureValue(row, item.prop) }}</span
|
||||
>
|
||||
<span v-else>{{ getFeatureValue(row, item.prop) }}</span>
|
||||
</template>-->
|
||||
</el-table-column>
|
||||
|
||||
|
||||
<el-table-column
|
||||
v-for="(item, index) in columns"
|
||||
v-if="item.visible"
|
||||
|
|
@ -627,6 +685,9 @@
|
|||
<script>
|
||||
import EquipmentEntryEditDialog from '@/views/EquipmentEntryApply/equipmentInput/edit.vue'
|
||||
import AddEquip from './AddEquip'
|
||||
import {
|
||||
getConfigApi
|
||||
} from '@/api/EquipmentEntryApply'
|
||||
|
||||
// 使用defineComponent规范组件定义
|
||||
import {
|
||||
|
|
@ -760,6 +821,8 @@ export default {
|
|||
{ key: 42, label: `特征项9`, prop: 'featureItem9', visible: true },
|
||||
{ key: 43, label: `特征值9`, prop: 'featureValue9', visible: true }
|
||||
],
|
||||
fieldVoList:[],
|
||||
|
||||
dialogVisible: false,
|
||||
dialogTitle: '',
|
||||
dialogList: [],
|
||||
|
|
@ -776,6 +839,7 @@ export default {
|
|||
watch: {
|
||||
isVisible(val) {
|
||||
if (val) {
|
||||
this.getConfig()
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
|
|
@ -783,6 +847,7 @@ export default {
|
|||
|
||||
mounted() {
|
||||
this.getManufacturerSelectList()
|
||||
this.getConfig()
|
||||
},
|
||||
methods: {
|
||||
handleNumberInput(key) {
|
||||
|
|
@ -985,6 +1050,14 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
getConfig() {
|
||||
getConfigApi().then(res => {
|
||||
this.fieldVoList = res.data.config || []
|
||||
})
|
||||
},
|
||||
|
||||
// 获取列表数据
|
||||
async getList() {
|
||||
try {
|
||||
|
|
@ -1003,6 +1076,8 @@ export default {
|
|||
const res = await getDeviceByOrderIdApi(params)
|
||||
this.tableData = res.data.rows
|
||||
this.total = res.data.total
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error('获取列表失败:', error)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue