工器具修改

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

View File

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