工器具修改

This commit is contained in:
cwchen 2025-10-31 14:15:26 +08:00
parent 1229708294
commit b50d3c81d7
2 changed files with 41 additions and 20 deletions

View File

@ -6,39 +6,42 @@
<el-form :model="form" :rules="rules" ref="ruleForm" label-width="110px"> <el-form :model="form" :rules="rules" ref="ruleForm" label-width="110px">
<el-form-item label="工器具名称" prop="toolName"> <el-form-item label="工器具名称" prop="toolName">
<el-input class="form-item" v-model="form.toolName" clearable show-word-limit placeholder="请输入工器具名称" <el-input class="form-item" v-model="form.toolName" clearable show-word-limit placeholder="请输入工器具名称"
maxlength="32"></el-input> maxlength="64" :disabled="isDisabled"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="规格型号" prop="model"> <el-form-item label="规格型号" prop="model">
<el-input class="form-item" v-model="form.model" clearable show-word-limit placeholder="请输入规格型号" <el-input class="form-item" v-model="form.model" clearable show-word-limit placeholder="请输入规格型号"
maxlength="32"></el-input> maxlength="32" :disabled="isDisabled"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="单位" prop="unit"> <el-form-item label="单位" prop="unit">
<el-input class="form-item" v-model="form.unit" clearable show-word-limit placeholder="请输入单位" <el-input class="form-item" v-model="form.unit" clearable show-word-limit placeholder="请输入单位"
maxlength="32"></el-input> maxlength="32" :disabled="isDisabled"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="技术参数" prop="technicalParameters"> <el-form-item label="技术参数" prop="technicalParameters">
<el-input class="form-item" v-model="form.technicalParameters" clearable show-word-limit <el-input class="form-item" v-model="form.technicalParameters" clearable show-word-limit
placeholder="请输入技术参数" maxlength="32"></el-input> placeholder="请输入技术参数" maxlength="100" :disabled="isDisabled"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="主要作用" prop="mainFunction"> <el-form-item label="主要作用" prop="mainFunction">
<el-input class="form-item" v-model="form.mainFunction" clearable show-word-limit <el-input class="form-item" v-model="form.mainFunction" clearable show-word-limit
placeholder="请输入主要作用" maxlength="32"></el-input> placeholder="请输入主要作用" maxlength="100" :disabled="isDisabled"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input type="textarea" :autosize="{ minRows: 4, maxRows: 6 }" class="form-item" <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" class="form-item"
v-model.trim="form.remark" clearable show-word-limit placeholder="请输入备注" v-model.trim="form.remark" clearable show-word-limit placeholder="请输入备注"
maxlength="300"></el-input> maxlength="200" :disabled="isDisabled"></el-input>
</el-form-item> </el-form-item>
<!-- 工器具图片 --> <!-- 工器具图片 -->
<el-form-item label="工器具图片" prop="fileList"> <el-form-item label="工器具图片" prop="fileList" v-if="!isDisabled">
<UploadFile :fileList="form.fileList" :fileUploadRule="defaultParams.fileUploadRule" <UploadFile :fileList="form.fileList" :fileUploadRule="defaultParams.fileUploadRule"
@file-change="handleFileChange" @del-file="handleDelFile" type="tool" /> @file-change="handleFileChange" @del-file="handleDelFile" type="tool" />
</el-form-item> </el-form-item>
<el-form-item label="工器具图片" v-if="isDisabled">
<FileOrImageDisplay :file="form.fileList[0]" :image-url="form.url"/>
</el-form-item>
</el-form> </el-form>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" class="confirm-btn" :disabled="disabled" <el-button type="primary" class="confirm-btn" :disabled="disabled"
@click="submitForm('ruleForm')">确认</el-button> @click="submitForm('ruleForm')" v-if="!isDisabled">确认</el-button>
<el-button class="cancel-btn" @click="handleClose" :disabled="disabled">取消</el-button> <el-button class="cancel-btn" @click="handleClose" :disabled="disabled">取消</el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -46,6 +49,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import UploadFile from '@/views/common/UploadFile.vue' import UploadFile from '@/views/common/UploadFile.vue'
import FileOrImageDisplay from '@/views/common/FileOrImageDisplay.vue';
import { addDataAPI, editDataAPI, getDetailDataAPI } from '@/api/enterpriseLibrary/tool/tool' import { addDataAPI, editDataAPI, getDetailDataAPI } from '@/api/enterpriseLibrary/tool/tool'
// //
const defaultParams = { const defaultParams = {
@ -58,14 +62,14 @@ const defaultParams = {
export default { export default {
name: "ToolForm", name: "ToolForm",
components: { components: {
UploadFile UploadFile,
FileOrImageDisplay
}, },
props: ["width", "rowData", "title", "disabled", "isAdd"], props: ["width", "rowData", "title", "disabled", "isAdd"],
data() { data() {
return { return {
lDialog: this.width > 500 ? "w700" : "w500", lDialog: this.width > 500 ? "w700" : "w500",
dialogVisible: true, dialogVisible: true,
isDisabled: true,
defaultParams, defaultParams,
form: { form: {
id: null, id: null,
@ -98,13 +102,18 @@ export default {
watch: { watch: {
isAdd: { isAdd: {
handler(newVal) { handler(newVal) {
if (newVal === 'edit') { if (newVal === 'edit' || newVal === 'detail') {
this.initFormData(); this.initFormData();
} }
}, },
immediate: true, immediate: true,
}, },
}, },
computed: {
isDisabled() {
return this.isAdd === 'detail';
}
},
methods: { methods: {
/** 初始化表单数据 */ /** 初始化表单数据 */
async initFormData() { async initFormData() {
@ -112,7 +121,8 @@ export default {
const files = await this.getDetail(); const files = await this.getDetail();
// //
this.form = { this.form = {
id: this.rowData.id, toolId: this.rowData.toolId,
enterpriseId: this.rowData.enterpriseId,
toolName: this.rowData.toolName || '', toolName: this.rowData.toolName || '',
model: this.rowData.model || '', model: this.rowData.model || '',
unit: this.rowData.unit || '', unit: this.rowData.unit || '',
@ -121,8 +131,11 @@ export default {
remark: this.rowData.remark || '', remark: this.rowData.remark || '',
fileList: Array.isArray(files) ? files : [], fileList: Array.isArray(files) ? files : [],
delFileList: [], delFileList: [],
}; };
if(this.isDisabled){
this.rules = [];
this.$set(this.form, 'url', files[0]?.lsFilePath || null);
}
}, },
async getDetail() { async getDetail() {
try { try {

View File

@ -26,7 +26,7 @@
</template> </template>
<template slot="handle" slot-scope="{ data }"> <template slot="handle" slot-scope="{ data }">
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:detail']" class="action-btn" <el-button type="text" v-hasPermi="['enterpriseLibrary:tool:detail']" class="action-btn"
@click="handleUpdate(data)"> @click="handleDetail(data)">
查看 查看
</el-button> </el-button>
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:edit']" class="action-btn" <el-button type="text" v-hasPermi="['enterpriseLibrary:tool:edit']" class="action-btn"
@ -103,19 +103,27 @@ export default {
/** 修改操作 */ /** 修改操作 */
handleUpdate(row) { handleUpdate(row) {
this.title = "修改"; this.title = "修改工器具";
this.isAdd = 'edit'; this.isAdd = 'edit';
this.row = row; this.row = row;
this.isflag = true; this.isflag = true;
}, },
//
handleBathchImport(){
/* 查看操作 */
handleDetail(row){
this.title = "查看工器具";
this.isAdd = 'detail';
this.row = row;
this.isflag = true;
}, },
// //
handleModelExport(){ handleModelExport(){
},
//
handleBathchImport(){
}, },
closeDialog() { closeDialog() {
this.isflag = false; this.isflag = false;
@ -126,7 +134,7 @@ export default {
}, },
/** 删除操作 */ /** 删除操作 */
handleDelete(row) { handleDelete(row) {
this.$confirm(`确定要删除"${raw.technicalSolutionName}"吗?删除后将无法恢复!`, '操作提示', { this.$confirm(`确定要删除"${row.toolName}"吗?删除后将无法恢复!`, '操作提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',