工器具修改
This commit is contained in:
parent
314e59a34f
commit
1229708294
|
|
@ -39,7 +39,7 @@ export function delDataAPI(data) {
|
|||
/* 工器具库->查询详情 */
|
||||
export function getDetailDataAPI(params) {
|
||||
return request({
|
||||
url: '/smartBid/mainDatabase/tool/getDetailData',
|
||||
url: '/smartBid/mainDatabase/tool/detailData',
|
||||
method: 'GET',
|
||||
params
|
||||
})
|
||||
|
|
|
|||
|
|
@ -42,27 +42,6 @@ export default {
|
|||
handleCategoryChange(categoryId) {
|
||||
this.activeCategory = categoryId
|
||||
},
|
||||
handleAddCategory() {
|
||||
},
|
||||
handleCategoryCommand(command) {
|
||||
if (command.type === 'edit') {
|
||||
console.log('编辑分类:', command.id)
|
||||
} else if (command.type === 'delete') {
|
||||
console.log('删除分类:', command.id)
|
||||
}
|
||||
},
|
||||
handleAddScheme() {
|
||||
console.log('新增方案')
|
||||
},
|
||||
handleView(row) {
|
||||
console.log('查看:', row)
|
||||
},
|
||||
handleEdit(row) {
|
||||
console.log('编辑:', row)
|
||||
},
|
||||
handleDelete(row) {
|
||||
console.log('删除:', row)
|
||||
},
|
||||
// 返回上一页
|
||||
handleBack() {
|
||||
const obj = {
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@
|
|||
<div>
|
||||
<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>
|
||||
<el-input class="form-item" v-model="form.toolName" clearable show-word-limit placeholder="请输入工器具名称"
|
||||
maxlength="32"></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>
|
||||
<el-input class="form-item" v-model="form.model" clearable show-word-limit placeholder="请输入规格型号"
|
||||
maxlength="32"></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>
|
||||
<el-input class="form-item" v-model="form.unit" clearable show-word-limit placeholder="请输入单位"
|
||||
maxlength="32"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="技术参数" prop="technicalParameters">
|
||||
<el-input class="form-item" v-model="form.technicalParameters" clearable show-word-limit
|
||||
|
|
@ -26,8 +26,13 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" :autosize="{ minRows: 4, maxRows: 6 }" class="form-item"
|
||||
v-model.trim="form.remark" clearable show-word-limit placeholder="请输入备注"
|
||||
maxlength="300"></el-input>
|
||||
v-model.trim="form.remark" clearable show-word-limit placeholder="请输入备注"
|
||||
maxlength="300"></el-input>
|
||||
</el-form-item>
|
||||
<!-- 工器具图片 -->
|
||||
<el-form-item label="工器具图片" prop="fileList">
|
||||
<UploadFile :fileList="form.fileList" :fileUploadRule="defaultParams.fileUploadRule"
|
||||
@file-change="handleFileChange" @del-file="handleDelFile" type="tool" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
|
@ -40,23 +45,39 @@
|
|||
</template>
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
|
||||
import UploadFile from '@/views/common/UploadFile.vue'
|
||||
import { addDataAPI, editDataAPI, getDetailDataAPI } from '@/api/enterpriseLibrary/tool/tool'
|
||||
// 默认参数
|
||||
const defaultParams = {
|
||||
fileUploadRule: {
|
||||
fileUploadType: 'tools',
|
||||
fields_json: '',
|
||||
suffix: 'tools_database'
|
||||
},
|
||||
};
|
||||
export default {
|
||||
name: "TypeForm",
|
||||
name: "ToolForm",
|
||||
components: {
|
||||
UploadFile
|
||||
},
|
||||
props: ["width", "rowData", "title", "disabled", "isAdd"],
|
||||
data() {
|
||||
return {
|
||||
lDialog: this.width > 500 ? "w700" : "w500",
|
||||
dialogVisible: true,
|
||||
isDisabled: true,
|
||||
defaultParams,
|
||||
form: {
|
||||
id: null,
|
||||
enterpriseId: this.rowData.enterpriseId,
|
||||
technicalSolutionName: '',
|
||||
model: '',
|
||||
unit: '',
|
||||
technicalParameters: '',
|
||||
mainFunction: '',
|
||||
remark: '',
|
||||
fileList: [],
|
||||
delFileList: []
|
||||
},
|
||||
rules: {
|
||||
toolName: [
|
||||
|
|
@ -68,6 +89,9 @@ export default {
|
|||
unit: [
|
||||
{ required: true, message: '单位不能为空', trigger: 'blur' }
|
||||
],
|
||||
fileList: [
|
||||
{ required: true, message: '工器具图片不能为空', trigger: ['blur', 'change'] }
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
@ -83,18 +107,59 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
/** 初始化表单数据 */
|
||||
initFormData() {
|
||||
if (this.isAdd === 'edit' && this.rowData) {
|
||||
// 编辑模式:填充表单数据
|
||||
this.form = {
|
||||
id: this.rowData.id,
|
||||
toolName: this.rowData.toolName || '',
|
||||
model: this.rowData.model || '',
|
||||
unit: this.rowData.unit || '',
|
||||
technicalParameters: this.rowData.technicalParameters || '',
|
||||
mainFunction: this.rowData.mainFunction || '',
|
||||
remark: this.rowData.remark || '',
|
||||
async initFormData() {
|
||||
if (!this.rowData) return;
|
||||
const files = await this.getDetail();
|
||||
// 编辑模式:填充表单数据
|
||||
this.form = {
|
||||
id: this.rowData.id,
|
||||
toolName: this.rowData.toolName || '',
|
||||
model: this.rowData.model || '',
|
||||
unit: this.rowData.unit || '',
|
||||
technicalParameters: this.rowData.technicalParameters || '',
|
||||
mainFunction: this.rowData.mainFunction || '',
|
||||
remark: this.rowData.remark || '',
|
||||
fileList: Array.isArray(files) ? files : [],
|
||||
delFileList: [],
|
||||
|
||||
};
|
||||
},
|
||||
async getDetail() {
|
||||
try {
|
||||
const res = await getDetailDataAPI({ toolId: this.rowData.toolId, enterpriseId: this.rowData.enterpriseId });
|
||||
if (res && res.code === 200) {
|
||||
return this.getFileList(res.data);
|
||||
}
|
||||
return [];
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
getFileList(detailData){
|
||||
const list = detailData && Array.isArray(detailData.resourceFileVoList)
|
||||
? detailData.resourceFileVoList
|
||||
: [];
|
||||
return list.map(item => {
|
||||
return {
|
||||
name: item.fileName,
|
||||
filePath: item.filePath,
|
||||
lsFilePath: item.lsFilePath,
|
||||
fileType: item.fileType
|
||||
};
|
||||
});
|
||||
},
|
||||
// 文件变化
|
||||
handleFileChange(file) {
|
||||
console.log(file);
|
||||
this.form.fileList = file;
|
||||
},
|
||||
// 文件删除时触发
|
||||
handleDelFile(file) {
|
||||
console.log(file);
|
||||
const delPath = file?.response?.fileRes?.filePath || file?.filePath || null;
|
||||
if (delPath) {
|
||||
this.form.delFileList.push(delPath);
|
||||
}
|
||||
},
|
||||
/*关闭弹窗 */
|
||||
|
|
@ -123,46 +188,80 @@ export default {
|
|||
this.$emit('handleQuery');
|
||||
this.handleClose();
|
||||
},
|
||||
/**验证 */
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate(valid => {
|
||||
if (valid) {
|
||||
// 显示遮罩层
|
||||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: "数据提交中,请稍候...",
|
||||
background: 'rgba(0,0,0,0.5)',
|
||||
target: this.$el.querySelector('.el-dialog') || document.body
|
||||
})
|
||||
let params = _.cloneDeep(this.form);
|
||||
if (this.isAdd === 'add') {
|
||||
addDataClassAPI(params).then(res => {
|
||||
this.loading.close();
|
||||
if (res.code === 200) {
|
||||
this.handleReuslt(res);
|
||||
} else {
|
||||
this.$modal.msgError(res.msg);
|
||||
}
|
||||
}).catch(error => {
|
||||
this.loading.close();
|
||||
this.$modal.msgError(this.errorMsg(error));
|
||||
});
|
||||
validate(formName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
resolve(this.form) // 校验成功返回表单数据
|
||||
} else {
|
||||
|
||||
updateDataClassAPI(params).then(res => {
|
||||
this.loading.close();
|
||||
if (res.code === 200) {
|
||||
this.handleReuslt(res);
|
||||
} else {
|
||||
this.$modal.msgError(res.msg);
|
||||
}
|
||||
}).catch(error => {
|
||||
this.loading.close();
|
||||
this.$modal.msgError(this.errorMsg(error));
|
||||
});
|
||||
reject(new Error('数据未填写完整'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
/**验证 */
|
||||
async submitForm(formName) {
|
||||
try {
|
||||
const data = await this.validate(formName);
|
||||
// 所有校验通过,组装完整数据
|
||||
let formData = {
|
||||
...data,
|
||||
allFiles: [
|
||||
...data.fileList.map(file => JSON.parse(JSON.stringify(file))),
|
||||
],
|
||||
delFiles: [
|
||||
...data.delFileList
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
let allFiles = formData.allFiles.map(file => {
|
||||
return file?.response?.fileRes ? {
|
||||
...file.response.fileRes,
|
||||
} : null;
|
||||
}).filter(item => item !== null);
|
||||
formData.files = allFiles;
|
||||
delete formData.fileList;
|
||||
delete formData.delFileList;
|
||||
delete formData.allFiles;
|
||||
// 显示遮罩层
|
||||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: "数据提交中,请稍候...",
|
||||
background: 'rgba(0,0,0,0.5)',
|
||||
target: this.$el.querySelector('.el-dialog') || document.body
|
||||
})
|
||||
console.log('所有表单校验通过,完整数据:', formData)
|
||||
const res = await this.saveData(formData)
|
||||
if (res.code === 200) {
|
||||
this.handleReuslt(res);
|
||||
} else {
|
||||
this.$modal.msgError(res.msg);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
} finally {
|
||||
this.loading.close();
|
||||
}
|
||||
},
|
||||
|
||||
// 保存接口
|
||||
async saveData(formData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.isAdd === 'add') { // 新增
|
||||
addDataAPI(formData).then(res => {
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
} else { // 修改
|
||||
editDataAPI(formData).then(res => {
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@ export const formLabel = [
|
|||
isShow: false, // 是否展示label
|
||||
f_type: 'ipt',
|
||||
f_label: '工器具名称',
|
||||
f_model: 'userName',
|
||||
f_model: 'toolName',
|
||||
f_max: 32,
|
||||
f_width: '250px',
|
||||
},
|
||||
]
|
||||
|
||||
export const columnsList = [
|
||||
{ t_props: 'userName', t_label: '名称' },
|
||||
{ t_props: 'nickName', t_label: '规格型号' },
|
||||
{ t_props: 'phonenumberDes', t_label: '单位' },
|
||||
{ t_props: 'phonenumberDes', t_label: '技术参数' },
|
||||
{ t_props: 'phonenumberDes', t_label: '主要作用' },
|
||||
{ t_props: 'toolName', t_label: '工器具名称' },
|
||||
{ t_props: 'model', t_label: '规格型号' },
|
||||
{ t_props: 'unit', t_label: '单位' },
|
||||
{ t_props: 'technicalParameters', t_label: '技术参数' },
|
||||
{ t_props: 'mainFunction', t_label: '主要作用' },
|
||||
]
|
||||
|
|
@ -8,32 +8,32 @@
|
|||
</el-button>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="false" ref="userTableRef"
|
||||
:columnsList="columnsList" :request-api="listUser">
|
||||
<TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="false" ref="toolTableRef"
|
||||
:columnsList="columnsList" :request-api="listAPI" :sendParams= "sendParams">
|
||||
<template slot="tableTitle">
|
||||
<h3>数据列表</h3>
|
||||
</template>
|
||||
<template slot="tableActions">
|
||||
<el-button @click="handleAdd" v-hasPermi="['enterpriseLibrary:technical:add']"
|
||||
<el-button @click="handleModelExport" v-hasPermi="['enterpriseLibrary:tool:add']"
|
||||
class="add-btn">导入模板下载</el-button>
|
||||
<el-button @click="handleAdd" v-hasPermi="['enterpriseLibrary:technical:add']"
|
||||
class="add-btn">导入模板下载</el-button>
|
||||
<el-button @click="handleAdd" v-hasPermi="['enterpriseLibrary:technical:add']" class="add-btn"><i
|
||||
<el-button @click="handleBathchImport" v-hasPermi="['enterpriseLibrary:tool:add']"
|
||||
class="add-btn">批量导入</el-button>
|
||||
<el-button @click="handleAdd" v-hasPermi="['enterpriseLibrary:tool:add']" class="add-btn"><i
|
||||
class="el-icon-plus"></i> 新增工器具</el-button>
|
||||
</template>
|
||||
<template slot="deptName" slot-scope="{ data }">
|
||||
<span>{{ data.dept.deptName || '--' }}</span>
|
||||
</template>
|
||||
<template slot="handle" slot-scope="{ data }">
|
||||
<el-button type="text" v-hasPermi="['enterpriseLibrary:technical:detail']" class="action-btn"
|
||||
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:detail']" class="action-btn"
|
||||
@click="handleUpdate(data)">
|
||||
查看
|
||||
</el-button>
|
||||
<el-button type="text" v-hasPermi="['enterpriseLibrary:technical:edit']" class="action-btn"
|
||||
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:edit']" class="action-btn"
|
||||
style="color: #EAA819;" @click="handleUpdate(data)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="text" v-hasPermi="['enterpriseLibrary:technical:del']" class="action-btn"
|
||||
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:del']" class="action-btn"
|
||||
style="color: #DB3E29;" @click="handleDelete(data)">
|
||||
删除
|
||||
</el-button>
|
||||
|
|
@ -51,10 +51,7 @@
|
|||
import TableModel from '@/components/TableModel2'
|
||||
import { columnsList, formLabel } from './config'
|
||||
import ToolForm from './components/ToolForm.vue'
|
||||
import {
|
||||
listUser,
|
||||
delUser,
|
||||
} from '@/api/system/user'
|
||||
import { listAPI, delDataAPI } from '@/api/enterpriseLibrary/tool/tool'
|
||||
import { encryptWithSM4, decryptWithSM4 } from '@/utils/sm'
|
||||
|
||||
export default {
|
||||
|
|
@ -63,12 +60,11 @@ export default {
|
|||
TableModel,
|
||||
ToolForm
|
||||
},
|
||||
dicts: ['construction_nature', 'structural_form', 'basic_form'],
|
||||
data() {
|
||||
return {
|
||||
formLabel,
|
||||
columnsList,
|
||||
listUser,
|
||||
listAPI,
|
||||
enterpriseId: decryptWithSM4(this.$route.query.enterpriseId) || '0',
|
||||
title: "",
|
||||
isflag: false,
|
||||
|
|
@ -78,16 +74,14 @@ export default {
|
|||
},
|
||||
|
||||
created() {
|
||||
// 将字典数据填充到表单配置的下拉选项中
|
||||
if (Array.isArray(this.formLabel)) {
|
||||
this.formLabel.forEach((item) => {
|
||||
if (item.f_dict && this.dict && this.dict.type && this.dict.type[item.f_dict]) {
|
||||
this.$set(item, 'f_selList', this.dict.type[item.f_dict])
|
||||
}
|
||||
})
|
||||
},
|
||||
computed:{
|
||||
sendParams(){
|
||||
return {
|
||||
enterpriseId : this.enterpriseId
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 返回上一页
|
||||
handleBack() {
|
||||
|
|
@ -103,7 +97,7 @@ export default {
|
|||
handleAdd() {
|
||||
this.title = "新增工器具";
|
||||
this.isAdd = 'add';
|
||||
this.row = {};
|
||||
this.row = {enterpriseId:this.enterpriseId};
|
||||
this.isflag = true;
|
||||
},
|
||||
|
||||
|
|
@ -113,34 +107,48 @@ export default {
|
|||
this.isAdd = 'edit';
|
||||
this.row = row;
|
||||
this.isflag = true;
|
||||
},
|
||||
// 批量导入
|
||||
handleBathchImport(){
|
||||
|
||||
|
||||
},
|
||||
// 模板下载
|
||||
handleModelExport(){
|
||||
|
||||
},
|
||||
closeDialog() {
|
||||
this.isflag = false;
|
||||
},
|
||||
/* 搜索操作 */
|
||||
handleQuery() {
|
||||
this.$refs.userTableRef.getTableList()
|
||||
this.$refs.toolTableRef.getTableList()
|
||||
},
|
||||
/** 删除操作 */
|
||||
handleDelete(row) {
|
||||
this.$modal.confirm(`是否确认删除此数据项?`).then(() => {
|
||||
// 显示加载遮罩
|
||||
this.$modal.loading("正在删除,请稍候...");
|
||||
delUser({ userId: row.userId }).then(res => {
|
||||
this.$modal.closeLoading();
|
||||
this.$confirm(`确定要删除"${raw.technicalSolutionName}"吗?删除后将无法恢复!`, '操作提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
dangerouslyUseHTMLString: true,
|
||||
customClass: 'delete-confirm-dialog'
|
||||
}).then(() => {
|
||||
delDataAPI(
|
||||
{
|
||||
toolId: raw.toolId,
|
||||
enterpriseId: this.enterpriseId
|
||||
}
|
||||
).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
this.$message.success('删除成功');
|
||||
this.handleQuery();
|
||||
} else {
|
||||
this.$modal.msgError(res.msg);
|
||||
this.$message.error(res.msg || '删除失败');
|
||||
}
|
||||
}).catch(error => {
|
||||
this.$modal.closeLoading();
|
||||
this.$modal.msgError(error);
|
||||
console.error('删除失败:', error);
|
||||
});
|
||||
}).catch(() => {
|
||||
// 用户取消删除,不需要处理
|
||||
});
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -203,5 +211,4 @@ export default {
|
|||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue