update code

dev_xds
haha 2024-06-06 22:43:56 +08:00
parent e97597db8e
commit 48041fecbb
3 changed files with 68 additions and 12 deletions

View File

@ -8,7 +8,7 @@
{{ dept.deptName }}
</el-form-item>
<el-form-item label="类型:" prop="standardType" style="margin-bottom: 16px;">
<treeselect v-model="form.standardType" :options="treeOpts" :show-count="true" placeholder="请选择类型" @select="doTypeSelect" />
<treeselect v-model="form.standardType" :options="treeOpts" ref="treeSel" :show-count="true" placeholder="请选择类型" @select="doTypeSelect" />
</el-form-item>
<div v-if="form.standardType" class="div-tip">
@ -42,7 +42,7 @@
</template>
<script>
import {addProjectStandard} from '@/api/project/projectStandard.js'
import {addProjectStandard,updateProjectStandard} from '@/api/project/projectStandard.js'
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import standardTypes from './standardType'
@ -73,7 +73,8 @@ export default {
{ label: '文明施工标准化', value: 5 },
{ label: '环境保护标准化', value: 6 },
],
treeOpts:standardTypes
treeOpts:standardTypes,
oldData:null
};
},
@ -92,8 +93,29 @@ export default {
submitForm() {
this.$refs.form.validate(v => {
if(v){
if(this.oldData){
this.doUpdate();
}else{
this.doSave();
}
}
});
},
doUpdate(){
this.oldData.imageFile=this.form.imageFile.map(d=>d.url).filter(d=>d).join(",")
this.oldData.standardDesc=this.form.desc;
this.oldData.standardType=this.form.standardType;
updateProjectStandard(this.oldData).then(d => {
if (d.code == 200) {
this.$message({
message: '修改成功',
type: 'success'
});
this.$emit("success");
this.open=false;
}
});
},
doSave(){
@ -118,15 +140,42 @@ export default {
cancel() {
this.open = false;
},
showDialog(prj, dept) {
showDialog(prj, dept,oldData) {
this.prj = prj || {};
this.dept = dept || {};
this.form.standardType=1;
this.form.desc='';
this.imageFile=[];
this.open = true;
if(oldData){
this.oldData=JSON.parse(JSON.stringify(oldData));
this.form.desc=this.oldData.standardDesc;
this.form.standardType=+this.oldData.standardType;
let imgs=(this.oldData.imageFile||"").split(",").filter(d=>d).map(d=>{
return {
url:d,
name:d
}
})
this.form.imageFile=imgs;
}
setTimeout(()=>{
if(this.oldData){
setTimeout(()=>{
let node=this.$refs.treeSel.getNode( this.form.standardType);
this.$refs.treeSel.select(node);
this.doTypeSelect(node.raw);
const func=p=>{
p.isExpanded=true;
if(p.parentNode){
func(p.parentNode);
}
};
func(node);
},400);
}else{
this.$refs.fu1.fileList=[];
}
},400);
}
},

View File

@ -47,6 +47,9 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit"
@click="handleEdit(scope.row)"
v-hasPermi="['project:projectStandard:remove']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['project:projectStandard:remove']">删除</el-button>
@ -190,6 +193,10 @@ export default {
let tmps = this.depts.filter(d => d.deptId == this.activeName);
this.$refs.dlg.showDialog(this.prj, tmps.length > 0 ? tmps[0] : {});
},
handleEdit(row){
let tmps = this.depts.filter(d => d.deptId == this.activeName);
this.$refs.dlg.showDialog(this.prj, tmps.length > 0 ? tmps[0] : {},row);
},
loadDepts(cb) {
let tmps = this.$root.prjDept2 && this.$root.prjDept2[this.prj.id] ? this.$root.prjDept2[this.prj.id] || [] : [];
if (tmps.length > 0) {

View File

@ -66,8 +66,8 @@
><i class="el-icon-picture-outline"></i>整改图片</template
>
<el-image
ref="preview"
v-for="img in item.fileUrls.split(',')"
ref="preview" :key="idx"
v-for="(img,idx) in item.fileUrls.split(',')"
:src="img + '.min.jpg'"
style="width: 50px; height: 50px; margin-right: 10px"
@click="onPreview(img)"
@ -102,8 +102,8 @@
</el-form-item>
<el-form-item label="隐患图片">
<el-image
ref="preview"
v-for="img in dataInfo.smarkUrl.split(',')"
ref="preview" :key="idx"
v-for="(img,idx) in dataInfo.smarkUrl.split(',')"
:src="getImageUrl(img)"
style="width: 60px; height: 60px; margin-right: 8px"
@click="onPreview(img)"